00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <stdlib.h>
00027 #include <stdio.h>
00028 #include <soi_key.h>
00029 #include "pe_hdata.h"
00030
00031 #define MONE (long)-1
00032
00033 int kludgey = 2;
00034
00035
00036 HDATA *hnext;
00037
00038 HDATA *gethname (HDATA *list, char *host_name)
00039 {
00040 HDATA *walk = list;
00041
00042 if(!host_name) return NULL;
00043 while(walk) {
00044 if(strcmp(walk->host_name, host_name))
00045 walk = walk->next;
00046 else
00047 return walk;
00048 }
00049 return walk;
00050 }
00051
00052 HDATA *gethtid (HDATA *list, int tid)
00053 {
00054 HDATA *walk = list;
00055
00056 while(walk) {
00057 if(walk->tid == tid)
00058 return walk;
00059 else
00060 walk = walk->next;
00061 }
00062 return walk;
00063 }
00064
00065 char *h_strdup (char *s)
00066 {
00067 char *duped;
00068
00069 if(!s) return NULL;
00070 duped = (char *)malloc(kludgey*(strlen(s)+1));
00071 strcpy(duped, s);
00072 return duped;
00073 }
00074
00075 void sethname (HDATA **list, char *host_name)
00076 {
00077 HDATA *newone;
00078
00079 if(!host_name) return;
00080 newone = (HDATA *)malloc(kludgey*sizeof(HDATA));
00081 newone->next = *list;
00082 newone->host_name = h_strdup(host_name);
00083 newone->tid = 0;
00084 newone->busy = 0;
00085 newone->param_list = NULL;
00086 *list = newone;
00087 }
00088
00089 HDATA *sethtid (HDATA *list, char *host_name, int tid)
00090 {
00091 HDATA *walk = list;
00092
00093 if(!host_name) return NULL;
00094 while(walk) {
00095 if(strcmp(walk->host_name, host_name))
00096 walk = walk->next;
00097 else {
00098 if(walk->tid == 0) {
00099 walk->tid = tid;
00100 return walk;
00101 }
00102 else
00103 walk = walk->next;
00104 }
00105 }
00106 return walk;
00107 }
00108
00109
00110
00111
00112 HDATA *gethnext (HDATA *list)
00113 {
00114 if(list != (HDATA *)MONE) {
00115 hnext = list;
00116 return list;
00117 }
00118 if(hnext)
00119 hnext = hnext->next;
00120 return hnext;
00121 }
00122
00123
00124 HDATA *gethrel (HDATA *oldlist, HDATA *hloc, HDATA *newlist)
00125 {
00126 HDATA *hstep, *hstep2;
00127
00128 if(!oldlist || !hloc || !newlist)
00129 return NULL;
00130 hstep2=newlist;
00131 for(hstep=(HDATA *)gethnext(oldlist); hstep != NULL;
00132 hstep=(HDATA *)gethnext((HDATA *)MONE)) {
00133 if(hstep == hloc) break;
00134 hstep2=hstep2->next;
00135 }
00136 if(hstep)
00137 return hstep2;
00138 else
00139 return NULL;
00140 }