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

Diff for /OpenXM/src/ox_math/Attic/ox.c between version 1.1 and 1.2

version 1.1, 1999/10/29 08:06:41 version 1.2, 1999/11/02 06:11:57
Line 43  static int          cmolen_cmo_mathcap(cmo_mathcap* c)
Line 43  static int          cmolen_cmo_mathcap(cmo_mathcap* c)
 static int          cmolen_cmo_null(cmo_null* c);  static int          cmolen_cmo_null(cmo_null* c);
 static int          cmolen_cmo_string(cmo_string* c);  static int          cmolen_cmo_string(cmo_string* c);
 static int          cmolen_cmo_zz(cmo_zz* c);  static int          cmolen_cmo_zz(cmo_zz* c);
   static int          cmolen_cmo_monomial32(cmo_monomial32* c);
   
 static char*        dump_cmo_int32(char* array, cmo_int32* m);  static char*        dump_cmo_int32(char* array, cmo_int32* m);
 static char*        dump_cmo_list(char* array, cmo_list* m);  static char*        dump_cmo_list(char* array, cmo_list* m);
 static char*        dump_cmo_mathcap(char* array, cmo_mathcap* m);  static char*        dump_cmo_mathcap(char* array, cmo_mathcap* m);
 static char*        dump_cmo_null(char* array, cmo_null* m);  static char*        dump_cmo_null(char* array, cmo_null* m);
 static char*        dump_cmo_string(char* array, cmo_string* m);  static char*        dump_cmo_string(char* array, cmo_string* m);
   static char*        dump_cmo_monomial32(char* array, cmo_monomial32* c);
 static char*        dump_cmo_zz(char* array, cmo_zz* c);  static char*        dump_cmo_zz(char* array, cmo_zz* c);
 static char*        dump_integer(char* array, int x);  static char*        dump_integer(char* array, int x);
 static char*        dump_mpz(char* array, mpz_ptr mpz);  static char*        dump_mpz(char* array, mpz_ptr mpz);
   
 static int          funcs(int cmo_type);  static int          funcs(int cmo_type);
   
   /* CMO_xxx の値順にならべること(デバッグのため) */
 static int          read_password(int fd, char* passwd);  static int          read_password(int fd, char* passwd);
 static cmo_error*   receive_cmo_error(int fd);  
 static cmo_int32*   receive_cmo_int32(int fd);  
 static cmo_list*    receive_cmo_list(int fd);  
 static cmo_mathcap* receive_cmo_mathcap(int fd);  
 static cmo_null*    receive_cmo_null(int fd);  static cmo_null*    receive_cmo_null(int fd);
   static cmo_int32*   receive_cmo_int32(int fd);
 static cmo_string*  receive_cmo_string(int fd);  static cmo_string*  receive_cmo_string(int fd);
   static cmo_mathcap* receive_cmo_mathcap(int fd);
   static cmo_list*    receive_cmo_list(int fd);
 static cmo_zz*      receive_cmo_zz(int fd);  static cmo_zz*      receive_cmo_zz(int fd);
   static cmo_zero*    receive_cmo_zero(int fd);
   static cmo_dms_generic* receive_cmo_dms_generic(int fd);
   static cmo_error2*  receive_cmo_error2(int fd);
 static void         receive_mpz(int fd, mpz_ptr mpz);  static void         receive_mpz(int fd, mpz_ptr mpz);
   
 static int          send_cmo_error(int fd, cmo_error* c);  
 static int          send_cmo_int32(int fd, cmo_int32* m);  
 static int          send_cmo_list(int fd, cmo_list* c);  
 static int          send_cmo_mathcap(int fd, cmo_mathcap* c);  
 static int          send_cmo_null(int fd, cmo_null* c);  static int          send_cmo_null(int fd, cmo_null* c);
   static int          send_cmo_int32(int fd, cmo_int32* m);
 static int          send_cmo_string(int fd, cmo_string* m);  static int          send_cmo_string(int fd, cmo_string* m);
   static int          send_cmo_mathcap(int fd, cmo_mathcap* c);
   static int          send_cmo_list(int fd, cmo_list* c);
 static int          send_cmo_zz(int fd, cmo_zz* c);  static int          send_cmo_zz(int fd, cmo_zz* c);
   static int          send_cmo_error2(int fd, cmo_error2* c);
 static int          send_mpz(int fd, mpz_ptr mpz);  static int          send_mpz(int fd, mpz_ptr mpz);
   
   
