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

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

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