_info 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "config.h"
  4. /**
  5. * str_talloc - string helper routines which use talloc
  6. *
  7. * This is a grab bag of fnctions for string operations, designed to enhance
  8. * the standard string.h; these are separated from the non-talloc-needing
  9. * string utilities in "str.h".
  10. *
  11. * Example:
  12. * #include <ccan/str_talloc/str_talloc.h>
  13. * #include <ccan/talloc/talloc.h>
  14. * #include <ccan/grab_file/grab_file.h>
  15. * #include <err.h>
  16. *
  17. * // Dumb demo program to double-linespace a file.
  18. * int main(int argc, char *argv[])
  19. * {
  20. * char *textfile;
  21. * char **lines;
  22. *
  23. * // Grab lines in file.
  24. * textfile = grab_file(NULL, argv[1], NULL);
  25. * if (!textfile)
  26. * err(1, "Failed reading %s", argv[1]);
  27. * lines = strsplit(textfile, textfile, "\n", NULL);
  28. *
  29. * // Join them back together with two linefeeds.
  30. * printf("%s", strjoin(textfile, lines, "\n\n"));
  31. *
  32. * // Free everything, just because we can.
  33. * talloc_free(textfile);
  34. * return 0;
  35. * }
  36. *
  37. * License: LGPL (2 or any later version)
  38. * Author: Rusty Russell <rusty@rustcorp.com.au>
  39. */
  40. int main(int argc, char *argv[])
  41. {
  42. if (argc != 2)
  43. return 1;
  44. if (strcmp(argv[1], "depends") == 0) {
  45. printf("ccan/talloc\n");
  46. printf("ccan/noerr\n");
  47. return 0;
  48. }
  49. return 1;
  50. }