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

File: [local] / OpenXM / src / ox_maple / simple.c (download)

Revision 1.1, Mon Jun 21 12:46:04 2004 UTC (19 years, 11 months ago) by takayama
Branch: MAIN
CVS Tags: RELEASE_1_2_3_12, RELEASE_1_2_3, KNOPPIX_2006, DEB_REL_1_2_3-9

A sample implementation of calling ox servers from maple.
It uses ox_toolkit.

/* -*- mode: C -*- */
/* $OpenXM: OpenXM/src/ox_maple/simple.c,v 1.1 2004/06/21 12:46:04 takayama Exp $ */

/* A sample implementation for maple 
   of an OpenXM client with OpenXM C library */

#include <stdio.h>

#include "ox_toolkit.h"

extern OXFILE *ox_start(char* host, char* prog1, char* prog2);
OXFILE *sv = NULL;

int ml_init() {
  static int p = 1;
  if (p) {
	GC_init();
    ox_stderr_init(stderr);
    p = 0;
  }
}

int ml_start_asir()
{
    char *server = "ox_asir";

	ml_init();

    sv = ox_start("localhost", "ox", server);  
    if (sv == NULL) {
        ox_printf("simple:: I cannot connect to servers.\n");
        return -1;
    }
	return 0;
}

int ml_push_int(int i) {
  if (sv == NULL) ml_start_asir();
  ox_push_cmo(sv,(cmo *)new_cmo_int32(i));
  return i;
}

int ml_execute_string(char *s) {
  if (sv == NULL) ml_start_asir();
  ox_execute_string(sv,s);
  return 0;
}

char *ml_pop_string() {
  if (sv == NULL) ml_start_asir();
  return ox_popString(sv);
  /* Is it protected from GC? */
}