chiark / gitweb /
Work on harness is progressing.
[adns] / src / hcommon.c
CommitLineData
74cf211e 1/*
2 * hcommon.c
3 * - complex test harness, routines used for both record and playback
4 */
5/*
6 * This file is part of adns, which is Copyright (C) 1997, 1998 Ian Jackson
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
22
23#include "harness.h"
24#include "internal.h"
25
26static vbuf vb;
27
28void Qgettimeofday(void) {
29 Tsyscall("gettimeofday()");
30}
31
32void Qselect(int n, fd_set rfds, fd_set wfds, fd_set efds, const struct timeval *t) {
33 char buf[100];
34
35 sprintf(buf,"select(%d, [",n);
36 vb.used= 0;
37 Tvba(&vb,buf);
38 Tvbfdset(&vb,n,rfds);
39 Tvba(&vb,"], [");
40 Tvbfdset(&vb,n,wfds);
41 Tvba(&vb,"], [");
42 Tvbfdset(&vb,n,efds);
43 if (t) {
44 sprintf(buf,"], %ld.%06ld)",t->tv_sec,t->tv_usec);
45 Tvba(&vb,buf);
46 } else {
47 Tvba(&vb,"], NULL)");
48 }
49 Tvbfin();
50 Tsyscall(vb.buf);
51}
52
53void Qsocket(int type) {
54 switch (type) {
55 case SOCK_STREAM: Tsyscall("socket(,SOCK_STREAM,)"); break;
56 case SOCK_DGRAM: Tsyscall("socket(,SOCK_DGRAM,)"); break;
57 default: abort();
58 }
59}
60
61void Qfcntl(int fd, int cmd, long arg) {
62 static char buf[100];
63
64 switch (cmd) {
65 case F_GETFL:
66 sprintf(buf,"fcntl(%d, %s, %ld)",
67}
68
69void Qconnect(int fd, struct sockaddr *addr, int addrlen);
70void Qclose(int fd);
71
72void Qsendto(int fd, const void *msg, int msglen, unsigned int flags,
73 const struct sockaddr *addr, int addrlen);
74void Qrecvfrom(int fd, int buflen, unsigned int flags, int *addrlen);
75
76void Qread(int fd, size_t len);
77void Qwrite(int fd, const void *buf, size_t len);