1 /*
2 * %CopyrightBegin%
3 *
4 * Copyright Ericsson AB 2002-2020. All Rights Reserved.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * %CopyrightEnd%
19 */
20
21 /***************************************************************************
22 *
23 * This is a fake program that contains all functions, variables and
24 * defined symbols mentioned in the manual. We compile this file to see
25 * that the header files and created library is complete.
26 *
27 * You can't run this program, it is for compiling and linking only.
28 *
29 ***************************************************************************/
30
31 /* This is a link and header file test. Including "ei.h" and linking
32 with libei.a should be enough */
33
34 /* Use most of
35 * CFLAGS="-I../include -g -O2
36 * -ansi -pedantic
37 * -Wall
38 * -Wshadow
39 * -Wstrict-prototypes
40 * -Wmissing-prototypes
41 * -Wmissing-declarations
42 * -Wnested-externs
43 * -Winline
44 * -Werror"
45 */
46
47 /* An exception from using eidef.h, use config.h directly */
48 #include "config.h"
49
50 #if defined(HAVE_GMP_H) && defined(HAVE_LIBGMP)
51 #include <gmp.h>
52 #endif /* HAVE_GMP_H && HAVE_LIBGMP */
53
54 /* #include <netdb.h> now included by ei.h */
55 #include "ei.h"
56
57 #ifdef VXWORKS
ei_fake_prog_main(void)58 int ei_fake_prog_main(void)
59 #else
60 int main(void)
61 #endif
62 {
63 ErlConnect conp;
64 Erl_IpAddr thisipaddr = (Erl_IpAddr)0;
65 FILE *fp = (FILE *)0;
66 char* charp = "foo";
67 double *doublep = NULL;
68 double doublex = 0.0;
69 ei_cnode xec;
70 ei_reg *ei_regp = NULL;
71 ei_term eterm;
72 ei_x_buff eix;
73 erlang_big *bigp = NULL;
74 erlang_fun efun;
75 erlang_msg *msgp = NULL;
76 erlang_msg emsg;
77 erlang_pid *pidp = NULL;
78 erlang_pid epid;
79 erlang_port eport;
80 erlang_ref eref;
81 erlang_trace etrace;
82 int *intp = NULL;
83 int intx = 0;
84 long *longp = NULL;
85 long longx = 0;
86 short creation = 0;
87 struct ei_reg_stat *ei_reg_statp = NULL;
88 struct ei_reg_tabstat *ei_reg_tabstatp = NULL;
89 struct hostent *hostp = NULL;
90 unsigned char * ucharp = (unsigned char *)"foo";
91 unsigned long *ulongp = NULL;
92 unsigned long ulongx = 0;
93 void *voidp = NULL;
94 #ifndef VXWORKS
95 EI_LONGLONG *longlongp = (EI_LONGLONG*)NULL;
96 EI_LONGLONG longlongx = 0;
97 EI_ULONGLONG *ulonglongp = (EI_ULONGLONG*)NULL;
98 EI_ULONGLONG ulonglongx = 0;
99 #endif
100 erlang_char_encoding enc;
101 ei_socket_callbacks cbs;
102
103 intx = erl_errno;
104
105 ei_init();
106
107 ei_close_connection(intx);
108
109 ei_connect_init(&xec, charp, charp, creation);
110 ei_connect_init_ussi(&xec, charp, charp, creation, &cbs, sizeof(cbs), NULL);
111 ei_connect_xinit (&xec, charp, charp, charp, thisipaddr, charp, creation);
112 ei_connect_xinit_ussi(&xec, charp, charp, charp, thisipaddr, charp, creation, &cbs, sizeof(cbs), NULL);
113
114 ei_connect(&xec, charp);
115 ei_xconnect (&xec, thisipaddr, charp);
116
117 ei_receive(intx, ucharp, intx);
118 ei_receive_msg(intx, &emsg, &eix);
119 ei_xreceive_msg(intx, &emsg, &eix);
120
121 ei_send(intx, &epid, charp, intx);
122 ei_reg_send(&xec, intx, charp, charp, intx);
123
124 ei_rpc(&xec, intx, charp, charp, charp, intx, &eix);
125 ei_rpc_to(&xec, intx, charp, charp, charp, intx);
126 ei_rpc_from(&xec, intx, intx, &emsg, &eix);
127
128 ei_publish(&xec, intx);
129 ei_accept(&xec, intx, &conp);
130 ei_unpublish(&xec);
131 ei_listen(&xec, intp, intx);
132 ei_xlisten(&xec, thisipaddr, intp, intx);
133
134 ei_thisnodename(&xec);
135 ei_thishostname(&xec);
136 ei_thisalivename(&xec);
137
138 ei_self(&xec);
139
140 ei_gethostbyname(charp);
141 ei_gethostbyaddr(charp, intx, intx);
142 ei_gethostbyname_r(charp, hostp, charp, intx, intp);
143 ei_gethostbyaddr_r(charp, intx, intx, hostp, charp, intx, intp);
144
145 ei_encode_version(charp, intp);
146 ei_x_encode_version(&eix);
147 ei_encode_long(charp, intp, longx);
148 ei_x_encode_long(&eix, longx);
149 ei_encode_ulong(charp, intp, ulongx);
150 ei_x_encode_ulong(&eix, ulongx);
151 ei_encode_double(charp, intp, doublex);
152 ei_x_encode_double(&eix, doublex);
153 ei_encode_boolean(charp, intp, intx);
154 ei_x_encode_boolean(&eix, intx);
155 ei_encode_char(charp, intp, 'a');
156 ei_x_encode_char(&eix, 'a');
157 ei_encode_string(charp, intp, charp);
158 ei_encode_string_len(charp, intp, charp, intx);
159 ei_x_encode_string(&eix, charp);
160 ei_x_encode_string_len(&eix, charp, intx);
161 ei_encode_atom(charp, intp, charp);
162 ei_encode_atom_as(charp, intp, charp, ERLANG_LATIN1, ERLANG_UTF8);
163 ei_encode_atom_len(charp, intp, charp, intx);
164 ei_encode_atom_len_as(charp, intp, charp, intx, ERLANG_ASCII, ERLANG_LATIN1);
165 ei_x_encode_atom(&eix, charp);
166 ei_x_encode_atom_as(&eix, charp, ERLANG_LATIN1, ERLANG_UTF8);
167 ei_x_encode_atom_len(&eix, charp, intx);
168 ei_x_encode_atom_len_as(&eix, charp, intx, ERLANG_LATIN1, ERLANG_UTF8);
169 ei_encode_binary(charp, intp, (void *)0, longx);
170 ei_x_encode_binary(&eix, (void*)0, intx);
171 ei_encode_pid(charp, intp, &epid);
172 ei_x_encode_pid(&eix, &epid);
173 ei_encode_fun(charp, intp, &efun);
174 ei_x_encode_fun(&eix, &efun);
175 ei_encode_port(charp, intp, &eport);
176 ei_x_encode_port(&eix, &eport);
177 ei_encode_ref(charp, intp, &eref);
178 ei_x_encode_ref(&eix, &eref);
179 ei_encode_trace(charp, intp, &etrace);
180 ei_x_encode_trace(&eix, &etrace);
181 ei_encode_tuple_header(charp, intp, intx);
182 ei_x_encode_tuple_header(&eix, longx);
183 ei_encode_list_header(charp, intp, intx);
184 ei_x_encode_list_header(&eix, longx);
185 /* #define ei_encode_empty_list(buf,i) ei_encode_list_header(buf,i,0) */
186 ei_x_encode_empty_list(&eix);
187
188 ei_get_type(charp, intp, intp, intp);
189
190 ei_decode_version(charp, intp, intp);
191 ei_decode_long(charp, intp, longp);
192 ei_decode_ulong(charp, intp, ulongp);
193 ei_decode_double(charp, intp, doublep);
194 ei_decode_boolean(charp, intp, intp);
195 ei_decode_char(charp, intp, charp);
196 ei_decode_string(charp, intp, charp);
197 ei_decode_atom(charp, intp, charp);
198 ei_decode_atom_as(charp, intp, charp, MAXATOMLEN_UTF8, ERLANG_UTF8, &enc, &enc);
199 ei_decode_binary(charp, intp, (void *)0, longp);
200 ei_decode_fun(charp, intp, &efun);
201 free_fun(&efun);
202 ei_decode_pid(charp, intp, &epid);
203 ei_decode_port(charp, intp, &eport);
204 ei_decode_ref(charp, intp, &eref);
205 ei_decode_trace(charp, intp, &etrace);
206 ei_decode_tuple_header(charp, intp, intp);
207 ei_decode_list_header(charp, intp, intp);
208
209 ei_decode_ei_term(charp, intp, &eterm);
210
211 ei_print_term(fp, charp, intp);
212 ei_s_print_term(&charp, charp, intp);
213
214 ei_x_format(&eix, charp);
215 ei_x_format_wo_ver(&eix, charp);
216
217 ei_x_new(&eix);
218 ei_x_new_with_version(&eix);
219 ei_x_free(&eix);
220 ei_x_append(&eix, &eix);
221 ei_x_append_buf(&eix, charp, intx);
222 ei_skip_term(charp, intp);
223
224 ei_reg_open(intx);
225 ei_reg_resize(ei_regp, intx);
226 ei_reg_close(ei_regp);
227
228 ei_reg_setival(ei_regp, charp, longx);
229 ei_reg_setfval(ei_regp, charp, doublex);
230 ei_reg_setsval(ei_regp, charp, charp);
231 ei_reg_setpval(ei_regp, charp, voidp, intx);
232
233 ei_reg_setval(ei_regp, charp, intx);
234
235 ei_reg_getival(ei_regp, charp);
236 ei_reg_getfval(ei_regp, charp);
237 ei_reg_getsval(ei_regp, charp);
238 ei_reg_getpval(ei_regp, charp, intp);
239
240 ei_reg_getval(ei_regp, charp, intx);
241
242 ei_reg_markdirty(ei_regp, charp);
243
244 ei_reg_delete(ei_regp, charp);
245
246 ei_reg_stat(ei_regp, charp, ei_reg_statp);
247
248 ei_reg_tabstat(ei_regp, ei_reg_tabstatp);
249
250 ei_reg_dump(intx, ei_regp, charp, intx);
251 ei_reg_restore(intx, ei_regp, charp);
252 ei_reg_purge(ei_regp);
253
254 #if defined(HAVE_GMP_H) && defined(HAVE_LIBGMP)
255 {
256 mpz_t obj;
257 ei_decode_bignum(charp, intp, obj);
258 ei_encode_bignum(charp, intp, obj);
259 ei_x_encode_bignum(&eix, obj);
260 }
261 #endif /* HAVE_GMP_H && HAVE_LIBGMP */
262
263 #ifndef VXWORKS
264
265 ei_decode_longlong(charp, intp, longlongp);
266 ei_decode_ulonglong(charp, intp, ulonglongp);
267 ei_encode_longlong(charp, intp, longlongx);
268 ei_encode_ulonglong(charp, intp, ulonglongx);
269 ei_x_encode_longlong(&eix, longlongx);
270 ei_x_encode_ulonglong(&eix, ulonglongx);
271
272 #endif
273
274 #ifdef USE_EI_UNDOCUMENTED
275
276 ei_decode_intlist(charp, intp, longp, intp);
277
278 ei_receive_encoded(intx, &charp, intp, msgp, intp);
279 ei_send_encoded(intx, pidp, charp, intx);
280 ei_send_reg_encoded(intx, pidp, charp, charp, intx);
281
282 ei_decode_big(charp, intp, bigp);
283 ei_big_comp(bigp, bigp);
284 ei_big_to_double(bigp, doublep);
285 ei_small_to_big(intx, bigp);
286 ei_alloc_big(intx);
287 ei_free_big(bigp);
288
289 #endif /* USE_EI_UNDOCUMENTED */
290
291 return
292 BUFSIZ +
293 EAGAIN +
294 EHOSTUNREACH +
295 EIO +
296 EI_BIN +
297 EI_DELET +
298 EI_DIRTY +
299 EI_FLT +
300 EI_FORCE +
301 EI_INT +
302 EI_NOPURGE +
303 EI_STR +
304 EMSGSIZE +
305 ENOMEM +
306 ERL_ERROR +
307 ERL_EXIT +
308 ERL_LINK +
309 ERL_MSG +
310 ERL_NO_TIMEOUT +
311 ERL_REG_SEND +
312 ERL_SEND +
313 ERL_TICK +
314 ERL_TIMEOUT +
315 ERL_UNLINK +
316 ETIMEDOUT +
317 MAXATOMLEN;
318 }
319