Subversion Repositories wimsdev

Rev

Rev 8067 | Rev 8185 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8067 Rev 8155
Line 1101... Line 1101...
1101
    }
1101
    }
1102
nothing:
1102
nothing:
1103
    value[0]=0; return;
1103
    value[0]=0; return;
1104
}
1104
}
1105
 
1105
 
1106
      /* Get variable definition from a file.
1106
/* Get variable definition from a file.
1107
       * Result stored in buffer value of length MAX_LINELEN. */
1107
 * Result stored in buffer value of length MAX_LINELEN.
-
 
1108
 */
1108
void getdef(char *fname, char *name, char value[])
1109
void getdef(char *fname, char *name, char value[])
1109
{
1110
{
1110
    char buf[MAX_LINELEN+1], tbuf[MAX_LINELEN+1], nbuf[MAX_NAMELEN+1];
1111
    char buf[MAX_LINELEN+1], tbuf[MAX_LINELEN+1], nbuf[MAX_NAMELEN+1];
1111
    char *p1, *p2;
1112
    char *p1, *p2;
1112
 
1113
 
Line 1149... Line 1150...
1149
    else
1150
    else
1150
      snprintf(buf+n,MAX_LINELEN-n,"%s=%s\n",name,value);
1151
      snprintf(buf+n,MAX_LINELEN-n,"%s=%s\n",name,value);
1151
    _setdef_changed++;
1152
    _setdef_changed++;
1152
}
1153
}
1153
 
1154
 
1154
      /* Set variable definition to a file. */
1155
/* Set variable definition to a file. */
1155
void setdef(char *fname, char *name)
1156
void setdef(char *fname, char *name)
1156
{
1157
{
1157
    char buf[MAX_LINELEN+1];
1158
    char buf[MAX_LINELEN+1];
1158
    char *p1, *p2, *p3;
1159
    char *p1, *p2, *p3;
1159
 
1160
 
Line 1176... Line 1177...
1176
      _setdef(buf,p1,p3);
1177
      _setdef(buf,p1,p3);
1177
    }
1178
    }
1178
    if(_setdef_changed) accessfile(buf,"w","%s",fname);
1179
    if(_setdef_changed) accessfile(buf,"w","%s",fname);
1179
}
1180
}
1180
 
1181
 
1181
      /* check whether connecting host is part of given list.
1182
/* check whether connecting host is part of given list.
1182
       * Returns 0 if no, 1 if yes. */
1183
 * Returns 0 if no, 1 if yes.
-
 
1184
 */
1183
int checkhost(char *hlist)
1185
int checkhost(char *hlist)
1184
{
1186
{
1185
    char buf[MAX_LINELEN+1];
1187
    char buf[MAX_LINELEN+1];
1186
    char lbuf[1024], hbuf1[256], hbuf2[256];
1188
    char lbuf[1024], hbuf1[256], hbuf2[256];
1187
    char *p1, *p2, *pb, *pe, *pp;
1189
    char *p1, *p2, *pb, *pe, *pp;
Line 1211... Line 1213...
1211
      if(strstr(pp,lbuf)!=NULL) return 1;      /* found */
1213
      if(strstr(pp,lbuf)!=NULL) return 1;      /* found */
1212
    }
1214
    }
1213
    return 0;
1215
    return 0;
1214
}
1216
}
1215
 
1217
 
1216
      /* return 1 if a word of bf2 is a substring of host.
1218
/* return 1 if a word of bf2 is a substring of host.
1217
       * Like checkhost, but with time check.
1219
 * Like checkhost, but with time check.
1218
       * The content of bf2[] is destroyed. */
1220
 * The content of bf2[] is destroyed.
-
 
1221
 */
