[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.8

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

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