gn.c 374 B

1234567891011121314151617181920212223242526
  1. #include "logfsos.h"
  2. #include "logfs.h"
  3. #include "fcall.h"
  4. #include "local.h"
  5. int
  6. logfsgn(uchar **pp, uchar *mep, char **v)
  7. {
  8. uchar *p = *pp;
  9. int l;
  10. if(p + BIT16SZ > mep)
  11. return 0;
  12. l = GBIT16(p); p += BIT16SZ;
  13. if(p + l > mep)
  14. return 0;
  15. *pp = p + l;
  16. if(l == 0) {
  17. *v = 0;
  18. return 1;
  19. }
  20. *v = (char *)(p - 1);
  21. memmove(p - 1, p, l);
  22. p[l - 1] = 0;
  23. return 1;
  24. }