1219
int checkhostt(char bf2[])
1222
int checkhostt(char bf2[])
1220
{
1223
{
1221
    char *p1, *p2, *p3;
1224
    char *p1, *p2, *p3;
1222
      /* compare with starting time */
1225
/* compare with starting time */
1223
    for(p1=strchr(bf2,'>'); p1!=NULL; p1=strchr(p1+1,'>')) {
1226
    for(p1=strchr(bf2,'>'); p1!=NULL; p1=strchr(p1+1,'>')) {
1224
      if(p1>bf2 && !isspace(*(p1-1))) continue;
1227
      if(p1>bf2 && !isspace(*(p1-1))) continue;
1225
      p3=find_word_start(++p1); p2=find_word_end(p3);
1228
      p3=find_word_start(++p1); p2=find_word_end(p3);
1226
      if(p2-p3!=14) continue;
1229
      if(p2-p3!=14) continue;
1227
      p3[8]='.'; p3[11]=':'; if(*p2) *p2++=0;
1230
      p3[8]='.'; p3[11]=':'; if(*p2) *p2++=0;
1228
      if(strncmp(nowstr,p3,14)<0) return 0;
1231
      if(strncmp(nowstr,p3,14)<0) return 0;
1229
      ovlstrcpy(p1-1,p2); p1-=2;
1232
      ovlstrcpy(p1-1,p2); p1-=2;
1230
    }
1233
    }
1231
      /* compare with ending time */
1234
/* compare with ending time */
1232
    for(p1=strchr(bf2,'<'); p1!=NULL; p1=strchr(p1+1,'<')) {
1235
    for(p1=strchr(bf2,'<'); p1!=NULL; p1=strchr(p1+1,'<')) {
1233
      if(p1>bf2 && !isspace(*(p1-1))) continue;
1236
      if(p1>bf2 && !isspace(*(p1-1))) continue;
1234
      p3=find_word_start(++p1); p2=find_word_end(p3);
1237
      p3=find_word_start(++p1); p2=find_word_end(p3);
1235
      if(p2-p3!=14) continue;
1238
      if(p2-p3!=14) continue;
1236
      p3[8]='.'; p3[11]=':'; if(*p2) *p2++=0;
1239
      p3[8]='.'; p3[11]=':'; if(*p2) *p2++=0;
Line 1239... Line 1242...
1239
    }
1242
    }
1240
    p1=find_word_start(bf2); if(*p1==0) return 1;
1243
    p1=find_word_start(bf2); if(*p1==0) return 1;
1241
    return checkhost(p1);
1244
    return checkhost(p1);
1242
}
1245
}
1243
 
1246
 
1244
      /* bad identification */
1247
/* bad identification */
1245
void bad_ident(void)
1248
void bad_ident(void)
1246
{
1249
{
1247
    if(cookiegot[0]!=0) {
1250
    if(cookiegot[0]!=0) {
1248
    }
1251
    }
1249
    user_error("bad_ident");
1252
    user_error("bad_ident");
Line 1264... Line 1267...
1264
                   tmp_dir,tmp_dir);
1267
                   tmp_dir,tmp_dir);
1265
    call_ssh("mv %s %s >/dev/null 2>/dev/null", instex_fname,s2_prefix);
1268
    call_ssh("mv %s %s >/dev/null 2>/dev/null", instex_fname,s2_prefix);
1266
    instex_src[0]=instex_fname[0]=0; instex_cnt=0;
1269
    instex_src[0]=instex_fname[0]=0; instex_cnt=0;
1267
}
1270
}
1268
 
1271
 
1269
      /* put last.phtml */
1272
/* put last.phtml */
1270
void putlastout(void)
1273
void putlastout(void)
1271
{
1274
{
1272
    int t;
1275
    int t;
1273
    if(instex_cnt>0) instex_flush();
1276
    if(instex_cnt>0) instex_flush();
1274
    t=catfile(stdout,"%s/%s",s2_prefix,lastout);
1277
    t=catfile(stdout,"%s/%s",s2_prefix,lastout);
1275
    if(t==0) printf("Content-type: text/plain\r\n\r\n");
1278
    if(t==0) printf("Content-type: text/plain\r\n\r\n");
1276
}
1279
}
1277
 
1280
 
1278
struct sockaddr_un sun;
1281
struct sockaddr_un sun;
1279
 
1282
 
1280
      /* returns >=0 if OK. */
1283
/* returns >=0 if OK. */
1281
 
1284
 
1282
int kerneld(char *p, int bufsize)
1285
int kerneld(char *p, int bufsize)
1283
{
1286
{
1284
    int sock, s, t, t1, l, *ip;
1287
    int sock, s, t, t1, l, *ip;
1285
    struct timeval tv;
1288
    struct timeval tv;