[BACK]Return to ox.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / ox_toolkit

Annotation of OpenXM/src/ox_toolkit/ox.c, Revision 1.18

1.1       ohara       1: /* -*- mode: C; coding: euc-japan -*- */
1.18    ! ohara       2: /* $OpenXM: OpenXM/src/ox_toolkit/ox.c,v 1.17 2000/12/03 16:15:03 ohara Exp $ */
1.1       ohara       3:
1.8       ohara       4: /*
                      5:    This module includes functions for sending/receiveng CMO's.
                      6:    Some commnets is written in Japanese by the EUC-JP coded
                      7:    character set.
1.1       ohara       8: */
                      9:
                     10: #include <stdio.h>
                     11: #include <stdlib.h>
                     12: #include <string.h>
                     13: #include <unistd.h>
                     14: #include <fcntl.h>
1.5       ohara      15: #include <sys/file.h>
1.13      ohara      16: #include <time.h>
1.1       ohara      17:
                     18: #include "mysocket.h"
1.12      ohara      19: #include "ox_toolkit.h"
1.1       ohara      20: #include "parse.h"
                     21:
1.17      ohara      22: /* sorting by the value of CMO_xxx.  (for debugging) */
1.13      ohara      23: static cmo_null*         receive_cmo_null(OXFILE *oxfp);
                     24: static cmo_int32*        receive_cmo_int32(OXFILE *oxfp);
                     25: static cmo_string*       receive_cmo_string(OXFILE *oxfp);
                     26: static cmo_mathcap*      receive_cmo_mathcap(OXFILE *oxfp);
                     27: static cmo_list*         receive_cmo_list(OXFILE *oxfp);
                     28: static cmo_monomial32*   receive_cmo_monomial32(OXFILE *oxfp);
                     29: static cmo_zz*           receive_cmo_zz(OXFILE *oxfp);
                     30: static cmo_zero*         receive_cmo_zero(OXFILE *oxfp);
                     31: static cmo_dms_generic*  receive_cmo_dms_generic(OXFILE *oxfp);
                     32: static cmo_ring_by_name* receive_cmo_ring_by_name(OXFILE *oxfp);
                     33: static cmo_distributed_polynomial* receive_cmo_distributed_polynomial(OXFILE *oxfp);
                     34:
                     35: static cmo_error2*       receive_cmo_error2(OXFILE *oxfp);
                     36: static void              receive_mpz(OXFILE *oxfp, mpz_ptr mpz);
                     37:
                     38: static int          send_cmo_null(OXFILE *oxfp, cmo_null* c);
                     39: static int          send_cmo_int32(OXFILE *oxfp, cmo_int32* m);
                     40: static int          send_cmo_string(OXFILE *oxfp, cmo_string* m);
                     41: static int          send_cmo_mathcap(OXFILE *oxfp, cmo_mathcap* c);
                     42: static int          send_cmo_list(OXFILE *oxfp, cmo_list* c);
                     43: static int          send_cmo_monomial32(OXFILE *oxfp, cmo_monomial32* c);
                     44: static int          send_cmo_zz(OXFILE *oxfp, cmo_zz* c);
                     45: static int          send_cmo_error2(OXFILE *oxfp, cmo_error2* c);
                     46: static int          send_mpz(OXFILE *oxfp, mpz_ptr mpz);
                     47: static int          send_cmo_distributed_polynomial(OXFILE *oxfp, cmo_distributed_polynomial* c);
1.3       ohara      48:
1.8       ohara      49: /* hook functions. (yet not implemented) */
1.2       ohara      50: static hook_t hook_before_send_cmo = NULL;
                     51: static hook_t hook_after_send_cmo  = NULL;
                     52:
                     53: int add_hook_before_send_cmo(hook_t func)
                     54: {
1.13      ohara      55:     hook_before_send_cmo = func;
                     56:     return 0;
1.2       ohara      57: }
                     58:
                     59: int add_hook_after_send_cmo(hook_t func)
                     60: {
1.13      ohara      61:     hook_after_send_cmo = func;
                     62:     return 0;
1.2       ohara      63: }
                     64:
