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

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

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