]> git.ozlabs.org Git - ccan/blob - ccan/charset/_info
tdb2: more tests, hash collision fixes, attribute support.
[ccan] / ccan / charset / _info
1 #include <stdio.h>
2 #include <string.h>
3 #include "config.h"
4
5 /**
6  * charset - character set conversion and validation routines
7  *
8  * This module provides a collection (well, only one, at the moment) of
9  * well-tested routines for dealing with character set nonsense.
10  *
11  * Validation functions:
12  *  - bool utf8_validate(const char *str, size_t length);
13  *
14  * Example:
15  *      #include <err.h>
16  *      #include <stdio.h>
17  *      #include <string.h>
18  *      #include <ccan/charset/charset.h>
19  *      #include <ccan/grab_file/grab_file.h>
20  *      #include <ccan/talloc/talloc.h> // For talloc_free()
21  *
22  *      int main(int argc, char *argv[])
23  *      {
24  *              size_t len;
25  *              char *file;
26  *              bool valid;
27  *
28  *              if (argc != 2)
29  *                      err(1, "Expected exactly one argument");
30  *
31  *              file = grab_file(NULL, argv[1], &len);
32  *              if (!file)
33  *                      err(1, "Could not read file %s", argv[1]);
34  *
35  *              valid = utf8_validate(file, len));
36  *              printf("File contents are %s UTF-8\n", valid ? "valid" : "invalid");
37  *
38  *              talloc_free(file);
39  *
40  *              return 0;
41  *      }
42  *
43  * Author: Joey Adams
44  * Licence: MIT
45  */
46 int main(int argc, char *argv[])
47 {
48         /* Expect exactly one argument */
49         if (argc != 2)
50                 return 1;
51
52         if (strcmp(argv[1], "depends") == 0) {
53                 /* Nothing */
54                 return 0;
55         }
56         
57         if (strcmp(argv[1], "libs") == 0) {
58                 printf("m\n"); /* Needed for the pow() invocation in run.c */
59                 return 0;
60         }
61
62         return 1;
63 }