EXIF library (libexif) Internals 0.6.26
test-null.c
Go to the documentation of this file.
1
24#include "libexif/exif-data.h"
25#include "libexif/exif-entry.h"
26#include "libexif/exif-loader.h"
28
29#include <stdio.h>
30#include <stdlib.h>
31
32static void loader_null_test(void)
33{
34 ExifLoader *l;
35 ExifData *d;
36 unsigned char ret;
37 const unsigned char *ccp;
38 unsigned int i;
39
40 l = exif_loader_new_mem(NULL);
41 if (l) {
42 fprintf(stderr, "Unexpected success in %s\n", "exif_loader_new_mem");
43 exit(13);
44 }
45
46 exif_loader_ref(NULL);
47
49
50 exif_loader_write_file(NULL, "test");
51
52 exif_loader_write_file(NULL, NULL);
53
54 ret = exif_loader_write(NULL, (unsigned char *)"x", 1);
55 if (ret) {
56 fprintf(stderr, "Unexpected success in %s\n", "exif_loader_write");
57 exit(13);
58 }
59
60 exif_loader_write(NULL, NULL, 123);
61
63
64 d = exif_loader_get_data(NULL);
65 if (d) {
66 fprintf(stderr, "Unexpected success in %s\n", "exif_loader_get_data");
67 exit(13);
68 }
69
70 exif_loader_get_buf(NULL, NULL, NULL);
71
72 exif_loader_log(NULL, NULL);
73
74 l = exif_loader_new();
75 if (!l) {
76 fprintf(stderr, "Out of memory\n");
77 exit(13);
78 }
79
81
82 exif_loader_write(l, NULL, 0);
83 exif_loader_write(l, NULL, 1);
84
85 exif_loader_get_buf(l, NULL, NULL);
86 exif_loader_get_buf(l, &ccp, NULL);
87 exif_loader_get_buf(l, NULL, &i);
88
89 exif_loader_log(l, NULL);
90
92}
93
94static void data_null_test(void)
95{
96 /* exif_data_new_from_file() is untested since it doesn't check path */
97
98 ExifData *d;
100 ExifMnoteData *m;
101 ExifDataType dt;
102 unsigned char *buf;
103 unsigned int len;
104
105 d = exif_data_new_mem(NULL);
106 if (d) {
107 fprintf(stderr, "Unexpected success in %s\n", "exif_data_new_mem");
108 exit(13);
109 }
110
111 d = exif_data_new_from_data(NULL, 123);
112 if (d) {
114 }
115
116 bo = exif_data_get_byte_order(NULL);
117 (void) bo;
118
120
121 m = exif_data_get_mnote_data(NULL);
122 if (m) {
123 fprintf(stderr, "Unexpected success in %s\n", "exif_data_get_mnote_data");
124 exit(13);
125 }
126
127 exif_data_fix(NULL);
128
129 exif_data_foreach_content(NULL, NULL, NULL);
130
132
134
136
137 dt = exif_data_get_data_type(NULL);
138 (void) dt;
139
140 exif_data_load_data(NULL, NULL, 123);
141
142 exif_data_save_data(NULL, NULL, NULL);
143
144 exif_data_log(NULL, NULL);
145
146 exif_data_dump(NULL);
147
148 exif_data_ref(NULL);
149
150 exif_data_unref(NULL);
151
152 d = exif_data_new();
153 if (!d) {
154 fprintf(stderr, "Out of memory\n");
155 exit(13);
156 }
157
158 exif_data_load_data(d, NULL, 123);
159
160 exif_data_save_data(d, NULL, &len);
161 exif_data_save_data(d, &buf, NULL);
162 exif_data_save_data(d, NULL, NULL);
163
164 exif_data_foreach_content(d, NULL, NULL);
165
166 exif_data_log(d, NULL);
167
169}
170
171static void content_null_test(void)
172{
173 ExifContent *c;
174 ExifIfd i;
175
176 c = exif_content_new_mem(NULL);
177 if (c) {
178 fprintf(stderr, "Unexpected success in %s\n", "exif_content_new_mem");
179 exit(13);
180 }
181
182 exif_content_ref(NULL);
183
184 exif_content_unref(NULL);
185
186 exif_content_free(NULL);
187
189
190 exif_content_fix(NULL);
191
192 exif_content_foreach_entry(NULL, NULL, NULL);
193
194 i = exif_content_get_ifd(NULL);
195 (void) i;
196
197 exif_content_dump(NULL, 0);
198
199 exif_content_add_entry(NULL, NULL);
200
201 exif_content_remove_entry(NULL, NULL);
202
203 exif_content_log(NULL, NULL);
204
205 c = exif_content_new();
206 if (!c) {
207 fprintf(stderr, "Out of memory\n");
208 exit(13);
209 }
210
211 exif_content_add_entry(c, NULL);
212
214
215 exif_content_log(c, NULL);
216
217 exif_content_foreach_entry(c, NULL, NULL);
218
220}
221
222static void entry_null_test(void)
223{
224 ExifEntry *e;
225 const char *v = NULL;
226 char buf[] = {0};
227 ExifData *d;
228
229 e = exif_entry_new_mem(NULL);
230 if (e) {
231 fprintf(stderr, "Unexpected success in %s\n", "exif_entry_new_mem");
232 exit(13);
233 }
234
235 exif_entry_ref(NULL);
236
237 exif_entry_unref(NULL);
238
239 exif_entry_free(NULL);
240
242
243 exif_entry_fix(NULL);
244
245 v = exif_entry_get_value(NULL, NULL, 123);
246 if (v) {
247 fprintf(stderr, "Unexpected success in %s\n", "exif_entry_get_value");
248 exit(13);
249 }
250
251 v = exif_entry_get_value(NULL, buf, 1);
252 if (v != buf) {
253 fprintf(stderr, "Unexpected value in %s\n", "exif_entry_get_value");
254 exit(13);
255 }
256
257 exif_entry_dump(NULL, 0);
258
259 /* Creating a plain ExifEntry isn't enough, since some functions require
260 * that it exists in an IFD.
261 */
262 d = exif_data_new();
263 if (!d) {
264 fprintf(stderr, "Out of memory\n");
265 exit(13);
266 }
267 /* Create the mandatory EXIF fields so we have something to work with */
268 exif_data_fix(d);
270
271 (void) exif_entry_get_value(e, NULL, 0);
272 (void) exif_entry_get_value(e, NULL, 123);
273
275}
276
277static void mnote_null_test(void)
278{
279 /* Note that these APIs aren't tested with a real ExifMnoteData pointer
280 * because it's impossible to create one without real data.
281 */
283
285
286 exif_mnote_data_load(NULL, NULL, 123);
287
288 exif_mnote_data_load(NULL, (const unsigned char *)"x", 1);
289
290 exif_mnote_data_save(NULL, NULL, NULL);
291
293
294 exif_mnote_data_get_id(NULL, 0);
295
297
299
301
302 exif_mnote_data_get_value(NULL, 0, NULL, 123);
303
304 exif_mnote_data_log(NULL, NULL);
305}
306
307static void log_null_test(void)
308{
309 ExifLog *l;
310 static va_list va;
311
312 l = exif_log_new_mem(NULL);
313 if (l) {
314 fprintf(stderr, "Unexpected success in %s\n", "exif_log_new_mem");
315 exit(13);
316 }
317
318 exif_log_ref(NULL);
319
320 exif_log_unref(NULL);
321
322 exif_log_free(NULL);
323
324 exif_log_set_func(NULL, NULL, NULL);
325
326 exif_log(NULL, EXIF_LOG_CODE_CORRUPT_DATA, "XXX", "YYY");
327
328 exif_logv(NULL, EXIF_LOG_CODE_CORRUPT_DATA, "XXX", "YYY", va);
329
330 l = exif_log_new();
331 if (!l) {
332 fprintf(stderr, "Out of memory\n");
333 exit(13);
334 }
335
336 exif_log_set_func(l, NULL, NULL);
337
339}
340
341int main(void)
342{
349
350 /* If it gets here, we didn't get a SIGSEGV, so success! */
351 return 0;
352}
ExifByteOrder
Which byte order to use.
@ EXIF_BYTE_ORDER_MOTOROLA
Big-endian byte order.
void exif_content_remove_entry(ExifContent *c, ExifEntry *e)
Remove an EXIF tag from an IFD.
ExifIfd exif_content_get_ifd(ExifContent *c)
Return the IFD number in which the given ExifContent is found.
void exif_content_fix(ExifContent *c)
Fix the IFD to bring it into specification.
void exif_content_ref(ExifContent *content)
Increase reference counter for ExifContent.
ExifContent * exif_content_new_mem(ExifMem *mem)
Reserve memory for and initialize new ExifContent using the specified memory allocator.
ExifEntry * exif_content_get_entry(ExifContent *content, ExifTag tag)
Return the ExifEntry in this IFD corresponding to the given tag.
void exif_content_unref(ExifContent *content)
Decrease reference counter for ExifContent.
void exif_content_add_entry(ExifContent *c, ExifEntry *entry)
Add an EXIF tag to an IFD.
void exif_content_dump(ExifContent *content, unsigned int indent)
Dump contents of the IFD to stdout.
void exif_content_log(ExifContent *content, ExifLog *log)
Set the log message object for this IFD.
ExifContent * exif_content_new(void)
Reserve memory for and initialize a new ExifContent.
void exif_content_foreach_entry(ExifContent *content, ExifContentForeachEntryFunc func, void *data)
Executes function on each EXIF tag in this IFD in turn.
void exif_content_free(ExifContent *content)
Actually free the ExifContent.
ExifDataType
Represents the type of image data to which the EXIF data applies.
@ EXIF_DATA_TYPE_UNCOMPRESSED_CHUNKY
void exif_data_set_byte_order(ExifData *data, ExifByteOrder order)
Set the byte order to use for this EXIF data.
Definition exif-data.c:1229
ExifData * exif_data_new_mem(ExifMem *mem)
Allocate a new ExifData using the given memory allocator.
Definition exif-data.c:109
void exif_data_unref(ExifData *data)
Definition exif-data.c:1110
ExifByteOrder exif_data_get_byte_order(ExifData *data)
Return the byte order in use by this EXIF structure.
Definition exif-data.c:1185
ExifMnoteData * exif_data_get_mnote_data(ExifData *d)
Return the MakerNote data out of the EXIF data.
Definition exif-data.c:92
void exif_data_ref(ExifData *data)
Definition exif-data.c:1101
void exif_data_load_data(ExifData *data, const unsigned char *d_orig, unsigned int ds)
Load the ExifData structure from the raw JPEG or EXIF data in the given memory buffer.
Definition exif-data.c:856
ExifDataType exif_data_get_data_type(ExifData *d)
Return the data type for the given ExifData.
Definition exif-data.c:1369
ExifData * exif_data_new(void)
Allocate a new ExifData.
Definition exif-data.c:98
ExifData * exif_data_new_from_data(const unsigned char *data, unsigned int size)
Allocate a new ExifData and load EXIF data from a memory buffer.
Definition exif-data.c:156
void exif_data_fix(ExifData *d)
Fix the EXIF data to bring it into specification.
Definition exif-data.c:1354
void exif_data_dump(ExifData *data)
Dump all EXIF data to stdout.
Definition exif-data.c:1158
void exif_data_unset_option(ExifData *d, ExifDataOption o)
Clear the given option on the given ExifData.
Definition exif-data.c:1317
void exif_data_set_data_type(ExifData *d, ExifDataType dt)
Set the data type for the given ExifData.
Definition exif-data.c:1360
void exif_data_save_data(ExifData *data, unsigned char **d, unsigned int *ds)
Store raw EXIF data representing the ExifData structure into a memory buffer.
Definition exif-data.c:1042
void exif_data_foreach_content(ExifData *data, ExifDataForeachContentFunc func, void *user_data)
Execute a function on each IFD in turn.
Definition exif-data.c:1194
void exif_data_log(ExifData *data, ExifLog *log)
Set the log message object for all IFDs.
Definition exif-data.c:1245
void exif_data_set_option(ExifData *d, ExifDataOption o)
Set the given option on the given ExifData.
Definition exif-data.c:1308
Defines the ExifData type and the associated functions.
@ EXIF_DATA_OPTION_FOLLOW_SPECIFICATION
Fix the EXIF tags to follow the spec.
Definition exif-data.h:180
ExifEntry * exif_entry_new_mem(ExifMem *mem)
Reserve memory for and initialize new ExifEntry using the specified memory allocator.
Definition exif-entry.c:124
void exif_entry_free(ExifEntry *e)
Actually free the ExifEntry.
Definition exif-entry.c:159
const char * exif_entry_get_value(ExifEntry *e, char *val, unsigned int maxlen)
Return a localized textual representation of the value of the EXIF entry.
Definition exif-entry.c:854
void exif_entry_unref(ExifEntry *e)
Decrease reference counter for ExifEntry.
Definition exif-entry.c:149
void exif_entry_fix(ExifEntry *e)
Fix the type or format of the given EXIF entry to bring it into spec.
Definition exif-entry.c:207
void exif_entry_initialize(ExifEntry *e, ExifTag tag)
Initialize an empty ExifEntry with default data in the correct format for the given tag.
void exif_entry_dump(ExifEntry *e, unsigned int indent)
Dump text representation of ExifEntry to stdout.
Definition exif-entry.c:600
void exif_entry_ref(ExifEntry *e)
Increase reference counter for ExifEntry.
Definition exif-entry.c:141
Handling EXIF entries.
ExifIfd
Possible EXIF Image File Directories.
Definition exif-ifd.h:31
@ EXIF_IFD_0
Definition exif-ifd.h:32
void exif_loader_log(ExifLoader *loader, ExifLog *log)
Set the log message object used by this ExifLoader.
void exif_loader_reset(ExifLoader *loader)
Free any data previously loaded and reset the ExifLoader to its newly-initialized state.
ExifLoader * exif_loader_new(void)
Allocate a new ExifLoader.
ExifData * exif_loader_get_data(ExifLoader *loader)
Create an ExifData from the data in the loader.
void exif_loader_unref(ExifLoader *loader)
Decrease the refcount of the ExifLoader.
ExifLoader * exif_loader_new_mem(ExifMem *mem)
Allocate a new ExifLoader using the specified memory allocator.
unsigned char exif_loader_write(ExifLoader *eld, unsigned char *buf, unsigned int len)
Load a buffer into the ExifLoader from a memory buffer.
void exif_loader_ref(ExifLoader *loader)
Increase the refcount of the ExifLoader.
void exif_loader_get_buf(ExifLoader *loader, const unsigned char **buf, unsigned int *buf_size)
Return the raw data read by the loader.
void exif_loader_write_file(ExifLoader *l, const char *path)
Load a file into the given ExifLoader from the filesystem.
Defines the ExifLoader type.
ExifLog * exif_log_new(void)
Create a new logging instance.
Definition exif-log.c:88
void exif_log(ExifLog *log, ExifLogCode code, const char *domain, const char *format,...)
Definition exif-log.c:137
ExifLog * exif_log_new_mem(ExifMem *mem)
Definition exif-log.c:73
void exif_log_set_func(ExifLog *log, ExifLogFunc func, void *data)
Register log callback function.
Definition exif-log.c:125
void exif_log_unref(ExifLog *log)
Definition exif-log.c:106
void exif_logv(ExifLog *log, ExifLogCode code, const char *domain, const char *format, va_list args)
Definition exif-log.c:148
void exif_log_ref(ExifLog *log)
Definition exif-log.c:99
void exif_log_free(ExifLog *log)
Delete instance of ExifLog.
Definition exif-log.c:114
@ EXIF_LOG_CODE_CORRUPT_DATA
Definition exif-log.h:60
void exif_mnote_data_load(ExifMnoteData *d, const unsigned char *buf, unsigned int buf_size)
Load the MakerNote data from a memory buffer.
char * exif_mnote_data_get_value(ExifMnoteData *d, unsigned int n, char *val, unsigned int maxlen)
Return a textual representation of the value of the MakerNote entry.
void exif_mnote_data_ref(ExifMnoteData *d)
void exif_mnote_data_save(ExifMnoteData *d, unsigned char **buf, unsigned int *buf_size)
Save the raw MakerNote data into a memory buffer.
const char * exif_mnote_data_get_description(ExifMnoteData *d, unsigned int n)
Returns verbose textual description of the given MakerNote tag.
unsigned int exif_mnote_data_get_id(ExifMnoteData *d, unsigned int n)
Return the MakerNote tag number for the tag at the specified index within the MakerNote.
const char * exif_mnote_data_get_title(ExifMnoteData *d, unsigned int n)
Returns textual title of the given MakerNote tag.
const char * exif_mnote_data_get_name(ExifMnoteData *d, unsigned int n)
Returns textual name of the given MakerNote tag.
void exif_mnote_data_log(ExifMnoteData *d, ExifLog *log)
unsigned int exif_mnote_data_count(ExifMnoteData *d)
Return the number of tags in the MakerNote.
void exif_mnote_data_unref(ExifMnoteData *d)
Handling EXIF MakerNote tags.
@ EXIF_TAG_COMPRESSION
Definition exif-tag.h:43
@ EXIF_TAG_X_RESOLUTION
Definition exif-tag.h:55
Represents the entire EXIF data found in an image.
Definition exif-data.h:48
ExifContent * ifd[EXIF_IFD_COUNT]
Data for each IFD.
Definition exif-data.h:50
Data found in one EXIF tag.
Definition exif-entry.h:45
static void log_null_test(void)
Definition test-null.c:307
static void mnote_null_test(void)
Definition test-null.c:277
static void data_null_test(void)
Definition test-null.c:94
int main(void)
Definition test-null.c:341
static void content_null_test(void)
Definition test-null.c:171
static void loader_null_test(void)
Definition test-null.c:32
static void entry_null_test(void)
Definition test-null.c:222

libexif Generated by doxygen