[BACK]Return to ox_toolkit.h CVS log [TXT][DIR] Up to [local] / OpenXM / src / ox_toolkit

Annotation of OpenXM/src/ox_toolkit/ox_toolkit.h, Revision 1.9

1.1       ohara       1: /* -*- mode: C -*- */
1.9     ! ohara       2: /* $OpenXM: OpenXM/src/ox_toolkit/ox_toolkit.h,v 1.8 2000/11/28 04:24:12 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:
                    105: /* The following is a derived class from cmo_list.
1.2       ohara     106:    that is, list_append can be used. */
1.1       ohara     107: typedef struct {
                    108:     int tag;
                    109:     int length;    /* number of monomials */
                    110:     cell head[1];  /* a list of monomials */
                    111:     cmo *ringdef;
                    112: } cmo_distributed_polynomial;
                    113:
                    114: typedef cmo ox;
                    115:
                    116: typedef ox ox_sync_ball;
                    117:
                    118: typedef struct {
                    119:     int tag;
                    120:     int command;
                    121: } ox_command;
                    122:
                    123: typedef struct {
                    124:     int tag;
                    125:     cmo *cmo;
                    126: } ox_data;
                    127:
                    128: cmo_null*          new_cmo_null();
                    129: cmo_int32*         new_cmo_int32(int i);
                    130: cmo_string*        new_cmo_string(char* s);
                    131: cmo_mathcap*       new_cmo_mathcap(cmo* ob);
                    132: cmo_list*          new_cmo_list();
                    133: cmo_monomial32*    new_cmo_monomial32();
                    134: cmo_monomial32*    new_cmo_monomial32_size(int size);
                    135: cmo_zz*            new_cmo_zz();
                    136: cmo_zz*            new_cmo_zz_size(int size);
                    137: cmo_zz*            new_cmo_zz_set_si(int integer);
                    138: cmo_zz*            new_cmo_zz_set_mpz(mpz_ptr z);
                    139: cmo_zz*            new_cmo_zz_noinit();
                    140: cmo_zz*            new_cmo_zz_set_string(char* s);
                    141: cmo_zero*          new_cmo_zero();
                    142: cmo_distributed_polynomial* new_cmo_distributed_polynomial();
                    143: cmo_dms_generic*   new_cmo_dms_generic();
                    144: cmo_ring_by_name*  new_cmo_ring_by_name(cmo* ob);
                    145: cmo_indeterminate* new_cmo_indeterminate(cmo* ob);
                    146: cmo_error2*        new_cmo_error2(cmo* ob);
                    147:
                    148: ox_data*           new_ox_data(cmo* c);
                    149: ox_command*        new_ox_command(int sm_code);
                    150: ox_sync_ball*      new_ox_sync_ball();
                    151:
                    152: char*              new_string_set_cmo(cmo* m);
                    153:
                    154: cmo_error2*        make_error_object(int err_code, cmo* ob);
                    155:
                    156: /* Low level API */
1.2       ohara     157: cmo*               receive_cmo(OXFILE *fp);
                    158: int                receive_int32(OXFILE *fp);
                    159: int                receive_ox_tag(OXFILE *fp);
                    160:
                    161: void               send_cmo(OXFILE *fp, cmo* m);
                    162: int                send_int32(OXFILE *fp, int integer);
                    163: void               send_ox(OXFILE *fp, ox* m);
                    164: void               send_ox_cmo(OXFILE *fp, cmo* m);
                    165: void               send_ox_command(OXFILE *fp, int sm_command);
                    166: int                send_ox_tag(OXFILE *fp, int tag);
1.1       ohara     167:
                    168: int                next_serial();
                    169: void               setCmotypeDisable(int type);
                    170:
                    171: /* High level API */
