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

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

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