_info 1.3 KB

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