Fosfat  0.4.0
fosfat.h
Go to the documentation of this file.
1 /*
2  * FOS libfosfat: API for Smaky file system
3  * Copyright (C) 2006-2010 Mathieu Schroeter <mathieu.schroeter@gamesover.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 0
46 #define LIBFOSFAT_VERSION_MINOR 4
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 {
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 
181 int fosfat_isdir (fosfat_t *fosfat, const char *location);
182 
192 int fosfat_islink (fosfat_t *fosfat, const char *location);
193 
203 int fosfat_isvisible (fosfat_t *fosfat, const char *location);
204 
214 int fosfat_isencoded (fosfat_t *fosfat, const char *location);
215 
225 int fosfat_isopenexm (fosfat_t *fosfat, const char *location);
226 
238 fosfat_file_t *fosfat_get_stat (fosfat_t *fosfat, const char *location);
239 
250 char *fosfat_symlink (fosfat_t *fosfat, const char *location);
251 
265 int fosfat_get_file (fosfat_t *fosfat,
266  const char *src, const char *dst, int output);
267 
281 uint8_t *fosfat_get_buffer (fosfat_t *fosfat,
282  const char *path, int offset, int size);
283 
284 #ifdef __cplusplus
285 }
286 #endif /* __cplusplus */
287 
288 #endif /* FOSFAT_H */