1 /*
2  * %CopyrightBegin%
3  *
4  * Copyright Ericsson AB 2002-2016. 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 /* Use most of
32  * CFLAGS="-I../include -g -O2
33  *         -ansi -pedantic
34  *         -Wall
35  *         -Wshadow
36  *         -Wstrict-prototypes
37  *         -Wmissing-prototypes
38  *         -Wmissing-declarations
39  *         -Wnested-externs
40  *         -Winline
41  *         -Werror"
42  */
43 
44 /* #include <netdb.h> now included by ei.h */
45 #include "erl_interface.h"
46 
47 #ifdef VXWORKS
erl_fake_prog_main(void)48 int erl_fake_prog_main(void)
49 #else
50 int main(void)
51 #endif
52 {
53   ei_x_buff eix;
54   int index = 0;
55   ETERM **etermpp = NULL, *etermp = NULL;
56   char *charp = NULL;
57   unsigned char uchar, **ucharpp = NULL, *ucharp = NULL;
58   void *voidp = NULL;
59   Erl_Heap *erl_heapp = NULL;
60   int intx = 0;
61   int *intp = NULL;
62   unsigned int uintx, *uintp;
63   unsigned long *ulongp = NULL;
64   long longx = 0;
65   double doublex = 0.0;
66   short shortx = 42;
67   FILE *filep = NULL;
68   Erl_IpAddr erl_ipaddr = NULL;
69   ErlMessage *erlmessagep = NULL;
70   ErlConnect *erlconnectp = NULL;
71   struct hostent *hostp = NULL;
72   struct in_addr *inaddrp = NULL;
73 
74   /* Converion to erl_interface format is in liberl_interface */
75 
76   intx = erl_errno;
77 
78   ei_encode_term(charp, &index, voidp);
79   ei_x_encode_term(&eix, voidp);
80   ei_decode_term(charp, &index, voidp);
81 
82   erl_init(voidp, longx);
83   erl_connect_init(intx, charp,shortx);
84   erl_connect_xinit(charp,charp,charp,erl_ipaddr,charp,shortx);
85   erl_connect(charp);
86   erl_xconnect(erl_ipaddr,charp);
87   erl_close_connection(intx);
88   erl_receive(intx, ucharp, intx);
89   erl_receive_msg(intx, ucharp, intx, erlmessagep);
90   erl_xreceive_msg(intx, ucharpp, intp, erlmessagep);
91   erl_send(intx, etermp, etermp);
92   erl_reg_send(intx, charp, etermp);
93   erl_rpc(intx,charp,charp,etermp);
94   erl_rpc_to(intx,charp,charp,etermp);
95   erl_rpc_from(intx,intx,erlmessagep);
96 
97   erl_publish(intx);
98   erl_accept(intx,erlconnectp);
99 
100   erl_thiscookie();
101   erl_thisnodename();
102   erl_thishostname();
103   erl_thisalivename();
104   erl_thiscreation();
105   erl_unpublish(charp);
106   erl_err_msg(charp);
107   erl_err_quit(charp);
108   erl_err_ret(charp);
109   erl_err_sys(charp);
110 
111   erl_cons(etermp,etermp);
112   erl_copy_term(etermp);
113   erl_element(intx,etermp);
114 
115   erl_hd(etermp);
116   erl_iolist_to_binary(etermp);
117   erl_iolist_to_string(etermp);
118   erl_iolist_length(etermp);
119   erl_length(etermp);
120   erl_mk_atom(charp);
121   erl_mk_binary(charp,intx);
122   erl_mk_empty_list();
123   erl_mk_estring(charp, intx);
124   erl_mk_float(doublex);
125   erl_mk_int(intx);
126   erl_mk_list(etermpp,intx);
127   erl_mk_pid(charp,uintx,uintx,uchar);
128   erl_mk_port(charp,uintx,uchar);
129   erl_mk_ref(charp,uintx,uchar);
130   erl_mk_long_ref(charp,uintx,uintx,uintx,uchar);
131   erl_mk_string(charp);
132   erl_mk_tuple(etermpp,intx);
133   erl_mk_uint(uintx);
134   erl_mk_var(charp);
135   erl_print_term(filep,etermp);
136   /*  erl_sprint_term(charp,etermp); */
137   erl_size(etermp);
138   erl_tl(etermp);
139   erl_var_content(etermp, charp);
140 
141   erl_format(charp);
142   erl_match(etermp, etermp);
143 
144   erl_global_names(intx, intp);
145   erl_global_register(intx, charp, etermp);
146   erl_global_unregister(intx, charp);
147   erl_global_whereis(intx, charp, charp);
148 
149   erl_init_malloc(erl_heapp,longx);
150   erl_alloc_eterm(uchar);
151   erl_eterm_release();
152   erl_eterm_statistics(ulongp,ulongp);
153   erl_free_array(etermpp,intx);
154   erl_free_term(etermp);
155   erl_free_compound(etermp);
156   erl_malloc(longx);
157   erl_free(voidp);
158 
159   erl_compare_ext(ucharp, ucharp);
160   erl_decode(ucharp);
161   erl_decode_buf(ucharpp);
162   erl_encode(etermp,ucharp);
163   erl_encode_buf(etermp,ucharpp);
164   erl_ext_size(ucharp);
165   erl_ext_type(ucharp);
166   erl_peek_ext(ucharp,intx);
167   erl_term_len(etermp);
168 
169   erl_gethostbyname(charp);
170   erl_gethostbyaddr(charp, intx, intx);
171   erl_gethostbyname_r(charp, hostp, charp, intx, intp);
172   erl_gethostbyaddr_r(charp, intx, intx, hostp, charp, intx, intp);
173 
174   erl_init_resolve();
175   erl_distversion(intx);
176 
177   erl_epmd_connect(inaddrp);
178   erl_epmd_port(inaddrp, charp, intp);
179 
180   charp  = ERL_ATOM_PTR(etermp);
181   intx   = ERL_ATOM_SIZE(etermp);
182   ucharp = ERL_BIN_PTR(etermp);
183   intx   = ERL_BIN_SIZE(etermp);
184   etermp = ERL_CONS_HEAD(etermp);
185   etermp = ERL_CONS_TAIL(etermp);
186   intx   = ERL_COUNT(etermp);
187   doublex= ERL_FLOAT_VALUE(etermp);
188   uintx  = ERL_INT_UVALUE(etermp);
189   intx   = ERL_INT_VALUE(etermp);
190   intx   = ERL_IS_ATOM(etermp);
191   intx   = ERL_IS_BINARY(etermp);
192   intx   = ERL_IS_CONS(etermp);
193   intx   = ERL_IS_EMPTY_LIST(etermp);
194   intx   = ERL_IS_FLOAT(etermp);
195   intx   = ERL_IS_INTEGER(etermp);
196   intx   = ERL_IS_LIST(etermp);
197   intx   = ERL_IS_PID(etermp);
198   intx   = ERL_IS_PORT(etermp);
199   intx   = ERL_IS_REF(etermp);
200   intx   = ERL_IS_TUPLE(etermp);
201   intx   = ERL_IS_UNSIGNED_INTEGER(etermp);
202   uchar  = ERL_PID_CREATION(etermp);
203   charp  = ERL_PID_NODE(etermp);
204   uintx  = ERL_PID_NUMBER(etermp);
205   uintx  = ERL_PID_SERIAL(etermp);
206   uchar  = ERL_PORT_CREATION(etermp);
207   charp  = ERL_PORT_NODE(etermp);
208   uintx  = ERL_PORT_NUMBER(etermp);
209   uchar  = ERL_REF_CREATION(etermp);
210   intx   = ERL_REF_LEN(etermp);
211   charp  = ERL_REF_NODE(etermp);
212   uintx  = ERL_REF_NUMBER(etermp);
213   uintp  = ERL_REF_NUMBERS(etermp);
214   etermp = ERL_TUPLE_ELEMENT(etermp,intx);
215   intx   = ERL_TUPLE_SIZE(etermp);
216 
217   return
218       BUFSIZ +
219       EAGAIN +
220       EHOSTUNREACH +
221       EINVAL +
222       EIO +
223       EMSGSIZE +
224       ENOMEM +
225       ERL_ATOM +
226       ERL_BINARY +
227       ERL_ERROR +
228       ERL_EXIT +
229       ERL_FLOAT +
230       ERL_INTEGER +
231       ERL_LINK +
232       ERL_LIST +
233       ERL_MSG +
234       ERL_NO_TIMEOUT +
235       ERL_PID +
236       ERL_PORT +
237       ERL_REF +
238       ERL_REG_SEND +
239       ERL_SEND +
240       ERL_SMALL_BIG +
241       ERL_TICK +
242       ERL_TIMEOUT +
243       ERL_TUPLE +
244       ERL_UNLINK +
245       ERL_U_INTEGER +
246       ERL_U_SMALL_BIG +
247       ERL_VARIABLE +
248       ETIMEDOUT +
249       MAXNODELEN +
250       MAXREGLEN;
251 }
252