Line 79  static int          send_mpz(int fd, mpz_ptr mpz);
Line 84  static int          send_mpz(int fd, mpz_ptr mpz);
 static int current_received_serial = 0;  static int current_received_serial = 0;
   
 /* エラーを起こしたときはサーバは次のようにすればよい.  */  /* エラーを起こしたときはサーバは次のようにすればよい.  */
 cmo_error* gen_error_object(int err_code)  cmo_error2* gen_error_object(int err_code)
 {  {
     cmo_list* li = new_cmo_list();      cmo_list* li = new_cmo_list();
     append_cmo_list(li, (cmo *)new_cmo_int32(current_received_serial));      append_cmo_list(li, (cmo *)new_cmo_int32(current_received_serial));
     append_cmo_list(li, (cmo *)new_cmo_int32(err_code));      append_cmo_list(li, (cmo *)new_cmo_int32(err_code));
     /* 他の情報を加えるならココ */      /* 他の情報を加えるならココ */
     return new_cmo_error(li);      return new_cmo_error2((cmo *)li);
 }  }
   
 /* add at Mon Sep  7 15:51:28 JST 1998 */  /* add at Mon Sep  7 15:51:28 JST 1998 */
Line 140  cell* new_cell(cmo* newcmo)
Line 145  cell* new_cell(cmo* newcmo)
     return h;      return h;
 }  }
   
   cell* next_cell(cell* this)
   {
       return this->next;
   }
   
 static cell* *tailp(cmo_list* this) {  static cell* *tailp(cmo_list* this) {
     cell **cp = &this->head;      cell **cp = &this->head;
     while (*cp != NULL) {      while (*cp != NULL) {
Line 163  int append_cmo_list(cmo_list* this, cmo* newcmo)
Line 173  int append_cmo_list(cmo_list* this, cmo* newcmo)
 }  }
   
 /** receive_cmo_XXX 関数群 **/  /** receive_cmo_XXX 関数群 **/
 static cmo_error* receive_cmo_error(int fd)  static cmo_null* receive_cmo_null(int fd)
 {  {
     cmo_list* li = (cmo_list *)receive_cmo(fd);      return new_cmo_null();
     return new_cmo_error(li);  
 }  }
   
 static cmo_int32* receive_cmo_int32(int fd)  static cmo_int32* receive_cmo_int32(int fd)
Line 175  static cmo_int32* receive_cmo_int32(int fd)
Line 184  static cmo_int32* receive_cmo_int32(int fd)
     return new_cmo_int32(i);      return new_cmo_int32(i);
 }  }
   
   static cmo_string* receive_cmo_string(int fd)
   {
       int len = receive_int32(fd);
       char* s = malloc(len+1);
       memset(s, '\0', len+1);
       if (len > 0) {
           read(fd, s, len);
       }
       return new_cmo_string(s);
   }
   
   static cmo_mathcap* receive_cmo_mathcap(int fd)
   {
       cmo* ob = receive_cmo(fd);
       return new_cmo_mathcap(ob);
   }
   
 static cmo_list* receive_cmo_list(int fd)  static cmo_list* receive_cmo_list(int fd)
 {  {
     cmo* newcmo;      cmo* newcmo;
Line 189  static cmo_list* receive_cmo_list(int fd)
Line 215  static cmo_list* receive_cmo_list(int fd)
     return c;      return c;
 }  }
   
 static cmo_mathcap* receive_cmo_mathcap(int fd)  static cmo_zz* receive_cmo_zz(int fd)
 {  {
     cmo_list* li = (cmo_list *)receive_cmo(fd);      cmo_zz* c = new_cmo_zz();
     return new_cmo_mathcap(li);      receive_mpz(fd, c->mpz);
       return c;
 }  }
   
 static cmo_null* receive_cmo_null(int fd)  static cmo_zero* receive_cmo_zero(int fd)
 {  {
     return new_cmo_null();      return new_cmo_zero();
 }  }
   
 static cmo_string* receive_cmo_string(int fd)  static cmo_dms_generic* receive_cmo_dms_generic(int fd)
 {  {
     int len = receive_int32(fd);      return new_cmo_dms_generic();
     char* s = malloc(len+1);  
     memset(s, '\0', len+1);  
     if (len > 0) {  
         read(fd, s, len);  
     }  
     return new_cmo_string(s);  
 }  }
   
 static cmo_zz* receive_cmo_zz(int fd)  static cmo_ring_by_name* receive_cmo_ring_by_name(int fd)
 {  {
     cmo_zz* c = new_cmo_zz();      cmo* ob = receive_cmo(fd);
     receive_mpz(fd, c->mpz);          /* 意味的チェックが必要 */
     return c;      return new_cmo_ring_by_name(ob);
 }  }
   
   static cmo_error2* receive_cmo_error2(int fd)
   {
       cmo* ob = receive_cmo(fd);
       return new_cmo_error2(ob);
   }
   
 static void receive_mpz(int fd, mpz_ptr mpz)  static void receive_mpz(int fd, mpz_ptr mpz)
 {  {
     int i;      int i;
Line 237  void resize_mpz(mpz_ptr mpz, int size)
Line 264  void resize_mpz(mpz_ptr mpz, int size)
 }  }
   
 /** new_cmo_XXX 関数群 **/  /** new_cmo_XXX 関数群 **/
 cmo_error* new_cmo_error(cmo_list* li)  cmo_null* new_cmo_null()
 {  {
     cmo_error* c = malloc(sizeof(cmo_error));      cmo_null* m = malloc(sizeof(cmo_null));
     c->tag = CMO_ERROR2;      m->tag = CMO_NULL;
     c->li  = li;      return m;
     return c;  
 }  }
   
 cmo_int32* new_cmo_int32(int i)  cmo_int32* new_cmo_int32(int i)
