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

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

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