EXIF library (libexif) Internals
0.6.26
test-sorted.c
Go to the documentation of this file.
1
/* test-sorted.c
2
*
3
* This test ensures that the ExifTagTable[] array is stored in sorted
4
* order. If that were not so, then it a binary search of the array would
5
* not give correct results.
6
*
7
* Copyright 2009-2022 Dan Fandrich <dan@coneharvesters.com>
8
*
9
* This library is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Lesser General Public
11
* License as published by the Free Software Foundation; either
12
* version 2 of the License, or (at your option) any later version.
13
*
14
* This library is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* Lesser General Public License for more details.
18
*
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library; if not, write to the
21
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22
* Boston, MA 02110-1301 USA
23
*
24
* SPDX-License-Identifier: LGPL-2.0-or-later
25
*/
26
27
#include <
libexif/exif-tag.h
>
28
#include <stdio.h>
29
#include <string.h>
30
31
int
32
main
(
void
)
33
{
34
int
rc = 0;
35
unsigned
int
i, num;
36
ExifTag
last = 0, current;
37
const
char
*
name
;
38
num =
exif_tag_table_count
() - 1;
/* last entry is a NULL terminator */
39
for
(i=0; i < num; ++i) {
40
current =
exif_tag_table_get_tag
(i);
41
if
(current < last) {
42
printf(
"Tag 0x%04x in ExifTagTable[] is out of order\n"
,
43
current);
44
rc = 1;
45
}
46
name
=
exif_tag_table_get_name
(i);
47
/* Ensure each tag has a name */
48
if
(
name
== NULL) {
49
printf(
"Tag 0x%04x has a NULL name\n"
, current);
50
rc = 1;
51
}
52
/* Ensure each tag's name contains only valid characters */
53
if
(strspn(
name
,
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890/"
) != strlen(
name
)) {
54
printf(
"Tag 0x%04x has an invalid name: %s\n"
, current,
name
);
55
rc = 1;
56
}
57
last = current;
58
}
59
60
return
rc;
61
}
exif_tag_table_get_name
const char * exif_tag_table_get_name(unsigned int n)
Definition
exif-tag.c:990
exif_tag_table_get_tag
ExifTag exif_tag_table_get_tag(unsigned int n)
Definition
exif-tag.c:984
exif_tag_table_count
unsigned int exif_tag_table_count(void)
Return the number of entries in the EXIF tag table, including the terminating NULL entry.
Definition
exif-tag.c:977
exif-tag.h
Handling EXIF tags.
ExifTag
ExifTag
EXIF tags.
Definition
exif-tag.h:36
name
const char * name
Definition
mnote-apple-tag.c:33
main
int main(void)
Definition
test-sorted.c:32
libexif
Generated by