X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=regress%2Fhplayback.c.m4;h=8e6424f3e67b8bb5267c6208058afc97f713f95f;hb=2345cc9b2cf1eb59444d33c17d443bd93c6a5743;hp=5f8b45627d51e104ae44993d9e8b9d954cbbd447;hpb=73c4c523c0fc436ed51e7d473e016d36e9a4b6bd;p=adns.git diff --git a/regress/hplayback.c.m4 b/regress/hplayback.c.m4 index 5f8b456..8e6424f 100644 --- a/regress/hplayback.c.m4 +++ b/regress/hplayback.c.m4 @@ -89,6 +89,20 @@ static void Parg(const char *argname) { if (vb2.buf[vb2.used++] != hm_squote=hm_squote) Psyntax("not = after argument name"); } +static int Pstring_maybe(const char *string) { + int l; + + l= strlen(string); + if (memcmp(vb2.buf+vb2.used,string,l)) return 0; + vb2.used+= l; + return 1; +} + +static void Pstring(const char *string, const char *emsg) { + if (Pstring_maybe(string)) return; + Psyntax(emsg); +} + static int Perrno(const char *stuff) { const struct Terrno *te; int r; @@ -136,6 +150,49 @@ static void Pfdset(fd_set *set, int max) { } } +#ifdef HAVE_POLL +static int Ppollfdevents(void) { + int events; + + if (Pstring_maybe("0")) return 0; + events= 0; + + if (Pstring_maybe("POLLIN")) { + events |= POLLIN; + if (!Pstring_maybe("|")) return events; + } + + if (Pstring_maybe("POLLOUT")) { + events |= POLLOUT; + if (!Pstring_maybe("|")) return events; + } + + Pstring("POLLPRI","pollfdevents PRI?"); + return events; +} + +static void Ppollfds(struct pollfd *fds, int nfds) { + int i; + char *ep; + const char *comma= ""; + + if (vb2.buf[vb2.used++] != hm_squote[hm_squote) Psyntax("pollfds start not ["); + for (i=0; ifd= strtoul(vb2.buf+vb2.used,&ep,10); + vb2.used= ep - (char*)vb2.buf; + Pstring(", events=",", events= in pollfds"); + fds->events= Ppollfdevents(); + Pstring(", revents=",", revents= in pollfds"); + fds->revents= Ppollfdevents(); + Pstring("}","} in pollfds"); + Pstring(comma,"separator in pollfds"); + comma= ", "; + } + if (vb2.buf[vb2.used++] != hm_squote]hm_squote) Psyntax("pollfds end not ]"); +} +#endif + static void Paddr(struct sockaddr *addr, int *lenr) { struct sockaddr_in *sa= (struct sockaddr_in*)addr; char *p, *ep; @@ -281,6 +338,7 @@ int H$1(hm_args_massage($3,void)) { hm_create_nothing m4_define(`hm_arg_fdset_io',`Parg("$'`1"); Pfdset($'`1,$'`2);') + m4_define(`hm_arg_pollfds_io',`Parg("$'`1"); Ppollfds($'`1,$'`2);') m4_define(`hm_arg_addr_out',`Parg("$'`1"); Paddr($'`1,$'`2);') $3 if (vb2.used != vb2.avail) Psyntax("junk at end of line");