1.13      ohara      65: static cmo *call_hook_before_send_cmo(OXFILE *oxfp, cmo *c)
1.2       ohara      66: {
1.13      ohara      67:     if (hook_before_send_cmo != NULL) {
                     68:         return hook_before_send_cmo(oxfp, c);
                     69:     }
                     70:     return c;
1.2       ohara      71: }
                     72:
1.13      ohara      73: static cmo *call_hook_after_send_cmo(OXFILE *oxfp, cmo *c)
1.2       ohara      74: {
1.13      ohara      75:     if (hook_after_send_cmo != NULL) {
                     76:         return hook_after_send_cmo(oxfp, c);
                     77:     }
                     78:     return c;
1.2       ohara      79: }
1.1       ohara      80:
1.7       ohara      81: /* Handling an error. */
1.1       ohara      82: static int current_received_serial = 0;
                     83:
1.7       ohara      84: /* If an error object be needed, then a server call the following function. */
1.1       ohara      85: cmo_error2* make_error_object(int err_code, cmo *ob)
                     86: {
                     87:     cmo_list* li = new_cmo_list();
1.13      ohara      88:     list_append(li, (cmo *)new_cmo_int32(current_received_serial));
                     89:     list_append(li, (cmo *)new_cmo_int32(err_code));
                     90:     list_append(li, ob);
1.1       ohara      91:     return new_cmo_error2((cmo *)li);
                     92: }
                     93:
1.7       ohara      94: /* getting a next serial number. */
1.13      ohara      95: int next_serial(OXFILE *oxfp)
1.1       ohara      96: {
1.13      ohara      97:     return oxfp->serial_number++;
1.1       ohara      98: }
                     99:
1.7       ohara     100: /* sending an object of int32 type. (not equal to cmo_int32 type)  */
1.13      ohara     101: int send_int32(OXFILE *oxfp, int int32)
1.1       ohara     102: {
1.13      ohara     103:     return oxfp->send_int32(oxfp, int32);
1.1       ohara     104: }
                    105:
1.13      ohara     106: /* receiving an object of int32 type. (not equal to cmo_int32 type)  */
                    107: int receive_int32(OXFILE *oxfp)
1.1       ohara     108: {
1.13      ohara     109:     return oxfp->receive_int32(oxfp);
1.1       ohara     110: }
                    111:
1.13      ohara     112: /* receiving an (OX_tag, serial number)  */
                    113: int receive_ox_tag(OXFILE *oxfp)
1.1       ohara     114: {
1.13      ohara     115:     int tag = receive_int32(oxfp);
1.16      ohara     116:     oxfp->received_serial_number = receive_int32(oxfp);
1.13      ohara     117:     return tag;
1.1       ohara     118: }
                    119:
1.13      ohara     120: /* sending an (OX_tag, serial number)  */
                    121: int send_ox_tag(OXFILE *oxfp, int tag)
1.3       ohara     122: {
1.13      ohara     123:     send_int32(oxfp, tag);
                    124:     return send_int32(oxfp, next_serial(oxfp));
1.1       ohara     125: }
                    126:
1.7       ohara     127: /* functions named receive_cmo_*. */
1.13      ohara     128: static cmo_null* receive_cmo_null(OXFILE *oxfp)
1.1       ohara     129: {
                    130:     return new_cmo_null();
                    131: }
                    132:
1.13      ohara     133: static cmo_int32* receive_cmo_int32(OXFILE *oxfp)
1.1       ohara     134: {
1.13      ohara     135:     int i = receive_int32(oxfp);
1.1       ohara     136:     return new_cmo_int32(i);
                    137: }
                    138:
1.13      ohara     139: static cmo_string* receive_cmo_string(OXFILE *oxfp)
1.1       ohara     140: {
1.13      ohara     141:     int len = receive_int32(oxfp);
1.1       ohara     142:     char* s = malloc(len+1);
                    143:     memset(s, '\0', len+1);
                    144:     if (len > 0) {
1.13      ohara     145:         oxf_read(s, 1, len, oxfp);
1.1       ohara     146:     }
                    147:     return new_cmo_string(s);
                    148: }
                    149:
