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