home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / sarg1221.zip / exclude.c < prev    next >
C/C++ Source or Header  |  2002-10-11  |  1KB  |  63 lines

  1. /*
  2.  * sarg - Squid user management log
  3.  * Mar/98 - Pedro L Orso - orso@onda.com.br
  4.  */
  5.  
  6. #include "include/conf.h"
  7.  
  8. int vhexclude(char *excludefile, char *ip)
  9. {
  10.  
  11.    char  whost[1024];
  12.    char  wip1[1024], wip2[1024];
  13.    char  sn1[4], sn2[4], sn3[4];
  14.    // DAS: Usage of "str[strlen(excludefile)]" is not corresponds to C standard
  15.    char *str = strdup(excludefile);
  16.  
  17.    whost[0]='\0';
  18.    getword(whost,str,' ');
  19.    
  20.    while(strcmp(whost,"*FIM*") != 0) {
  21.  
  22.       if(strstr(ip,whost) !=0)
  23.       {
  24.          free(str);
  25.          return(0);
  26.       }
  27.  
  28.       strcpy(wip1,ip);
  29.       getword(sn1,wip1,'.');
  30.       getword(sn2,wip1,'.');
  31.       getword(sn3,wip1,'.');
  32.  
  33.       sprintf(wip1,"%s.%s.%s.0",sn1,sn2,sn3);
  34.       sprintf(wip2,"%s.%s.0.0",sn1,sn2);
  35.  
  36.       if(strstr(whost,wip1) !=0 || strstr(whost,wip2) !=0 )
  37.       {
  38.          free(str);
  39.          return(0);
  40.       }
  41.  
  42.       getword(whost,str,' ');
  43.    }
  44.  
  45.    free(str);
  46.    return(1);
  47. }
  48.  
  49.  
  50. int vuexclude(char *excludeuser, char *user)
  51. {
  52.  
  53.    char wuser[MAXLEN];
  54.  
  55.    strcpy(wuser,user);
  56.    strcat(wuser," ");
  57.  
  58.    if(strstr(excludeuser,wuser) != 0 )
  59.       return(0);
  60.  
  61.    return(1);
  62. }
  63.