Line 254  cmo_int32* new_cmo_int32(int i)
Line 280  cmo_int32* new_cmo_int32(int i)
     return c;      return c;
 }  }
   
 cmo_list* new_cmo_list()  cmo_string* new_cmo_string(char* s)
 {  {
     cmo_list* c = malloc(sizeof(cmo_list));      cmo_string* c = malloc(sizeof(cmo_string));
     c->tag    = CMO_LIST;          char *s2 = malloc(strlen(s)+1);
     c->length = 0;          strcpy(s2, s);
     c->head   = NULL;  
       c->tag = CMO_STRING;
       c->s   = s2;
     return c;      return c;
 }  }
   
 cmo_mathcap* new_cmo_mathcap(cmo_list* li)  cmo_mathcap* new_cmo_mathcap(cmo* ob)
 {  {
     cmo_mathcap* c = malloc(sizeof(cmo_mathcap));      cmo_mathcap* c = malloc(sizeof(cmo_mathcap));
     c->tag = CMO_MATHCAP;      c->tag = CMO_MATHCAP;
     c->li  = li;      c->ob  = ob;
     return c;      return c;
 }  }
   
 cmo_null* new_cmo_null()  cmo_list* new_cmo_list()
 {  {
     cmo* m = malloc(sizeof(cmo));      cmo_list* c = malloc(sizeof(cmo_list));
     m->tag = CMO_NULL;      c->tag    = CMO_LIST;
     return m;      c->length = 0;
       c->head   = NULL;
       return c;
 }  }
   
 cmo_string* new_cmo_string(char* s)  cmo_monomial32* new_cmo_monomial32()
 {  {
     cmo_string* c = malloc(sizeof(cmo_string));      cmo_monomial32* c = malloc(sizeof(cmo_monomial32));
     c->tag = CMO_STRING;      c->tag  = CMO_MONOMIAL32;
     c->s   = s;  
     return c;      return c;
 }  }
   
   cmo_monomial32* new_cmo_monomial32_size(int size)
   {
       cmo_monomial32* c = new_cmo_monomial32();
           if (size>0) {
                   c->length = size;
                   c->exps = malloc(sizeof(int)*size);
           }
       return c;
   }
   
 cmo_zz* new_cmo_zz()  cmo_zz* new_cmo_zz()
 {  {
     cmo_zz* c = malloc(sizeof(cmo_zz));      cmo_zz* c = malloc(sizeof(cmo_zz));
Line 315  cmo_zz* new_cmo_zz_size(int size)
Line 354  cmo_zz* new_cmo_zz_size(int size)
     return c;      return c;
 }  }
   
   cmo_zero* new_cmo_zero()
   {
       cmo_zero* m = malloc(sizeof(cmo_zero));
       m->tag = CMO_ZERO;
       return m;
   }
   
   cmo_dms_generic* new_cmo_dms_generic()
   {
       cmo_dms_generic* m = malloc(sizeof(cmo_dms_generic));
       m->tag = CMO_DMS_GENERIC;
       return m;
   }
   
   cmo_ring_by_name* new_cmo_ring_by_name(cmo* ob)
   {
       cmo_ring_by_name* c = malloc(sizeof(cmo_ring_by_name));
       c->tag = CMO_RING_BY_NAME;
       c->ob  = ob;
       return c;
   }
   
   cmo_indeterminate* new_cmo_indeterminate(cmo* ob)
   {
       cmo_indeterminate* c = malloc(sizeof(cmo_indeterminate));
       c->tag = CMO_INDETERMINATE;
       c->ob  = ob;
       return c;
   }
   
   cmo_error2* new_cmo_error2(cmo* ob)
   {
       cmo_error2* c = malloc(sizeof(cmo_error2));
       c->tag = CMO_ERROR2;
       c->ob  = ob;
       return c;
   }
   
 /* receive_ox_tag() == OX_DATA の後に呼び出される */  /* receive_ox_tag() == OX_DATA の後に呼び出される */
 /* 関数ポインタを使った方がきれいに書けるような気がする.  */  /* 関数ポインタを使った方がきれいに書けるような気がする.  */
 /* if (foo[tag] != NULL) foo[tag](fd); とか */  /* if (foo[tag] != NULL) foo[tag](fd); とか */
