📄 hplayback.c
字号:
if (amtread<=0 || vb2.buf[--amtread]!='\n') Psyntax("badly formed line"); vb2.buf[amtread]= 0; if (memcmp(vb2.buf," socket=",8)) Psyntax("syscall reply mismatch"); if (vb2.buf[8] == 'E') { int e; e= Perrno(vb2.buf+8); P_updatetime(); errno= e; return -1; } r= strtoul(vb2.buf+8,&ep,10); if (*ep && *ep!=' ') Psyntax("return value not E* or positive number"); vb2.used= ep - (char*)vb2.buf; assert(vb2.used <= amtread); if (vb2.used != amtread) Psyntax("junk at end of line"); P_updatetime(); return r;}int Hfcntl( int fd , int cmd , ... ) { int r, amtread; va_list al; long arg; Tmust("fcntl","cmd",cmd==F_SETFL || cmd==F_GETFL); if (cmd == F_SETFL) { va_start(al,cmd); arg= va_arg(al,long); va_end(al); } else { arg= 0; } Qfcntl( fd , cmd , arg ); if (!adns__vbuf_ensure(&vb2,1000)) Tnomem(); fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput(); Tensurereportfile(); fprintf(Treportfile,"%s",vb2.buf); amtread= strlen(vb2.buf); if (amtread<=0 || vb2.buf[--amtread]!='\n') Psyntax("badly formed line"); vb2.buf[amtread]= 0; if (memcmp(vb2.buf," fcntl=",7)) Psyntax("syscall reply mismatch"); if (vb2.buf[7] == 'E') { int e; e= Perrno(vb2.buf+7); P_updatetime(); errno= e; return -1; } r= 0; if (cmd == F_GETFL) { if (!memcmp(vb2.buf+7,"O_NONBLOCK|...",14)) { r= O_NONBLOCK; vb2.used= 7+14; } else if (!memcmp(vb2.buf+7,"~O_NONBLOCK&...",15)) { vb2.used= 7+15; } else { Psyntax("fcntl flags not O_NONBLOCK|... or ~O_NONBLOCK&..."); } } else if (cmd == F_SETFL) { if (memcmp(vb2.buf+7,"OK",2)) Psyntax("success/fail not E* or OK"); vb2.used= 7+2; r= 0; } else { Psyntax("fcntl not F_GETFL or F_SETFL"); } assert(vb2.used <= amtread); if (vb2.used != amtread) Psyntax("junk at end of line"); P_updatetime(); return r;}int Hconnect( int fd , const struct sockaddr *addr , int addrlen ) { int r, amtread; Qconnect( fd , addr , addrlen ); if (!adns__vbuf_ensure(&vb2,1000)) Tnomem(); fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput(); Tensurereportfile(); fprintf(Treportfile,"%s",vb2.buf); amtread= strlen(vb2.buf); if (amtread<=0 || vb2.buf[--amtread]!='\n') Psyntax("badly formed line"); vb2.buf[amtread]= 0; if (memcmp(vb2.buf," connect=",9)) Psyntax("syscall reply mismatch"); if (vb2.buf[9] == 'E') { int e; e= Perrno(vb2.buf+9); P_updatetime(); errno= e; return -1; } if (memcmp(vb2.buf+9,"OK",2)) Psyntax("success/fail not E* or OK"); vb2.used= 9+2; r= 0; assert(vb2.used <= amtread); if (vb2.used != amtread) Psyntax("junk at end of line"); P_updatetime(); return r;}int Hbind( int fd , const struct sockaddr *addr , int addrlen ) { int r, amtread; Qbind( fd , addr , addrlen ); if (!adns__vbuf_ensure(&vb2,1000)) Tnomem(); fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput(); Tensurereportfile(); fprintf(Treportfile,"%s",vb2.buf); amtread= strlen(vb2.buf); if (amtread<=0 || vb2.buf[--amtread]!='\n') Psyntax("badly formed line"); vb2.buf[amtread]= 0; if (memcmp(vb2.buf," bind=",6)) Psyntax("syscall reply mismatch"); if (vb2.buf[6] == 'E') { int e; e= Perrno(vb2.buf+6); P_updatetime(); errno= e; return -1; } if (memcmp(vb2.buf+6,"OK",2)) Psyntax("success/fail not E* or OK"); vb2.used= 6+2; r= 0; assert(vb2.used <= amtread); if (vb2.used != amtread) Psyntax("junk at end of line"); P_updatetime(); return r;}int Hlisten( int fd , int backlog ) { int r, amtread; Qlisten( fd , backlog ); if (!adns__vbuf_ensure(&vb2,1000)) Tnomem(); fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput(); Tensurereportfile(); fprintf(Treportfile,"%s",vb2.buf); amtread= strlen(vb2.buf); if (amtread<=0 || vb2.buf[--amtread]!='\n') Psyntax("badly formed line"); vb2.buf[amtread]= 0; if (memcmp(vb2.buf," listen=",8)) Psyntax("syscall reply mismatch"); if (vb2.buf[8] == 'E') { int e; e= Perrno(vb2.buf+8); P_updatetime(); errno= e; return -1; } if (memcmp(vb2.buf+8,"OK",2)) Psyntax("success/fail not E* or OK"); vb2.used= 8+2; r= 0; assert(vb2.used <= amtread); if (vb2.used != amtread) Psyntax("junk at end of line"); P_updatetime(); return r;}int Hclose( int fd ) { int r, amtread; Qclose( fd ); if (!adns__vbuf_ensure(&vb2,1000)) Tnomem(); fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput(); Tensurereportfile(); fprintf(Treportfile,"%s",vb2.buf); amtread= strlen(vb2.buf); if (amtread<=0 || vb2.buf[--amtread]!='\n') Psyntax("badly formed line"); vb2.buf[amtread]= 0; if (memcmp(vb2.buf," close=",7)) Psyntax("syscall reply mismatch"); if (vb2.buf[7] == 'E') { int e; e= Perrno(vb2.buf+7); P_updatetime(); errno= e; return -1; } if (memcmp(vb2.buf+7,"OK",2)) Psyntax("success/fail not E* or OK"); vb2.used= 7+2; r= 0; assert(vb2.used <= amtread); if (vb2.used != amtread) Psyntax("junk at end of line"); P_updatetime(); return r;}int Hsendto( int fd , const void *msg , int msglen , unsigned int flags , const struct sockaddr *addr , int addrlen ) { int r, amtread; char *ep; Tmust("sendto","flags",flags==0); Qsendto( fd , msg , msglen , addr , addrlen ); if (!adns__vbuf_ensure(&vb2,1000)) Tnomem(); fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput(); Tensurereportfile(); fprintf(Treportfile,"%s",vb2.buf); amtread= strlen(vb2.buf); if (amtread<=0 || vb2.buf[--amtread]!='\n') Psyntax("badly formed line"); vb2.buf[amtread]= 0; if (memcmp(vb2.buf," sendto=",8)) Psyntax("syscall reply mismatch"); if (vb2.buf[8] == 'E') { int e; e= Perrno(vb2.buf+8); P_updatetime(); errno= e; return -1; } r= strtoul(vb2.buf+8,&ep,10); if (*ep && *ep!=' ') Psyntax("return value not E* or positive number"); vb2.used= ep - (char*)vb2.buf; assert(vb2.used <= amtread); if (vb2.used != amtread) Psyntax("junk at end of line"); P_updatetime(); return r;}int Hrecvfrom( int fd , void *buf , int buflen , unsigned int flags , struct sockaddr *addr , int *addrlen ) { int r, amtread; Tmust("recvfrom","flags",flags==0); Tmust("recvfrom","*addrlen",*addrlen>=sizeof(struct sockaddr_in)); Qrecvfrom( fd , buflen , *addrlen ); if (!adns__vbuf_ensure(&vb2,1000)) Tnomem(); fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput(); Tensurereportfile(); fprintf(Treportfile,"%s",vb2.buf); amtread= strlen(vb2.buf); if (amtread<=0 || vb2.buf[--amtread]!='\n') Psyntax("badly formed line"); vb2.buf[amtread]= 0; if (memcmp(vb2.buf," recvfrom=",10)) Psyntax("syscall reply mismatch"); if (vb2.buf[10] == 'E') { int e; e= Perrno(vb2.buf+10); P_updatetime(); errno= e; return -1; } if (memcmp(vb2.buf+10,"OK",2)) Psyntax("success/fail not E* or OK"); vb2.used= 10+2; r= 0; Parg("addr"); Paddr(addr,addrlen); assert(vb2.used <= amtread); if (vb2.used != amtread) Psyntax("junk at end of line"); r= Pbytes(buf,buflen); P_updatetime(); return r;}int Hread( int fd , void *buf , size_t buflen ) { int r, amtread; Qread( fd , buflen ); if (!adns__vbuf_ensure(&vb2,1000)) Tnomem(); fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput(); Tensurereportfile(); fprintf(Treportfile,"%s",vb2.buf); amtread= strlen(vb2.buf); if (amtread<=0 || vb2.buf[--amtread]!='\n') Psyntax("badly formed line"); vb2.buf[amtread]= 0; if (memcmp(vb2.buf," read=",6)) Psyntax("syscall reply mismatch"); if (vb2.buf[6] == 'E') { int e; e= Perrno(vb2.buf+6); P_updatetime(); errno= e; return -1; } if (memcmp(vb2.buf+6,"OK",2)) Psyntax("success/fail not E* or OK"); vb2.used= 6+2; r= 0; assert(vb2.used <= amtread); if (vb2.used != amtread) Psyntax("junk at end of line"); r= Pbytes(buf,buflen); P_updatetime(); return r;}int Hwrite( int fd , const void *buf , size_t len ) { int r, amtread; char *ep; Qwrite( fd , buf , len ); if (!adns__vbuf_ensure(&vb2,1000)) Tnomem(); fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput(); Tensurereportfile(); fprintf(Treportfile,"%s",vb2.buf); amtread= strlen(vb2.buf); if (amtread<=0 || vb2.buf[--amtread]!='\n') Psyntax("badly formed line"); vb2.buf[amtread]= 0; if (memcmp(vb2.buf," write=",7)) Psyntax("syscall reply mismatch"); if (vb2.buf[7] == 'E') { int e; e= Perrno(vb2.buf+7); P_updatetime(); errno= e; return -1; } r= strtoul(vb2.buf+7,&ep,10); if (*ep && *ep!=' ') Psyntax("return value not E* or positive number"); vb2.used= ep - (char*)vb2.buf; assert(vb2.used <= amtread); if (vb2.used != amtread) Psyntax("junk at end of line"); P_updatetime(); return r;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -