m4_dnl (part of complex test harness, not of the library)
m4_dnl - routines used for both record and playback
-m4_dnl This file is part of adns, which is Copyright (C) 1997, 1998 Ian Jackson
+m4_dnl This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson
m4_dnl
m4_dnl This program is free software; you can redistribute it and/or modify
m4_dnl it under the terms of the GNU General Public License as published by
m4_define(`hm_arg_nullptr',`')
m4_define(`hm_arg_int', `Tvbf(" $'`1=%d",$'`1);')
m4_define(`hm_arg_fdset_io', `Tvbf(" $'`1="); Tvbfdset($'`2,$'`1);')
+ m4_define(`hm_arg_pollfds_io', `Tvbf(" $'`1="); Tvbpollfds($'`1,$'`2);')
m4_define(`hm_arg_timeval_in_rel_null', `
if ($'`1) Tvbf(" $'`1=%ld.%06ld",(long)$'`1->tv_sec,(long)$'`1->tv_usec);
else Tvba(" $'`1=null");')
m4_define(`hm_arg_fd', `Tvbf(" $'`1=%d",$'`1);')
m4_define(`hm_arg_fcntl_cmd_arg', `
if ($'`1 == F_SETFL) {
- Tvbf(" $'`1=F_SETFL %ld",arg);
- } else {
+ Tvbf(" $'`1=F_SETFL %s",arg & O_NONBLOCK ? "O_NONBLOCK|..." : "~O_NONBLOCK&...");
+ } else if ($'`1 == F_GETFL) {
Tvba(" $'`1=F_GETFL");
+ } else {
+ Tmust("$'`1","F_GETFL/F_SETFL",0);
}')
m4_define(`hm_arg_addr_in', `Tvba(" $'`1="); Tvbaddr($'`1,$'`2);')
m4_define(`hm_arg_bytes_in', `')
Tvba("]");
}
+static void Tvbpollevents(int events) {
+ const char *delim= "";
+
+ events &= (POLLIN|POLLOUT|POLLPRI);
+ if (!events) { Tvba("0"); return; }
+ if (events & POLLIN) { Tvba("POLLIN"); delim= "|"; }
+ if (events & POLLOUT) { Tvba(delim); Tvba("POLLOUT"); delim= "|"; }
+ if (events & POLLPRI) { Tvba(delim); Tvba("POLLPRI"); }
+}
+
+void Tvbpollfds(const struct pollfd *fds, int nfds) {
+ const char *comma= "";
+
+ Tvba("[");
+ while (nfds>0) {
+ Tvba(comma);
+ Tvbf("{fd=%d, events=",fds->fd);
+ Tvbpollevents(fds->events);
+ Tvba(", revents=");
+ Tvbpollevents(fds->revents);
+ Tvba("}");
+ comma= ", ";
+ nfds--; fds++;
+ }
+ Tvba("]");
+}
+
void Tvberrno(int e) {
const struct Terrno *te;