Line 335  cmo* receive_cmo(int fd)
Line 412  cmo* receive_cmo(int fd)
     case CMO_STRING:      case CMO_STRING:
         m = (cmo *)receive_cmo_string(fd);          m = (cmo *)receive_cmo_string(fd);
         break;          break;
     case CMO_ZZ:      case CMO_MATHCAP:
         m = (cmo *)receive_cmo_zz(fd);          m = (cmo *)receive_cmo_mathcap(fd);
         break;          break;
     case CMO_LIST:      case CMO_LIST:
         m = (cmo *)receive_cmo_list(fd);          m = (cmo *)receive_cmo_list(fd);
         break;          break;
     case CMO_MATHCAP:      case CMO_ZZ:
         m = (cmo *)receive_cmo_mathcap(fd);          m = (cmo *)receive_cmo_zz(fd);
         break;          break;
     case CMO_ERROR2:      case CMO_ERROR2:
         m = (cmo *)receive_cmo_error(fd);          m = (cmo *)receive_cmo_error2(fd);
         break;          break;
     case CMO_DATUM:      case CMO_DATUM:
     case CMO_QQ:      case CMO_QQ:
Line 407  int print_cmo_list(cmo_list* li)
Line 484  int print_cmo_list(cmo_list* li)
 int print_cmo_mathcap(cmo_mathcap* c)  int print_cmo_mathcap(cmo_mathcap* c)
 {  {
     fprintf(stderr, "\n");      fprintf(stderr, "\n");
     print_cmo((cmo *)c->li);      print_cmo(c->ob);
 }  }
   
 int print_cmo_string(cmo_string* c)  int print_cmo_string(cmo_string* c)
