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

File: [local] / OpenXM / src / ox_toolkit / sample1.c (download)

Revision 1.8, Mon Sep 15 09:31:42 2003 UTC (20 years, 7 months ago) by ohara
Branch: MAIN
CVS Tags: new-mathcap-branch, R_1_3_1-2, RELEASE_1_3_1_13b, RELEASE_1_2_3_12, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, KNOPPIX_2006, HEAD, DEB_REL_1_2_3-9
Changes since 1.7: +6 -4 lines

Add some "cast".
Fixed some bugs.

/* -*- mode: C -*- */
/* $OpenXM: OpenXM/src/ox_toolkit/sample1.c,v 1.8 2003/09/15 09:31:42 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"

OXFILE* ox_start(char* host, char* prog1, char* prog2);

/* This program uses High-level functions of OpenXM C library. */
int main()
{
    OXFILE *s;
    cmo_list *c;

    ox_stderr_init(stderr);
    /* 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, (cmo *)new_cmo_zz_set_si(10000));
    list_append(c, (cmo *)new_cmo_zz_set_si(-2342));
    list_append(c, (cmo *)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;
}