version 1.14, 2015/08/04 05:24:44 |
version 1.17, 2016/08/23 02:24:19 |
|
|
/* -*- mode: C; coding: euc-japan -*- */ |
/* -*- mode: C; coding: euc-japan -*- */ |
/* $OpenXM: OpenXM/src/ox_toolkit/mathcap.c,v 1.13 2005/10/12 04:03:37 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/ox_toolkit/mathcap.c,v 1.16 2016/06/29 05:07:23 ohara Exp $ */ |
|
|
/* This module includes functions for handling mathcap databases. */ |
/* This module includes functions for handling mathcap databases. */ |
|
|
Line 40 static int cmotbl_a[] = { |
|
Line 40 static int cmotbl_a[] = { |
|
CMO_MONOMIAL32, |
CMO_MONOMIAL32, |
CMO_ZZ, |
CMO_ZZ, |
CMO_QQ, |
CMO_QQ, |
CMO_BIGFLOAT, |
CMO_BIGFLOAT32, |
|
CMO_COMPLEX, |
CMO_IEEE_DOUBLE_FLOAT, |
CMO_IEEE_DOUBLE_FLOAT, |
CMO_ZERO, |
CMO_ZERO, |
CMO_DMS_GENERIC, |
CMO_DMS_GENERIC, |
CMO_RING_BY_NAME, |
CMO_RING_BY_NAME, |
CMO_INDETERMINATE, |
CMO_INDETERMINATE, |
CMO_DISTRIBUTED_POLYNOMIAL, |
CMO_DISTRIBUTED_POLYNOMIAL, |
|
CMO_RECURSIVE_POLYNOMIAL, |
|
CMO_POLYNOMIAL_IN_ONE_VARIABLE, |
CMO_ERROR2, |
CMO_ERROR2, |
0, |
0, |
}; |
}; |
|
|
char *hosttype; |
char *hosttype; |
int *cmo_tags; |
int *cmo_tags; |
int *sm_cmds; |
int *sm_cmds; |
} sysinfo = {0, "NO VERSION", "NONAME", "UNKNOWN", cmotbl_a, smtbl_a}; |
char **opts; |
|
} sysinfo = {0, "NO VERSION", "NONAME", "UNKNOWN", cmotbl_a, smtbl_a, NULL}; |
|
|
__inline__ |
__inline__ |
static void table_init(table *m, int key) |
static void table_init(table *m, int key) |
Line 256 static int *new_int_array(int *array) |
|
Line 260 static int *new_int_array(int *array) |
|
|
|
void mathcap_init(int ver, char *vstr, char *sysname, int cmos[], int sms[]) |
void mathcap_init(int ver, char *vstr, char *sysname, int cmos[], int sms[]) |
{ |
{ |
|
mathcap_init2(ver, vstr, sysname, cmos, sms, NULL); |
|
} |
|
|
|
/* src must be terminated by NULL */ |
|
static char **clone_str_list(char **src) |
|
{ |
|
int i,len; |
|
char **new = NULL; |
|
if(!src) { |
|
for(len=0; src[len]!=NULL; len++) { |
|
} |
|
new = (char **)MALLOC(sizeof(char *)*(len+1)); |
|
new[len] = NULL; |
|
for(i=0; i<len; i++) { |
|
new[i] = (char *)MALLOC(strlen(src[i])+1); |
|
strcpy(new[i], src[i]); |
|
} |
|
} |
|
return new; |
|
} |
|
|
|
/* options must be terminated by NULL */ |
|
void mathcap_init2(int ver, char *vstr, char *sysname, int cmos[], int sms[], char *options[]) |
|
{ |
char *host = getenv("HOSTTYPE"); |
char *host = getenv("HOSTTYPE"); |
sysinfo.hosttype = (host != NULL)? new_string(host): "UNKNOWN"; |
sysinfo.hosttype = (host != NULL)? new_string(host): "UNKNOWN"; |
sysinfo.sysname = new_string(sysname); |
sysinfo.sysname = new_string(sysname); |
Line 267 void mathcap_init(int ver, char *vstr, char *sysname, |
|
Line 295 void mathcap_init(int ver, char *vstr, char *sysname, |
|
if (sms != NULL) { |
if (sms != NULL) { |
sysinfo.sm_cmds = new_int_array(sms); |
sysinfo.sm_cmds = new_int_array(sms); |
} |
} |
|
sysinfo.opts = clone_str_list(options); |
} |
} |
|
|
mathcap *new_mathcap() |
mathcap *new_mathcap() |
Line 274 mathcap *new_mathcap() |
|
Line 303 mathcap *new_mathcap() |
|
mathcap *new = MALLOC(sizeof(mathcap)); |
mathcap *new = MALLOC(sizeof(mathcap)); |
new->cmotbl = new_table(sysinfo.cmo_tags); |
new->cmotbl = new_table(sysinfo.cmo_tags); |
new->smtbl = new_table(sysinfo.sm_cmds); |
new->smtbl = new_table(sysinfo.sm_cmds); |
|
new->opts = clone_str_list(sysinfo.opts); |
return new; |
return new; |
} |
} |
|
|
Line 282 cmo_mathcap* mathcap_get(mathcap *this) |
|
Line 312 cmo_mathcap* mathcap_get(mathcap *this) |
|
{ |
{ |
cmo_list *mc = new_cmo_list(); |
cmo_list *mc = new_cmo_list(); |
cmo_list *l3 = new_cmo_list(); |
cmo_list *l3 = new_cmo_list(); |
|
cmo_list *si = sysinfo_get(); |
|
cmo_list *sm= table_get_all(this->smtbl); |
|
cmo_list *opts; |
|
int i; |
|
|
list_append(l3, (cmo *)list_appendl(new_cmo_list(), |
list_append(l3, (cmo *)list_appendl(new_cmo_list(), |
new_cmo_int32(OX_DATA), |
new_cmo_int32(OX_DATA), |
table_get_all(this->cmotbl), NULL)); |
table_get_all(this->cmotbl), NULL)); |
list_appendl(mc, (cmo *)sysinfo_get(), |
if(this->opts) { |
(cmo *)table_get_all(this->smtbl), (cmo *)l3, NULL); |
opts = new_cmo_list(); |
|
for(i=0; this->opts[i]!=NULL; i++) { |
|
list_append(opts, (cmo *)new_cmo_string(this->opts[i])); |
|
} |
|
list_appendl(mc, (cmo *)si, (cmo *)sm, (cmo *)l3, (cmo *)opts, NULL); |
|
}else { |
|
list_appendl(mc, (cmo *)si, (cmo *)sm, (cmo *)l3, NULL); |
|
} |
return new_cmo_mathcap((cmo *)mc); |
return new_cmo_mathcap((cmo *)mc); |
} |
} |
|
|