_info 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include <string.h>
  2. #include "config.h"
  3. /**
  4. * rbuf - buffered I/O input primitive.
  5. *
  6. * This code is like stdio, only simpler and more transparent to the user.
  7. *
  8. * Author: Rusty Russell <rusty@rustcorp.com.au>
  9. * License: BSD-MIT
  10. *
  11. * Example:
  12. * #include <ccan/rbuf/rbuf.h>
  13. * #include <ccan/err/err.h>
  14. * #include <stdlib.h>
  15. * #include <unistd.h>
  16. *
  17. * // Dumb demo program to replace ' ' with '*'.
  18. * int main(int argc, char *argv[])
  19. * {
  20. * struct rbuf in;
  21. * char *word;
  22. *
  23. * if (argv[1]) {
  24. * if (!rbuf_open(&in, argv[1], NULL, 0))
  25. * err(1, "Failed opening %s", argv[1]);
  26. * } else
  27. * rbuf_init(&in, STDIN_FILENO, NULL, 0);
  28. *
  29. * while ((word = rbuf_read_str(&in, ' ', realloc)) != NULL)
  30. * printf("%s*", word);
  31. *
  32. * if (errno)
  33. * err(1, "Reading %s", argv[1] ? argv[1] : "<stdin>");
  34. *
  35. * // Free the buffer, just because we can.
  36. * free(in.buf);
  37. * return 0;
  38. * }
  39. */
  40. int main(int argc, char *argv[])
  41. {
  42. /* Expect exactly one argument */
  43. if (argc != 2)
  44. return 1;
  45. if (strcmp(argv[1], "depends") == 0) {
  46. return 0;
  47. }
  48. return 1;
  49. }