[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.2

1.1       ohara       1: /* -*- mode: C -*- */
1.2     ! ohara       2: /* $OpenXM: OpenXM/src/ox_toolkit/sample1.c,v 1.1 1999/12/16 06:09:42 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: {
                     22:        ox_file_t s;
                     23:        cmo_list *c;
                     24:
                     25:        /* starting an OpenXM server */
                     26:     s = ox_start("localhost", "ox", "ox_sm1");
                     27:
                     28:        ox_push_cmo(s, (cmo *)new_cmo_int32(32));
                     29:        ox_push_cmo(s, (cmo *)new_cmo_string("Hello"));
                     30:
                     31:        /* making a list {10000, -2342, 3141592653289793238462643383279}.
                     32:        the elements are a bignum. */
                     33:        c = new_cmo_list();
                     34:
                     35:        append_cmo_list(c, new_cmo_zz_set_si(10000));
                     36:        append_cmo_list(c, new_cmo_zz_set_si(-2342));
                     37:        append_cmo_list(c, new_cmo_zz_set_string("3141592653289793238462643383279"));
                     38:
                     39:        /* sending the list above. */
                     40:        ox_push_cmo(s, (cmo *)c);
                     41:
                     42:        ox_push_cmd(s, SM_popCMO);
                     43:        ox_push_cmd(s, SM_popCMO);
                     44:        ox_push_cmd(s, SM_popCMO);
                     45:
                     46:     ox_close(s);
                     47:     return 0;
                     48: }

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