=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/plugin/oxmisc2.c,v retrieving revision 1.13 retrieving revision 1.22 diff -u -p -r1.13 -r1.22 --- OpenXM/src/kan96xx/plugin/oxmisc2.c 2002/02/24 10:27:20 1.13 +++ OpenXM/src/kan96xx/plugin/oxmisc2.c 2004/03/08 08:24:42 1.22 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/kan96xx/plugin/oxmisc2.c,v 1.12 2001/05/04 01:06:30 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kan96xx/plugin/oxmisc2.c,v 1.21 2004/03/01 07:19:45 takayama Exp $ */ #include #include "ox_kan.h" #include "oxmisc2.h" /* This file requires sm1 object description. */ @@ -226,6 +226,14 @@ int oxReq(oxclientp client,int func,struct object ob) oxReqExecuteFunction(client->datafp2,KopString(ob)); client->dstate = DSTATE_ANY; break; + case SM_executeFunctionWithOptionalArgument: + if (ob.tag != Sdollar) { + errorOxmisc2("SM_executeFunctionWithOptionalArgument : the argument must be a string."); + return(-1); + } + oxReqExecuteFunctionWithOptionalArgument(client->datafp2,KopString(ob)); + client->dstate = DSTATE_ANY; + break; case SM_popString: oxReqPopString(client->datafp2); client->dstate = DSTATE_ANY; @@ -254,6 +262,10 @@ int oxReq(oxclientp client,int func,struct object ob) oxReqSingleOperand(client->datafp2,SM_dupErrors); client->dstate = DSTATE_ANY; break; + case SM_pushCMOtag: + oxReqSingleOperand(client->datafp2,SM_pushCMOtag); + client->dstate = DSTATE_ANY; + break; default: fprintf(MyErrorOut,"func=%d ",func); errorOxmisc2("This function is not implemented."); @@ -301,6 +313,7 @@ struct object KoxCreateClient(struct object ip, } rob = newObjectArray(N_OF_CLIENT_FIELDS); oxClientToObject(client,rob); + oxClientListUpdate(rob); return(rob); } @@ -381,6 +394,7 @@ int oxClientToObject(oxclientp client,struct object ro } putoa(rob,11,KpoInteger(client->engineByteOrder)); putoa(rob,12,KpoInteger(client->controlByteOrder)); + putoa(rob,13,KpoInteger(client->engineID)); return(0); } @@ -437,6 +451,9 @@ int oxObjectToClient(struct object ob,oxclientp cp) cp->engineByteOrder = KopInteger(ob1); ob1 = getoa(ob,12); cp->controlByteOrder = KopInteger(ob1); + + ob1 = getoa(ob,13); + cp->engineID = KopInteger(ob1); return(0); @@ -643,6 +660,63 @@ struct object KoxWatch(struct object client,struct obj return(KpoInteger(ans)); } +struct object KoxLog(struct object client,struct object in,struct object out) +{ + int ans,k; + static oxclientp cc1 = NULL; + struct object rob; + rob.tag = Snull; + if (cc1 == NULL) { + cc1 = (oxclientp) mymalloc(sizeof(oxclient)); + if (cc1 == NULL) { + errorOxmisc2("KoxLog(): no more memory."); + return(rob); + } + oxInitClient(cc1); + } + + if (oxObjectToClient(client,cc1) == -1) return(rob); + if (cc1 == NULL) { + errorOxmisc2("KoxLog(): the first argument must be a client object."); + return(rob); + } + + if (in.tag != Sfile) { + errorOxmisc2("KoxLog(): the second argument is not a file object."); + return rob; + } + if (out.tag != Sfile) { + errorOxmisc2("KoxLog(): the third argument is not a file object."); + return rob; + } + k = fp2log(cc1->datafp2,in.rc.file,out.rc.file); + fputc(cc1->engineByteOrder,out.rc.file); /* Output engineByteOrder. */ + /* synchronize cc1 and client. */ + oxClientToObject(cc1,client); + + return(KpoInteger(ans)); +} + +struct object KoxLogStop(struct object client) { + static oxclientp cc1 = NULL; + struct object rob; + rob.tag = Snull; + if (cc1 == NULL) { + cc1 = (oxclientp) mymalloc(sizeof(oxclient)); + if (cc1 == NULL) { + errorOxmisc2("KoxLog(): no more memory."); + return(rob); + } + oxInitClient(cc1); + } + + if (oxObjectToClient(client,cc1) == -1) return(rob); + if (cc1 == NULL) { + errorOxmisc2("KoxLog(): the first argument must be a client object."); + return(rob); + } + return(KpoInteger(fp2stopLog(cc1->datafp2))); +} struct object KoxCloseClient(struct object client) { oxclientp cc1 = NULL; @@ -674,6 +748,7 @@ struct object KoxCloseClient(struct object client) { errorOxmisc2("Unknown client->type\n"); break; } + oxClientListRemove(client); return(KpoInteger(0)); } @@ -703,6 +778,7 @@ static int cmoCheck00(struct object obj,int cmo[], int /* typeTrans[Spoly] = CMO_DMS; */ typeTrans[Spoly] = CMO_DISTRIBUTED_POLYNOMIAL; typeTrans[Sdouble] = CMO_64BIT_MACHINE_DOUBLE; + typeTrans[SrationalFunction] = CMO_RATIONAL; typeTrans[CLASSNAME_ERROR_PACKET] = CMO_ERROR2; typeTrans[CLASSNAME_mathcap] = CMO_MATHCAP; typeTrans[CLASSNAME_indeterminate] = CMO_INDETERMINATE; @@ -982,6 +1058,7 @@ struct object KoxCreateClient2(struct object peer, } rob = newObjectArray(N_OF_CLIENT_FIELDS); oxClientToObject(client,rob); + oxClientListUpdate(rob); return(rob); } @@ -1113,7 +1190,6 @@ struct object KoxCreateControl_RFC_101(struct object p oxclientp oxCreateControl_RFC_101(int fdstream,int portStream, int ipmask,char *pass) { - static int clnum = 0; int v = 0; int fdControl = -1; int fdStream = -1; @@ -1174,7 +1250,7 @@ oxclientp oxCreateControl_RFC_101(int fdstream,int por client->dataport = portStream; client->controlport = -1; client->controlfd = -1; - client->id = clnum; clnum++; + client->id = oxGetClientID(); client->type = CLIENT_SOCKET; /* socket */ client->engineByteOrder = engineByteOrder; client->controlByteOrder = -1; @@ -1226,6 +1302,7 @@ struct object KoxCreateEngine_RFC_101(struct object pe } rob = newObjectArray(N_OF_CLIENT_FIELDS); oxClientToObject(client,rob); + oxClientListUpdate(rob); return(rob); } @@ -1293,9 +1370,71 @@ oxclientp oxCreateEngine_RFC_101(int fdstream,int port client->dataport = portStream; client->controlport = -1; client->controlfd = -1; - client->id = engineID; + client->id = oxGetClientID(); + client->engineID = engineID; client->type = CLIENT_SOCKET; /* socket */ client->engineByteOrder = engineByteOrder; client->controlByteOrder = -1; return(client); } + +void oxClientListUpdate(struct object ob) { + int id; + extern struct object OxClientList[]; + id = KopInteger(getoa(ob,8)); + /* printf("id=%d\n",id); */ + if ((id = 0)) { + OxClientList[id] = ob; + }else{ + errorOxmisc2("oxClientListUpdate(): the client table is full.\n"); + } +} +void oxClientListRemove(struct object ob) { + int id; + extern struct object OxClientList[]; + id = KopInteger(getoa(ob,8)); + if ((id = 0)) { + (OxClientList[id]).tag = Snull; + }else{ + /* errorOxmisc2("oxClientListRemove(): the client table is full.\n");*/ + } +} +static void KoxCleanClientList() { + extern int OxClientListn; + extern struct object OxClientList[]; + int i,j,n; + struct object ob; + n = 0; + for (i=0; i= n) { + j=0; + errorOxmisc2("oxGetClientList(): the client table is broken.\n"); + } + putoa(rob,j,OxClientList[i]); + j++; + } + } + return rob; +} + +