String.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #pragma src "/sys/src/libString"
  10. #pragma lib "libString.a"
  11. /* extensible Strings */
  12. typedef struct String {
  13. Lock;
  14. char *base; /* base of String */
  15. char *end; /* end of allocated space+1 */
  16. char *ptr; /* ptr into String */
  17. short ref;
  18. unsigned char fixed;
  19. } String;
  20. #define s_clone(s) s_copy((s)->base)
  21. #define s_to_c(s) ((s)->base)
  22. #define s_len(s) ((s)->ptr-(s)->base)
  23. extern String* s_append(String*, char*);
  24. extern String* s_array(char*, int);
  25. extern String* s_copy(char*);
  26. extern void s_free(String*);
  27. extern String* s_incref(String*);
  28. extern String* s_memappend(String*, char*, int);
  29. extern String* s_nappend(String*, char*, int);
  30. extern String* s_new(void);
  31. extern String* s_newalloc(int);
  32. extern String* s_parse(String*, String*);
  33. extern String* s_reset(String*);
  34. extern String* s_restart(String*);
  35. extern void s_terminate(String*);
  36. extern void s_tolower(String*);
  37. extern void s_putc(String*, int);
  38. extern String* s_unique(String*);
  39. extern String* s_grow(String*, int);
  40. #ifdef BGETC
  41. extern int s_read(Biobuf*, String*, int);
  42. extern char *s_read_line(Biobuf*, String*);
  43. extern char *s_getline(Biobuf*, String*);
  44. typedef struct Sinstack Sinstack;
  45. #pragma incomplete Sinstack
  46. extern char *s_rdinstack(Sinstack*, String*);
  47. extern Sinstack *s_allocinstack(char*);
  48. extern void s_freeinstack(Sinstack*);
  49. #endif /* BGETC */