1.13      ohara     150: static cmo_mathcap* receive_cmo_mathcap(OXFILE *oxfp)
1.1       ohara     151: {
1.13      ohara     152:     cmo* ob = receive_cmo(oxfp);
1.1       ohara     153:     return new_cmo_mathcap(ob);
                    154: }
                    155:
1.13      ohara     156: static cmo_list* receive_cmo_list(OXFILE *oxfp)
1.1       ohara     157: {
                    158:     cmo* ob;
                    159:     cmo_list* c = new_cmo_list();
1.13      ohara     160:     int len = receive_int32(oxfp);
1.1       ohara     161:
                    162:     while (len>0) {
1.13      ohara     163:         ob = receive_cmo(oxfp);
                    164:         list_append(c, ob);
1.1       ohara     165:         len--;
                    166:     }
                    167:     return c;
                    168: }
                    169:
1.13      ohara     170: static cmo_monomial32* receive_cmo_monomial32(OXFILE *oxfp)
1.1       ohara     171: {
                    172:     int i;
1.13      ohara     173:     int len = receive_int32(oxfp);
1.1       ohara     174:     cmo_monomial32* c = new_cmo_monomial32(len);
                    175:
                    176:     for(i=0; i<len; i++) {
1.13      ohara     177:         c->exps[i] = receive_int32(oxfp);
1.1       ohara     178:     }
1.13      ohara     179:     c->coef = receive_cmo(oxfp);
1.1       ohara     180:     return c;
                    181: }
                    182:
1.13      ohara     183: static cmo_zz* receive_cmo_zz(OXFILE *oxfp)
1.1       ohara     184: {
                    185:     cmo_zz* c = new_cmo_zz();
1.13      ohara     186:     receive_mpz(oxfp, c->mpz);
1.1       ohara     187:     return c;
                    188: }
                    189:
1.13      ohara     190: static cmo_zero* receive_cmo_zero(OXFILE *oxfp)
1.1       ohara     191: {
                    192:     return new_cmo_zero();
                    193: }
                    194:
1.13      ohara     195: static cmo_dms_generic* receive_cmo_dms_generic(OXFILE *oxfp)
1.1       ohara     196: {
                    197:     return new_cmo_dms_generic();
                    198: }
                    199:
1.13      ohara     200: static cmo_ring_by_name* receive_cmo_ring_by_name(OXFILE *oxfp)
1.1       ohara     201: {
1.13      ohara     202:     cmo* ob = receive_cmo(oxfp);
                    203:     /* We need to check semantics but yet ... */
1.1       ohara     204:     return new_cmo_ring_by_name(ob);
                    205: }
                    206:
1.13      ohara     207: static cmo_distributed_polynomial* receive_cmo_distributed_polynomial(OXFILE *oxfp)
1.1       ohara     208: {
                    209:     cmo* ob;
                    210:     cmo_distributed_polynomial* c = new_cmo_distributed_polynomial();
1.13      ohara     211:     int len = receive_int32(oxfp);
                    212:     c->ringdef = receive_cmo(oxfp);
1.1       ohara     213:
                    214:     while (len>0) {
1.13      ohara     215:         ob = receive_cmo(oxfp);
                    216:         list_append((cmo_list *)c, ob);
1.1       ohara     217:         len--;
                    218:     }
                    219:     return c;
                    220: }
                    221:
1.13      ohara     222: static cmo_error2* receive_cmo_error2(OXFILE *oxfp)
1.1       ohara     223: {
1.13      ohara     224:     cmo* ob = receive_cmo(oxfp);
1.1       ohara     225:     return new_cmo_error2(ob);
                    226: }
                    227:
