version 1.3, 1999/11/18 23:57:19 |
version 1.8, 2001/05/04 01:06:29 |
|
|
/*$OpenXM$*/ |
/*$OpenXM: OpenXM/src/kan96xx/plugin/cmo.c,v 1.7 2001/04/15 07:55:07 takayama Exp $*/ |
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
/* #include <netinet/in.h> */ |
/* #include <netinet/in.h> */ |
|
|
#include "cmo.h" |
#include "cmo.h" |
|
|
#include "cmotag.htmp" /* static char *cmotagToName(int tag) is defined |
#include "cmotag.htmp" /* static char *cmotagToName(int tag) is defined |
here. */ |
here. */ |
|
|
extern int OxVersion; |
extern int OxVersion; |
|
|
int CmoClientMode = 1; /* This flag is used to translate names for |
int CmoClientMode = 1; /* This flag is used to translate names for |
indeterminates. |
indeterminates. |
It does not work well if ox_sm1 have a server, i.e., |
It does not work well if ox_sm1 have a server, i.e., |
sm1 --> ox_sm1 --> ox_sm1 |
sm1 --> ox_sm1 --> ox_sm1 |
*/ |
*/ |
|
|
/* void *malloc(int s); |
/* void *malloc(int s); |
#define GC_malloc(x) malloc(x) */ |
#define GC_malloc(x) malloc(x) */ |
Line 37 int CmoClientMode = 1; /* This flag is used to transl |
|
Line 37 int CmoClientMode = 1; /* This flag is used to transl |
|
**************************************************************************/ |
**************************************************************************/ |
/* If you change the format of mathcap, do the follows. |
/* If you change the format of mathcap, do the follows. |
Mofify cmoCheckMathCap in oxmisc2.c, |
Mofify cmoCheckMathCap in oxmisc2.c, |
oxReq, SM_setMathCap:, and |
oxSendMathCap in oxmisc.c, |
|
newMathCap in cmo.c, |
|
oxReq, SM_setMathCap: in oxmisc2.c, and |
grep mathCap and make all modifications. |
grep mathCap and make all modifications. |
*/ |
*/ |
|
|
Line 87 struct cmoBuffer *cmoOutputToBuf(cmoAction a,void *dat |
|
Line 89 struct cmoBuffer *cmoOutputToBuf(cmoAction a,void *dat |
|
break; |
break; |
case CMOPUT: |
case CMOPUT: |
for (i=0; i<size; i++) { |
for (i=0; i<size; i++) { |
fp2fputc((int) ((char *)data)[i], b.fp); |
fp2fputc((int) ((char *)data)[i], b.fp); |
} |
} |
break; |
break; |
case CMOFLUSH: |
case CMOFLUSH: |
if (fp2fflush(b.fp)<0) { |
if (fp2fflush(b.fp)<0) { |
errorCmo("cmoOutputToBuf: CMOFLUSH failed in stream mode."); |
errorCmo("cmoOutputToBuf: CMOFLUSH failed in stream mode."); |
} |
} |
cb = (struct cmoBuffer *)sGC_malloc(sizeof(struct cmoBuffer)); |
cb = (struct cmoBuffer *)sGC_malloc(sizeof(struct cmoBuffer)); |
cb->isStream = b.isStream; |
cb->isStream = b.isStream; |
Line 126 struct cmoBuffer *cmoOutputToBuf(cmoAction a,void *dat |
|
Line 128 struct cmoBuffer *cmoOutputToBuf(cmoAction a,void *dat |
|
break; |
break; |
case CMOPUT: |
case CMOPUT: |
if (b.pos + size >= b.size) { |
if (b.pos + size >= b.size) { |
tmp = sGC_malloc((b.size)*2+size); |
tmp = sGC_malloc((b.size)*2+size); |
memcpy(tmp,b.buf,b.pos); |
memcpy(tmp,b.buf,b.pos); |
b.buf = tmp; |
b.buf = tmp; |
b.size = (b.size)*2+size; |
b.size = (b.size)*2+size; |
} |
} |
memcpy((void *) &(((char *)(b.buf))[b.pos]),data,size); |
memcpy((void *) &(((char *)(b.buf))[b.pos]),data,size); |
b.pos += size; |
b.pos += size; |
Line 375 int cmoOutRingDefinition(struct ring *rp,int option) |
|
Line 377 int cmoOutRingDefinition(struct ring *rp,int option) |
|
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)*3); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)*3); |
cmoOutInt32((rp->n)*2); /* number of variables */ |
cmoOutInt32((rp->n)*2); /* number of variables */ |
cmoOutInt32(rp->p); /* coefficient field. |
cmoOutInt32(rp->p); /* coefficient field. |
CMO_INT32 or CMO_DMS_OF_N_VARIABLES */ |
CMO_INT32 or CMO_DMS_OF_N_VARIABLES */ |
/* Optional arguments are name of variables, weight_vector, output_order */ |
/* Optional arguments are name of variables, weight_vector, output_order */ |
break; |
break; |
default: /* including 0. */ |
default: /* including 0. */ |
Line 401 int cmoOutRingDefinition2(struct ring *rp,int option) |
|
Line 403 int cmoOutRingDefinition2(struct ring *rp,int option) |
|
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)*3); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)*3); |
cmoOutInt32((rp->n)*2); /* number of variables */ |
cmoOutInt32((rp->n)*2); /* number of variables */ |
cmoOutInt32(rp->p); /* coefficient field. |
cmoOutInt32(rp->p); /* coefficient field. |
CMO_INT32 or CMO_DMS_OF_N_VARIABLES */ |
CMO_INT32 or CMO_DMS_OF_N_VARIABLES */ |
/* Optional arguments are list of indeterminates (name of variables), |
/* Optional arguments are list of indeterminates (name of variables), |
weight_vector by list , output_order by list. */ |
weight_vector by list , output_order by list. */ |
break; |
break; |
Line 423 int cmoGetIntFromBuf(cmoAction a,struct cmoBuffer *cb) |
|
Line 425 int cmoGetIntFromBuf(cmoAction a,struct cmoBuffer *cb) |
|
switch(a) { |
switch(a) { |
case CMOGET: |
case CMOGET: |
for (i=0; i<4; i++) { |
for (i=0; i<4; i++) { |
cc = fp2fgetc(cb->fp); |
cc = fp2fgetc(cb->fp); |
if (cc < 0) { |
if (cc < 0) { |
return(-1); |
return(-1); |
errorCmo("cmoGetIntFromBuf CMOGET: unexpected EOF.\n"); |
errorCmo("cmoGetIntFromBuf CMOGET: unexpected EOF.\n"); |
} |
} |
data[i] = cc; |
data[i] = cc; |
} |
} |
return( (int) ntohl( *((cmoint *) data) )); |
return( (int) ntohl( *((cmoint *) data) )); |
break; |
break; |
case CMOGETBYTE: |
case CMOGETBYTE: |
cc = fp2fgetc(cb->fp); |
cc = fp2fgetc(cb->fp); |
if (cc < 0) { |
if (cc < 0) { |
return(-1); |
return(-1); |
errorCmo("cmoGetIntFromBuf CMOGETBYTE: unexpected EOF.\n"); |
errorCmo("cmoGetIntFromBuf CMOGETBYTE: unexpected EOF.\n"); |
} |
} |
return(cc); |
return(cc); |
break; |
break; |
Line 460 int cmoGetIntFromBuf(cmoAction a,struct cmoBuffer *cb) |
|
Line 462 int cmoGetIntFromBuf(cmoAction a,struct cmoBuffer *cb) |
|
switch(a) { |
switch(a) { |
case CMOGET: |
case CMOGET: |
if (cb->rpos + sizeof(cmoint) > cb->pos) { |
if (cb->rpos + sizeof(cmoint) > cb->pos) { |
fprintf(stderr,"No more data in the buffer. Returns -1.\n"); |
fprintf(stderr,"No more data in the buffer. Returns -1.\n"); |
return(-1); |
return(-1); |
} |
} |
memcpy(tmp,(void *) &(((char *)(cb->buf))[cb->rpos]), |
memcpy(tmp,(void *) &(((char *)(cb->buf))[cb->rpos]), |
sizeof(cmoint)); |
sizeof(cmoint)); |
cb->rpos += sizeof(cmoint); |
cb->rpos += sizeof(cmoint); |
return( (int) ntohl(tmp[0])); |
return( (int) ntohl(tmp[0])); |
break; |
break; |
case CMOGETBYTE: |
case CMOGETBYTE: |
if (cb->rpos + 1 > cb->pos) { |
if (cb->rpos + 1 > cb->pos) { |
fprintf(stderr,"No more data in the buffer. Returns -1.\n"); |
fprintf(stderr,"No more data in the buffer. Returns -1.\n"); |
return(-1); |
return(-1); |
} |
} |
tmp[0] = ((unsigned char *)(cb->buf))[cb->rpos]; |
tmp[0] = ((unsigned char *)(cb->buf))[cb->rpos]; |
cb->rpos += 1; |
cb->rpos += 1; |
Line 542 POLY cmoGetMonomial32(struct cmoBuffer *cb) |
|
Line 544 POLY cmoGetMonomial32(struct cmoBuffer *cb) |
|
warningCmo("cmoGetMonomials32(): Changed the current ring, because your peer sent a DMS that does not fit to the current ring."); |
warningCmo("cmoGetMonomials32(): Changed the current ring, because your peer sent a DMS that does not fit to the current ring."); |
|
|
/* original code. |
/* original code. |
skip = nn - (CurrentRingp->n)*2; |
skip = nn - (CurrentRingp->n)*2; |
nn1 = nn0 = CurrentRingp->n; |
nn1 = nn0 = CurrentRingp->n; |
if (! (cb->errorno) ) { |
if (! (cb->errorno) ) { |
warningCmo("cmoGetMonomial32(): serialized polynomial \\not\\in CurrentRing."); |
warningCmo("cmoGetMonomial32(): serialized polynomial \\not\\in CurrentRing."); |
} |
} |
cmoGetIntFromBuf(CMOERROR,cb); |
cmoGetIntFromBuf(CMOERROR,cb); |
*/ |
*/ |
} |
} |
if (nn == (CurrentRingp->n)*2 ) { |
if (nn == (CurrentRingp->n)*2 ) { |
Line 669 void cmoObjectToCmo00(struct object ob) |
|
Line 671 void cmoObjectToCmo00(struct object ob) |
|
case CLASSNAME_ERROR_PACKET: |
case CLASSNAME_ERROR_PACKET: |
/* fprintf(stderr,"ectag=%d\n",ectag(*KopErrorPacket(ob))); **kxx:CMO_ERROR*/ |
/* fprintf(stderr,"ectag=%d\n",ectag(*KopErrorPacket(ob))); **kxx:CMO_ERROR*/ |
if (ectag(*KopErrorPacket(ob)) == CLASSNAME_ERROR_PACKET) { |
if (ectag(*KopErrorPacket(ob)) == CLASSNAME_ERROR_PACKET) { |
tmp[0] = htonl(CMO_ERROR); |
tmp[0] = htonl(CMO_ERROR); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
}else{ |
}else{ |
tmp[0] = htonl(CMO_ERROR2); |
tmp[0] = htonl(CMO_ERROR2); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
/* Send without OX_DATA header !! */ |
/* Send without OX_DATA header !! */ |
cmoObjectToCmo00(*(KopErrorPacket(ob))); |
cmoObjectToCmo00(*(KopErrorPacket(ob))); |
} |
} |
break; |
break; |
case CLASSNAME_mathcap: |
case CLASSNAME_mathcap: |
Line 690 void cmoObjectToCmo00(struct object ob) |
|
Line 692 void cmoObjectToCmo00(struct object ob) |
|
/* cmoObjectToCmo00(KopIndeterminate(ob)); Old code. */ |
/* cmoObjectToCmo00(KopIndeterminate(ob)); Old code. */ |
/* If you need to translate the name, do it here. */ |
/* If you need to translate the name, do it here. */ |
if (CmoClientMode) { |
if (CmoClientMode) { |
ob = KopIndeterminate(ob); |
ob = KopIndeterminate(ob); |
}else{ |
}else{ |
ob = cmoTranslateVariable_outGoing(KopIndeterminate(ob)); |
ob = cmoTranslateVariable_outGoing(KopIndeterminate(ob)); |
} |
} |
cmoObjectToCmo00(ob); |
cmoObjectToCmo00(ob); |
break; |
break; |
case CLASSNAME_recursivePolynomial: |
case CLASSNAME_recursivePolynomial: |
/* We assume that the format of the recursive polynomial |
/* We assume that the format of the recursive polynomial |
is OK. */ |
is OK. */ |
tmp[0] = htonl(CMO_RECURSIVE_POLYNOMIAL); |
tmp[0] = htonl(CMO_RECURSIVE_POLYNOMIAL); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
ob = KopRecursivePolynomial(ob); |
ob = KopRecursivePolynomial(ob); |
vlist = getoa(ob,0); |
vlist = getoa(ob,0); |
vlist0 = newObjectArray(getoaSize(vlist)); |
vlist0 = newObjectArray(getoaSize(vlist)); |
for (i=0; i<getoaSize(vlist); i++) { |
for (i=0; i<getoaSize(vlist); i++) { |
if (CmoClientMode) { |
if (getoa(vlist,i).tag == Sdollar) { |
putoa(vlist0,i, |
if (CmoClientMode) { |
KpoIndeterminate(getoa(vlist,i))); |
putoa(vlist0,i, |
}else{ |
KpoIndeterminate(getoa(vlist,i))); |
putoa(vlist0,i, |
}else{ |
KpoIndeterminate(cmoTranslateVariable_outGoing(getoa(vlist,i)))); |
putoa(vlist0,i, |
} |
KpoIndeterminate(cmoTranslateVariable_outGoing(getoa(vlist,i)))); |
|
} |
|
}else{ |
|
putoa(vlist0,i,getoa(vlist,i)); |
|
} |
} |
} |
cmoObjectToCmo00(vlist0); /* output the list of variables. */ |
cmoObjectToCmo00(vlist0); /* output the list of variables. */ |
cmoObjectToCmo00(getoa(ob,1)); /* output the body of the recursive poly |
cmoObjectToCmo00(getoa(ob,1)); /* output the body of the recursive poly |
polynomial in one variable or any object*/ |
polynomial in one variable or any object*/ |
break; |
break; |
case CLASSNAME_polynomialInOneVariable: |
case CLASSNAME_polynomialInOneVariable: |
tmp[0] = htonl(CMO_POLYNOMIAL_IN_ONE_VARIABLE); |
tmp[0] = htonl(CMO_POLYNOMIAL_IN_ONE_VARIABLE); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
ob = KopPolynomialInOneVariable(ob); |
ob = KopPolynomialInOneVariable(ob); |
if (ob.tag != Sarray) { |
if (ob.tag != Sarray) { |
cmoObjectToCmo00(ob); |
cmoObjectToCmo00(ob); |
}else{ |
}else{ |
/* We do not check the format. */ |
/* We do not check the format. */ |
m = (getoaSize(ob)-1)/2; /* the number of monomials */ |
m = (getoaSize(ob)-1)/2; /* the number of monomials */ |
cmoOutRawInt(m); |
cmoOutRawInt(m); |
ob2 = getoa(ob,0); /* the variable name by integer. */ |
ob2 = getoa(ob,0); /* the variable name by integer. */ |
if (ob2.tag != Sinteger) { |
if (ob2.tag != Sinteger) { |
warningCmo("cmoObjectToCmo00(): polynomial in one variable: this field should be integer. Output 0"); |
warningCmo("cmoObjectToCmo00(): polynomial in one variable: this field should be integer. Output 0"); |
/* cmoOutInt32(0); */ |
/* cmoOutInt32(0); */ |
cmoOutRawInt(0); |
cmoOutRawInt(0); |
}else{ |
}else{ |
/* cmoObjectToCmo00(ob2); */ |
/* cmoObjectToCmo00(ob2); */ |
cmoOutRawInt(KopInteger(ob2)); |
cmoOutRawInt(KopInteger(ob2)); |
} |
} |
for (i=1; i<getoaSize(ob); i = i+2) { |
for (i=1; i<getoaSize(ob); i = i+2) { |
cmoOutRawInt(KopInteger(getoa(ob,i))); /* exponent */ |
cmoOutRawInt(KopInteger(getoa(ob,i))); /* exponent */ |
cmoObjectToCmo00(getoa(ob,i+1)); /* coefficient */ |
cmoObjectToCmo00(getoa(ob,i+1)); /* coefficient */ |
} |
} |
} |
} |
break; |
break; |
case CLASSNAME_tree: |
case CLASSNAME_tree: |
Line 855 struct object cmoCmoToObject00(struct cmoBuffer *cb) |
|
Line 861 struct object cmoCmoToObject00(struct cmoBuffer *cb) |
|
putoa(rob,i,cmoCmoToObject00(cb)); |
putoa(rob,i,cmoCmoToObject00(cb)); |
/* printObject(getoa(rob,i),0,stdout); */ |
/* printObject(getoa(rob,i),0,stdout); */ |
if (i==0) { |
if (i==0) { |
ob1 = getoa(rob,0); |
ob1 = getoa(rob,0); |
if (ob1.tag == CMO+CMO_DMS) { |
if (ob1.tag == CMO+CMO_DMS) { |
goto dmscase ; |
goto dmscase ; |
} |
} |
} |
} |
} |
} |
break; |
break; |
Line 877 struct object cmoCmoToObject00(struct cmoBuffer *cb) |
|
Line 883 struct object cmoCmoToObject00(struct cmoBuffer *cb) |
|
/* Change the CurrentRingp by looking up the name. */ |
/* Change the CurrentRingp by looking up the name. */ |
ob1 = KfindUserDictionary(KopString(ob1)); |
ob1 = KfindUserDictionary(KopString(ob1)); |
if (ob1.tag != Sring) { |
if (ob1.tag != Sring) { |
errorCmo("cmoCmoToObject00(): your ring is not defined in the name space."); |
errorCmo("cmoCmoToObject00(): your ring is not defined in the name space."); |
} |
} |
CurrentRingp = KopRingp(ob1); |
CurrentRingp = KopRingp(ob1); |
} |
} |
Line 954 struct object cmoCmoToObject00(struct cmoBuffer *cb) |
|
Line 960 struct object cmoCmoToObject00(struct cmoBuffer *cb) |
|
for (i=0; i<getoaSize(vlist0); i++) { |
for (i=0; i<getoaSize(vlist0); i++) { |
ob1 = getoa(vlist0,i); |
ob1 = getoa(vlist0,i); |
if (ectag(ob1) == CLASSNAME_indeterminate) { |
if (ectag(ob1) == CLASSNAME_indeterminate) { |
ob1 = KopIndeterminate(ob1); |
ob1 = KopIndeterminate(ob1); |
|
}else if (ectag(ob1) == CLASSNAME_tree) { |
|
/* do nothing. */ |
} |
} |
putoa(vlist,i,ob1); |
putoa(vlist,i,ob1); |
} |
} |
Line 1083 struct object cmoListToPoly(struct object ob) { |
|
Line 1091 struct object cmoListToPoly(struct object ob) { |
|
if (n >= 1) { |
if (n >= 1) { |
ob0 = getoa(ob,0); |
ob0 = getoa(ob,0); |
if (ob0.tag == CMO+CMO_DMS) { |
if (ob0.tag == CMO+CMO_DMS) { |
rob = KpoPOLY(cmoListToPOLY(ob)); /* not ToPoly, ToPOLY */ |
rob = KpoPOLY(cmoListToPOLY(ob)); /* not ToPoly, ToPOLY */ |
}else{ |
}else{ |
rob = newObjectArray(n); |
rob = newObjectArray(n); |
for (i=0; i<n; i++) { |
for (i=0; i<n; i++) { |
putoa(rob,i,cmoListToPoly(getoa(ob,i))); |
putoa(rob,i,cmoListToPoly(getoa(ob,i))); |
} |
} |
} |
} |
}else{ |
}else{ |
rob = ob; |
rob = ob; |
Line 1105 struct object cmoListToPoly2(struct object ob) |
|
Line 1113 struct object cmoListToPoly2(struct object ob) |
|
struct object ob0,ob1; |
struct object ob0,ob1; |
POLY f; |
POLY f; |
/* |
/* |
printf("<<");printObject(ob,0,stdout); printf(">>\n"); fflush(stdout); |
printf("<<");printObject(ob,0,stdout); printf(">>\n"); fflush(stdout); |
*/ |
*/ |
if (ob.tag != Sarray) { |
if (ob.tag != Sarray) { |
errorCmo("cmoListToPoly2(): the argument must be array."); |
errorCmo("cmoListToPoly2(): the argument must be array."); |
} |
} |
Line 1146 POLY cmoListToPOLY(struct object ob) |
|
Line 1154 POLY cmoListToPOLY(struct object ob) |
|
struct object ob0,ob1; |
struct object ob0,ob1; |
POLY f; |
POLY f; |
/* |
/* |
printf("<<");printObject(ob,0,stdout); printf(">>\n"); fflush(stdout); |
printf("<<");printObject(ob,0,stdout); printf(">>\n"); fflush(stdout); |
*/ |
*/ |
if (ob.tag != Sarray) { |
if (ob.tag != Sarray) { |
errorCmo("cmoListToPOLY(): the argument must be array."); |
errorCmo("cmoListToPOLY(): the argument must be array."); |
} |
} |
Line 1165 POLY cmoListToPOLY(struct object ob) |
|
Line 1173 POLY cmoListToPOLY(struct object ob) |
|
for (i=size-1; i>=2; i--) { |
for (i=size-1; i>=2; i--) { |
ob1 = getoa(ob,i); |
ob1 = getoa(ob,i); |
if (ob1.tag == Spoly) { |
if (ob1.tag == Spoly) { |
f = ppAdd(f,KopPOLY(ob1)); |
f = ppAdd(f,KopPOLY(ob1)); |
}else{ |
}else{ |
f = ppAdd(f,cmoListToPOLY(ob1)); |
f = ppAdd(f,cmoListToPOLY(ob1)); |
} |
} |
} |
} |
return(f); |
return(f); |
Line 1318 struct object newMathCap(struct mathCap *mathcap){ |
|
Line 1326 struct object newMathCap(struct mathCap *mathcap){ |
|
struct object ob3; |
struct object ob3; |
struct object obOx; |
struct object obOx; |
struct object obSm; |
struct object obSm; |
|
struct object ob3tmp; |
struct object *obp; |
struct object *obp; |
int i; |
int i,j; |
struct object mathinfo; |
struct object mathinfo; |
|
|
rob = newObjectArray(3); |
rob = newObjectArray(3); |
Line 1329 struct object newMathCap(struct mathCap *mathcap){ |
|
Line 1338 struct object newMathCap(struct mathCap *mathcap){ |
|
for (i=0; i<getoaSize(mathinfo); i++) { |
for (i=0; i<getoaSize(mathinfo); i++) { |
putoa(ob1,i,getoa(mathinfo,i)); |
putoa(ob1,i,getoa(mathinfo,i)); |
} |
} |
ob2 = newObjectArray(mathcap->n); |
ob3 = newObjectArray(mathcap->oxSize); |
for (i=0; i<mathcap->n; i++) { |
|
putoa(ob2,i,KpoInteger((mathcap->cmo)[i])); |
|
} |
|
obOx = newObjectArray(mathcap->oxSize); |
|
for (i=0; i<mathcap->oxSize; i++) { |
for (i=0; i<mathcap->oxSize; i++) { |
putoa(obOx,i,KpoInteger((mathcap->ox)[i])); |
ob3tmp = newObjectArray(2); |
|
putoa(ob3tmp,0,KpoInteger((mathcap->ox)[i])); |
|
ob2 = newObjectArray(mathcap->n); |
|
for (j=0; j<mathcap->n; j++) { |
|
putoa(ob2,j,KpoInteger((mathcap->cmo)[j])); |
|
} |
|
putoa(ob3tmp,1,ob2); |
|
putoa(ob3,i,ob3tmp); |
} |
} |
ob3 = newObjectArray(2); |
|
putoa(ob3,0,obOx); |
|
putoa(ob3,1,ob2); |
|
|
|
obSm = newObjectArray(mathcap->smSize); |
obSm = newObjectArray(mathcap->smSize); |
for (i=0; i<mathcap->smSize; i++) { |
for (i=0; i<mathcap->smSize; i++) { |
Line 1361 struct object KSmathCap(void) |
|
Line 1370 struct object KSmathCap(void) |
|
} |
} |
|
|
void *KSmathCapByStruct(void) |
void *KSmathCapByStruct(void) |
/* Return the math cap of kan/sm1 with cmo.c as a mathcap classObject*/ |
/* Return the math cap of kan/sm1 with cmo.c as a mathcap classObject*/ |
{ |
{ |
struct mathCap *mathcap; |
struct mathCap *mathcap; |
struct object ob; |
struct object ob; |
Line 1386 void *KSmathCapByStruct(void) |
|
Line 1395 void *KSmathCapByStruct(void) |
|
putoa(ob,1,KpoString(sys)); |
putoa(ob,1,KpoString(sys)); |
putoa(ob,2,KpoString(sysVersion)); |
putoa(ob,2,KpoString(sysVersion)); |
s1 = getenv("HOSTTYPE"); |
s1 = getenv("HOSTTYPE"); |
|
if (s1 == NULL) s1="unknown"; |
s2 = (char *)sGC_malloc(strlen(s1)+2+strlen("HOSTTYPE=")); |
s2 = (char *)sGC_malloc(strlen(s1)+2+strlen("HOSTTYPE=")); |
strcpy(s2,"HOSTTYPE="); |
strcpy(s2,"HOSTTYPE="); |
strcat(s2,s1); |
strcat(s2,s1); |
Line 1422 void *KSmathCapByStruct(void) |
|
Line 1432 void *KSmathCapByStruct(void) |
|
mathcap->cmo[21]= CMO_RATIONAL; |
mathcap->cmo[21]= CMO_RATIONAL; |
|
|
mathcap->n = 22 ; /* This is the number of cmo object. You can use |
mathcap->n = 22 ; /* This is the number of cmo object. You can use |
cmo upto 1023. see mathcap.h */ |
cmo upto 1023. see mathcap.h */ |
|
|
mathcap->ox[0] = OX_DATA; |
mathcap->ox[0] = OX_DATA; |
mathcap->oxSize = 1 ; /* This is the number of OX object. You can use |
mathcap->oxSize = 1 ; /* This is the number of OX object. You can use |
OX upto 1023. see mathcap.h */ |
OX upto 1023. see mathcap.h */ |
|
|
mathcap->sm[0] = SM_popCMO; |
mathcap->sm[0] = SM_popCMO; |
mathcap->sm[1] = SM_popString; |
mathcap->sm[1] = SM_popString; |
Line 1439 void *KSmathCapByStruct(void) |
|
Line 1449 void *KSmathCapByStruct(void) |
|
mathcap->sm[8] = SM_setMathCap; |
mathcap->sm[8] = SM_setMathCap; |
mathcap->sm[9] = SM_getsp; |
mathcap->sm[9] = SM_getsp; |
mathcap->sm[10] = SM_dupErrors; |
mathcap->sm[10] = SM_dupErrors; |
mathcap->smSize = 11; |
mathcap->sm[11] = SM_pushCMOtag; |
|
mathcap->smSize = 12; |
|
|
return((void *)mathcap); |
return((void *)mathcap); |
} |
} |
Line 1467 errorCmo(char *s) { |
|
Line 1478 errorCmo(char *s) { |
|
int outfp2(FILE2 *fp2) { |
int outfp2(FILE2 *fp2) { |
int i; |
int i; |
printf("--------- outfp2 ---------\n"); fflush(stdout); |
printf("--------- outfp2 ---------\n"); fflush(stdout); |
/* if (checkfp2(fp2," f2pdumpBuf ") == -1) { |
/* if (checkfp2(fp2," f2pdumpBuf ") == -1) { |
return(-1); |
return(-1); |
}*/ |
}*/ |
printf("fd=%d\n",fp2->fd); |
printf("fd=%d\n",fp2->fd); |
printf("initialied=%d\n",fp2->initialized); |
printf("initialied=%d\n",fp2->initialized); |
printf("readpos=%d\n",fp2->readpos); |
printf("readpos=%d\n",fp2->readpos); |
Line 1502 static char *translateReservedName(char *s) { |
|
Line 1513 static char *translateReservedName(char *s) { |
|
return(NULL); |
return(NULL); |
} |
} |
} |
} |
|
|
struct object cmoTranslateVariable_inComming(struct object ob) { |
struct object cmoTranslateVariable_inComming(struct object ob) { |
/* ob must be Sdollar, return value must be Sdollar. */ |
/* ob must be Sdollar, return value must be Sdollar. */ |
/* Read a variable name from an other system, |
/* Read a variable name from an other system, |
Line 1530 struct object cmoTranslateVariable_inComming(struct ob |
|
Line 1541 struct object cmoTranslateVariable_inComming(struct ob |
|
if (t == NULL) errorCmo("No more memory."); |
if (t == NULL) errorCmo("No more memory."); |
for (i=count=0; i<n; i++) { |
for (i=count=0; i<n; i++) { |
if (s[i] <= ' ' || s[i] == '#') { |
if (s[i] <= ' ' || s[i] == '#') { |
t[count++] = '#'; |
t[count++] = '#'; |
t[count++] = (s[i]/16 < 10? s[i]/16+'0': (s[i]/16-10)+'A'); |
t[count++] = (s[i]/16 < 10? s[i]/16+'0': (s[i]/16-10)+'A'); |
t[count++] = (s[i]%16 < 10? s[i]%16+'0': (s[i]%16-10)+'A'); |
t[count++] = (s[i]%16 < 10? s[i]%16+'0': (s[i]%16-10)+'A'); |
}else{ |
}else{ |
t[count++] = s[i]; |
t[count++] = s[i]; |
} |
} |
} |
} |
t[count] = '\0'; |
t[count] = '\0'; |