chiark / gitweb /
src/event.c: Use `continue' in adns_processreadable (style)
[adns.git] / regress / hcommon.c
index ff984fecd1cd8d0924ce7f1323a92e9588e3211a..ebbef9400e4d361dc96c24cbabe2dcec6d54fd33 100644 (file)
@@ -67,9 +67,12 @@ void Qpoll(  const struct pollfd *fds , int nfds , int timeout       ) {
   Q_vb();
 }
 #endif
-void Qsocket(   int type       ) {
+void Qsocket(  int domain , int type   ) {
  vb.used= 0;
  Tvba("socket");
+  Tvbf(domain==AF_INET ? " domain=AF_INET" :
+         domain==AF_INET6 ? " domain=AF_INET6" :
+         " domain=AF_???"); 
   Tvbf(type==SOCK_STREAM ? " type=SOCK_STREAM" : " type=SOCK_DGRAM"); 
   Q_vb();
 }
@@ -126,7 +129,6 @@ void Qrecvfrom(     int fd , int buflen , int addrlen       ) {
  Tvba("recvfrom");
        Tvbf(" fd=%d",fd); 
        Tvbf(" buflen=%lu",(unsigned long)buflen); 
-       Tvbf(" *addrlen=%d",addrlen); 
   Q_vb();
 }
 void Qread(    int fd , size_t buflen  ) {
@@ -144,10 +146,12 @@ void Qwrite(      int fd , const void *buf , size_t len   ) {
   Q_vb();
 }
 void Tvbaddr(const struct sockaddr *addr, int len) {
-  const struct sockaddr_in *ai= (const struct sockaddr_in*)addr;
-  assert(len==sizeof(struct sockaddr_in));
-  assert(ai->sin_family==AF_INET);
-  Tvbf("%s:%u",inet_ntoa(ai->sin_addr),htons(ai->sin_port));
+  char buf[ADNS_ADDR2TEXT_BUFLEN];
+  int err, port;
+  int sz= sizeof(buf);
+  err= adns_addr2text(addr, 0, buf,&sz, &port);
+  assert(!err);
+  Tvbf(strchr(buf, ':') ? "[%s]:%d" : "%s:%d", buf,port);
 }
 void Tvbbytes(const void *buf, int len) {
   const byte *bp;
@@ -295,3 +299,6 @@ void Hexit(int rv) {
   }
   exit(rv);
 }
+pid_t Hgetpid(void) {
+  return 2264; /* just some number */
+}