1.17      ohara     228: /* receive_cmo() is called after receive_ox_tag(). */
1.13      ohara     229: cmo* receive_cmo(OXFILE *oxfp)
1.1       ohara     230: {
                    231:     cmo* m;
1.13      ohara     232:     int tag = receive_int32(oxfp);
1.1       ohara     233:     switch(tag) {
                    234:     case CMO_NULL:
1.13      ohara     235:         m = receive_cmo_null(oxfp);
1.1       ohara     236:         break;
                    237:     case CMO_INT32:
1.13      ohara     238:         m = (cmo *)receive_cmo_int32(oxfp);
1.1       ohara     239:         break;
                    240:     case CMO_STRING:
1.13      ohara     241:         m = (cmo *)receive_cmo_string(oxfp);
1.1       ohara     242:         break;
                    243:     case CMO_MATHCAP:
1.13      ohara     244:         m = (cmo *)receive_cmo_mathcap(oxfp);
1.1       ohara     245:         break;
                    246:     case CMO_LIST:
1.13      ohara     247:         m = (cmo *)receive_cmo_list(oxfp);
1.1       ohara     248:         break;
                    249:     case CMO_MONOMIAL32:
1.13      ohara     250:         m = (cmo *)receive_cmo_monomial32(oxfp);
1.1       ohara     251:         break;
                    252:     case CMO_ZZ:
1.13      ohara     253:         m = (cmo *)receive_cmo_zz(oxfp);
1.1       ohara     254:         break;
                    255:     case CMO_ZERO:
1.13      ohara     256:         m = (cmo *)receive_cmo_zero(oxfp);
1.1       ohara     257:         break;
                    258:     case CMO_DMS_GENERIC:
1.13      ohara     259:         m = (cmo *)receive_cmo_dms_generic(oxfp);
1.1       ohara     260:         break;
                    261:     case CMO_RING_BY_NAME:
1.13      ohara     262:         m = (cmo *)receive_cmo_ring_by_name(oxfp);
1.1       ohara     263:         break;
                    264:     case CMO_DISTRIBUTED_POLYNOMIAL:
1.13      ohara     265:         m = (cmo *)receive_cmo_distributed_polynomial(oxfp);
1.1       ohara     266:         break;
                    267:     case CMO_ERROR2:
1.13      ohara     268:         m = (cmo *)receive_cmo_error2(oxfp);
1.1       ohara     269:         break;
                    270:     case CMO_DATUM:
                    271:     case CMO_QQ:
                    272:     default:
1.13      ohara     273:         m = NULL;
                    274:         fprintf(stderr, "the CMO (%d) is not implemented.\n", tag);
1.1       ohara     275:     }
                    276:     return m;
                    277: }
                    278:
1.13      ohara     279: static void receive_mpz(OXFILE *oxfp, mpz_ptr mpz)
1.1       ohara     280: {
                    281:     int i;
1.13      ohara     282:     int size  = receive_int32(oxfp);
1.1       ohara     283:     int len   = abs(size);
                    284:     resize_mpz(mpz, size);
                    285:
                    286:     for(i=0; i<len; i++) {
1.13      ohara     287:         mpz->_mp_d[i] = receive_int32(oxfp);
1.1       ohara     288:     }
                    289: }
                    290:
1.13      ohara     291: void send_ox_command(OXFILE *oxfp, int sm_command)
1.1       ohara     292: {
1.13      ohara     293:     send_ox_tag(oxfp, OX_COMMAND);
                    294:     send_int32(oxfp, sm_command);
                    295:     oxf_flush(oxfp);
1.1       ohara     296: }
                    297:
1.13      ohara     298: void ox_close(OXFILE *sv)
1.1       ohara     299: {
1.13      ohara     300:     send_ox_command(oxf_control(sv), SM_control_kill);
1.1       ohara     301: #ifdef DEBUG
1.7       ohara     302:     sleep(2);
1.13      ohara     303:     /* We wait thar an OpenXM server terminates. */
1.1       ohara     304:     fprintf(stderr, "I have closed the connection to an Open XM server.\n");
                    305: #endif
                    306: }
                    307:
1.13      ohara     308: void ox_shutdown(OXFILE *sv)
1.3       ohara     309: {
1.13      ohara     310:     /* We need to use SM_shutdown but yet ... */
                    311:     ox_close(sv);
1.3       ohara     312: }
                    313:
