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

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

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