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