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

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

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