Annotation of OpenXM/src/ox_toolkit/ox_toolkit.h, Revision 1.6
1.1 ohara 1: /* -*- mode: C -*- */
1.6 ! ohara 2: /* $OpenXM: OpenXM/src/ox_toolkit/ox_toolkit.h,v 1.5 2000/11/18 04:49:55 ohara Exp $ */
1.1 ohara 3:
4: #ifndef _OX_TOOLKIT_H_
5:
6: #define _OX_TOOLKIT_H_
7:
1.2 ohara 8: #include <stdio.h>
1.5 ohara 9: #include <gmp.h>
10: #include <ox/cmotag.h>
11: #include <ox/oxMessageTag.h>
12: #include <ox/smCommand.h>
1.1 ohara 13:
1.2 ohara 14: #if !defined(__GNUC__) && !defined(__inline__)
15: #define __inline__
16: #endif
17:
1.1 ohara 18: /* Open Xm File Descripter */
1.2 ohara 19: typedef struct OXFILE{
1.6 ! ohara 20: int fd;
! 21: int (*send_int32)(struct OXFILE *oxfp, int int32);
! 22: int (*receive_int32)(struct OXFILE *oxfp);
! 23: int serial_number;
! 24: struct OXFILE *control; /* pointer to his control server. */
! 25: struct mathcap *mathcap;
! 26: int error;
1.2 ohara 27: } OXFILE;
1.1 ohara 28:
29: typedef struct {
30: int tag;
31: } cmo;
32:
33: typedef cmo cmo_null;
34: typedef cmo cmo_zero;
35: typedef cmo cmo_dms_generic;
36:
37: typedef struct {
38: int tag;
39: int i;
40: } cmo_int32;
41:
42: typedef struct {
43: int tag;
44: int size;
45: char *body;
46: } cmo_datum;
47:
48: typedef struct {
49: int tag;
50: char *s;
51: } cmo_string;
52:
53: typedef struct {
54: int tag;
55: cmo *ob;
56: } cmo_mathcap;
57:
58: typedef cmo_mathcap cmo_error2;
59: typedef cmo_mathcap cmo_ring_by_name;
60: typedef cmo_mathcap cmo_indeterminate;
61:
1.2 ohara 62: /* a double linked list */
1.1 ohara 63: typedef struct cell {
1.2 ohara 64: cmo *cmo;
1.1 ohara 65: struct cell *next;
1.2 ohara 66: struct cell *prev;
1.1 ohara 67: } cell;
68:
69: typedef struct {
70: int tag;
71: int length; /* length of this list (unnecessary) */
72: cell head[1];
73: } cmo_list;
74:
75: typedef struct {
76: int tag;
77: int length;
78: int *exps;
79: cmo *coef;
80: } cmo_monomial32;
81:
82: typedef struct {
83: int tag;
84: mpz_t mpz;
85: } cmo_zz;
86:
87: typedef struct {
88: int tag;
89: cmo *num; /* Bunshi (cmo_zz) */
90: cmo *den; /* Bunbo (cmo_zz) */
91: } cmo_qq;
92:
93: /* The following is a derived class from cmo_list.
1.2 ohara 94: that is, list_append can be used. */
1.1 ohara 95: typedef struct {
96: int tag;
97: int length; /* number of monomials */
98: cell head[1]; /* a list of monomials */
99: cmo *ringdef;
100: } cmo_distributed_polynomial;
101:
102: typedef cmo ox;
103:
104: typedef ox ox_sync_ball;
105:
106: typedef struct {
107: int tag;
108: int command;
109: } ox_command;
110:
111: typedef struct {
112: int tag;
113: cmo *cmo;
114: } ox_data;
115:
116: cmo_null* new_cmo_null();
117: cmo_int32* new_cmo_int32(int i);
118: cmo_string* new_cmo_string(char* s);
119: cmo_mathcap* new_cmo_mathcap(cmo* ob);
120: cmo_list* new_cmo_list();
121: cmo_monomial32* new_cmo_monomial32();
122: cmo_monomial32* new_cmo_monomial32_size(int size);
123: cmo_zz* new_cmo_zz();
124: cmo_zz* new_cmo_zz_size(int size);
125: cmo_zz* new_cmo_zz_set_si(int integer);
126: cmo_zz* new_cmo_zz_set_mpz(mpz_ptr z);
127: cmo_zz* new_cmo_zz_noinit();
128: cmo_zz* new_cmo_zz_set_string(char* s);
129: cmo_zero* new_cmo_zero();
130: cmo_distributed_polynomial* new_cmo_distributed_polynomial();
131: cmo_dms_generic* new_cmo_dms_generic();
132: cmo_ring_by_name* new_cmo_ring_by_name(cmo* ob);
133: cmo_indeterminate* new_cmo_indeterminate(cmo* ob);
134: cmo_error2* new_cmo_error2(cmo* ob);
135:
136: ox_data* new_ox_data(cmo* c);
137: ox_command* new_ox_command(int sm_code);
138: ox_sync_ball* new_ox_sync_ball();
139:
140: char* new_string_set_cmo(cmo* m);
141:
142: cmo_error2* make_error_object(int err_code, cmo* ob);
143:
144: /* Low level API */
1.2 ohara 145: cmo* receive_cmo(OXFILE *fp);
146: int receive_int32(OXFILE *fp);
147: int receive_ox_tag(OXFILE *fp);
148:
149: void send_cmo(OXFILE *fp, cmo* m);
150: int send_int32(OXFILE *fp, int integer);
151: void send_ox(OXFILE *fp, ox* m);
152: void send_ox_cmo(OXFILE *fp, cmo* m);
153: void send_ox_command(OXFILE *fp, int sm_command);
154: int send_ox_tag(OXFILE *fp, int tag);
1.1 ohara 155:
156: int next_serial();
157: void setCmotypeDisable(int type);
158:
159: /* High level API */
1.2 ohara 160: void ox_close(OXFILE *sv);
161: void ox_shutdown(OXFILE *sv);
162: void ox_reset(OXFILE *sv);
163: void ox_execute_string(OXFILE *sv, char* str);
164: cmo_mathcap* ox_mathcap(OXFILE *sv);
165: char* ox_popString(OXFILE *sv);
166: void ox_pops(OXFILE *sv, int num);
167: cmo* ox_pop_cmo(OXFILE *sv);
168: void ox_push_cmo(OXFILE *sv, cmo *c);
169: void ox_push_cmd(OXFILE *sv, int sm_code);
170: void ox_cmo_rpc(OXFILE *sv, char *function, int argc, cmo *argv[]);
171: int ox_flush(OXFILE *sv);
172:
173: cell* list_first(cmo_list *this);
174: int list_endof(cmo_list *this, cell *el);
175: cell* list_next(cell *el);
176: cmo_list* list_append(cmo_list* this, cmo *ob);
177: cmo_list* list_appendl(cmo_list* this, ...);
178: int list_length(cmo_list* this);
179: cmo* list_nth(cmo_list* this, int n);
180:
1.1 ohara 181: int cmolen_cmo(cmo* m);
1.2 ohara 182: void dump_buffer_init(char *s);
183: void dump_cmo(cmo* m);
184: void dump_ox_command(ox_command* m);
185: void dump_ox_data(ox_data* m);
1.1 ohara 186:
1.2 ohara 187: void print_cmo(cmo* c);
188: void resize_mpz(mpz_ptr mpz, int size);
1.1 ohara 189:
1.2 ohara 190: typedef cmo *(*hook_t)(OXFILE *, cmo *);
1.1 ohara 191:
192: int add_hook_before_send_cmo(hook_t func);
193: int add_hook_after_send_cmo(hook_t func);
194:
195: /* functions related to parse.c */
196:
197: #define PFLAG_ADDREV 1
198:
199: typedef struct symbol *symbol_t;
200:
1.2 ohara 201: void setflag_parse(int flag);
1.1 ohara 202: cmo *parse();
1.2 ohara 203: void init_parser(char *s);
1.1 ohara 204:
205: symbol_t lookup_by_symbol(char *key);
206: symbol_t lookup_by_token(int tok);
207: symbol_t lookup_by_tag(int tag);
208: symbol_t lookup(int i);
209: char *symbol_get_key(symbol_t sp);
1.2 ohara 210:
211: /* for mathcap database */
1.6 ! ohara 212: mathcap *new_mathcap();
! 213: void mathcap_init(int ver, char *vstr, char *sysname, int cmos[], int sms[]);
! 214: cmo_mathcap* mathcap_get(mathcap *this);
! 215: mathcap *mathcap_update(mathcap *this, cmo_mathcap *mc);
! 216: int mathcap_allowQ_cmo(mathcap *this, cmo *ob);
1.2 ohara 217:
218: int oxf_read(void *buffer, size_t size, size_t num, OXFILE *oxfp);
219: int oxf_write(void *buffer, size_t size, size_t num, OXFILE *oxfp);
220:
221: /* for OXFILE */
1.4 ohara 222: int oxf_listen(short *portp);
1.2 ohara 223: OXFILE *oxf_connect_active(char *hostname, short port);
224: OXFILE *oxf_connect_passive(int listened);
225: OXFILE *oxf_open(int fd);
226: OXFILE *oxf_control_set(OXFILE *oxfp, OXFILE *control);
227: OXFILE *oxf_control(OXFILE *oxfp);
228: int oxf_confirm_client(OXFILE *oxfp, char *passwd);
229: int oxf_confirm_server(OXFILE *oxfp, char *passwd);
230: void oxf_flush(OXFILE *oxfp);
231: void oxf_close(OXFILE *oxfp);
232: void oxf_setopt(OXFILE *oxfp, int mode);
233: void oxf_determine_byteorder_client(OXFILE *oxfp);
234: void oxf_determine_byteorder_server(OXFILE *oxfp);
1.4 ohara 235: OXFILE *oxf_execute_cmd(OXFILE *oxfp, char *cmd);
1.6 ! ohara 236: void oxf_mathcap_update(OXFILE *oxfp, cmo_mathcap *ob);
1.2 ohara 237:
238: /* example: which("xterm", getenv("PATH")); */
239: char *which(char *exe, const char *env);
240: char *generate_otp();
1.1 ohara 241:
242: #endif /* _OX_TOOLKIT_H_ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>