Annotation of OpenXM/src/ox_toolkit/ox.h, Revision 1.7
1.1 ohara 1: /* -*- mode: C; coding: euc-japan -*- */
1.7 ! ohara 2: /* $OpenXM: OpenXM/src/ox_toolkit/ox.h,v 1.6 2000/01/17 19:55:55 ohara Exp $ */
! 3:
! 4: /*
! 5: Some commnets is written in Japanese by the EUC-JP coded
! 6: character set.
! 7: */
1.1 ohara 8:
9: #ifndef _OX_H_
10:
11: #define _OX_H_
12:
13: #include <gmp.h>
14: #include "oxtag.h"
15:
1.5 ohara 16: #define LOGFILE "/tmp/oxtk.XXXXXX"
1.1 ohara 17:
18: /* Open Xm File Descripter */
19: typedef int oxfd;
20:
21: #if 0
22: typedef struct {
1.3 ohara 23: int fd;
1.1 ohara 24: int byteorder;
25: } oxfile;
26: typedef oxfile *oxfd;
27: #endif
28:
1.7 ! ohara 29: /* descripter pair. (needed by a client) */
1.1 ohara 30: typedef struct {
31: oxfd stream;
32: oxfd control;
33: } __ox_file_struct;
34:
35: typedef __ox_file_struct *ox_file_t;
36:
37: typedef struct {
38: int tag;
39: } cmo;
40:
41: typedef cmo cmo_null;
42: typedef cmo cmo_zero;
43: typedef cmo cmo_dms_generic;
44:
45: typedef struct {
46: int tag;
47: int i;
48: } cmo_int32;
49:
50: typedef struct {
51: int tag;
52: int size;
53: char *body;
54: } cmo_datum;
55:
56: typedef struct {
57: int tag;
58: char *s;
59: } cmo_string;
60:
61: typedef struct {
62: int tag;
63: cmo *ob;
64: } cmo_mathcap;
65:
66: typedef cmo_mathcap cmo_error2;
67: typedef cmo_mathcap cmo_ring_by_name;
68: typedef cmo_mathcap cmo_indeterminate;
69:
70: typedef struct cell {
71: struct cell *next;
72: cmo *cmo;
73: } cell;
74:
75: typedef struct {
76: int tag;
1.7 ! ohara 77: int length; /* length of this list (unnecessary) */
1.1 ohara 78: cell head[1];
79: } cmo_list;
80:
81:
82: typedef struct {
83: int tag;
84: int length;
85: int *exps;
86: cmo *coef;
87: } cmo_monomial32;
88:
89: typedef struct {
90: int tag;
91: mpz_t mpz;
92: } cmo_zz;
93:
94: typedef struct {
95: int tag;
1.7 ! ohara 96: cmo *num; /* Bunshi (cmo_zz) */
! 97: cmo *den; /* Bunbo (cmo_zz) */
1.1 ohara 98: } cmo_qq;
99:
1.7 ! ohara 100: /* The following is a derived class from cmo_list.
! 101: that is, append_cmo_list can be used. */
1.1 ohara 102: typedef struct {
103: int tag;
104: int length; /* number of monomials */
105: cell head[1]; /* a list of monomials */
106: cmo *ringdef;
107: } cmo_distributed_polynomial;
108:
109: typedef cmo ox;
110:
111: typedef ox ox_sync_ball;
112:
113: typedef struct {
114: int tag;
115: int command;
116: } ox_command;
117:
118: typedef struct {
119: int tag;
120: cmo *cmo;
121: } ox_data;
122:
123: cmo_null* new_cmo_null();
124: cmo_int32* new_cmo_int32(int i);
125: cmo_string* new_cmo_string(char* s);
126: cmo_mathcap* new_cmo_mathcap(cmo* ob);
127: cmo_list* new_cmo_list();
128: cmo_monomial32* new_cmo_monomial32();
129: cmo_monomial32* new_cmo_monomial32_size(int size);
130: cmo_zz* new_cmo_zz();
131: cmo_zz* new_cmo_zz_size(int size);
132: cmo_zz* new_cmo_zz_set_si(int integer);
1.6 ohara 133: cmo_zz* new_cmo_zz_set_mpz(mpz_ptr z);
1.1 ohara 134: cmo_zz* new_cmo_zz_noinit();
1.4 ohara 135: cmo_zz* new_cmo_zz_set_string(char* s);
1.1 ohara 136: cmo_zero* new_cmo_zero();
137: cmo_distributed_polynomial* new_cmo_distributed_polynomial();
138: cmo_dms_generic* new_cmo_dms_generic();
139: cmo_ring_by_name* new_cmo_ring_by_name(cmo* ob);
140: cmo_indeterminate* new_cmo_indeterminate(cmo* ob);
141: cmo_error2* new_cmo_error2(cmo* ob);
142:
143: ox_data* new_ox_data(cmo* c);
144: ox_command* new_ox_command(int sm_code);
1.4 ohara 145: ox_sync_ball* new_ox_sync_ball();
1.1 ohara 146:
1.4 ohara 147: char* new_string_set_cmo(cmo* m);
1.3 ohara 148:
1.4 ohara 149: cmo_error2* make_error_object(int err_code, cmo* ob);
1.1 ohara 150: cmo* make_mathcap_object(int version, char *id_string);
151:
1.7 ! ohara 152: /* Low level API */
1.1 ohara 153: cmo* receive_cmo(int fd);
154: int receive_int32(int fd);
155: int receive_ox_tag(int fd);
156:
1.4 ohara 157: int send_cmo(int fd, cmo* m);
158: int send_int32(int fd, int integer);
159: int send_ox(int fd, ox* m);
160: int send_ox_cmo(int fd, cmo* m);
161: void send_ox_command(int fd, int sm_command);
162: int send_ox_tag(int fd, int tag);
163:
164: int decideByteOrderClient(int fd, int order);
165: int decideByteOrderServer(int fd, int order);
166: int next_serial();
167: void setCmotypeDisable(int type);
168: cell* new_cell();
169: cmo* nth_cmo_list(cmo_list* this, int n);
170: int set_current_fd(int fd);
171:
1.7 ! ohara 172: /* High level API */
1.4 ohara 173: ox_file_t ox_start(char* host, char* prog1, char* prog2);
174: ox_file_t ox_start_insecure_nonreverse(char* host, short portControl, short portStream);
1.7 ! ohara 175: ox_file_t ox_start_remote_with_ssh(char *dat_prog, char* host);
! 176:
1.4 ohara 177: void ox_close(ox_file_t sv);
178: void ox_shutdown(ox_file_t sv);
179: void ox_reset(ox_file_t sv);
180: void ox_execute_string(ox_file_t sv, char* str);
181: cmo_mathcap* ox_mathcap(ox_file_t sv);
182: char* ox_popString(ox_file_t sv);
183: int ox_pops(ox_file_t sv, int num);
184: cmo* ox_pop_cmo(ox_file_t sv);
185: void ox_push_cmo(ox_file_t sv, cmo *c);
186: void ox_push_cmd(ox_file_t sv, int sm_code);
187: int ox_cmo_rpc(ox_file_t sv, char *function, int argc, cmo *argv[]);
188: int ox_flush(ox_file_t sv);
189:
190: int append_cmo_list(cmo_list* this, cmo *ob);
191: int length_cmo_list(cmo_list* this);
192: cell* next_cell(cell *this);
193: int cmolen_cmo(cmo* m);
194: int init_dump_buff(char *buff);
195: int dump_cmo(cmo* m);
196: int dump_ox_command(ox_command* m);
197: int dump_ox_data(ox_data* m);
198:
199: int print_cmo(cmo* c);
1.2 ohara 200:
201: typedef cmo *(*hook_t)(int, cmo *);
202:
203: int add_hook_before_send_cmo(hook_t func);
204: int add_hook_after_send_cmo(hook_t func);
1.1 ohara 205:
206: #endif /* _OX_H_ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>