_info 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "config.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. /**
  5. * bytestring - simple bytestring handling
  6. *
  7. * This code handles manipulation of "bytestrings" represented as a
  8. * structure containing a pointer and length. Bytestrings are not
  9. * NUL-terminated, and may include internal \0 characters. The main
  10. * use case is for referencing sub-sections of a large data buffer
  11. * without the inconvenience of manually passing (and returning) both
  12. * pointer and length all the time.
  13. *
  14. * Because of this use case, the bytestrings are treated as having
  15. * immutable contents (we use a const char pointer). The caller code
  16. * is responsible for ensuring that the lifetime of the data
  17. * referenced by the bytestrings is long enough not to leave
  18. * bytestring structures with a dangling pointer.
  19. *
  20. * Example:
  21. * const char buf[] = "ABCDEFGH";
  22. * struct bytestring abcd = BYTESTRING("ABCD");
  23. *
  24. * assert(bytestring_eq(bytestring(buf, 4), abcd));
  25. *
  26. * License: LGPL (v2.1 or any later version)
  27. * Author: David Gibson <david@gibson.dropbear.id.au>
  28. */
  29. int main(int argc, char *argv[])
  30. {
  31. /* Expect exactly one argument */
  32. if (argc != 2)
  33. return 1;
  34. if (strcmp(argv[1], "depends") == 0) {
  35. printf("ccan/array_size\n");
  36. printf("ccan/mem\n");
  37. printf("ccan/compiler\n");
  38. return 0;
  39. }
  40. return 1;
  41. }