libgphoto2 photo camera library (libgphoto2) API  2.5.3.1
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_WAV "audio/wav"
37 #define GP_MIME_RAW "image/x-raw"
38 #define GP_MIME_PNG "image/png"
39 #define GP_MIME_PGM "image/x-portable-graymap"
40 #define GP_MIME_PPM "image/x-portable-pixmap"
41 #define GP_MIME_PNM "image/x-portable-anymap"
42 #define GP_MIME_JPEG "image/jpeg"
43 #define GP_MIME_TIFF "image/tiff"
44 #define GP_MIME_BMP "image/bmp"
45 #define GP_MIME_QUICKTIME "video/quicktime"
46 #define GP_MIME_AVI "video/x-msvideo"
47 #define GP_MIME_CRW "image/x-canon-raw"
48 #define GP_MIME_CR2 "image/x-canon-cr2"
49 #define GP_MIME_UNKNOWN "application/octet-stream"
50 #define GP_MIME_EXIF "application/x-exif"
51 #define GP_MIME_MP3 "audio/mpeg"
52 #define GP_MIME_OGG "application/ogg"
53 #define GP_MIME_WMA "audio/x-wma"
54 #define GP_MIME_ASF "audio/x-asf"
55 #define GP_MIME_MPEG "video/mpeg"
56 #define GP_MIME_AVCHD "video/mp2t"
57 #define GP_MIME_RW2 "image/x-panasonic-raw2"
58 
69 typedef enum {
79 
86 typedef enum {
91 
92 /* FIXME: api might be unstable. function return gphoto results codes. */
93 typedef struct _CameraFileHandler {
94  int (*size) (void*priv, uint64_t *size); /* only for read? */
95  int (*read) (void*priv, unsigned char *data, uint64_t *len);
96  int (*write) (void*priv, unsigned char *data, uint64_t *len);
97  /* FIXME: should we have both read/write methods? */
98  /* FIXME: how to finish method, due to LRU it might be longlived. */
100 
107 typedef struct _CameraFile CameraFile;
108 
109 int gp_file_new (CameraFile **file);
110 int gp_file_new_from_fd (CameraFile **file, int fd);
111 int gp_file_new_from_handler (CameraFile **file, CameraFileHandler *handler, void*priv);
112 int gp_file_ref (CameraFile *file);
113 int gp_file_unref (CameraFile *file);
114 int gp_file_free (CameraFile *file);
115 
116 int gp_file_set_name (CameraFile *file, const char *name);
117 int gp_file_get_name (CameraFile *file, const char **name);
118 
119 int gp_file_set_mime_type (CameraFile *file, const char *mime_type);
120 int gp_file_get_mime_type (CameraFile *file, const char **mime_type);
121 
122 int gp_file_set_mtime (CameraFile *file, time_t mtime);
123 int gp_file_get_mtime (CameraFile *file, time_t *mtime);
124 
127 int gp_file_get_name_by_type (CameraFile *file, const char *basename, CameraFileType type, char **newname);
128 
129 int gp_file_set_data_and_size (CameraFile*, char *data,
130  unsigned long int size);
131 int gp_file_get_data_and_size (CameraFile*, const char **data,
132  unsigned long int *size);
133 /* "Do not use those"
134  *
135  * These functions probably were originally intended for internal use only.
136  * However, due to
137  * - the lack of good documentation
138  * - this being the obvious way to save a file
139  * - the fact that libgphoto2 has been exporting all its internal
140  * symbols for years (until 2005-06)
141  * - our in-house frontends gphoto2 and gtkam using them
142  * a number of external frontends started to use these functions, as
143  * of 2005-06:
144  * - digikam
145  * - f-spot
146  * - gthumb
147  * But a few frontends can live without it (and thus are likely to
148  * use the correct API):
149  * - flphoto
150  * - kamera
151  *
152  * So we're going to phase these functions out over the next year or
153  * so, going the GTK way of keeping the ABI but breaking the API. So
154  * we'll continue to export functionally equivalent functions, but the
155  * header files will not contain definitions for you to use any more.
156  */
157 int gp_file_open (CameraFile *file, const char *filename);
158 int gp_file_save (CameraFile *file, const char *filename);
159 int gp_file_clean (CameraFile *file);
160 int gp_file_copy (CameraFile *destination, CameraFile *source);
161 
162 
163 /* These are for use by camera drivers only */
164 int gp_file_append (CameraFile*, const char *data,
165  unsigned long int size);
166 int gp_file_slurp (CameraFile*, char *data,
167  size_t size, size_t *readlen);
168 
169 #ifdef __cplusplus
170 }
171 #endif /* __cplusplus */
172 
173 #endif /* __GPHOTO2_FILE_H__ */
int gp_file_set_mtime(CameraFile *file, time_t mtime)
Definition: gphoto2-file.c:1180
Definition: gphoto2-file.h:71
Definition: gphoto2-file.h:88
int gp_file_get_mtime(CameraFile *file, time_t *mtime)
Definition: gphoto2-file.c:1163
int gp_file_get_name(CameraFile *file, const char **name)
Definition: gphoto2-file.c:918
Definition: gphoto2-file.h:70
Definition: gphoto2-file.h:76
int gp_file_set_mime_type(CameraFile *file, const char *mime_type)
Definition: gphoto2-file.c:1046
int gp_file_unref(CameraFile *file)
Decrease reference counter for CameraFile object.
Definition: gphoto2-file.c:194
int gp_file_detect_mime_type(CameraFile *file)
Definition: gphoto2-file.c:1062
int gp_file_append(CameraFile *file, const char *data, unsigned long int size)
Definition: gphoto2-file.c:215
int gp_file_copy(CameraFile *destination, CameraFile *source)
Definition: gphoto2-file.c:766
int gp_file_set_name(CameraFile *file, const char *name)
Definition: gphoto2-file.c:1029
Definition: gphoto2-file.h:77
Definition: gphoto2-file.h:72
Definition: gphoto2-file.h:89
File structure.
int gp_file_save(CameraFile *file, const char *filename)
Definition: gphoto2-file.c:518
int gp_file_clean(CameraFile *file)
Definition: gphoto2-file.c:735
int gp_file_get_mime_type(CameraFile *file, const char **mime_type)
Definition: gphoto2-file.c:1012
int gp_file_get_data_and_size(CameraFile *file, const char **data, unsigned long int *size)
Definition: gphoto2-file.c:423
Definition: gphoto2-file.h:75
int gp_file_slurp(CameraFile *file, char *data, size_t size, size_t *readlen)
Definition: gphoto2-file.c:276
int gp_file_new_from_fd(CameraFile **file, int fd)
Definition: gphoto2-file.c:109
int gp_file_ref(CameraFile *file)
Increase reference counter for CameraFile object.
Definition: gphoto2-file.c:177
Definition: gphoto2-file.h:93
Definition: gphoto2-file.h:87
int gp_file_free(CameraFile *file)
descruct a CameraFile object.
Definition: gphoto2-file.c:157
int gp_file_new(CameraFile **file)
Definition: gphoto2-file.c:86
int gp_file_new_from_handler(CameraFile **file, CameraFileHandler *handler, void *private)
Definition: gphoto2-file.c:133
int gp_file_set_data_and_size(CameraFile *file, char *data, unsigned long int size)
Definition: gphoto2-file.c:338
int gp_file_get_name_by_type(CameraFile *file, const char *basename, CameraFileType type, char **newname)
Definition: gphoto2-file.c:944
CameraFileAccessType
File storage type.
Definition: gphoto2-file.h:86
int gp_file_adjust_name_for_mime_type(CameraFile *file)
Definition: gphoto2-file.c:1116
CameraFileType
The type of view on the specified file.
Definition: gphoto2-file.h:69
int gp_file_open(CameraFile *file, const char *filename)
Definition: gphoto2-file.c:639
Definition: gphoto2-file.c:58