String.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma src "/sys/src/libString"
  2. #pragma lib "libString.a"
  3. /* extensible Strings */
  4. typedef struct String {
  5. Lock;
  6. char *base; /* base of String */
  7. char *end; /* end of allocated space+1 */
  8. char *ptr; /* ptr into String */
  9. short ref;
  10. uchar fixed;
  11. } String;
  12. #define s_clone(s) s_copy((s)->base)
  13. #define s_to_c(s) ((s)->base)
  14. #define s_len(s) ((s)->ptr-(s)->base)
  15. extern String* s_append(String*, char*);
  16. extern String* s_array(char*, int);
  17. extern String* s_copy(char*);
  18. extern void s_free(String*);
  19. extern String* s_incref(String*);
  20. extern String* s_memappend(String*, char*, int);
  21. extern String* s_nappend(String*, char*, int);
  22. extern String* s_new(void);
  23. extern String* s_newalloc(int);
  24. extern String* s_parse(String*, String*);
  25. extern String* s_reset(String*);
  26. extern String* s_restart(String*);
  27. extern void s_terminate(String*);
  28. extern void s_tolower(String*);
  29. extern void s_putc(String*, int);
  30. extern String* s_unique(String*);
  31. extern String* s_grow(String*, int);
  32. #ifdef BGETC
  33. extern int s_read(Biobuf*, String*, int);
  34. extern char *s_read_line(Biobuf*, String*);
  35. extern char *s_getline(Biobuf*, String*);
  36. typedef struct Sinstack Sinstack;
  37. #pragma incomplete Sinstack
  38. extern char *s_rdinstack(Sinstack*, String*);
  39. extern Sinstack *s_allocinstack(char*);
  40. extern void s_freeinstack(Sinstack*);
  41. #endif BGETC