1.13      ohara     314: void ox_cmo_rpc(OXFILE *sv, char *function, int argc, cmo *argv[])
1.3       ohara     315: {
1.13      ohara     316:     int i = argc;
                    317:     while(i-- > 0) {
                    318:         send_ox_cmo(sv, argv[i]);
                    319:     }
                    320:     send_ox_cmo(sv, (cmo *)new_cmo_int32(argc));
                    321:     send_ox_cmo(sv, (cmo *)new_cmo_string(function));
                    322:     send_ox_command(sv, SM_executeFunction);
1.3       ohara     323: }
                    324:
1.13      ohara     325: void ox_execute_string(OXFILE *sv, char* s)
1.3       ohara     326: {
1.13      ohara     327:     send_ox_cmo(sv, (cmo *)new_cmo_string(s));
                    328:     send_ox_command(sv, SM_executeStringByLocalParser);
1.3       ohara     329: }
                    330:
1.13      ohara     331: void ox_push_cmd(OXFILE *sv, int sm_code)
1.1       ohara     332: {
1.13      ohara     333:     send_ox_command(sv, sm_code);
1.1       ohara     334: }
                    335:
1.13      ohara     336: cmo_mathcap* ox_mathcap(OXFILE *sv)
1.1       ohara     337: {
1.13      ohara     338:     send_ox_command(sv, SM_mathcap);
                    339:     send_ox_command(sv, SM_popCMO);
                    340:     receive_ox_tag(sv);          /* OX_DATA */
                    341:     return (cmo_mathcap *)receive_cmo(sv);
1.1       ohara     342: }
                    343:
1.13      ohara     344: char* ox_popString(OXFILE *sv)
1.1       ohara     345: {
                    346:     cmo_string* m = NULL;
                    347:
1.13      ohara     348:     send_ox_command(sv, SM_popString);
                    349:     receive_ox_tag(sv); /* OX_DATA */
                    350:     m = (cmo_string *)receive_cmo(sv);
1.1       ohara     351:     return m->s;
                    352: }
                    353:
1.13      ohara     354: void ox_pops(OXFILE *sv, int num)
1.3       ohara     355: {
1.13      ohara     356:     send_ox_cmo(sv, (cmo *)new_cmo_int32(num));
                    357:     send_ox_command(sv, SM_pops);
1.3       ohara     358: }
                    359:
1.13      ohara     360: cmo* ox_pop_cmo(OXFILE *sv)
1.3       ohara     361: {
1.13      ohara     362:     send_ox_command(sv, SM_popCMO);
                    363:     receive_ox_tag(sv); /* OX_DATA */
                    364:     return receive_cmo(sv);
1.3       ohara     365: }
                    366:
1.13      ohara     367: void ox_push_cmo(OXFILE *sv, cmo *c)
1.3       ohara     368: {
1.13      ohara     369:     send_ox_cmo(sv, c);
1.3       ohara     370: }
                    371:
1.7       ohara     372: /* a dummy function for flushing a connection. */
1.13      ohara     373: int ox_flush(OXFILE *sv)
1.5       ohara     374: {
1.13      ohara     375:     return 1;
1.5       ohara     376: }
                    377:
1.13      ohara     378: void ox_reset(OXFILE *sv)
1.1       ohara     379: {
1.13      ohara     380:     send_ox_command(oxf_control(sv), SM_control_reset_connection);
                    381:     while(receive_ox_tag(sv) != OX_SYNC_BALL) {
                    382:         receive_cmo(sv); /* skipping a message. */
1.1       ohara     383:     }
                    384:
1.13      ohara     385:     send_ox_tag(sv, OX_SYNC_BALL);
1.1       ohara     386: #ifdef DEBUG
                    387:     fprintf(stderr, "I have reset an Open XM server.\n");
                    388: #endif
                    389: }
                    390:
