Annotation of OpenXM/src/ox_maple/simple.c, Revision 1.2
1.1 takayama 1: /* -*- mode: C -*- */
1.2 ! iwane 2: /* $OpenXM: OpenXM/src/ox_maple/simple.c,v 1.1 2004/06/21 12:46:04 takayama Exp $ */
1.1 takayama 3:
4: /* A sample implementation for maple
5: of an OpenXM client with OpenXM C library */
6:
7: #include <stdio.h>
8:
9: #include "ox_toolkit.h"
10:
11: extern OXFILE *ox_start(char* host, char* prog1, char* prog2);
12: OXFILE *sv = NULL;
13:
14: int ml_init() {
15: static int p = 1;
16: if (p) {
17: GC_init();
18: ox_stderr_init(stderr);
19: p = 0;
20: }
21: }
22:
23: int ml_start_asir()
24: {
25: char *server = "ox_asir";
26:
27: ml_init();
28:
29: sv = ox_start("localhost", "ox", server);
30: if (sv == NULL) {
31: ox_printf("simple:: I cannot connect to servers.\n");
32: return -1;
33: }
34: return 0;
35: }
36:
1.2 ! iwane 37: int ml_start_maple()
! 38: {
! 39: char *server = "ox_maple";
! 40:
! 41: ml_init();
! 42:
! 43: sv = ox_start("localhost", "ox", server);
! 44: if (sv == NULL) {
! 45: ox_printf("simple:: I cannot connect to servers.\n");
! 46: return -1;
! 47: }
! 48: return 0;
! 49: }
! 50:
! 51:
! 52:
! 53:
1.1 takayama 54: int ml_push_int(int i) {
55: if (sv == NULL) ml_start_asir();
56: ox_push_cmo(sv,(cmo *)new_cmo_int32(i));
57: return i;
58: }
59:
60: int ml_execute_string(char *s) {
61: if (sv == NULL) ml_start_asir();
62: ox_execute_string(sv,s);
63: return 0;
64: }
65:
66: char *ml_pop_string() {
67: if (sv == NULL) ml_start_asir();
68: return ox_popString(sv);
69: /* Is it protected from GC? */
70: }
71:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>