Line 529  void ox_reset(ox_file_t sv)
Line 606  void ox_reset(ox_file_t sv)
 #endif  #endif
 }  }
   
 /* 以下は parse.c で必要とする関数たち */  /* 以下は bconv.c で必要とする関数群である. */
 /* cmolen 関数は cmo の(送信時の)バイト長を返す */  
 /* cmolen_XXX 関数は tag を除いたバイト長を返す */  
   
   /* cmolen 関数は cmo の(送信時の)バイト長を返す. */
   /* cmolen_XXX 関数は cmo_XXX の tag を除いたバイト長を返す. */
   
   static int cmolen_cmo_null(cmo_null* c)
   {
       return 0;
   }
   
 static int cmolen_cmo_int32(cmo_int32* c)  static int cmolen_cmo_int32(cmo_int32* c)
 {  {
     return sizeof(int);      return sizeof(int);
 }  }
   
   static int cmolen_cmo_string(cmo_string* c)
   {
       return sizeof(int)+strlen(c->s);
   }
   
   static int cmolen_cmo_mathcap(cmo_mathcap* c)
   {
       return cmolen_cmo(c->ob);
   }
   
 static int cmolen_cmo_list(cmo_list* c)  static int cmolen_cmo_list(cmo_list* c)
 {  {
     int size = sizeof(c->head);      int size = sizeof(c->head);
Line 550  static int cmolen_cmo_list(cmo_list* c)
Line 643  static int cmolen_cmo_list(cmo_list* c)
     return size;      return size;
 }  }
   
 static int cmolen_cmo_mathcap(cmo_mathcap* c)  static int cmolen_cmo_monomial32(cmo_monomial32* c)
 {  {
     return cmolen_cmo((cmo *)c->li);          int len = (c->length + 1)*sizeof(int);
           return len + cmolen_cmo(c->coef);
 }  }
   
 static int cmolen_cmo_null(cmo_null* c)  
 {  
     return 0;  
 }  
   
 static int cmolen_cmo_string(cmo_string* c)  
 {  
     return sizeof(int)+strlen(c->s);  
 }  
   
 static int cmolen_cmo_zz(cmo_zz* c)  static int cmolen_cmo_zz(cmo_zz* c)
 {  {
     int len = abs(c->mpz->_mp_size);      int len = abs(c->mpz->_mp_size);
Line 578  int cmolen_cmo(cmo* c)
Line 662  int cmolen_cmo(cmo* c)
   
     switch(c->tag) {      switch(c->tag) {
     case CMO_NULL:      case CMO_NULL:
       case CMO_ZERO:
       case CMO_DMS_GENERIC:
         size += cmolen_cmo_null(c);          size += cmolen_cmo_null(c);
         break;          break;
     case CMO_INT32:      case CMO_INT32:
Line 586  int cmolen_cmo(cmo* c)
Line 672  int cmolen_cmo(cmo* c)
     case CMO_STRING:      case CMO_STRING:
         size += cmolen_cmo_string((cmo_string *)c);          size += cmolen_cmo_string((cmo_string *)c);
         break;          break;
       case CMO_MATHCAP:
       case CMO_RING_BY_NAME:
       case CMO_ERROR2:
           size += cmolen_cmo_mathcap((cmo_mathcap *)c);
           break;
     case CMO_LIST:      case CMO_LIST:
         size += cmolen_cmo_list((cmo_list *)c);          size += cmolen_cmo_list((cmo_list *)c);
         break;          break;
       case CMO_MONOMIAL32:
           size += cmolen_cmo_monomial32((cmo_monomial32 *)c);
           break;
     case CMO_ZZ:      case CMO_ZZ:
         size += cmolen_cmo_zz((cmo_zz *)c);          size += cmolen_cmo_zz((cmo_zz *)c);
         break;          break;
     case CMO_MATHCAP:  
         size += cmolen_cmo_mathcap((cmo_mathcap *)c);  
         break;  
     default:      default:
     }      }
     return size;      return size;
 }  }
   
   static char* dump_cmo_null(char* array, cmo_null* m)
   {
       return array;
   }
   
 static char* dump_cmo_int32(char* array, cmo_int32* m)  static char* dump_cmo_int32(char* array, cmo_int32* m)
 {  {
     return dump_integer(array, m->i);      return dump_integer(array, m->i);
 }  }
   
   static char* dump_cmo_string(char* array, cmo_string* m)
   {
       int len = strlen(m->s);
       array = dump_integer(array, len);
       memcpy(array, m->s, len);
       return array + len;
   }
   
   static char* dump_cmo_mathcap(char* array, cmo_mathcap* c)
   {
       return dump_cmo(array, c->ob);
   }
   
 static char* dump_cmo_list(char* array, cmo_list* m)  static char* dump_cmo_list(char* array, cmo_list* m)
 {  {
     cell* cp = m->head;      cell* cp = m->head;
Line 618  static char* dump_cmo_list(char* array, cmo_list* m)
Line 727  static char* dump_cmo_list(char* array, cmo_list* m)
     return array;      return array;
 }  }
   
 static char* dump_cmo_mathcap(char* array, cmo_mathcap* c)  static char* dump_cmo_monomial32(char* array, cmo_monomial32* c)
 {  {
     return dump_cmo(array, (cmo *)c->li);          int i;
           int length = c->length;
           array = dump_integer(array, c->length);
           for(i=0; i<length; i++) {
                   array = dump_integer(array, c->exps[i]);
           }
           array = dump_cmo(array, c->coef);
           return array;
 }  }
   
 static char* dump_cmo_null(char* array, cmo_null* m)  
 {  
     return array;  
 }  
   
 static char* dump_cmo_string(char* array, cmo_string* m)  
 {  
     int len = strlen(m->s);  
     array = dump_integer(array, len);  
     memcpy(array, m->s, len);  
     return array + len;  
 }  
   
 static char* dump_cmo_zz(char* array, cmo_zz* c)  static char* dump_cmo_zz(char* array, cmo_zz* c)
 {  {
     return dump_mpz(array, c->mpz);      return dump_mpz(array, c->mpz);
Line 647  char* dump_cmo(char* array, cmo* m)
Line 750  char* dump_cmo(char* array, cmo* m)
     array = dump_integer(array, m->tag);      array = dump_integer(array, m->tag);
     switch(m->tag) {      switch(m->tag) {
     case CMO_NULL:      case CMO_NULL:
       case CMO_ZERO:
       case CMO_DMS_GENERIC:
         return dump_cmo_null(array, m);          return dump_cmo_null(array, m);
     case CMO_INT32:      case CMO_INT32:
         return dump_cmo_int32(array, (cmo_int32 *)m);          return dump_cmo_int32(array, (cmo_int32 *)m);
     case CMO_STRING:      case CMO_STRING:
         return dump_cmo_string(array, (cmo_string *)m);          return dump_cmo_string(array, (cmo_string *)m);
       case CMO_MATHCAP:
       case CMO_RING_BY_NAME:
       case CMO_ERROR2:
           return dump_cmo_mathcap(array, (cmo_mathcap *)m);
     case CMO_LIST:      case CMO_LIST:
         return dump_cmo_list(array, (cmo_list *)m);          return dump_cmo_list(array, (cmo_list *)m);
       case CMO_MONOMIAL32:
           return dump_cmo_monomial32(array, (cmo_monomial32 *)m);
     case CMO_ZZ:      case CMO_ZZ:
         return dump_cmo_zz(array, (cmo_zz *)m);          return dump_cmo_zz(array, (cmo_zz *)m);
     case CMO_MATHCAP:  
         return dump_cmo_mathcap(array, (cmo_mathcap *)m);  
     default:      default:
         return NULL;          return NULL;
     }      }
Line 708  int send_ox_cmo(int fd, cmo* m)
Line 817  int send_ox_cmo(int fd, cmo* m)
     send_cmo(fd, m);      send_cmo(fd, m);
 }  }
   
 int append_cell(cell* this, cell* cp);  /* send_cmo_xxx 関数群 */
   static int send_cmo_null(int fd, cmo_null* c)
 cell* next_cell(cell* this)  
 {  {
     return this->next;  
 }  
   
 static int send_cmo_error(int fd, cmo_error* c)  
 {  
     send_cmo(fd, (cmo *)c->li);  
     return 0;      return 0;
 }  }
   
