=================================================================== RCS file: /home/cvs/OpenXM/src/ox_toolkit/cmo.c,v retrieving revision 1.1 retrieving revision 1.7 diff -u -p -r1.1 -r1.7 --- OpenXM/src/ox_toolkit/cmo.c 2000/10/10 05:23:20 1.1 +++ OpenXM/src/ox_toolkit/cmo.c 2003/01/17 07:40:10 1.7 @@ -1,5 +1,5 @@ /* -*- mode: C; coding: euc-japan -*- */ -/* $OpenXM$ */ +/* $OpenXM: OpenXM/src/ox_toolkit/cmo.c,v 1.6 2003/01/17 06:49:53 ohara Exp $ */ /* This module includes functions for sending/receiveng CMO's. @@ -11,21 +11,15 @@ #include #include #include -#include -#include -#include -#include - -#include "mysocket.h" #include "ox_toolkit.h" #include "parse.h" static cell* new_cell(); - static char* new_string_set_cmo_null(); static char* new_string_set_cmo_int32(int integer); static char* new_string_set_cmo_list(cmo_list *c); static char* new_string_set_cmo_zz(cmo_zz *c); +static char* new_string_set_cmo_double(cmo_double *m); /* functions for a cmo_list */ static cell* new_cell(cmo *ob) @@ -80,6 +74,9 @@ cmo_list *list_appendl(cmo_list* this, ...) cmo *ob; va_list ap; va_start(ap, this); + if (this == NULL) { + this = new_cmo_list(); + } while((ob = va_arg(ap, cmo *)) != NULL) { list_append(this, ob); } @@ -227,6 +224,14 @@ cmo_zero* new_cmo_zero() return m; } +cmo_double *new_cmo_double(double d) +{ + cmo_double* m = malloc(sizeof(cmo_double)); + m->tag = CMO_64BIT_MACHINE_DOUBLE; + m->d = d; + return m; +} + cmo_dms_generic* new_cmo_dms_generic() { cmo_dms_generic* m = malloc(sizeof(cmo_dms_generic)); @@ -269,7 +274,8 @@ cmo_error2* new_cmo_error2(cmo* ob) return c; } -/* cmo と string (ここではC言語のstring) の変換関数群 */ + +/* Following functions translate cmo's to (asciiz) strings. */ static char *new_string_set_cmo_zz(cmo_zz *c) { return mpz_get_str(NULL, 10, c->mpz); @@ -319,6 +325,18 @@ static char *new_string_set_cmo_list(cmo_list *m) return s; } +static char *new_string_set_cmo_double(cmo_double *m) +{ + char buff[1024]; + char *s; + + sprintf(buff, "%lf", m->d); + s = malloc(strlen(buff)+1); + strcpy(s, buff); + + return s; +} + char *new_string_set_cmo(cmo *m) { symbol_t symp; @@ -333,13 +351,14 @@ char *new_string_set_cmo(cmo *m) return new_string_set_cmo_null(); case CMO_LIST: return new_string_set_cmo_list((cmo_list *)m); + case CMO_64BIT_MACHINE_DOUBLE: + return new_string_set_cmo_int32(m); default: #ifdef DEBUG symp = lookup_by_tag(m->tag); - fprintf(stderr, "I do not know how to convert %s to a string.\n", symp->key); + ox_printf("I do not know how to convert %s to a string.\n", symp->key); #endif /* yet not implemented. */ return NULL; } } -