1.13      ohara     391: void send_ox(OXFILE *oxfp, ox *m)
1.1       ohara     392: {
                    393:     switch(m->tag) {
1.13      ohara     394:     case OX_DATA:
                    395:         send_ox_cmo(oxfp, ((ox_data *)m)->cmo);
1.1       ohara     396:         break;
1.13      ohara     397:     case OX_COMMAND:
                    398:         send_ox_command(oxfp, ((ox_command *)m)->command);
1.1       ohara     399:         break;
                    400:     default:
                    401:         /* CMO?? */
1.13      ohara     402:         send_ox_cmo(oxfp, (cmo *)m);
1.1       ohara     403:     }
                    404: }
                    405:
1.13      ohara     406: void send_ox_cmo(OXFILE *oxfp, cmo* m)
1.1       ohara     407: {
1.13      ohara     408:     send_ox_tag(oxfp, OX_DATA);
                    409:     send_cmo(oxfp, m);
                    410:     oxf_flush(oxfp);
1.1       ohara     411: }
                    412:
1.8       ohara     413: /* send_cmo_* functions */
1.13      ohara     414: static int send_cmo_null(OXFILE *oxfp, cmo_null* c)
1.1       ohara     415: {
                    416:     return 0;
                    417: }
                    418:
1.13      ohara     419: static int send_cmo_int32(OXFILE *oxfp, cmo_int32* m)
1.1       ohara     420: {
1.13      ohara     421:     return send_int32(oxfp, m->i);
1.1       ohara     422: }
                    423:
1.13      ohara     424: static int send_cmo_string(OXFILE *oxfp, cmo_string* m)
1.1       ohara     425: {
                    426:     int len = (m->s != NULL)? strlen(m->s): 0;
1.13      ohara     427:     send_int32(oxfp, len);
1.1       ohara     428:     if (len > 0) {
1.13      ohara     429:         oxf_write(m->s, 1, len, oxfp);
1.1       ohara     430:     }
                    431:     return 0;
                    432: }
                    433:
1.13      ohara     434: static int send_cmo_mathcap(OXFILE *oxfp, cmo_mathcap* c)
1.1       ohara     435: {
1.13      ohara     436:     send_cmo(oxfp, c->ob);
1.1       ohara     437:     return 0;
                    438: }
                    439:
1.13      ohara     440: static int send_cmo_list(OXFILE *oxfp, cmo_list* c)
1.1       ohara     441: {
1.13      ohara     442:     cell* el = list_first(c);
                    443:     int len = list_length(c);
                    444:     send_int32(oxfp, len);
                    445:
                    446:     while(!list_endof(c, el)) {
                    447:         send_cmo(oxfp, el->cmo);
                    448:         el = list_next(el);
1.1       ohara     449:     }
                    450:     return 0;
                    451: }
                    452:
1.13      ohara     453: static int send_cmo_distributed_polynomial(OXFILE *oxfp, cmo_distributed_polynomial* c)
1.1       ohara     454: {
1.13      ohara     455:     cell* el = list_first((cmo_list *)c);
                    456:     int len = list_length((cmo_list *)c);
                    457:     send_int32(oxfp, len);
                    458:     send_cmo(oxfp, c->ringdef);
                    459:     while(!list_endof((cmo_list *)c, el)) {
                    460:         send_cmo(oxfp, el->cmo);
                    461:         el = list_next(el);
1.1       ohara     462:     }
                    463:     return 0;
                    464: }
                    465:
1.13      ohara     466: static int send_cmo_monomial32(OXFILE *oxfp, cmo_monomial32* c)
1.1       ohara     467: {
                    468:     int i;
                    469:     int len = c->length;
1.13      ohara     470:     send_int32(oxfp, len);
1.1       ohara     471:     for(i=0; i<len; i++) {
1.13      ohara     472:         send_int32(oxfp, c->exps[i]);
1.1       ohara     473:     }
1.13      ohara     474:     send_cmo(oxfp, c->coef);
1.1       ohara     475:     return 0;
                    476: }
                    477:
1.13      ohara     478: static int send_cmo_zz(OXFILE *oxfp, cmo_zz* c)
1.1       ohara     479: {
1.13      ohara     480:     send_mpz(oxfp, c->mpz);
1.1       ohara     481:     return 0;
                    482: }
                    483:
