Fosfat  1.0.0
fosfat.h
Go to the documentation of this file.
1 /*
2  * FOS libfosfat: API for Smaky file system
3  * Copyright (C) 2006-2010,2023 Mathieu Schroeter <mathieu@schroetersa.ch>
4  *
5  * Thanks to Pierre Arnaud for his help and the documentation
6  * And to Epsitec SA for the Smaky computers
7  *
8  * This file is part of Fosfat.
9  *
10  * This library is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24 
25 #ifndef FOSFAT_H
26 #define FOSFAT_H
27 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif /* __cplusplus */
37 
38 #define FF_STRINGIFY(s) #s
39 #define FF_TOSTRING(s) FF_STRINGIFY(s)
40 
41 #define FF_VERSION_INT(a, b, c) (a << 16 | b << 8 | c)
42 #define FF_VERSION_DOT(a, b, c) a ##.## b ##.## c
43 #define FF_VERSION(a, b, c) FF_VERSION_DOT(a, b, c)
44 
45 #define LIBFOSFAT_VERSION_MAJOR 1
46 #define LIBFOSFAT_VERSION_MINOR 0
47 #define LIBFOSFAT_VERSION_MICRO 0
48 
49 #define LIBFOSFAT_VERSION_INT FF_VERSION_INT(LIBFOSFAT_VERSION_MAJOR, \
50  LIBFOSFAT_VERSION_MINOR, \
51  LIBFOSFAT_VERSION_MICRO)
52 #define LIBFOSFAT_VERSION FF_VERSION(LIBFOSFAT_VERSION_MAJOR, \
53  LIBFOSFAT_VERSION_MINOR, \
54  LIBFOSFAT_VERSION_MICRO)
55 #define LIBFOSFAT_VERSION_STR FF_TOSTRING(LIBFOSFAT_VERSION)
56 #define LIBFOSFAT_BUILD LIBFOSFAT_VERSION_INT
57 
58 #include <inttypes.h>
59 
60 #define FOSFAT_NAMELGT 17
61 
62 #define F_UNDELETE (1 << 0)
63 
65 typedef enum disk_type {
69  FOSFAT_ED
71 
73 typedef struct time_s {
74  short int year;
75  short int month;
76  short int day;
77  short int hour;
78  short int minute;
79  short int second;
81 
83 typedef struct att_s {
84  int isdir : 1;
85  int isvisible : 1;
86  int isencoded : 1;
87  int islink : 1;
88  int isdel : 1;
89 } fosfat_att_t;
90 
92 typedef struct file_info_s {
93  char name[FOSFAT_NAMELGT];
94  int size;
99  /* Linked list */
100  struct file_info_s *next_file;
101 } fosfat_file_t;
102 
104 typedef struct fosfat_s fosfat_t;
105 
106 
123 fosfat_t *fosfat_open (const char *dev, fosfat_disk_t disk, unsigned int flag);
124 
130 void fosfat_close (fosfat_t *fosfat);
131 
141 void fosfat_logger (int state);
142 
151 char *fosfat_diskname (fosfat_t *fosfat);
152 
163 fosfat_file_t *fosfat_list_dir (fosfat_t *fosfat, const char *location);
164 
171 
182 
192 int fosfat_isdir (fosfat_t *fosfat, const char *location);
193 
203 int fosfat_islink (fosfat_t *fosfat, const char *location);
204 
214 int fosfat_isvisible (fosfat_t *fosfat, const char *location);
215 
225 int fosfat_isencoded (fosfat_t *fosfat, const char *location);
226 
236 int fosfat_isopenexm (fosfat_t *fosfat, const char *location);
237 
249 fosfat_file_t *fosfat_get_stat (fosfat_t *fosfat, const char *location);
250 
261 char *fosfat_symlink (fosfat_t *fosfat, const char *location);
262 
277  const char *src, const char *dst, int output);
278 
292 uint8_t *fosfat_get_buffer (fosfat_t *fosfat,
293  const char *path, int offset, int size);
294 
295 #ifdef __cplusplus
296 }
297 #endif /* __cplusplus */
298 
299 #endif /* FOSFAT_H */
int fosfat_isdir(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
void fosfat_close(fosfat_t *fosfat)
Free the memory and close the device properly.
fosfat_file_t * fosfat_get_stat(fosfat_t *fosfat, const char *location)
Get some informations on a file or a directory.
fosfat_disk_t fosfat_type(fosfat_t *fosfat)
Get the disk type.
uint8_t * fosfat_get_buffer(fosfat_t *fosfat, const char *path, int offset, int size)
Get a buffer of a file.
fosfat_file_t * fosfat_list_dir(fosfat_t *fosfat, const char *location)
Get file/dir list of a directory in a linked list.
int fosfat_islink(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
int fosfat_isvisible(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
char * fosfat_symlink(fosfat_t *fosfat, const char *location)
Get the target of a soft-link.
fosfat_disk_t
Definition: fosfat.h:65
@ FOSFAT_AD
Definition: fosfat.h:68
@ FOSFAT_HD
Definition: fosfat.h:67
@ FOSFAT_FD
Definition: fosfat.h:66
@ FOSFAT_ED
Definition: fosfat.h:69
int fosfat_get_file(fosfat_t *fosfat, const char *src, const char *dst, int output)
Get a file from a location and put this on the user hard drive.
char * fosfat_diskname(fosfat_t *fosfat)
Get the disk's name of a specific device.
void fosfat_free_listdir(fosfat_file_t *var)
Free the memory for an linked list created by fosfat_list_dir().
struct fosfat_s fosfat_t
Definition: fosfat.h:104
int fosfat_isencoded(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
void fosfat_logger(int state)
Change log level (verbosity).
int fosfat_isopenexm(fosfat_t *fosfat, const char *location)
Get boolean information on a specific file or folder.
fosfat_t * fosfat_open(const char *dev, fosfat_disk_t disk, unsigned int flag)
Load a device compatible Smaky FOS.
fosfat_time_t time_r
Definition: fosfat.h:98
int size
Definition: fosfat.h:94
fosfat_time_t time_c
Definition: fosfat.h:96
fosfat_att_t att
Definition: fosfat.h:95
fosfat_time_t time_w
Definition: fosfat.h:97