chiark / gitweb /
New TCP tests.
[adns.git] / regress / hmacros.i4
1 m4_dnl hmacros.h.m4
2 m4_dnl (part of complex test harness, not of the library)
3 m4_dnl - common macros
4
5 m4_dnl  This file is
6 m4_dnl    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
7 m4_dnl
8 m4_dnl  It is part of adns, which is
9 m4_dnl    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
10 m4_dnl    Copyright (C) 1999 Tony Finch <dot@dotat.at>
11 m4_dnl  
12 m4_dnl  This program is free software; you can redistribute it and/or modify
13 m4_dnl  it under the terms of the GNU General Public License as published by
14 m4_dnl  the Free Software Foundation; either version 2, or (at your option)
15 m4_dnl  any later version.
16 m4_dnl  
17 m4_dnl  This program is distributed in the hope that it will be useful,
18 m4_dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
19 m4_dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 m4_dnl  GNU General Public License for more details.
21 m4_dnl  
22 m4_dnl  You should have received a copy of the GNU General Public License
23 m4_dnl  along with this program; if not, write to the Free Software Foundation,
24 m4_dnl  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
25
26 m4_define(`hm_args_massage',
27         `m4_ifelse(
28                 m4_patsubst(
29                                 $1,
30                                 `hm_comma\|[
31          ]+',
32                                 `'),
33                 `',
34                 `$2',
35                 `
36         m4_patsubst(m4_patsubst(m4_patsubst(m4_translit($1, `
37         ',` '), `\(hm_comma *\)*$', `'), `^\( *hm_comma\)*', `'),
38                 `\( *hm_comma *\)+',` hm_comma ')
39         ')')
40
41 m4_define(`hm_create_nothing', `
42  m4_define(`hm_na',`')
43  m4_define(`hm_arg_nullptr', `')
44  m4_define(`hm_arg_int', `')
45  m4_define(`hm_arg_fdset_io', `')
46  m4_define(`hm_arg_pollfds_io', `')
47  m4_define(`hm_arg_timeval_in_rel_null',`')
48  m4_define(`hm_arg_must', `')
49  m4_define(`hm_arg_socktype',`')
50  m4_define(`hm_arg_ign', `')
51  m4_define(`hm_arg_fd', `')
52  m4_define(`hm_arg_fcntl_cmd_arg',`')
53  m4_define(`hm_arg_addr_in', `')
54  m4_define(`hm_arg_bytes_in', `')
55  m4_define(`hm_arg_bytes_out', `')
56  m4_define(`hm_arg_addr_out', `')
57 ')
58
59 m4_define(`hm_create_proto_h',`
60  m4_define(`hm_na', `hm_comma')
61  m4_define(`hm_arg_nullptr', `$'`1 $'`2')
62  m4_define(`hm_arg_int', `int $'`1')
63  m4_define(`hm_arg_fdset_io', `fd_set *$'`1')
64  m4_define(`hm_arg_pollfds_io', `struct pollfd *$'`1 hm_comma int $'`2')
65  m4_define(`hm_arg_timeval_in_rel_null', `struct timeval *$'`1')
66  m4_define(`hm_arg_must', `$'`1 $'`2')
67  m4_define(`hm_arg_socktype', `int $'`1')
68  m4_define(`hm_arg_ign', `$'`1 $'`2')
69  m4_define(`hm_arg_fd', `int $'`1')
70  m4_define(`hm_arg_fcntl_cmd_arg', `int $'`1 hm_comma ...')
71  m4_define(`hm_arg_addr_in', `const struct sockaddr *$'`1 hm_comma int $'`2')
72  m4_define(`hm_arg_bytes_in', `const $'`1 *$'`2 hm_comma $'`3 $'`4')
73  m4_define(`hm_arg_bytes_out', `$'`1 *$'`2 hm_comma $'`3 $'`4')
74  m4_define(`hm_arg_addr_out', `struct sockaddr *$'`1 hm_comma int *$'`2')
75 ')
76
77 m4_define(`hm_create_proto_q',`
78  hm_create_proto_h
79  m4_define(`hm_arg_nullptr', `')
80  m4_define(`hm_arg_fdset_io', `const fd_set *$'`1')
81  m4_define(`hm_arg_pollfds_io', `const struct pollfd *$'`1 hm_comma int $'`2')
82  m4_define(`hm_arg_must', `')
83  m4_define(`hm_arg_ign', `')
84  m4_define(`hm_arg_fcntl_cmd_arg', `int $'`1 hm_comma long $'`2')
85  m4_define(`hm_arg_bytes_out', `$'`3 $'`4')
86  m4_define(`hm_arg_addr_out', `int $'`2')
87 ')
88
89 m4_define(`hm_create_hqcall_vars',`
90  hm_create_nothing
91  m4_define(`hm_arg_fcntl_cmd_arg',`va_list al; long $'`2;')
92 ')
93
94 m4_define(`hm_create_hqcall_init',`
95  hm_create_nothing
96  m4_define(`hm_arg_nullptr', `Tmust("$1","$'`2",!$'`2);')
97  m4_define(`hm_arg_must', `Tmust("$1","$'`2",$'`2==$'`3);')
98  m4_define(`hm_arg_socktype',`
99   Tmust("$1","$'`1",$'`1==SOCK_STREAM || $'`1==SOCK_DGRAM);')
100  m4_define(`hm_arg_fcntl_cmd_arg',`
101   Tmust("$1","$'`1",$'`1==F_SETFL || $'`1==F_GETFL);
102   if ($'`1 == F_SETFL) {
103     va_start(al,$'`1); $'`2= va_arg(al,long); va_end(al);
104   } else {
105     $'`2= 0;
106   }')
107  m4_define(`hm_arg_addr_out',`Tmust("$1","*$'`2",*$'`2>=sizeof(struct sockaddr_in));')
108 ')
109
110 m4_define(`hm_create_realcall_args',`
111  m4_define(`hm_na',`hm_comma')
112  m4_define(`hm_arg_nullptr', `0')
113  m4_define(`hm_arg_int', `$'`1')
114  m4_define(`hm_arg_fdset_io', `$'`1')
115  m4_define(`hm_arg_pollfds_io', `$'`1 hm_comma $'`2')
116  m4_define(`hm_arg_timeval_in_rel_null', `$'`1')
117  m4_define(`hm_arg_must', `$'`2')
118  m4_define(`hm_arg_socktype', `$'`1')
119  m4_define(`hm_arg_ign', `$'`2')
120  m4_define(`hm_arg_fd', `$'`1')
121  m4_define(`hm_arg_fcntl_cmd_arg', `$'`1 hm_comma $'`2')
122  m4_define(`hm_arg_addr_in', `$'`1 hm_comma $'`2')
123  m4_define(`hm_arg_bytes_in', `$'`2 hm_comma $'`4')
124  m4_define(`hm_arg_bytes_out', `$'`2 hm_comma $'`4')
125  m4_define(`hm_arg_addr_out', `$'`1 hm_comma $'`2')
126 ')
127
128 m4_define(`hm_create_hqcall_args',`
129  hm_create_realcall_args
130  m4_define(`hm_arg_nullptr', `')
131  m4_define(`hm_arg_must', `')
132  m4_define(`hm_arg_ign', `')
133  m4_define(`hm_arg_bytes_in', `$'`2 hm_comma $'`4')
134  m4_define(`hm_arg_bytes_out', `$'`4')
135  m4_define(`hm_arg_addr_out', `*$'`2')
136 ')