[BACK]Return to sample1.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / ox_toolkit

Annotation of OpenXM/src/ox_toolkit/sample1.c, Revision 1.7

1.1       ohara       1: /* -*- mode: C -*- */
1.7     ! ohara       2: /* $OpenXM: OpenXM/src/ox_toolkit/sample1.c,v 1.6 2003/03/23 20:17:35 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.3       ohara      36:     list_append(c, new_cmo_zz_set_si(10000));
                     37:     list_append(c, new_cmo_zz_set_si(-2342));
                     38:     list_append(c, new_cmo_zz_set_string("3141592653289793238462643383279"));
                     39:
                     40:     /* sending the list above. */
                     41:     ox_push_cmo(s, (cmo *)c);
                     42:
                     43:     ox_push_cmd(s, SM_popCMO);
                     44:     ox_push_cmd(s, SM_popCMO);
                     45:     ox_push_cmd(s, SM_popCMO);
1.1       ohara      46:
                     47:     ox_close(s);
                     48:     return 0;
                     49: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>