Line 726  static int send_cmo_int32(int fd, cmo_int32* m)
Line 828  static int send_cmo_int32(int fd, cmo_int32* m)
     send_int32(fd, m->i);      send_int32(fd, m->i);
 }  }
   
 static int send_cmo_list(int fd, cmo_list* c)  static int send_cmo_string(int fd, cmo_string* m)
 {  {
     cell* cp = c->head;      int len = strlen(m->s);
     int len = length_cmo_list(c);  
     send_int32(fd, len);      send_int32(fd, len);
       if (len > 0) {
     while(cp != NULL) {          write(fd, m->s, len);
         send_cmo(fd, cp->cmo);  
         cp = cp->next;  
     }      }
     return 0;      return 0;
 }  }
   
 static int send_cmo_mathcap(int fd, cmo_mathcap* c)  static int send_cmo_mathcap(int fd, cmo_mathcap* c)
 {  {
     send_cmo(fd, (cmo *)c->li);      send_cmo(fd, c->ob);
     return 0;      return 0;
 }  }
   
 static int send_cmo_null(int fd, cmo_null* c)  static int send_cmo_list(int fd, cmo_list* c)
 {  {
     return 0;      cell* cp = c->head;
 }      int len = length_cmo_list(c);
   
 static int send_cmo_string(int fd, cmo_string* m)  
 {  
     int len = strlen(m->s);  
     send_int32(fd, len);      send_int32(fd, len);
     if (len > 0) {  
         write(fd, m->s, len);      while(cp != NULL) {
           send_cmo(fd, cp->cmo);
           cp = cp->next;
     }      }
     return 0;      return 0;
 }  }
