util.c 465 B

12345678910111213141516171819202122232425
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <auth.h>
  4. #include <fcall.h>
  5. #include <thread.h>
  6. #include "9p.h"
  7. void
  8. readbuf(Req *r, void *s, long n)
  9. {
  10. r->ofcall.count = r->ifcall.count;
  11. if(r->ifcall.offset >= n){
  12. r->ofcall.count = 0;
  13. return;
  14. }
  15. if(r->ifcall.offset+r->ofcall.count > n)
  16. r->ofcall.count = n - r->ifcall.offset;
  17. memmove(r->ofcall.data, (char*)s+r->ifcall.offset, r->ofcall.count);
  18. }
  19. void
  20. readstr(Req *r, char *s)
  21. {
  22. readbuf(r, s, strlen(s));
  23. }