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

1.1       ohara       1: /* -*- mode: C -*- */
1.2     ! ohara       2: /* $OpenXM: OpenXM/src/ox_toolkit/ox_toolkit.h,v 1.1 2000/03/10 12:24:39 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.1       ohara       9: #include <gmp.h>
                     10: #include "ox_toolkit_tags.h"
                     11:
1.2     ! ohara      12: #if !defined(__GNUC__) && !defined(__inline__)
        !            13: #define __inline__
        !            14: #endif
        !            15:
1.1       ohara      16: /* functions related to ox.c */
                     17:
1.2     ! ohara      18: #define LOGOXFILE  "/tmp/oxtk.XXXXXX"
        !            19:
        !            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: /*    FILE *fp; */
        !            27:        int (*send_int32)(struct OXFILE *oxfp, int int32);
        !            28:        int (*receive_int32)(struct OXFILE *oxfp);
        !            29:        int serial_number;
        !            30:        struct OXFILE *control;  /* pointer to his control server. */
        !            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: cmo*               make_mathcap_object(int version, char *id_string);
                    148:
                    149: /* Low level API */
1.2     ! ohara     150: cmo*               receive_cmo(OXFILE *fp);
        !           151: int                receive_int32(OXFILE *fp);
        !           152: int                receive_ox_tag(OXFILE *fp);
        !           153:
        !           154: void               send_cmo(OXFILE *fp, cmo* m);
        !           155: int                send_int32(OXFILE *fp, int integer);
        !           156: void               send_ox(OXFILE *fp, ox* m);
        !           157: void               send_ox_cmo(OXFILE *fp, cmo* m);
        !           158: void               send_ox_command(OXFILE *fp, int sm_command);
        !           159: int                send_ox_tag(OXFILE *fp, int tag);
1.1       ohara     160:
                    161: int                next_serial();
                    162: void               setCmotypeDisable(int type);
                    163:
                    164: /* High level API */
1.2     ! ohara     165: void               ox_close(OXFILE *sv);
        !           166: void               ox_shutdown(OXFILE *sv);
        !           167: void               ox_reset(OXFILE *sv);
        !           168: void               ox_execute_string(OXFILE *sv, char* str);
        !           169: cmo_mathcap*       ox_mathcap(OXFILE *sv);
        !           170: char*              ox_popString(OXFILE *sv);
        !           171: void               ox_pops(OXFILE *sv, int num);
        !           172: cmo*               ox_pop_cmo(OXFILE *sv);
        !           173: void               ox_push_cmo(OXFILE *sv, cmo *c);
        !           174: void               ox_push_cmd(OXFILE *sv, int sm_code);
        !           175: void               ox_cmo_rpc(OXFILE *sv, char *function, int argc, cmo *argv[]);
        !           176: int                ox_flush(OXFILE *sv);
        !           177:
        !           178: cell*              list_first(cmo_list *this);
        !           179: int                list_endof(cmo_list *this, cell *el);
        !           180: cell*              list_next(cell *el);
        !           181: cmo_list*          list_append(cmo_list* this, cmo *ob);
        !           182: cmo_list*          list_appendl(cmo_list* this, ...);
        !           183: int                list_length(cmo_list* this);
        !           184: cmo*               list_nth(cmo_list* this, int n);
        !           185:
1.1       ohara     186: int                cmolen_cmo(cmo* m);
1.2     ! ohara     187: void               dump_buffer_init(char *s);
        !           188: void               dump_cmo(cmo* m);
        !           189: void               dump_ox_command(ox_command* m);
        !           190: void               dump_ox_data(ox_data* m);
1.1       ohara     191:
1.2     ! ohara     192: void               print_cmo(cmo* c);
        !           193: void               resize_mpz(mpz_ptr mpz, int size);
1.1       ohara     194:
1.2     ! ohara     195: typedef cmo *(*hook_t)(OXFILE *, cmo *);
1.1       ohara     196:
                    197: int add_hook_before_send_cmo(hook_t func);
                    198: int add_hook_after_send_cmo(hook_t func);
                    199:
                    200: /* functions related to parse.c */
                    201:
                    202: #define PFLAG_ADDREV   1
                    203:
                    204: typedef struct symbol *symbol_t;
                    205:
1.2     ! ohara     206: void setflag_parse(int flag);
1.1       ohara     207: cmo *parse();
1.2     ! ohara     208: void init_parser(char *s);
1.1       ohara     209:
                    210: symbol_t lookup_by_symbol(char *key);
                    211: symbol_t lookup_by_token(int tok);
                    212: symbol_t lookup_by_tag(int tag);
                    213: symbol_t lookup(int i);
                    214: char *symbol_get_key(symbol_t sp);
1.2     ! ohara     215:
        !           216: /* for mathcap database */
        !           217: cmo_mathcap *mathcap_get();
        !           218: int mathcap_cmo_isallow_cmo(cmo *ob);
        !           219: void mathcap_cmo_allow(int tag);
        !           220: void mathcap_cmo_deny(int tag);
        !           221: void mathcap_cmo_deny_all();
        !           222: void mathcap_cmo_allow_all();
        !           223: cmo_list *mathcap_cmo_get_allow_all();
        !           224: cmo_list *mathcap_sm_get_all();
        !           225: cmo_list *mathcap_sysinfo_get_all();
        !           226: void mathcap_sysinfo_set(int version, char *id, char *sysname);
        !           227:
        !           228:
        !           229:
        !           230: int oxf_read(void *buffer, size_t size, size_t num, OXFILE *oxfp);
        !           231: int oxf_write(void *buffer, size_t size, size_t num, OXFILE *oxfp);
        !           232:
        !           233: /* for OXFILE */
        !           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);
        !           246:
        !           247: int send_int32_lbo(OXFILE *oxfp, int int32);
        !           248: int send_int32_nbo(OXFILE *oxfp, int int32);
        !           249: int receive_int32_lbo(OXFILE *oxfp);
        !           250: int receive_int32_nbo(OXFILE *oxfp);
        !           251:
        !           252: /* example: which("xterm", getenv("PATH")); */
        !           253: char *which(char *exe, const char *env);
        !           254: char *generate_otp();
        !           255:
1.1       ohara     256:
                    257: #endif /* _OX_TOOLKIT_H_ */

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