Licensing: Update copyright dates for Ian Jackson
[adns] / regress / hmacros.i4
CommitLineData
bb7ba677 1m4_dnl hmacros.h.m4
2m4_dnl (part of complex test harness, not of the library)
3m4_dnl - common macros
4
ae8cc977 5m4_dnl This file is part of adns, which is
26e1c3d6 6m4_dnl Copyright (C) 1997-2000,2003,2006,2014 Ian Jackson
ae8cc977 7m4_dnl Copyright (C) 1999-2000,2003,2006 Tony Finch
8m4_dnl Copyright (C) 1991 Massachusetts Institute of Technology
9m4_dnl (See the file INSTALL for full details.)
bb7ba677 10m4_dnl
11m4_dnl This program is free software; you can redistribute it and/or modify
12m4_dnl it under the terms of the GNU General Public License as published by
7f8bbe29 13m4_dnl the Free Software Foundation; either version 3, or (at your option)
bb7ba677 14m4_dnl any later version.
15m4_dnl
16m4_dnl This program is distributed in the hope that it will be useful,
17m4_dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
18m4_dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19m4_dnl GNU General Public License for more details.
20m4_dnl
21m4_dnl You should have received a copy of the GNU General Public License
8c09a4c6 22m4_dnl along with this program; if not, write to the Free Software Foundation.
bb7ba677 23
24m4_define(`hm_args_massage',
25 `m4_ifelse(
26 m4_patsubst(
27 $1,
28 `hm_comma\|[
29 ]+',
30 `'),
31 `',
32 `$2',
0ebff22d 33 `m4_dnl
bb7ba677 34 m4_patsubst(m4_patsubst(m4_patsubst(m4_translit($1, `
35 ',` '), `\(hm_comma *\)*$', `'), `^\( *hm_comma\)*', `'),
0ebff22d 36 `\( *hm_comma *\)+',` hm_comma ')m4_dnl
bb7ba677 37 ')')
38
39m4_define(`hm_create_nothing', `
40 m4_define(`hm_na',`')
bb7ba677 41 m4_define(`hm_arg_nullptr', `')
42 m4_define(`hm_arg_int', `')
43 m4_define(`hm_arg_fdset_io', `')
8b1171e6 44 m4_define(`hm_arg_pollfds_io', `')
bb7ba677 45 m4_define(`hm_arg_timeval_in_rel_null',`')
46 m4_define(`hm_arg_must', `')
47 m4_define(`hm_arg_socktype',`')
5c6cd9e0 48 m4_define(`hm_arg_addrfam',`')
bb7ba677 49 m4_define(`hm_arg_ign', `')
50 m4_define(`hm_arg_fd', `')
51 m4_define(`hm_arg_fcntl_cmd_arg',`')
52 m4_define(`hm_arg_addr_in', `')
53 m4_define(`hm_arg_bytes_in', `')
54 m4_define(`hm_arg_bytes_out', `')
55 m4_define(`hm_arg_addr_out', `')
56')
57
58m4_define(`hm_create_proto_h',`
59 m4_define(`hm_na', `hm_comma')
bb7ba677 60 m4_define(`hm_arg_nullptr', `$'`1 $'`2')
61 m4_define(`hm_arg_int', `int $'`1')
62 m4_define(`hm_arg_fdset_io', `fd_set *$'`1')
8b1171e6 63 m4_define(`hm_arg_pollfds_io', `struct pollfd *$'`1 hm_comma int $'`2')
bb7ba677 64 m4_define(`hm_arg_timeval_in_rel_null', `struct timeval *$'`1')
65 m4_define(`hm_arg_must', `$'`1 $'`2')
66 m4_define(`hm_arg_socktype', `int $'`1')
5c6cd9e0 67 m4_define(`hm_arg_addrfam', `int $'`1')
bb7ba677 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
77m4_define(`hm_create_proto_q',`
78 hm_create_proto_h
bb7ba677 79 m4_define(`hm_arg_nullptr', `')
80 m4_define(`hm_arg_fdset_io', `const fd_set *$'`1')
8b1171e6 81 m4_define(`hm_arg_pollfds_io', `const struct pollfd *$'`1 hm_comma int $'`2')
bb7ba677 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
89m4_define(`hm_create_hqcall_vars',`
90 hm_create_nothing
91 m4_define(`hm_arg_fcntl_cmd_arg',`va_list al; long $'`2;')
92')
93
94m4_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);')
5c6cd9e0 100 m4_define(`hm_arg_addrfam',`
9ec92889 101 Tmust("$1","$'`1",$'`1==AF_INET || $'`1==AF_INET6);')
bb7ba677 102 m4_define(`hm_arg_fcntl_cmd_arg',`
103 Tmust("$1","$'`1",$'`1==F_SETFL || $'`1==F_GETFL);
104 if ($'`1 == F_SETFL) {
105 va_start(al,$'`1); $'`2= va_arg(al,long); va_end(al);
106 } else {
107 $'`2= 0;
108 }')
70a778e5 109 m4_define(`hm_arg_addr_out',`Tmust("$1","*$'`2",*$'`2>=sizeof(struct sockaddr_in));')
bb7ba677 110')
111
112m4_define(`hm_create_realcall_args',`
113 m4_define(`hm_na',`hm_comma')
bb7ba677 114 m4_define(`hm_arg_nullptr', `0')
115 m4_define(`hm_arg_int', `$'`1')
116 m4_define(`hm_arg_fdset_io', `$'`1')
8b1171e6 117 m4_define(`hm_arg_pollfds_io', `$'`1 hm_comma $'`2')
bb7ba677 118 m4_define(`hm_arg_timeval_in_rel_null', `$'`1')
119 m4_define(`hm_arg_must', `$'`2')
120 m4_define(`hm_arg_socktype', `$'`1')
5c6cd9e0 121 m4_define(`hm_arg_addrfam', `$'`1')
bb7ba677 122 m4_define(`hm_arg_ign', `$'`2')
123 m4_define(`hm_arg_fd', `$'`1')
124 m4_define(`hm_arg_fcntl_cmd_arg', `$'`1 hm_comma $'`2')
125 m4_define(`hm_arg_addr_in', `$'`1 hm_comma $'`2')
126 m4_define(`hm_arg_bytes_in', `$'`2 hm_comma $'`4')
127 m4_define(`hm_arg_bytes_out', `$'`2 hm_comma $'`4')
128 m4_define(`hm_arg_addr_out', `$'`1 hm_comma $'`2')
129')
130
131m4_define(`hm_create_hqcall_args',`
132 hm_create_realcall_args
bb7ba677 133 m4_define(`hm_arg_nullptr', `')
134 m4_define(`hm_arg_must', `')
135 m4_define(`hm_arg_ign', `')
136 m4_define(`hm_arg_bytes_in', `$'`2 hm_comma $'`4')
137 m4_define(`hm_arg_bytes_out', `$'`4')
138 m4_define(`hm_arg_addr_out', `*$'`2')
139')