xref: /plan9/sys/src/lib9p/util.c (revision 9a747e4fd48b9f4522c70c07e8f882a15030f964)
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 
8 void
readbuf(Req * r,void * s,long n)9 readbuf(Req *r, void *s, long n)
10 {
11 	r->ofcall.count = r->ifcall.count;
12 	if(r->ifcall.offset >= n){
13 		r->ofcall.count = 0;
14 		return;
15 	}
16 	if(r->ifcall.offset+r->ofcall.count > n)
17 		r->ofcall.count = n - r->ifcall.offset;
18 	memmove(r->ofcall.data, (char*)s+r->ifcall.offset, r->ofcall.count);
19 }
20 
21 void
readstr(Req * r,char * s)22 readstr(Req *r, char *s)
23 {
24 	readbuf(r, s, strlen(s));
25 }
26