Line 765  static int send_cmo_zz(int fd, cmo_zz* c)
Line 862  static int send_cmo_zz(int fd, cmo_zz* c)
     send_mpz(fd, c->mpz);      send_mpz(fd, c->mpz);
 }  }
   
   static int send_cmo_error2(int fd, cmo_error2* c)
   {
       send_cmo(fd, c->ob);
       return 0;
   }
   
 /* CMOを送る.  OX_tag は送信済*/  /* CMOを送る.  OX_tag は送信済*/
 int send_cmo(int fd, cmo* c)  int send_cmo(int fd, cmo* c)
 {  {
Line 791  int send_cmo(int fd, cmo* c)
Line 894  int send_cmo(int fd, cmo* c)
         send_cmo_zz(fd, (cmo_zz *)c);          send_cmo_zz(fd, (cmo_zz *)c);
         break;          break;
     case CMO_ERROR2:      case CMO_ERROR2:
         send_cmo_error(fd, (cmo_error *)c);          send_cmo_error2(fd, (cmo_error2 *)c);
         break;          break;
     default:      default:
     }      }
 }  }
   
 /* CMO_ZZ の例外の実装が不十分?? */  
 static int send_mpz(int fd, mpz_ptr mpz)  static int send_mpz(int fd, mpz_ptr mpz)
 {  {
     int i;      int i;
Line 851  static int known_types[] = {
Line 953  static int known_types[] = {
     CMO_ERROR2,      CMO_ERROR2,
 };  };
   
 #define VER_STR   "(CMO_LIST, 2, (CMO_LIST, (CMO_INT32, %d), (CMO_STRING, \"%s\")), (CMO_LIST, 7, (CMO_INT32, 1), (CMO_INT32, 2), (CMO_INT32, 4), (CMO_INT32, 5), (CMO_INT32, 17), (CMO_INT32, 20), (CMO_INT32, 2130706434)))\n"  #define ID_TEMP   "(CMO_MATHCAP, (CMO_LIST, (CMO_LIST, (CMO_INT32, %d), (CMO_STRING, \"%s\"), (CMO_STRING, \"%s\"), (CMO_STRING, \"%s\")), (CMO_LIST, (CMO_INT32, 1), (CMO_INT32, 2), (CMO_INT32, 4), (CMO_INT32, 5), (CMO_INT32, 17), (CMO_INT32, 20), (CMO_INT32, 2130706434))))\n"
   
 cmo* make_mathcap_object2(int version, char* id_string)  cmo* make_mathcap_object2(int ver, char* ver_s, char* sysname)
 {  {
     cmo_list *li;      cmo *cap;
     char buff[4096];      char buff[8192];
   
     setgetc(mygetc);      setgetc(mygetc);
     sprintf(buff, VER_STR, version, id_string);      sprintf(buff, ID_TEMP, ver, sysname, ver_s, getenv("HOSTTYPE"));
     setmode_mygetc(buff, 4096);      setmode_mygetc(buff, 8192);
     li = parse();      cap = parse();
     resetgetc();      resetgetc();
   
     return (cmo *)new_cmo_mathcap(li);      return cap;
 }  }
   
 cmo* make_mathcap_object(int version, char* id_string)  cmo* make_mathcap_object(int version, char* id_string)
Line 887  cmo* make_mathcap_object(int version, char* id_string)
Line 989  cmo* make_mathcap_object(int version, char* id_string)
     append_cmo_list(li, (cmo *)li_ver);      append_cmo_list(li, (cmo *)li_ver);
     append_cmo_list(li, (cmo *)li_cmo);      append_cmo_list(li, (cmo *)li_cmo);
   
     return (cmo *)new_cmo_mathcap(li);      return (cmo *)new_cmo_mathcap((cmo *)li);
 }  }
   
 static int funcs(int cmo_type)  static int funcs(int cmo_type)
