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

1.1       ohara       1: /* -*- mode: C -*- */
1.3     ! ohara       2: /* $OpenXM: OpenXM/src/ox_toolkit/sample1.c,v 1.2 2000/03/10 12:24:39 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.3     ! ohara      25:     /* starting an OpenXM server */
1.1       ohara      26:     s = ox_start("localhost", "ox", "ox_sm1");
                     27:
1.3     ! ohara      28:     ox_push_cmo(s, (cmo *)new_cmo_int32(32));
        !            29:     ox_push_cmo(s, (cmo *)new_cmo_string("Hello"));
1.1       ohara      30:
1.3     ! ohara      31:     /* making a list {10000, -2342, 3141592653289793238462643383279}.
1.1       ohara      32:        the elements are a bignum. */
1.3     ! ohara      33:     c = new_cmo_list();
1.1       ohara      34:
1.3     ! ohara      35:     list_append(c, new_cmo_zz_set_si(10000));
        !            36:     list_append(c, new_cmo_zz_set_si(-2342));
        !            37:     list_append(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);
1.1       ohara      45:
                     46:     ox_close(s);
                     47:     return 0;
                     48: }

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