libgphoto2 photo camera library (libgphoto2) API  2.5.7
gphoto2-file.h
Go to the documentation of this file.
1 
26 #ifndef __GPHOTO2_FILE_H__
27 #define __GPHOTO2_FILE_H__
28 
29 #include <time.h>
30 #include <stdint.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35 
36 #define GP_MIME_TXT "text/plain"
37 #define GP_MIME_WAV "audio/wav"
38 #define GP_MIME_RAW "image/x-raw"
39 #define GP_MIME_PNG "image/png"
40 #define GP_MIME_PGM "image/x-portable-graymap"
41 #define GP_MIME_PPM "image/x-portable-pixmap"
42 #define GP_MIME_PNM "image/x-portable-anymap"
43 #define GP_MIME_JPEG "image/jpeg"
44 #define GP_MIME_TIFF "image/tiff"
45 #define GP_MIME_BMP "image/bmp"
46 #define GP_MIME_QUICKTIME "video/quicktime"
47 #define GP_MIME_AVI "video/x-msvideo"
48 #define GP_MIME_CRW "image/x-canon-raw"
49 #define GP_MIME_CR2 "image/x-canon-cr2"
50 #define GP_MIME_UNKNOWN "application/octet-stream"
51 #define GP_MIME_EXIF "application/x-exif"
52 #define GP_MIME_MP3 "audio/mpeg"
53 #define GP_MIME_OGG "application/ogg"
54 #define GP_MIME_WMA "audio/x-wma"
55 #define GP_MIME_ASF "audio/x-asf"
56 #define GP_MIME_MPEG "video/mpeg"
57 #define GP_MIME_AVCHD "video/mp2t"
58 #define GP_MIME_RW2 "image/x-panasonic-raw2"
59 #define GP_MIME_ARW "image/x-sony-arw"
60 
71 typedef enum {
81 
88 typedef enum {
93 
94 /* FIXME: api might be unstable. function return gphoto results codes. */
95 typedef struct _CameraFileHandler {
96  int (*size) (void*priv, uint64_t *size); /* only for read? */
97  int (*read) (void*priv, unsigned char *data, uint64_t *len);
98  int (*write) (void*priv, unsigned char *data, uint64_t *len);
99  /* FIXME: should we have both read/write methods? */
100  /* FIXME: how to finish method, due to LRU it might be longlived. */
102 
109 typedef struct _CameraFile CameraFile;
110 
111 int gp_file_new (CameraFile **file);
112 int gp_file_new_from_fd (CameraFile **file, int fd);
113 int gp_file_new_from_handler (CameraFile **file, CameraFileHandler *handler, void*priv);
114 int gp_file_ref (CameraFile *file);
115 int gp_file_unref (CameraFile *file);
116 int gp_file_free (CameraFile *file);
117 
118 int gp_file_set_name (CameraFile *file, const char *name);
119 int gp_file_get_name (CameraFile *file, const char **name);
120 
121 int gp_file_set_mime_type (CameraFile *file, const char *mime_type);
122 int gp_file_get_mime_type (CameraFile *file, const char **mime_type);
123 
124 int gp_file_set_mtime (CameraFile *file, time_t mtime);
125 int gp_file_get_mtime (CameraFile *file, time_t *mtime);
126 
129 int gp_file_get_name_by_type (CameraFile *file, const char *basename, CameraFileType type, char **newname);
130 
131 int gp_file_set_data_and_size (CameraFile*, char *data,
132  unsigned long int size);
133 int gp_file_get_data_and_size (CameraFile*, const char **data,
134  unsigned long int *size);
135 /* "Do not use those"
136  *
137  * These functions probably were originally intended for internal use only.
138  * However, due to
139  * - the lack of good documentation
140  * - this being the obvious way to save a file
141  * - the fact that libgphoto2 has been exporting all its internal
142  * symbols for years (until 2005-06)
143  * - our in-house frontends gphoto2 and gtkam using them
144  * a number of external frontends started to use these functions, as
145  * of 2005-06:
146  * - digikam
147  * - f-spot
148  * - gthumb
149  * But a few frontends can live without it (and thus are likely to
150  * use the correct API):
151  * - flphoto
152  * - kamera
153  *
154  * So we're going to phase these functions out over the next year or
155  * so, going the GTK way of keeping the ABI but breaking the API. So
156  * we'll continue to export functionally equivalent functions, but the
157  * header files will not contain definitions for you to use any more.
158  */
159 int gp_file_open (CameraFile *file, const char *filename);
160 int gp_file_save (CameraFile *file, const char *filename);
161 int gp_file_clean (CameraFile *file);
162 int gp_file_copy (CameraFile *destination, CameraFile *source);
163 
164 
165 /* These are for use by camera drivers only */
166 int gp_file_append (CameraFile*, const char *data,
167  unsigned long int size);
168 int gp_file_slurp (CameraFile*, char *data,
169  size_t size, size_t *readlen);
170 
171 #ifdef __cplusplus
172 }
173 #endif /* __cplusplus */
174 
175 #endif /* __GPHOTO2_FILE_H__ */
Definition: gphoto2-file.h:73
int gp_file_save(CameraFile *file, const char *filename)
Definition: gphoto2-file.c:481
Definition: gphoto2-file.h:90
int gp_file_free(CameraFile *file)
descruct a CameraFile object.
Definition: gphoto2-file.c:146
Definition: gphoto2-file.h:72
Definition: gphoto2-file.h:78
int gp_file_new_from_fd(CameraFile **file, int fd)
Definition: gphoto2-file.c:104
int gp_file_new_from_handler(CameraFile **file, CameraFileHandler *handler, void *priv)
Definition: gphoto2-file.c:125
int gp_file_get_name_by_type(CameraFile *file, const char *basename, CameraFileType type, char **newname)
Definition: gphoto2-file.c:894
int gp_file_set_mtime(CameraFile *file, time_t mtime)
Definition: gphoto2-file.c:1123
int gp_file_get_mime_type(CameraFile *file, const char **mime_type)
Definition: gphoto2-file.c:956
Definition: gphoto2-file.h:79
Definition: gphoto2-file.h:74
Definition: gphoto2-file.h:91
File structure.
int gp_file_detect_mime_type(CameraFile *file)
Definition: gphoto2-file.c:1006
int gp_file_adjust_name_for_mime_type(CameraFile *file)
Definition: gphoto2-file.c:1060
int gp_file_new(CameraFile **file)
Definition: gphoto2-file.c:84
int gp_file_set_data_and_size(CameraFile *, char *data, unsigned long int size)
Definition: gphoto2-file.c:312
int gp_file_get_name(CameraFile *file, const char **name)
Definition: gphoto2-file.c:868
int gp_file_set_mime_type(CameraFile *file, const char *mime_type)
Definition: gphoto2-file.c:990
Definition: gphoto2-file.h:77
int gp_file_open(CameraFile *file, const char *filename)
Definition: gphoto2-file.c:598
int gp_file_slurp(CameraFile *, char *data, size_t size, size_t *readlen)
Definition: gphoto2-file.c:253
int gp_file_get_mtime(CameraFile *file, time_t *mtime)
Definition: gphoto2-file.c:1106
Definition: gphoto2-file.h:95
Definition: gphoto2-file.h:89
int gp_file_clean(CameraFile *file)
Definition: gphoto2-file.c:694
int gp_file_get_data_and_size(CameraFile *, const char **data, unsigned long int *size)
Definition: gphoto2-file.c:393
int gp_file_append(CameraFile *, const char *data, unsigned long int size)
Definition: gphoto2-file.c:204
int gp_file_copy(CameraFile *destination, CameraFile *source)
Definition: gphoto2-file.c:724
CameraFileAccessType
File storage type.
Definition: gphoto2-file.h:88
int gp_file_ref(CameraFile *file)
Increase reference counter for CameraFile object.
Definition: gphoto2-file.c:166
int gp_file_set_name(CameraFile *file, const char *name)
Definition: gphoto2-file.c:973
int gp_file_unref(CameraFile *file)
Decrease reference counter for CameraFile object.
Definition: gphoto2-file.c:183
CameraFileType
The type of view on the specified file.
Definition: gphoto2-file.h:71
Definition: gphoto2-file.c:56