1
0

String.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. /* extensible Strings */
  10. typedef struct String {
  11. Lock Lock;
  12. char *base; /* base of String */
  13. char *end; /* end of allocated space+1 */
  14. char *ptr; /* ptr into String */
  15. short ref;
  16. unsigned char fixed;
  17. } String;
  18. #define s_clone(s) s_copy((s)->base)
  19. #define s_to_c(s) ((s)->base)
  20. #define s_len(s) ((s)->ptr-(s)->base)
  21. extern String* s_append(String*, char*);
  22. extern String* s_array(char*, int);
  23. extern String* s_copy(char*);
  24. extern void s_free(String*);
  25. extern String* s_incref(String*);
  26. extern String* s_memappend(String*, char*, int);
  27. extern String* s_nappend(String*, char*, int);
  28. extern String* s_new(void);
  29. extern String* s_newalloc(int);
  30. extern String* s_parse(String*, String*);
  31. extern String* s_reset(String*);
  32. extern String* s_restart(String*);
  33. extern void s_terminate(String*);
  34. extern void s_tolower(String*);
  35. extern void s_putc(String*, int);
  36. extern String* s_unique(String*);
  37. extern String* s_grow(String*, int);
  38. #ifdef BGETC
  39. extern int s_read(Biobuf*, String*, int);
  40. extern char *s_read_line(Biobuf*, String*);
  41. extern char *s_getline(Biobuf*, String*);
  42. typedef struct Sinstack Sinstack;
  43. extern char *s_rdinstack(Sinstack*, String*);
  44. extern Sinstack *s_allocinstack(char*);
  45. extern void s_freeinstack(Sinstack*);
  46. #endif /* BGETC */