1.2       ohara     172: void               ox_close(OXFILE *sv);
                    173: void               ox_shutdown(OXFILE *sv);
                    174: void               ox_reset(OXFILE *sv);
                    175: void               ox_execute_string(OXFILE *sv, char* str);
                    176: cmo_mathcap*       ox_mathcap(OXFILE *sv);
                    177: char*              ox_popString(OXFILE *sv);
                    178: void               ox_pops(OXFILE *sv, int num);
                    179: cmo*               ox_pop_cmo(OXFILE *sv);
                    180: void               ox_push_cmo(OXFILE *sv, cmo *c);
                    181: void               ox_push_cmd(OXFILE *sv, int sm_code);
                    182: void               ox_cmo_rpc(OXFILE *sv, char *function, int argc, cmo *argv[]);
                    183: int                ox_flush(OXFILE *sv);
                    184:
                    185: cell*              list_first(cmo_list *this);
                    186: int                list_endof(cmo_list *this, cell *el);
                    187: cell*              list_next(cell *el);
                    188: cmo_list*          list_append(cmo_list* this, cmo *ob);
                    189: cmo_list*          list_appendl(cmo_list* this, ...);
                    190: int                list_length(cmo_list* this);
                    191: cmo*               list_nth(cmo_list* this, int n);
                    192:
1.1       ohara     193: int                cmolen_cmo(cmo* m);
1.2       ohara     194: void               dump_buffer_init(char *s);
                    195: void               dump_cmo(cmo* m);
                    196: void               dump_ox_command(ox_command* m);
                    197: void               dump_ox_data(ox_data* m);
1.1       ohara     198:
1.2       ohara     199: void               print_cmo(cmo* c);
                    200: void               resize_mpz(mpz_ptr mpz, int size);
1.1       ohara     201:
1.2       ohara     202: typedef cmo *(*hook_t)(OXFILE *, cmo *);
1.1       ohara     203:
                    204: int add_hook_before_send_cmo(hook_t func);
                    205: int add_hook_after_send_cmo(hook_t func);
                    206:
                    207: /* functions related to parse.c */
                    208:
                    209: #define PFLAG_ADDREV   1
                    210:
                    211: typedef struct symbol *symbol_t;
                    212:
1.2       ohara     213: void setflag_parse(int flag);
1.1       ohara     214: cmo *parse();
1.2       ohara     215: void init_parser(char *s);
1.1       ohara     216:
                    217: symbol_t lookup_by_symbol(char *key);
                    218: symbol_t lookup_by_token(int tok);
                    219: symbol_t lookup_by_tag(int tag);
                    220: symbol_t lookup(int i);
                    221: char *symbol_get_key(symbol_t sp);
1.2       ohara     222:
                    223: /* for mathcap database */
1.6       ohara     224: mathcap *new_mathcap();
                    225: void mathcap_init(int ver, char *vstr, char *sysname, int cmos[], int sms[]);
                    226: cmo_mathcap* mathcap_get(mathcap *this);
                    227: mathcap *mathcap_update(mathcap *this, cmo_mathcap *mc);
                    228: int mathcap_allowQ_cmo(mathcap *this, cmo *ob);
1.2       ohara     229:
                    230: int oxf_read(void *buffer, size_t size, size_t num, OXFILE *oxfp);
                    231: int oxf_write(void *buffer, size_t size, size_t num, OXFILE *oxfp);
                    232:
                    233: /* for OXFILE */
1.4       ohara     234: int oxf_listen(short *portp);
1.2       ohara     235: OXFILE *oxf_connect_active(char *hostname, short port);
                    236: OXFILE *oxf_connect_passive(int listened);
                    237: OXFILE *oxf_open(int fd);
                    238: OXFILE *oxf_control_set(OXFILE *oxfp, OXFILE *control);
                    239: OXFILE *oxf_control(OXFILE *oxfp);
                    240: int  oxf_confirm_client(OXFILE *oxfp, char *passwd);
                    241: int  oxf_confirm_server(OXFILE *oxfp, char *passwd);
                    242: void oxf_flush(OXFILE *oxfp);
                    243: void oxf_close(OXFILE *oxfp);
                    244: void oxf_setopt(OXFILE *oxfp, int mode);
                    245: void oxf_determine_byteorder_client(OXFILE *oxfp);
                    246: void oxf_determine_byteorder_server(OXFILE *oxfp);
1.4       ohara     247: OXFILE *oxf_execute_cmd(OXFILE *oxfp, char *cmd);
1.8       ohara     248: cmo_mathcap *oxf_cmo_mathcap(OXFILE *oxfp);
1.6       ohara     249: void oxf_mathcap_update(OXFILE *oxfp, cmo_mathcap *ob);
1.2       ohara     250:
                    251: /* example: which("xterm", getenv("PATH")); */
                    252: char *which(char *exe, const char *env);
                    253: char *generate_otp();
1.1       ohara     254:
                    255: #endif /* _OX_TOOLKIT_H_ */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>