Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

24 lines
473 B

  1. #include "byte.h"
  2. #include "stralloc.h"
  3. #include "buffer.h"
  4. #include <errno.h>
  5. int buffer_get_token_sa(buffer* b,stralloc* sa,
  6. const char* charset,
  7. unsigned long int setlen) {
  8. for (;;) {
  9. char x;
  10. if (!stralloc_readyplus(sa,1)) goto nomem;
  11. switch (buffer_getc(b,&x)) {
  12. case -1: return -1;
  13. case 0: return 0;
  14. }
  15. stralloc_append(sa,&x);
  16. if (byte_chr(charset,setlen,x)<setlen) break;
  17. }
  18. return 1;
  19. nomem:
  20. errno=ENOMEM;
  21. return -1;
  22. }