version 1.15, 2016/08/28 02:43:14 |
version 1.18, 2020/10/06 11:33:47 |
|
|
/*$OpenXM: OpenXM/src/kan96xx/plugin/cmo.c,v 1.14 2013/11/06 06:23:24 takayama Exp $*/ |
/*$OpenXM: OpenXM/src/kan96xx/plugin/cmo.c,v 1.17 2020/10/04 06:10:36 noro Exp $*/ |
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
/* #include <netinet/in.h> */ |
/* #include <netinet/in.h> */ |
#include <stdlib.h> |
#include <stdlib.h> |
|
#include <arpa/inet.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
#include "extern.h" |
#include "extern.h" |
|
|
#include "cmotag.htmp" /* static char *cmotagToName(int tag) is defined |
#include "cmotag.htmp" /* static char *cmotagToName(int tag) is defined |
here. */ |
here. */ |
|
|
|
void warningCmo(char *s); |
|
void errorCmo(char *s); |
|
size_t cmoOutGMPCoeff(mpz_srcptr x); // defined in cmo-gmp.c |
|
size_t cmoGetGMPCoeff(MP_INT *x, struct cmoBuffer *cb); |
|
int cmoCheckMathCap(struct object ob, struct object *mathcapObjp); // in oxmisc2.h |
|
|
|
|
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 |
Line 156 struct cmoBuffer *cmoOutputToBuf(cmoAction a,void *dat |
|
Line 164 struct cmoBuffer *cmoOutputToBuf(cmoAction a,void *dat |
|
} |
} |
} |
} |
|
|
dumpCmoBuf(struct cmoBuffer *cb) |
int dumpCmoBuf(struct cmoBuffer *cb) |
{ |
{ |
int i,size, tag; |
int i,size, tag; |
char *s; |
char *s; |
Line 167 dumpCmoBuf(struct cmoBuffer *cb) |
|
Line 175 dumpCmoBuf(struct cmoBuffer *cb) |
|
size = cb->pos; |
size = cb->pos; |
s = (char *)(cb->buf); |
s = (char *)(cb->buf); |
tag = htonl(*((int *) s)); |
tag = htonl(*((int *) s)); |
printf("CMO StandardEncoding: size = %d, size/sizeof(int) = %d, tag=%s \n",size,size/sizeof(int),cmotagToName(tag)); |
printf("CMO StandardEncoding: size = %d, size/sizeof(int) = %d, tag=%s \n",size,size/((int)sizeof(int)),cmotagToName(tag)); |
for (i=0; i<size; i++) { |
for (i=0; i<size; i++) { |
if (i % 20 == 0) putchar('\n'); |
if (i % 20 == 0) putchar('\n'); |
printf("%3x",(int)(unsigned char)s[i]); |
printf("%3x",(int)(unsigned char)s[i]); |
Line 179 dumpCmoBuf(struct cmoBuffer *cb) |
|
Line 187 dumpCmoBuf(struct cmoBuffer *cb) |
|
/* This obsolete function is used to write data |
/* This obsolete function is used to write data |
in cmoBuffer (cmo object in kan) |
in cmoBuffer (cmo object in kan) |
to a stream */ |
to a stream */ |
cmoToStream(struct object cmoObj,struct object of) |
int cmoToStream(struct object cmoObj,struct object of) |
{ |
{ |
int i,size; |
int i,size; |
struct cmoBuffer *cb; |
struct cmoBuffer *cb; |
Line 245 struct object streamToCmo(struct object of) |
|
Line 253 struct object streamToCmo(struct object of) |
|
} |
} |
|
|
|
|
cmoOutCmoNull() { |
void cmoOutCmoNull() { |
cmoint tmp[1]; |
cmoint tmp[1]; |
tmp[0] = htonl((cmoint) CMO_NULL); |
tmp[0] = htonl((cmoint) CMO_NULL); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
Line 255 cmoOutCmoNull() { |
|
Line 263 cmoOutCmoNull() { |
|
|
|
|
|
/* unsigned short int must be 32 bits */ |
/* unsigned short int must be 32 bits */ |
cmoOutInt32(int k) |
void cmoOutInt32(int k) |
{ |
{ |
cmoint tmp[2]; |
cmoint tmp[2]; |
tmp[0] = htonl((cmoint) CMO_INT32); |
tmp[0] = htonl((cmoint) CMO_INT32); |
Line 263 cmoOutInt32(int k) |
|
Line 271 cmoOutInt32(int k) |
|
cmoOutputToBuf(CMOPUT,tmp,2*sizeof(cmoint)); |
cmoOutputToBuf(CMOPUT,tmp,2*sizeof(cmoint)); |
} |
} |
|
|
cmoOutString(char *d,int size) { |
int cmoOutString(char *d,int size) { |
cmoint tmp[2]; |
cmoint tmp[2]; |
tmp[0] = htonl((cmoint) CMO_STRING); |
tmp[0] = htonl((cmoint) CMO_STRING); |
tmp[1] = htonl((cmoint ) size); |
tmp[1] = htonl((cmoint ) size); |
cmoOutputToBuf(CMOPUT,tmp,2*sizeof(cmoint)); |
cmoOutputToBuf(CMOPUT,tmp,2*sizeof(cmoint)); |
cmoOutputToBuf(CMOPUT,d,size); |
cmoOutputToBuf(CMOPUT,d,size); |
|
return 0; |
} |
} |
|
|
|
|
Line 362 int cmoOutPolynomial2(POLY f) |
|
Line 371 int cmoOutPolynomial2(POLY f) |
|
return(0); |
return(0); |
} |
} |
|
|
int cmoOutRingDefinition(struct ring *rp,int option) |
void cmoOutRingDefinition(struct ring *rp,int option) |
{ |
{ |
cmoint tmp[3]; |
cmoint tmp[3]; |
/* minimal information */ |
/* minimal information */ |
Line 388 int cmoOutRingDefinition(struct ring *rp,int option) |
|
Line 397 int cmoOutRingDefinition(struct ring *rp,int option) |
|
|
|
} |
} |
|
|
int cmoOutRingDefinition2(struct ring *rp,int option) |
void cmoOutRingDefinition2(struct ring *rp,int option) |
{ |
{ |
cmoint tmp[3]; |
cmoint tmp[3]; |
/* minimal information */ |
/* minimal information */ |
Line 1234 struct object cmoObjectFromStream(struct object obStre |
|
Line 1243 struct object cmoObjectFromStream(struct object obStre |
|
{ |
{ |
struct cmoBuffer cb; |
struct cmoBuffer cb; |
struct object rob = OINIT; |
struct object rob = OINIT; |
extern DebugCMO; |
extern int DebugCMO; |
if (obStream.tag != Sfile) { |
if (obStream.tag != Sfile) { |
errorCmo("cmoObjectFromStream: Argument must be of type file."); |
errorCmo("cmoObjectFromStream: Argument must be of type file."); |
} |
} |
Line 1476 int cmoOutRawInt(int k) |
|
Line 1485 int cmoOutRawInt(int k) |
|
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
} |
} |
|
|
warningCmo(char *s) { |
void warningCmo(char *s) { |
fprintf(stderr,"Warning: plugin/cmo.c : %s\n",s); |
fprintf(stderr,"Warning: plugin/cmo.c : %s\n",s); |
} |
} |
|
|
errorCmo(char *s) { |
void errorCmo(char *s) { |
fprintf(stderr,"plugin/cmo.c : %s\n",s); |
fprintf(stderr,"plugin/cmo.c : %s\n",s); |
errorKan1("%s\n","cmo fatal error. ox servers need SM_control_reset_connection."); |
errorKan1("%s\n","cmo fatal error. ox servers need SM_control_reset_connection."); |
/* ErrorPacket is automatically push on the ErrorStack. |
/* ErrorPacket is automatically push on the ErrorStack. |