Line 915  cmo* (*received_funcs[])(int fd) = {
Line 1017  cmo* (*received_funcs[])(int fd) = {
     receive_cmo_mathcap,      receive_cmo_mathcap,
     receive_cmo_list,      receive_cmo_list,
     receive_cmo_zz,      receive_cmo_zz,
     receive_cmo_error      receive_cmo_error2
 };  };
   
 cmo* receive_cmo2(int fd)  cmo* receive_cmo2(int fd)
Line 957  cmo_zz *new_cmo_zz_set_string(char *s)
Line 1059  cmo_zz *new_cmo_zz_set_string(char *s)
     return c;      return c;
 }  }
   
 char *CONVERT_ZZ_TO_CSTRING(cmo_zz *c)  char *convert_zz_to_cstring(cmo_zz *c)
 {  {
     return mpz_get_str(NULL, 10, c->mpz);      return mpz_get_str(NULL, 10, c->mpz);
 }  }
   
 char *CONVERT_CMO_TO_CSTRING(cmo *m)  char *convert_cmo_to_cstring(cmo *m)
 {  {
     switch(m->tag) {      switch(m->tag) {
     case CMO_ZZ:      case CMO_ZZ:
         return CONVERT_ZZ_TO_CSTRING((cmo_zz *)m);          return convert_zz_to_cstring((cmo_zz *)m);
     case CMO_INT32:      case CMO_INT32:
         return CONVERT_INT_TO_CSTRING(((cmo_int32 *)m)->i);          return convert_int_to_cstring(((cmo_int32 *)m)->i);
     case CMO_STRING:      case CMO_STRING:
         return ((cmo_string *)m)->s;          return ((cmo_string *)m)->s;
     case CMO_NULL:      case CMO_NULL:
         return CONVERT_NULL_TO_CSTRING();          return convert_null_to_cstring();
     default:      default:
         fprintf(stderr, "sorry, not implemented CMO\n");          fprintf(stderr, "sorry, not implemented CMO\n");
         /* まだ実装していません. */          /* まだ実装していません. */
Line 980  char *CONVERT_CMO_TO_CSTRING(cmo *m)
Line 1082  char *CONVERT_CMO_TO_CSTRING(cmo *m)
     }      }
 }  }
   
 char *CONVERT_NULL_TO_CSTRING()  char *convert_null_to_cstring()
 {  {
     static char* null_string = "";      static char* null_string = "";
     return null_string;      return null_string;
 }  }
   
 char *CONVERT_INT_TO_CSTRING(int integer)  char *convert_int_to_cstring(int integer)
 {  {
     char buff[1024];      char buff[1024];
     char *s;      char *s;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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