_info 1.1 KB

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