Annotation of OpenXM/src/ox_toolkit/sample1.c, Revision 1.6
1.1 ohara 1: /* -*- mode: C -*- */
1.6 ! ohara 2: /* $OpenXM: OpenXM/src/ox_toolkit/sample1.c,v 1.5 2003/02/04 20:43:55 ohara Exp $ */
1.1 ohara 3:
4: /*
5: This sample program explains how to construct
6: (OX_DATA,(CMO_INT,32))
7: (OX_DATA,(CMO_STRING,"Hello"))
8: (OX_DATA,(CMO_LIST,1,2,3))
9: (OX_COMMAND,(SM_popCMO))
10: etc
11: by using C functions.
12: */
13:
14: #include <stdio.h>
15: #include <stdlib.h>
16: #include <unistd.h>
1.2 ohara 17: #include "ox_toolkit.h"
1.1 ohara 18:
19: /* This program uses High-level functions of OpenXM C library. */
20: int main()
21: {
1.3 ohara 22: OXFILE *s;
23: cmo_list *c;
1.1 ohara 24:
1.5 ohara 25: ox_stderr_init(stderr);
1.3 ohara 26: /* starting an OpenXM server */
1.1 ohara 27: s = ox_start("localhost", "ox", "ox_sm1");
28:
1.3 ohara 29: ox_push_cmo(s, (cmo *)new_cmo_int32(32));
30: ox_push_cmo(s, (cmo *)new_cmo_string("Hello"));
1.1 ohara 31:
1.3 ohara 32: /* making a list {10000, -2342, 3141592653289793238462643383279}.
1.1 ohara 33: the elements are a bignum. */
1.3 ohara 34: c = new_cmo_list();
1.1 ohara 35:
1.6 ! ohara 36: #if defined(WITH_GMP)
1.3 ohara 37: list_append(c, new_cmo_zz_set_si(10000));
38: list_append(c, new_cmo_zz_set_si(-2342));
39: list_append(c, new_cmo_zz_set_string("3141592653289793238462643383279"));
1.6 ! ohara 40: #endif /* WITH_GMP */
1.3 ohara 41:
42: /* sending the list above. */
43: ox_push_cmo(s, (cmo *)c);
44:
45: ox_push_cmd(s, SM_popCMO);
46: ox_push_cmd(s, SM_popCMO);
47: ox_push_cmd(s, SM_popCMO);
1.1 ohara 48:
49: ox_close(s);
50: return 0;
51: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>