1.13      ohara     484: static int send_cmo_error2(OXFILE *oxfp, cmo_error2* c)
1.1       ohara     485: {
1.13      ohara     486:     send_cmo(oxfp, c->ob);
1.1       ohara     487:     return 0;
                    488: }
                    489:
1.8       ohara     490: /* sending a CMO.  (Remarks: OX_tag is already sent.) */
1.13      ohara     491: void send_cmo(OXFILE *oxfp, cmo* c)
1.1       ohara     492: {
                    493:     int tag = c->tag;
                    494:
1.13      ohara     495:     c = call_hook_before_send_cmo(oxfp, c);
1.2       ohara     496:
1.13      ohara     497:     send_int32(oxfp, tag);
1.1       ohara     498:     switch(tag) {
                    499:     case CMO_NULL:
                    500:     case CMO_ZERO:
                    501:     case CMO_DMS_GENERIC:
1.13      ohara     502:         send_cmo_null(oxfp, c);  /* empty function. */
1.1       ohara     503:         break;
                    504:     case CMO_INT32:
1.13      ohara     505:         send_cmo_int32(oxfp, (cmo_int32 *)c);
1.1       ohara     506:         break;
                    507:     case CMO_STRING:
1.13      ohara     508:         send_cmo_string(oxfp, (cmo_string *)c);
1.1       ohara     509:         break;
                    510:     case CMO_MATHCAP:
                    511:     case CMO_ERROR2:
                    512:     case CMO_RING_BY_NAME:
                    513:     case CMO_INDETERMINATE:
1.13      ohara     514:         send_cmo_mathcap(oxfp, (cmo_mathcap *)c);
1.1       ohara     515:         break;
                    516:     case CMO_LIST:
1.13      ohara     517:         send_cmo_list(oxfp, (cmo_list *)c);
1.1       ohara     518:         break;
                    519:     case CMO_MONOMIAL32:
1.13      ohara     520:         send_cmo_monomial32(oxfp, (cmo_monomial32 *)c);
1.1       ohara     521:         break;
                    522:     case CMO_ZZ:
1.13      ohara     523:         send_cmo_zz(oxfp, (cmo_zz *)c);
1.1       ohara     524:         break;
                    525:     case CMO_DISTRIBUTED_POLYNOMIAL:
1.13      ohara     526:         send_cmo_distributed_polynomial(oxfp, (cmo_distributed_polynomial *)c);
1.1       ohara     527:         break;
                    528:     default:
1.13      ohara     529:         call_hook_after_send_cmo(oxfp, c);
1.1       ohara     530:     }
                    531: }
                    532:
1.13      ohara     533: static int send_mpz(OXFILE *oxfp, mpz_ptr mpz)
1.1       ohara     534: {
                    535:     int i;
                    536:     int len = abs(mpz->_mp_size);
1.13      ohara     537:     send_int32(oxfp, mpz->_mp_size);
1.1       ohara     538:     for(i=0; i<len; i++) {
1.13      ohara     539:         send_int32(oxfp, mpz->_mp_d[i]);
1.1       ohara     540:     }
                    541:     return 0;
                    542: }
                    543:
                    544: ox_data* new_ox_data(cmo* c)
                    545: {
                    546:     ox_data* m = malloc(sizeof(ox_data));
                    547:     m->tag = OX_DATA;
                    548:     m->cmo = c;
                    549:     return m;
                    550: }
                    551:
                    552: ox_command* new_ox_command(int sm_code)
                    553: {
                    554:     ox_command* m = malloc(sizeof(ox_command));
                    555:     m->tag = OX_COMMAND;
                    556:     m->command = sm_code;
                    557:     return m;
                    558: }
                    559:
                    560: ox_sync_ball* new_ox_sync_ball()
                    561: {
                    562:     ox_sync_ball *m = malloc(sizeof(ox_sync_ball));
                    563:     m->tag = OX_SYNC_BALL;
                    564:     return m;
                    565: }

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