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