Debian Codegraph @

debian/external_deps/fetk/maloc/tools/tests/aloc/mainc.c

raw
1 /*
2 * ***************************************************************************
3 * MALOC = < Minimal Abstraction Layer for Object-oriented C >
4 * Copyright (C) 1994-- Michael Holst
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * rcsid="$Id: mainc.c,v 1.13 2010/08/12 05:40:43 fetk Exp $"
21 * ***************************************************************************
22 */
23
24 /*
25 * ***************************************************************************
26 * File: main.c
27 *
28 * Purpose: Test the C interface to the VIO library.
29 *
30 * Author: Michael Holst
31 * ***************************************************************************
32 */
33
34 #include <maloc/maloc.h>
35
36 #define VEMBED(rctag) VPRIVATE const char* rctag; \
37 static void* use_rcsid=(0 ? &use_rcsid : (void*)&rcsid);
38 VEMBED(rcsid="$Id: mainc.c,v 1.13 2010/08/12 05:40:43 fetk Exp $")
39
40 extern void outputMyStuff(Vio *sock);
41
42 int main(int argc, char *argv[])
43 {
44 Vio *sock;
45
46 char *oskey = "INET"; /* FILE, PIPE, UNIX, INET, MPI1 */
47 char *osfmt = "ASC"; /* ASC, XDR */
48 char *osnam = "1"; /* socket number or filename */
49 char *ohval = "localhost"; /* hostname to send things to */
50
51 /* open and connect to the socket */
52 Vio_start();
53 VJMPERR1( VNULL != (sock=Vio_ctor(oskey,osfmt,ohval,osnam,"w")) );
54 VJMPERR1( 0 <= Vio_connect(sock,0) );
55
56 /* write some data to the socket */
57 outputMyStuff(sock);
58
59 /* disconnect and close the socket */
60 Vio_connectFree(sock);
61 Vio_dtor(&sock);
62 Vio_stop();
63
64 return 1;
65
66 VERROR1:
67 fprintf(stderr,"Problem occurred.\n");
68 return 0;
69 }
70
71 void outputMyStuff(Vio *sock)
72 {
73 Vio_printf(sock,"%s\n","bhsingle");
74
75 Vio_printf(sock,"%s %d\n","putl",4);
76 Vio_printf(sock,"%e %e %e %e\n",0.0,1.0,0.0,0.0);
77 Vio_printf(sock,"%e %e %e %e\n",0.0,0.0,1.0,0.0);
78 Vio_printf(sock,"%e %e %e %e\n",0.0,0.0,0.0,1.0);
79
80 Vio_printf(sock,"%s %d\n","list",7);
81 Vio_printf(sock,"%s %d %d\n","fill",3,3);
82 Vio_printf(sock,"%e %e %e\n",0.1,0.9,0.1);
83 Vio_printf(sock,"%e %e %e\n",0.1,0.1,0.9);
84 Vio_printf(sock,"%e %e %e\n",0.1,0.1,0.1);
85 Vio_printf(sock,"%s %d %d\n","line",1,4);
86 Vio_printf(sock,"%e %e %e\n",0.1,0.9,0.1);
87 Vio_printf(sock,"%e %e %e\n",0.1,0.1,0.9);
88 Vio_printf(sock,"%e %e %e\n",0.1,0.1,0.1);
89 Vio_printf(sock,"%e %e %e\n",0.1,0.9,0.1);
90 Vio_printf(sock,"%s %d\n","list",-7);
91
92 Vio_printf(sock,"%s %d\n","list",2);
93 Vio_printf(sock,"%s %d %d\n","fill",2,3);
94 Vio_printf(sock,"%e %e %e\n",0.9,0.9,0.1);
95 Vio_printf(sock,"%e %e %e\n",0.1,0.9,0.9);
96 Vio_printf(sock,"%e %e %e\n",0.1,0.1,0.1);
97 Vio_printf(sock,"%s %d %d\n","line",1,4);
98 Vio_printf(sock,"%e %e %e\n",0.9,0.9,0.1);
99 Vio_printf(sock,"%e %e %e\n",0.1,0.9,0.9);
100 Vio_printf(sock,"%e %e %e\n",0.1,0.1,0.1);
101 Vio_printf(sock,"%e %e %e\n",0.9,0.9,0.1);
102 Vio_printf(sock,"%s %d\n","list",-2);
103
104 Vio_printf(sock,"%s %d\n","list",3);
105 Vio_printf(sock,"%s %d %d\n","fill",4,3);
106 Vio_printf(sock,"%e %e %e\n",0.9,0.9,0.1);
107 Vio_printf(sock,"%e %e %e\n",0.1,0.9,0.9);
108 Vio_printf(sock,"%e %e %e\n",0.1,0.1,0.1);
109 Vio_printf(sock,"%s %d %d\n","line",1,4);
110 Vio_printf(sock,"%e %e %e\n",0.9,0.9,0.1);
111 Vio_printf(sock,"%e %e %e\n",0.1,0.9,0.9);
112 Vio_printf(sock,"%e %e %e\n",0.1,0.1,0.1);
113 Vio_printf(sock,"%e %e %e\n",0.9,0.9,0.1);
114 Vio_printf(sock,"%s %d\n","list",-3);
115
116 Vio_printf(sock,"%s %d\n","putl",-1);
117 }
118