File: [local] / OpenXM / src / ox_toolkit / sample1.c (download)
Revision 1.3, Tue Oct 10 05:23:21 2000 UTC (23 years, 11 months ago) by ohara
Branch: MAIN
CVS Tags: maekawa-ipv6, RELEASE_1_2_1 Changes since 1.2: +18 -18
lines
ox_toolkit is up to date.
0. OXFILE is introduced.
1. we support new method of ox connection.
2. we support exchaging byte order.
(in possible, we choose a byte order of machine integer).
3. cmo_list is rewritten.
4. we support a mathcap database.
etc.
Sorry, I forgot many changes.
|
/* -*- mode: C -*- */
/* $OpenXM: OpenXM/src/ox_toolkit/sample1.c,v 1.3 2000/10/10 05:23:21 ohara Exp $ */
/*
This sample program explains how to construct
(OX_DATA,(CMO_INT,32))
(OX_DATA,(CMO_STRING,"Hello"))
(OX_DATA,(CMO_LIST,1,2,3))
(OX_COMMAND,(SM_popCMO))
etc
by using C functions.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "ox_toolkit.h"
/* This program uses High-level functions of OpenXM C library. */
int main()
{
OXFILE *s;
cmo_list *c;
/* starting an OpenXM server */
s = ox_start("localhost", "ox", "ox_sm1");
ox_push_cmo(s, (cmo *)new_cmo_int32(32));
ox_push_cmo(s, (cmo *)new_cmo_string("Hello"));
/* making a list {10000, -2342, 3141592653289793238462643383279}.
the elements are a bignum. */
c = new_cmo_list();
list_append(c, new_cmo_zz_set_si(10000));
list_append(c, new_cmo_zz_set_si(-2342));
list_append(c, new_cmo_zz_set_string("3141592653289793238462643383279"));
/* sending the list above. */
ox_push_cmo(s, (cmo *)c);
ox_push_cmd(s, SM_popCMO);
ox_push_cmd(s, SM_popCMO);
ox_push_cmd(s, SM_popCMO);
ox_close(s);
return 0;
}