[BACK]Return to oxmisc2.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / plugin

Diff for /OpenXM/src/kan96xx/plugin/oxmisc2.c between version 1.13 and 1.18

version 1.13, 2002/02/24 10:27:20 version 1.18, 2003/11/17 05:45:47
Line 1 
Line 1 
 /* $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.17 2002/11/08 14:18:02 takayama Exp $ */
 #include <stdio.h>  #include <stdio.h>
 #include "ox_kan.h"  #include "ox_kan.h"
 #include "oxmisc2.h"   /* This file requires sm1 object description. */  #include "oxmisc2.h"   /* This file requires sm1 object description. */
Line 301  struct object KoxCreateClient(struct object ip,
Line 301  struct object KoxCreateClient(struct object ip,
   }    }
   rob = newObjectArray(N_OF_CLIENT_FIELDS);    rob = newObjectArray(N_OF_CLIENT_FIELDS);
   oxClientToObject(client,rob);    oxClientToObject(client,rob);
     oxClientListUpdate(rob);
   return(rob);    return(rob);
 }  }
   
Line 381  int oxClientToObject(oxclientp client,struct object ro
Line 382  int oxClientToObject(oxclientp client,struct object ro
   }    }
   putoa(rob,11,KpoInteger(client->engineByteOrder));    putoa(rob,11,KpoInteger(client->engineByteOrder));
   putoa(rob,12,KpoInteger(client->controlByteOrder));    putoa(rob,12,KpoInteger(client->controlByteOrder));
     putoa(rob,13,KpoInteger(client->engineID));
   return(0);    return(0);
 }  }
   
Line 437  int oxObjectToClient(struct object ob,oxclientp cp)
Line 439  int oxObjectToClient(struct object ob,oxclientp cp)
   cp->engineByteOrder = KopInteger(ob1);    cp->engineByteOrder = KopInteger(ob1);
   ob1 = getoa(ob,12);    ob1 = getoa(ob,12);
   cp->controlByteOrder = KopInteger(ob1);    cp->controlByteOrder = KopInteger(ob1);
   
     ob1 = getoa(ob,13);
     cp->engineID = KopInteger(ob1);
   
   
   return(0);    return(0);
Line 643  struct object KoxWatch(struct object client,struct obj
Line 648  struct object KoxWatch(struct object client,struct obj
   return(KpoInteger(ans));    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);
     /* 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) {  struct object KoxCloseClient(struct object client) {
   oxclientp cc1 = NULL;    oxclientp cc1 = NULL;
Line 674  struct object KoxCloseClient(struct object client) {
Line 735  struct object KoxCloseClient(struct object client) {
     errorOxmisc2("Unknown client->type\n");      errorOxmisc2("Unknown client->type\n");
     break;      break;
   }    }
     oxClientListRemove(client);
   return(KpoInteger(0));    return(KpoInteger(0));
   
 }  }
Line 982  struct object KoxCreateClient2(struct object peer,
Line 1044  struct object KoxCreateClient2(struct object peer,
   }    }
   rob = newObjectArray(N_OF_CLIENT_FIELDS);    rob = newObjectArray(N_OF_CLIENT_FIELDS);
   oxClientToObject(client,rob);    oxClientToObject(client,rob);
     oxClientListUpdate(rob);
   return(rob);    return(rob);
 }  }
   
Line 1113  struct object KoxCreateControl_RFC_101(struct object p
Line 1176  struct object KoxCreateControl_RFC_101(struct object p
 oxclientp oxCreateControl_RFC_101(int fdstream,int portStream,  oxclientp oxCreateControl_RFC_101(int fdstream,int portStream,
                                   int ipmask,char *pass)                                    int ipmask,char *pass)
 {  {
   static int clnum = 0;  
   int v = 0;    int v = 0;
   int fdControl = -1;    int fdControl = -1;
   int fdStream = -1;    int fdStream = -1;
Line 1174  oxclientp oxCreateControl_RFC_101(int fdstream,int por
Line 1236  oxclientp oxCreateControl_RFC_101(int fdstream,int por
   client->dataport = portStream;    client->dataport = portStream;
   client->controlport = -1;    client->controlport = -1;
   client->controlfd = -1;    client->controlfd = -1;
   client->id = clnum; clnum++;    client->id = oxGetClientID();
   client->type = CLIENT_SOCKET; /* socket */    client->type = CLIENT_SOCKET; /* socket */
   client->engineByteOrder = engineByteOrder;    client->engineByteOrder = engineByteOrder;
   client->controlByteOrder = -1;    client->controlByteOrder = -1;
Line 1226  struct object KoxCreateEngine_RFC_101(struct object pe
Line 1288  struct object KoxCreateEngine_RFC_101(struct object pe
   }    }
   rob = newObjectArray(N_OF_CLIENT_FIELDS);    rob = newObjectArray(N_OF_CLIENT_FIELDS);
   oxClientToObject(client,rob);    oxClientToObject(client,rob);
     oxClientListUpdate(rob);
   return(rob);    return(rob);
 }  }
   
Line 1293  oxclientp oxCreateEngine_RFC_101(int fdstream,int port
Line 1356  oxclientp oxCreateEngine_RFC_101(int fdstream,int port
   client->dataport = portStream;    client->dataport = portStream;
   client->controlport = -1;    client->controlport = -1;
   client->controlfd = -1;    client->controlfd = -1;
   client->id = engineID;    client->id = oxGetClientID();
     client->engineID = engineID;
   client->type = CLIENT_SOCKET; /* socket */    client->type = CLIENT_SOCKET; /* socket */
   client->engineByteOrder = engineByteOrder;    client->engineByteOrder = engineByteOrder;
   client->controlByteOrder = -1;    client->controlByteOrder = -1;
   return(client);    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 <MAX_N_OF_CLIENT) && (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 <MAX_N_OF_CLIENT) && (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<OxClientListn; i++) {
           if ((OxClientList[i]).tag != Snull) {
             if (!isItClientObject(OxClientList[i])) {
                   (OxClientList[i]).tag = Snull;
             }
           }
     }
   }
   struct object KoxGetClientList() {
     extern int OxClientListn;
     extern struct object OxClientList[];
     int i,j,n;
     struct object rob;
     KoxCleanClientList();
     n = 0;
     for (i=0; i<OxClientListn; i++) {
           if ((OxClientList[i]).tag != Snull) n++;
     }
     rob = newObjectArray(n);
     for (i=0, j=0; i<OxClientListn; i++) {
           if ((OxClientList[i]).tag != Snull) {
             if (j >= n) {
                   j=0;
                   errorOxmisc2("oxGetClientList(): the client table is broken.\n");
             }
             putoa(rob,j,OxClientList[i]);
             j++;
           }
     }
     return rob;
   }
   
   

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.18

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>