home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / sarg1221.zip / log.c < prev    next >
C/C++ Source or Header  |  2002-10-11  |  32KB  |  1,186 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. char *userfile;
  9. char *excludefile;
  10. char *excludeuser;
  11.  
  12. numlist weekdays = { { 0, 1, 2, 3, 4, 5, 6 }, 7 };
  13. numlist hours = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
  14.          13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }, 24 };
  15.  
  16. void getusers(char *pwdfile, int debug);
  17. void gethexclude(char *hexfile, int debug);
  18. void getuexclude(char *uexfile, int debug);
  19. void ttx(char *user);
  20. int compar( const void *, const void * );
  21.  
  22. int main(argc,argv)
  23.    int argc;
  24.    char *argv[];
  25. {
  26.  
  27.    FILE *fp_in = NULL, *fp_ou = NULL, *fp_denied, *fp_usr, *fp_authfail;
  28.  
  29.    extern int optind;
  30.    extern int optopt;
  31.    extern char *optarg;
  32.  
  33.    char w[MAXLEN];
  34.    char data[255]; 
  35.    char elap[255];
  36.    char none[255];
  37.    char ip[MAXLEN];
  38.    char msg[MAXLEN];
  39.    char tam[255];
  40.    char fun[255];
  41.    char url[8192];
  42.    char urly[8192];
  43.    char user[MAXLEN];
  44.    char wuser[MAXLEN]; 
  45.    char code[MAXLEN];
  46.    char code2[MAXLEN];
  47.    char periodo[MAXLEN];
  48.    char dia[128]; 
  49.    char wdata[128];
  50.    char mes[30];
  51.    char ano[30];
  52.    char hora[30];
  53.    char tmp[MAXLEN];
  54.    char tmp2[MAXLEN];
  55.    char tmp3[MAXLEN];
  56.    char wtemp[MAXLEN];
  57.    char wtemp2[255];
  58.    char us[50];
  59.    char date[255];
  60.    char arq[255];
  61.    char warq[255][255];
  62.    char addr[MAXLEN];
  63.    char hm[6];
  64.    char smartfilter[MAXLEN];
  65.    char site[MAXLEN];
  66.    char uagent[MAXLEN];
  67.    char hexclude[MAXLEN];
  68.    char csort[MAXLEN]; 
  69.    char tbuf[128];
  70.    char email[MAXLEN];
  71.    char zip[20];
  72.    char *str;
  73.    char outdir[MAXLEN];
  74.    char cdfrom[30];
  75.    char cduntil[30];
  76.    char bufz[8192];
  77.    char bufy[8192];
  78.    int  common; 
  79.    int  common_log=0;
  80.    int  squid_log=0;
  81.    int  userip=0;
  82.    int  indexonly=0;
  83.    int  ch;
  84.    int  d;
  85.    int  x, l, i;
  86.    int  errflg=0;
  87.    int  debug=0;
  88.    int  debugz=0;
  89.    int  debugm=0;
  90.    int  iprel=0;
  91.    int  puser=0;
  92.    int  fhost=0;
  93.    int  dns=0;
  94.    int  fuser=0;
  95.    int  dfrom=0; 
  96.    int  duntil=0;
  97.    int  idata=0;
  98.    int  narq=0;
  99.    int  iarq=0;
  100.    long totregsl=0; 
  101.    long totregsg=0;
  102.    long totregsx=0;
  103.    long totper=0;
  104.    long int  max_elapsed=0;
  105.    time_t tt;
  106.    struct tm *t;
  107.    unsigned long nreg=0;
  108.    off_t recs1=0;
  109.    unsigned long recs2=0;
  110.  
  111.    BgImage[0]='\0';
  112.    LogoImage[0]='\0';
  113.    LogoText[0]='\0';
  114.    FontFace[0]='\0';
  115.    PasswdFile[0]='\0';
  116.    OutputEmail[0]='\0';
  117.    Ip2Name[0]='\0';
  118.    UserAgentLog[0]='\0';
  119.    ExcludeHosts[0]='\0';
  120.    ExcludeUsers[0]='\0';
  121.    ConfigFile[0]='\0';
  122.    code[0]='\0';
  123.    LastLog[0]='\0';
  124.    UserIp[0]='\0';
  125.    MaxElapsed[0]='\0';
  126.    ReportType[0]='\0';
  127.    UserTabFile[0]='\0';
  128.  
  129.    strcpy(AccessLog,"/usr/local/squid/logs/access.log");
  130.    sprintf(ExcludeCodes,"%s/exclude_codes",SYSCONFDIR);
  131.    strcpy(BgColor,"white");
  132.    strcpy(TxColor,"black");
  133.    strcpy(TxBgColor,"beige");
  134.    strcpy(TiColor,"green");
  135.    strcpy(Width,"80");
  136.    strcpy(Height,"45");
  137.    strcpy(LogoTextColor,"black");
  138.    strcpy(HeaderColor,"darkblue");
  139.    strcpy(HeaderBgColor,"blanchedalmond");
  140.    strcpy(FontSize,"-1");
  141.    strcpy(TempDir,"/tmp");
  142.    strcpy(OutputDir,"/usr/local/etc/httpd/htdocs/squid-reports");
  143.    strcpy(Ip2Name,"no");
  144.    strcpy(DateFormat,"u");
  145.    strcpy(OverwriteReport,"no");
  146.    strcpy(RemoveTempFiles,"yes");
  147.    strcpy(ReplaceIndex,"index.html");
  148.    strcpy(Index,"yes");
  149.    strcpy(RecordsWithoutUser,"ip");
  150.    strcpy(UseComma,"no");
  151.    strcpy(MailUtility,"mailx");
  152.    strcpy(TopSitesNum,"100");
  153.    strcpy(UserIp,"no");
  154.    strcpy(TopuserSortField,"BYTES");
  155.    strcpy(UserSortField,"BYTES");
  156.    strcpy(TopuserSortOrder,"reverse");
  157.    strcpy(UserSortOrder,"reverse");
  158.    strcpy(TopsitesSortField,"CONNECT");
  159.    strcpy(TopsitesSortType,"D");
  160.    strcpy(LongUrl,"no");
  161.    strcpy(language,"English");
  162.    strcpy(datetimeby,"bytes");
  163.    strcpy(CharSet,"ISO-8859-1");
  164.    strcpy(Privacy,"no");
  165.    strcpy(PrivacyString,"***.***.***.***");
  166.    strcpy(PrivacyStringColor,"blue");
  167.    strcpy(SuccessfulMsg,"yes");
  168.    strcpy(TopUserFields,"NUM DATE_TIME USERID CONNECT BYTES %BYTES IN-CACHE-OUT USED_TIME MILISEC %TIME TOTAL AVERAGE");
  169.    strcpy(DataFileDelimiter,";");
  170.    strcpy(DataFileFields,"user;date;time;url;connect;bytes;in_cache;out_cache;elapsed");
  171.  
  172.    dia[0]='\0';
  173.    mes[0]='\0';
  174.    ano[0]='\0';
  175.    hora[0]='\0';
  176.    tmp[0]='\0';
  177.    tmp2[0]='\0';
  178.    tmp3[0]='\0';
  179.    wtemp[0]='\0';
  180.    wtemp2[0]='\0';
  181.    us[0]='\0';
  182.    date[0]='\0';
  183.    df[0]='\0';
  184.    uagent[0]='\0';
  185.    hexclude[0]='\0';
  186.    addr[0]='\0';
  187.    hm[0]='\0';
  188.    site[0]='\0';
  189.    outdir[0]='\0';
  190.    elap[0]='\0';
  191.    email[0]='\0';
  192.    zip[0]='\0';
  193.    UserInvalidChar[0]='\0';
  194.    DataFile[0]='\0';
  195.    excode=0;
  196.    denied_count=0;
  197.    authfail_count=0;
  198.  
  199.    bzero(IncludeUsers, MAXLEN);
  200.    bzero(ExcludeString, MAXLEN);
  201.  
  202.    for(x=0; x<=254; x++) 
  203.       warq[x][0]='\0';
  204.  
  205.    language_load(language);
  206.    strcpy(Title,text[88]);
  207.  
  208.    while((ch = getopt(argc, argv, "a:b:c:d:e:f:g:u:l:o:r:s:t:w:hijmnpxz")) != -1){
  209.       switch(ch)
  210.       {
  211.          case 'a':
  212.             strcpy(addr,optarg);
  213.             break;
  214.          case 'b':
  215.             strcpy(uagent,optarg);
  216.             break;
  217.          case 'c':
  218.             strcpy(hexclude,optarg);
  219.             break;
  220.          case 'd':
  221.             strcpy(date,optarg);
  222.             strcpy(cduntil,optarg);
  223.             getword(cdfrom,cduntil,'-');
  224.             date_from(date, cdfrom, cduntil);
  225.             dfrom=atoi(cdfrom);
  226.             duntil=atoi(cduntil);
  227.             break;
  228.          case 'e':
  229.             strcpy(email,optarg);
  230.             break;
  231.          case 'f':
  232.             strcpy(ConfigFile,optarg);
  233.             break;
  234.          case 'g':
  235.             strcpy(df,optarg);
  236.             break;
  237.         case 'h':
  238.           usage(argv[0]);
  239.             exit(0);
  240.          break;
  241.          case 'i':
  242.             iprel++;
  243.             break;
  244.          case 'l':
  245.             strcpy(warq[narq],optarg);
  246.             narq++;
  247.             break;
  248.          case 'm':
  249.             debugm++;
  250.             break;
  251.          case 'n':
  252.             dns++;
  253.             break;
  254.          case 'o':
  255.             strcpy(outdir,optarg);
  256.             break;
  257.          case 'p':
  258.             userip++;
  259.             break;
  260.          case 's':
  261.             strcpy(site,optarg);
  262.             break;
  263.          case 't':
  264.             strcpy(hm,optarg);
  265.             break;
  266.          case 'u':
  267.             strcpy(us,optarg);
  268.             break;
  269.          case 'w':
  270.             strcpy(tmp,optarg);
  271.             break;
  272.          case 'x':
  273.             debug++;
  274.             break;
  275.          case 'z':
  276.             debugz++;
  277.             break;
  278.          case ':':
  279.         fprintf(stderr, "Option -%c require an argument\n",optopt);
  280.         errflg++;
  281.         break;
  282.          case '?':
  283.             usage(argv[0]);
  284.             exit(1);
  285.             break;
  286.       }
  287.  
  288.    }
  289.  
  290.    if (errflg) {
  291.       usage(argv[0]);
  292.       exit(2);
  293.    }
  294.  
  295.    if(debug)
  296.       debuga("Init");
  297.  
  298.    if(ConfigFile[0] == '\0')
  299.       sprintf(ConfigFile,"%s/sarg.conf",SYSCONFDIR);
  300.     else {
  301.       if(access(ConfigFile, R_OK) != 0) {
  302.          sprintf(msg,"Cannot open config file: %s",ConfigFile);
  303.          debuga(msg);
  304.          exit(1);
  305.       }
  306.    }
  307.     
  308.    if(access(ConfigFile, R_OK) == 0)
  309.       getconf(debugm, ConfigFile, AccessLog, debug, BgColor, TxColor, TxBgColor, TiColor, LogoImage, LogoText, LogoTextColor, Width, Height, Title, BgImage, FontFace, HeaderColor, HeaderBgColor, FontSize, PasswdFile, TempDir, OutputDir, OutputEmail, Ip2Name, TopuserSortField, UserSortField, TopuserSortOrder, UserSortOrder, UserAgentLog, ExcludeHosts, DateFormat, ExcludeUsers, PerUserLimitFile, PerUserLimit, UserIp, MaxElapsed);
  310.  
  311.    if(debugz) {
  312.       fprintf(stderr, "SARG: ConfigFile.........= %s\n",ConfigFile);
  313.       fprintf(stderr, "SARG: AccessLog..........= %s\n",AccessLog);
  314.       fprintf(stderr, "SARG: BgColor............= %s\n",BgColor);
  315.       fprintf(stderr, "SARG: TxColor............= %s\n",TxColor);
  316.       fprintf(stderr, "SARG: TxBgColor..........= %s\n",TxBgColor);
  317.       fprintf(stderr, "SARG: TiColor............= %s\n",TiColor);
  318.       fprintf(stderr, "SARG: LogoImage..........= %s\n",LogoImage);
  319.       fprintf(stderr, "SARG: LogoText...........= %s\n",LogoText);
  320.       fprintf(stderr, "SARG: LogoTextColor......= %s\n",LogoTextColor);
  321.       fprintf(stderr, "SARG: Width..............= %s\n",Width);
  322.       fprintf(stderr, "SARG: Height.............= %s\n",Height);
  323.       fprintf(stderr, "SARG: Title..............= %s\n",Title);
  324.       fprintf(stderr, "SARG: BgImage............= %s\n",BgImage);
  325.       fprintf(stderr, "SARG: FontFace...........= %s\n",FontFace);
  326.       fprintf(stderr, "SARG: HeaderColor........= %s\n",HeaderColor);
  327.       fprintf(stderr, "SARG: HeaderBgColor......= %s\n",HeaderBgColor);
  328.       fprintf(stderr, "SARG: FontSize...........= %s\n",FontSize);
  329.       fprintf(stderr, "SARG: PasswdFile.........= %s\n",PasswdFile);
  330.       fprintf(stderr, "SARG: TempDir............= %s\n",TempDir);
  331.       fprintf(stderr, "SARG: OutputDir..........= %s\n",OutputDir);
  332.       fprintf(stderr, "SARG: Ip2Name............= %s\n",Ip2Name);
  333.       fprintf(stderr, "SARG: TopuserSortField.........= %s\n",TopuserSortField);
  334.       fprintf(stderr, "SARG: UserSortField.........= %s\n",UserSortField);
  335.       fprintf(stderr, "SARG: TopuserSortOrder.........= %s\n",TopuserSortOrder);
  336.       fprintf(stderr, "SARG: UserSortOrder.........= %s\n",UserSortOrder);
  337.       fprintf(stderr, "SARG: UserAgentLog.......= %s\n",UserAgentLog);
  338.       fprintf(stderr, "SARG: ExcludeHosts.......= %s\n",ExcludeHosts);
  339.       fprintf(stderr, "SARG: DateFormat.........= %s\n",DateFormat);
  340.       fprintf(stderr, "SARG: ExcludeUsers.......= %s\n",ExcludeUsers);
  341.       fprintf(stderr, "SARG: PerUserLimitFile...= %s\n",PerUserLimitFile);
  342.       fprintf(stderr, "SARG: PerUserLimit.......= %s\n",PerUserLimit);
  343.       fprintf(stderr, "SARG: UserIp.............= %s\n",UserIp);
  344.       fprintf(stderr, "SARG: MaxElapsed.........= %s\n",MaxElapsed);
  345.       fprintf(stderr, "SARG: LastLog............= %s\n",LastLog);
  346.       fprintf(stderr, "SARG:\n");
  347.    }
  348.  
  349.  
  350.    dataonly=0;
  351.    if(DataFile[0] != '\0');
  352.       dataonly++;
  353.    
  354.    str2=(char *)subs(TopUserFields,"%BYTES","SETYB");
  355.    strcpy(TopUserFields,str2);
  356.  
  357.    if(!narq) {
  358.       strcpy(warq[0],AccessLog);
  359.       narq++;
  360.    }
  361.  
  362.    if(strcmp(hexclude,"onvert") == 0 && strcmp(site,"plit") != 0) {
  363.       convlog(warq[0], df, dfrom, duntil);
  364.       exit(0);
  365.    }
  366.    
  367.    if(strcmp(site,"plit") == 0) {
  368.       splitlog(warq[0], df, dfrom, duntil, hexclude);
  369.       exit(0);
  370.    }
  371.  
  372.    if(ExcludeCodes[0] != '\0') {
  373.       if((excludecode=(char *) malloc(1024))==NULL) {
  374.          fprintf(stderr, "SARG: %s (1024):\n",text[59]);
  375.          exit(1);
  376.       }
  377.       bzero(excludecode,1024);
  378.       load_excludecodes();
  379.    }
  380.  
  381.    if(access(PasswdFile, R_OK) == 0) {
  382.       getusers(PasswdFile,debug);
  383.       puser++;
  384.    }
  385.  
  386.    if(hexclude[0] == '\0')
  387.       strcpy(hexclude,ExcludeHosts);
  388.    if(access(hexclude, R_OK) == 0) {
  389.       gethexclude(hexclude,debug);
  390.       fhost++;
  391.    }
  392.  
  393.    if(ReportType[0] == '\0')
  394.       strcpy(ReportType,"topsites users_sites sites_users date_time denied auth_failures site_user_time_date");
  395.  
  396.    if(access(ExcludeUsers, R_OK) == 0) {
  397.       getuexclude(ExcludeUsers,debug);
  398.       fuser++;
  399.    }
  400.  
  401.    indexonly=0;
  402.    if(fuser) {
  403.       if(strstr(excludeuser,"indexonly") != 0)
  404.          indexonly++;
  405.    }
  406.    if(strcmp(ExcludeUsers,"indexonly") == 0)
  407.       indexonly++;
  408.    if(strcmp(Index,"only") == 0)
  409.       indexonly++;
  410.  
  411.    if(dns)
  412.       strcpy(Ip2Name,"yes");
  413.  
  414.    if(strcmp(UserIp,"yes") == 0)
  415.       userip++;
  416.  
  417.    if(strcmp(UserIp,"yes") == 0)
  418.       userip++;
  419.  
  420.    if(strlen(MaxElapsed)>1)
  421.       max_elapsed=atol(MaxElapsed);
  422.  
  423.    if(strlen(outdir)<1)
  424.       strcpy(outdir,OutputDir);
  425.    strcat(outdir,"/");
  426.  
  427.  
  428.    if(arq[0] == '\0')
  429.       strcpy(arq,AccessLog);
  430.  
  431.    if(uagent[0] == '\0')
  432.       strcpy(uagent,UserAgentLog);
  433.  
  434.    if(tmp[0] == '\0')
  435.      strcpy(tmp,TempDir);
  436.     else
  437.      strcpy(TempDir,tmp);
  438.  
  439.    if(df[0] == '\0')
  440.       strcpy(df,DateFormat);
  441.     else
  442.       strcpy(DateFormat,df);
  443.  
  444.    if(df[0] == '\0') {
  445.       strcpy(df,"u");
  446.       strcpy(DateFormat,"u");
  447.    }
  448.  
  449.    if(strlen(email)<1){
  450.       if(strlen(OutputEmail)>0)
  451.          strcpy(email,OutputEmail);
  452.    }
  453.  
  454.    strcpy(tmp2,tmp);
  455.    strcpy(tmp4,tmp);
  456.    strcpy(tmp5,tmp);
  457.    strcpy(tmp6,tmp);
  458.  
  459.    if(strlen(email) > 0) {
  460.       sprintf(wtemp2, MKDIR" -p %s/sarg_tmp",tmp2);
  461.       system(wtemp2);
  462.       strcat(tmp2,"/sarg_tmp");
  463.       strcpy(outdir,tmp2);
  464.       strcat(outdir,"/");
  465.     }
  466.  
  467.    strcat(tmp2,"/sarg.log");
  468.  
  469.    strcpy(tmp3,tmp2);
  470.    strcat(tmp3,".unsort");
  471.    strcat(tmp4,"/denied.log.unsort");
  472.    strcat(tmp5,"/denied.log");
  473.    strcat(tmp6,"/authfail.log.unsort");
  474.  
  475.    if(debug) {
  476.       fprintf(stderr, "SARG: %s:\nSARG:\n",text[22]);
  477.       fprintf(stderr, "SARG: %35s (-a) = %s\n",text[23],addr);
  478.       fprintf(stderr, "SARG: %35s (-b) = %s\n",text[71],uagent);
  479.       fprintf(stderr, "SARG: %35s (-c) = %s\n",text[69],hexclude);
  480.       fprintf(stderr, "SARG: %35s (-d) = %s\n",text[24],date);
  481.       fprintf(stderr, "SARG: %35s (-e) = %s\n",text[41],email);
  482.       fprintf(stderr, "SARG: %35s (-f) = %s\n",text[70],ConfigFile);
  483.       if(strcmp(df,"e") == 0)
  484.          fprintf(stderr, "SARG: %35s (-g) = %s (dd/mm/yyyy)\n",text[25],text[26]);
  485.       if(strcmp(df,"u") == 0)
  486.          fprintf(stderr, "SARG: %35s (-g) = %s (mm/dd/yyyy)\n",text[25],text[27]);
  487.       if(strcmp(df,"w") == 0)
  488.          fprintf(stderr, "SARG: %35s (-g) = %s (yyyy/ww)\n",text[25],text[85]);
  489.       if(iprel)
  490.          fprintf(stderr, "SARG: %35s (-i) = %s\n",text[28],text[1]);
  491.        else
  492.          fprintf(stderr, "SARG: %35s (-i) = %s\n",text[28],text[2]);
  493.       fprintf(stderr, "SARG: %35s (-l) = %s\n",text[37],arq);
  494.       if(strcmp(Ip2Name,"yes") == 0)
  495.          fprintf(stderr, "SARG: %35s (-n) = %s\n",text[65],text[1]);
  496.        else
  497.          fprintf(stderr, "SARG: %35s (-n) = %s\n",text[65],text[2]);
  498.       fprintf(stderr, "SARG: %35s (-o) = %s\n",text[38],outdir);
  499.       if(strcmp(UserIp,"yes") == 0)
  500.          fprintf(stderr, "SARG: %35s (-p) = %s\n",text[29],text[1]);
  501.        else
  502.          fprintf(stderr, "SARG: %35s (-p) = %s\n",text[29],text[2]);
  503.       fprintf(stderr, "SARG: %35s (-s) = %s\n",text[30],site);
  504.       fprintf(stderr, "SARG: %35s (-t) = %s\n",text[31],hm);
  505.       fprintf(stderr, "SARG: %35s (-u) = %s\n",text[32],us);
  506.       fprintf(stderr, "SARG: %35s (-w) = %s\n",text[34],tmp);
  507.       if(debug)
  508.          fprintf(stderr, "SARG: %35s (-x) = %s\n",text[35],text[1]);
  509.        else
  510.          fprintf(stderr, "SARG: %35s (-x) = %s\n",text[35],text[2]);
  511.       if(debugz)
  512.          fprintf(stderr, "SARG: %35s (-z) = %s\n",text[36],text[1]);
  513.        else
  514.          fprintf(stderr, "SARG: %35s (-z) = %s\n",text[36],text[2]);
  515.       fprintf(stderr, "SARG:\n");
  516.    }
  517.  
  518.    if(debugm) {
  519.       printf("%s:\nSARG:\n",text[22]);
  520.       printf("%35s (-a) = %s\n",text[23],addr);
  521.       printf("%35s (-b) = %s\n",text[71],uagent);
  522.       printf("%35s (-c) = %s\n",text[69],hexclude);
  523.       printf("%35s (-d) = %s\n",text[24],date);
  524.       printf("%35s (-e) = %s\n",text[41],email);
  525.       printf("%35s (-f) = %s\n",text[70],ConfigFile);
  526.       if(strcmp(df,"e") == 0)
  527.          printf("%35s (-g) = %s (dd/mm/yyyy)\n",text[25],text[26]);
  528.       if(strcmp(df,"u") == 0)
  529.          printf("%35s (-g) = %s (mm/dd/yyyy)\n",text[25],text[27]);
  530.       if(strcmp(df,"w") == 0)
  531.          printf("%35s (-g) = %s (yyyy/ww)\n",text[25],text[85]);
  532.       if(iprel)
  533.          printf("%35s (-i) = %s\n",text[28],text[1]);
  534.        else
  535.          printf("%35s (-i) = %s\n",text[28],text[2]);
  536.       printf("%35s (-l) = %s\n",text[37],arq);
  537.       if(strcmp(Ip2Name,"yes") == 0)
  538.          printf("%35s (-n) = %s\n",text[65],text[1]);
  539.        else
  540.          printf("%35s (-n) = %s\n",text[65],text[2]);
  541.       printf("%35s (-o) = %s\n",text[38],outdir);
  542.       if(strcmp(UserIp,"yes") == 0)
  543.          printf("%35s (-p) = %s\n",text[29],text[1]);
  544.        else
  545.          printf("%35s (-p) = %s\n",text[29],text[2]);
  546.       printf("%35s (-s) = %s\n",text[30],site);
  547.       printf("%35s (-t) = %s\n",text[31],hm);
  548.       printf("%35s (-u) = %s\n",text[32],us);
  549.       printf("%35s (-w) = %s\n",text[34],tmp);
  550.       if(debug)
  551.          printf("%35s (-x) = %s\n",text[35],text[1]);
  552.        else
  553.          printf("%35s (-x) = %s\n",text[35],text[2]);
  554.       if(debugz)
  555.          printf("%35s (-z) = %s\n",text[36],text[1]);
  556.        else
  557.          printf("%35s (-z) = %s\n",text[36],text[2]);
  558.       printf("sarg %s: %s\n",text[73],VERSION);
  559.       printf("Language=%s\n\n",text[3]);
  560.    }
  561.  
  562.    if(debug){
  563.       sprintf(msg,"sarg %s: %s",text[73],VERSION);
  564.       debuga(msg);
  565.    }
  566.  
  567.    if(UserTabFile[0] != '\0') {
  568.       if(debug){
  569.          sprintf(msg,"%s: %s",text[86],UserTabFile);
  570.          debuga(msg);
  571.       }
  572.       if((fp_usr=fopen(UserTabFile,"r"))==NULL) {
  573.         fprintf(stderr, "%s: (log) %s: %s\n",argv[0],text[45],UserTabFile);
  574.         exit(1);
  575.       }
  576.       nreg = lseek(fileno(fp_usr), 0, SEEK_END);
  577.       lseek(fileno(fp_usr), 0, 0);
  578.       if((userfile=(char *) malloc(nreg+100))==NULL){
  579.          fprintf(stderr, "%s ERROR: %s",argv[0],text[87]);
  580.          exit(1);
  581.       }
  582.       bzero(userfile,nreg+100);
  583.       strncat(userfile,":",1);
  584.       z1=0;
  585.       z2=1;
  586.       while(fgets(buf,MAXLEN,fp_usr)!=NULL){
  587.         buf[strlen(buf)-1]='\0';
  588.         if(strstr(buf,"\r") != 0)
  589.            buf[strlen(buf)-1]='\0';
  590.         getword(bufy,buf,' ');
  591.         for(z1=0; z1<=strlen(bufy); z1++) {
  592.            userfile[z2]=bufy[z1];
  593.            z2++;
  594.         }
  595.         strncat(userfile,":",1);
  596.         for(z1=0; z1<=strlen(buf); z1++) {
  597.            userfile[z2]=buf[z1];
  598.            z2++;
  599.         }
  600.         strncat(userfile,":",1);
  601.       }
  602.       fclose(fp_usr);
  603.    }
  604.  
  605.    if((fp_ou=fopen(tmp3,"w"))==NULL) {
  606.      fprintf(stderr, "%s: (log) %s: %s\n",argv[0],text[9],tmp3);
  607.      exit(1);
  608.    }
  609.  
  610.    while(narq--) {
  611.       strcpy(arq,warq[iarq]);
  612.       iarq++;  
  613.  
  614.    decomp(arq,zip);
  615.    if(debug) {
  616.       sprintf(msg, "%s: %s",text[7],arq);
  617.       debuga(msg);
  618.    }
  619.  
  620.    if((fp_in=fopen(arq,"r"))==NULL) {
  621.      fprintf(stderr, "%s: (log) %s: %s\n",argv[0],text[8],arq);
  622.      exit(1);
  623.    }
  624.  
  625.    if(strstr(ReportType,"denied") != 0) {
  626.       if((fp_denied=fopen(tmp4,"w"))==NULL) {
  627.          fprintf(stderr, "%s: (log) %s: %s\n",argv[0],text[45],tmp4);
  628.          exit(1);
  629.       }
  630.    }
  631.  
  632.    if(DataFile[0]=='\0') {
  633.       if(strstr(ReportType,"denied") != 0 || strstr(ReportType,"auth_failures") != 0) {
  634.          if((fp_authfail=fopen(tmp6,"w"))==NULL) {
  635.             fprintf(stderr, "%s: (log) %s: %s\n",argv[0],text[45],tmp6);
  636.             exit(1);
  637.          }
  638.       }
  639.    }
  640.  
  641.    if(debug) {
  642.       recs1=0;
  643.       while(fgets(bufz,sizeof(bufz),fp_in)!=NULL)
  644.          recs1++;
  645.       lseek(fileno(fp_in), 0, 0);
  646.    }
  647.    
  648.    while(fgets(bufz,sizeof(bufz),fp_in)!=NULL) {
  649.     recs2++;
  650.     if(debug) 
  651.        printf("SARG: Records in file=%d Reading=%d Rest=%d \r",recs1,recs2,recs1-recs2);
  652.         if(!bufz[0]) continue;
  653.         if(strstr(bufz,"HTTP/0.0") != 0) continue;
  654.         if(strstr(bufz,"logfile turned over") != 0) continue;
  655.         if(bufz[0] == ' ') continue;
  656.         if(strlen(bufz) < 58) continue;
  657.  
  658.     // Record only hours usage which is required
  659.     tt = (time_t) strtoul( bufz, NULL, 10 );
  660.     t = localtime( &tt );
  661.  
  662.     if( bsearch( &( t -> tm_wday ), weekdays.list, weekdays.len,
  663.                     sizeof( int ), compar ) == NULL )
  664.       continue;
  665.  
  666.     if( bsearch( &( t -> tm_hour ), hours.list, hours.len,
  667.                     sizeof( int ), compar ) == NULL )
  668.       continue;
  669.  
  670.     // exclude_string
  671.     if(strlen(ExcludeString) > 0) {
  672.        strcpy(warea,bufz);
  673.        strcpy(html,ExcludeString);
  674.        while(strstr(html,":") != 0) {
  675.               getword(val1,html,':');
  676.               if((str=(char *) strstr(warea,val1)) != (char *) NULL )
  677.              continue;;
  678.        }
  679.            if((str=(char *) strstr(warea,html)) != (char *) NULL )
  680.              continue;;
  681.     }
  682.         
  683.         strcpy(bufy,bufz);
  684.         if ((str = strchr(bufz, '\n')) != NULL)
  685.            *str = '\0';          /* strip \n */       
  686.  
  687.         totregsl++;
  688.         common=0;
  689.         if(debugm)
  690.               printf("BUF=%s\n",bufz);
  691.  
  692.     getword(data,bufz,' ');
  693.         if((str=(char *) strstr(data, ".")) != (char *) NULL ) {
  694.            if((str=(char *) strstr(str+1, ".")) != (char *) NULL ) {
  695.           strcpy(ip,data);
  696.           strcpy(elap,"0");
  697.           getword(user,bufz,' ');
  698.           getword(none,bufz,' ');
  699.           getword(data,bufz,']');
  700.           getword(fun,bufz,'"');
  701.           getword(fun,bufz,' ');
  702.           getword(url,bufz,'"');
  703.               getword(code2,bufz,' ');
  704.               getword(code2,bufz,' ');
  705.               getword(tam,bufz,' ');
  706.               strcpy(code,bufz);
  707.  
  708.               if ((str = strchr(code, ':')) != NULL)
  709.                  *str = '/'; 
  710.  
  711.           if(strcmp(tam,"\0") == 0)
  712.              strcpy(tam,"0");
  713.  
  714.           common++;
  715.           common_log=1;
  716.        }
  717.     }
  718.  
  719.     if(!common) {
  720.           getword(elap,bufz,' ');
  721.           while(strcmp(elap,"") == 0)
  722.              getword(elap,bufz,' ');
  723.           getword(ip,bufz,' ');
  724.           getword(code,bufz,' ');
  725.           getword(tam,bufz,' ');
  726.           getword(fun,bufz,' ');
  727.           getword(url,bufz,' ');
  728.           getword(user,bufz,' ');
  729.           squid_log=1;
  730.     }
  731.  
  732.     // include_users
  733.     if(strlen(IncludeUsers) > 0) {
  734.            sprintf(val1,":%s:",user);
  735.            if((str=(char *) strstr(IncludeUsers,val1)) == (char *) NULL )
  736.               continue;
  737.     }
  738.  
  739.         if(excode) {
  740.            if(vercode(code)) {
  741.               totregsx++;
  742.               continue;
  743.            }
  744.         }
  745.  
  746.         if(testvaliduserchar(user))
  747.        continue;
  748.  
  749.         if(strstr(user,"%5c") != 0) {
  750.            getword(w,user,'%');
  751.            strcpy(wuser,user+2);
  752.            sprintf(user,"%s.%s",w,wuser);
  753.         }
  754.  
  755.     z1=0;
  756.     z2=0;
  757.     str=user;
  758.     for(z1=0; z1<=strlen(str); z1++) {
  759.        if(isalnum(str[z1]) || ispunct(str[z1])) {
  760.           if(str[z1]=='/')
  761.              str[z1]='_';
  762.           if(str[z1]=='\\')
  763.              str[z1]='_';
  764.           if(str[z1]==';')
  765.              str[z1]='_';
  766.           user[z2]=str[z1];
  767.           z2++;
  768.        }
  769.     }
  770.  
  771.         strlow(user);
  772.  
  773.         if(strstr(ReportType,"denied") != 0)
  774.            strcpy(urly,url);
  775.  
  776.         if (strchr(url,'/')) {
  777.            getword(w,url,'/');
  778.            getword(w,url,'/');
  779.         }
  780.  
  781.         if(strcmp(LongUrl,"no") == 0) {
  782.            getword(w,url,'/');
  783.            strcpy(url,w);
  784.         }
  785.  
  786.         if(!common) {
  787.            tt=atoi(data);
  788.            t=localtime(&tt);
  789.  
  790.            if(strncmp(df,"u",1) == 0)
  791.           strftime(tbuf, 127, "%Y%b%d", t);
  792.            if(strncmp(df,"e",1) == 0)
  793.           strftime(tbuf, 127, "%d%b%Y", t);
  794.            if(strncmp(df,"w",1) == 0)
  795.           strftime(tbuf, 127, "%Y.%U", t);
  796.  
  797.            strftime(dia, 127, "%d/%m/%Y", t);
  798.            strftime(wdata, 127, "%Y%m%d", t);
  799.           
  800.            idata=atoi(wdata);
  801.  
  802.            if(strncmp(df,"u",1)==0)
  803.               strftime(dia, 127, "%m/%d/%Y", t);
  804.            sprintf(hora,"%02d:%02d:%02d",t->tm_hour,t->tm_min,t->tm_sec);
  805.      } else {
  806.        strcpy(wtemp,data+1);
  807.        getword(data,wtemp,':');
  808.        getword(hora,wtemp,' ');
  809.        getword(dia,data,'/');
  810.        getword(mes,data,'/');
  811.        getword(ano,data,'/');
  812.  
  813.            if(strcmp(df,"u") == 0)
  814.           sprintf(tbuf,"%s%s%s",ano,mes,dia);
  815.            if(strcmp(df,"e") == 0)
  816.           sprintf(tbuf,"%s%s%s",dia,mes,ano);
  817.        builddia(dia,mes,ano,df,wdata);
  818.            idata=atoi(wdata);
  819.     }
  820.  
  821.         if(debugm)
  822.            printf("DATE=%s IDATA=%d DFROM=%d DUNTIL=%d\n",date,idata,dfrom,duntil);
  823.  
  824.         l=1;
  825.         if(strlen(us)>0){
  826.          if(strcmp(user,us)==0)
  827.           l=1;else l=0;
  828.      }
  829.            
  830.         if(l){
  831.            if(strlen(addr)>0){
  832.             if(strcmp(addr,ip)==0)
  833.              l=1;else l=0;
  834.         }
  835.            if(fhost) {
  836.               l=vhexclude(excludefile,ip);
  837.               l=vhexclude(excludefile,url);
  838.               if(!l)
  839.              totregsx++;
  840.            }
  841.         }
  842.  
  843.         if(l){
  844.            if(strlen(date) > 0){
  845.               if(idata >= dfrom && idata <= duntil)
  846.              l=1;else l=0;
  847.         }
  848.         }
  849.         if(l){
  850.            if(strlen(hm)>0){
  851.             if(strncmp(hm,hora,strlen(hm))==0)
  852.              l=1;else l=0;
  853.         }
  854.         }
  855.         if(l){
  856.            if(strlen(site)>0){
  857.             if(strstr(url,site)!=0)
  858.              l=1;else l=0;
  859.         }
  860.         }
  861.  
  862.         if(userip)
  863.            strcpy(user,ip);
  864.  
  865.         if(strcmp(user,"-") == 0 || strcmp(user," ") == 0 || strcmp(user,"") == 0) {
  866.            if(strcmp(RecordsWithoutUser,"ip") == 0)
  867.           strcpy(user,ip);
  868.            if(strcmp(RecordsWithoutUser,"ignore") == 0)
  869.           continue;
  870.            if(strcmp(RecordsWithoutUser,"everybody") == 0)
  871.           strcpy(user,"everybody");
  872.         }
  873.  
  874.         if(puser) {
  875.            sprintf(wuser,":%s:",user);
  876.            if(strstr(userfile, wuser) == 0)
  877.               continue;
  878.         }
  879.         
  880.         if(l) {
  881.            if(fuser) {
  882.               l=vuexclude(excludeuser,user);
  883.               if(!l)
  884.              totregsx++;
  885.            }
  886.         }
  887.  
  888.         if(l) {
  889.            if(userip)
  890.               fixip(user);
  891.         }
  892.  
  893.         if(l&&max_elapsed) {
  894.            if(atol(elap)>max_elapsed) {
  895.               elap[0]='0';
  896.               elap[1]='\0';
  897.         }
  898.         }
  899.  
  900.         if(l) {
  901.        if(strcmp(user,"-") !=0 && strlen(url) > 0 && strcmp(user," ") !=0 && strcmp(user,"") !=0 && strcmp(user,":") !=0){
  902.               if((str=(char *) strstr(bufz, "[SmartFilter:")) != (char *) NULL ) {
  903.                  str[strlen(str)-1]='\0';
  904.                  sprintf(smartfilter,"\"%s\"",str+1);
  905.               } else sprintf(smartfilter,"\"\"");
  906.  
  907.               sprintf(bufz, "%s %s %s %s %s %s %s %s %s\n",dia,hora,user,ip,url,tam,code,elap,smartfilter);
  908.               fputs(bufz,fp_ou);
  909.           totregsg++;
  910.  
  911.               if(strstr(ReportType,"denied") != 0 || strstr(ReportType,"auth_failures") != 0) {
  912.                  if(strstr(code,"DENIED/403") != 0) {
  913.                     sprintf(bufz, "%s %s %s %s %s\n",dia,hora,user,ip,urly);
  914.                     fputs(bufz,fp_denied);
  915.                     denied_count++;
  916.                  }
  917.                  if(strstr(code,"DENIED/401") != 0 || strstr(code,"DENIED/407") != 0) {
  918.                     sprintf(bufz, "%s %s %s %s %s\n",dia,hora,user,ip,urly);
  919.                     if(fp_authfail)
  920.                        fputs(bufz,fp_authfail);
  921.                     authfail_count++;
  922.                  }
  923.               }
  924.        
  925.               if(!totper){
  926.              totper++;
  927.                  sprintf(periodo,"%s-",tbuf);
  928.                  if(strlen(date)>0)
  929.                     fixper(tbuf, periodo, cduntil);
  930.                  if(debugz){
  931.                     debugaz("tbuf",tbuf);
  932.                     debugaz("periodo",periodo);
  933.                  }
  934.           }
  935.            }
  936.  
  937.            if(debugm){
  938.               printf("IP=\t%s\n",ip);
  939.               printf("USER=\t%s\n",user);
  940.               printf("ELAP=\t%s\n",elap);
  941.               printf("DATE=\t%s\n",dia);
  942.               printf("TIME=\t%s\n",hora);
  943.               printf("FUNC=\t%s\n",fun);
  944.               printf("URL=\t%s\n",url);
  945.               printf("CODE=\t%s\n",code);
  946.               printf("LEN=\t%s\n",tam);
  947.        }
  948.         }
  949.       }
  950.    }
  951.  
  952.    if(debug) {
  953.       printf("\n");
  954.       sprintf(msg, "   %s: %ld, %s: %ld, %s: %ld",text[10],totregsl,text[11],totregsg,text[68],totregsx);
  955.       debuga(msg);
  956.   
  957.       if((common_log) && (squid_log))
  958.          debuga(text[12]);
  959.   
  960.       if((common_log) && (!squid_log)) 
  961.          debuga(text[13]);
  962.  
  963.       if((!common_log) && (squid_log))
  964.          debuga(text[14]);
  965.  
  966.       if((!common_log) && (!squid_log)) {
  967.          if(!totregsg){
  968.             fprintf(stderr, "SARG: %s\n",text[16]);
  969.             fprintf(stderr, "SARG: %s\n",text[21]);
  970.      } else fprintf(stderr, "---->SARG: %s\n",text[15]);
  971.          bzero(msg,sizeof(msg));
  972.          fclose(fp_in);
  973.          fclose(fp_ou);
  974.          if(fp_denied)
  975.             fclose(fp_denied);
  976.          if(fp_authfail)
  977.             fclose(fp_authfail);
  978.          if(*tmp4)
  979.             unlink(tmp4);
  980.          if(*tmp6)
  981.             unlink(tmp6);
  982.          unlink(tmp3);
  983.          exit(0);
  984.       }
  985.    }
  986.  
  987.    if(!totregsg){
  988.       fprintf(stderr, "SARG: %s\n",text[16]);
  989.       fprintf(stderr, "SARG: %s\n",text[21]);
  990.       fclose(fp_in);
  991.       fclose(fp_ou);
  992.       if(fp_denied)
  993.          fclose(fp_denied);
  994.       if(fp_authfail)
  995.          fclose(fp_authfail);
  996.       exit(0);
  997.    }
  998.  
  999.    if(date[0] == '\0')
  1000.       strcat(periodo,tbuf);
  1001.  
  1002.    if(debugz){
  1003.       debugaz("data",dia);
  1004.       debugaz("tbuf",tbuf);
  1005.       debugaz("periodo",periodo);
  1006.    }
  1007.  
  1008.    if(debug){
  1009.      sprintf(msg, "%s: %s",text[17],periodo);
  1010.      debuga(msg);
  1011.    }
  1012.  
  1013.    fclose(fp_in);
  1014.    fclose(fp_ou);
  1015.    if(fp_denied)
  1016.       fclose(fp_denied);
  1017.    if(fp_authfail)
  1018.       fclose(fp_authfail);
  1019.  
  1020.    if(debug){
  1021.      sprintf(msg,"Sort: %s %s %s",text[18],tmp,text[19]);
  1022.      debuga(msg);
  1023.      sprintf(msg, "%s: %s",text[20],tmp2);
  1024.      debuga(msg);
  1025.    }
  1026.  
  1027.    sprintf(csort, SORT" -T %s -k 3,3 -k 5,5 -o %s %s", tmp, tmp2, tmp3);
  1028.    system(csort);
  1029.    unlink(tmp3);
  1030.  
  1031.    if(strstr(ReportType,"denied") != 0) {
  1032.       sprintf(csort, SORT" -T %s -k 3,3 -k 5,5 -o %s %s", tmp, tmp5, tmp4);
  1033.       system(csort);
  1034.       unlink(tmp4);
  1035.    }
  1036.  
  1037.    if(strlen(DataFile) > 0)
  1038.       data_file(tmp2,debug,periodo,debugz,iprel,outdir,addr,site,us,userip,email,wtemp2,BgColor,TxColor, TxBgColor,TiColor,LogoImage,LogoText,LogoTextColor,Width,Height,Title,BgImage,FontFace,HeaderColor,HeaderBgColor,FontSize,TempDir,Ip2Name,TopuserSortField,UserSortField,TopuserSortOrder,UserSortOrder,uagent,DateFormat,indexonly,PerUserLimitFile,PerUserLimit);
  1039.    else
  1040.       gerarel(tmp2,debug,periodo,debugz,iprel,outdir,addr,site,us,userip,email,wtemp2,BgColor,TxColor, TxBgColor,TiColor,LogoImage,LogoText,LogoTextColor,Width,Height,Title,BgImage,FontFace,HeaderColor,HeaderBgColor,FontSize,TempDir,Ip2Name,TopuserSortField,UserSortField,TopuserSortOrder,UserSortOrder,uagent,DateFormat,indexonly,PerUserLimitFile,PerUserLimit);
  1041.  
  1042.    unlink(tmp2);
  1043.    if(strstr(ReportType,"denied") != 0)
  1044.       unlink(tmp5);
  1045.  
  1046.    if(strlen(zip) > 0)
  1047.       recomp(arq, zip);
  1048.  
  1049.    if(debug)
  1050.       debuga(text[21]);
  1051.  
  1052.    exit(0);
  1053.  
  1054. }
  1055.  
  1056.  
  1057. void getusers(char *pwdfile, int debug)
  1058. {
  1059.  
  1060.    FILE *fp_usr;
  1061.    char buf[255];
  1062.    char Msg[255];
  1063.    char user[255];
  1064.    unsigned long int nreg=0;
  1065.  
  1066.    if(debug) {
  1067.       sprintf(Msg,"%s: %s",text[60],pwdfile);
  1068.       debuga(Msg);
  1069.    }
  1070.  
  1071.    if ((fp_usr = fopen(pwdfile, "r")) == NULL) {
  1072.       fprintf(stderr, "SARG: (getusers) %s: %s\n",text[45],pwdfile);
  1073.       exit(1);
  1074.    }
  1075.  
  1076.    nreg = lseek(fileno(fp_usr), (off_t)0, SEEK_END);
  1077.    nreg = nreg+5000; 
  1078.    lseek(fileno(fp_usr), (off_t)0, 0);
  1079.  
  1080.    if((userfile=(char *) malloc(nreg))==NULL){
  1081.       fprintf(stderr, "SARG: %s (%ld):\n",text[59],nreg);
  1082.       exit(1);
  1083.    }
  1084.  
  1085.    bzero(userfile,nreg);
  1086.    sprintf(userfile,":");
  1087.  
  1088.    while(fgets(buf,300,fp_usr)!=NULL){
  1089.      getword(user,buf,':');
  1090.      strncat(userfile,user,strlen(user));
  1091.      strncat(userfile,":",1);
  1092.    }
  1093.  
  1094.    fclose(fp_usr);
  1095.  
  1096.    return;
  1097. }
  1098.  
  1099.  
  1100. void gethexclude(char *hexfile, int debug)
  1101. {
  1102.  
  1103.    FILE *fp_ex;
  1104.    char buf[255];
  1105.    char Msg[255];
  1106.    unsigned long int nreg=0;
  1107.  
  1108.    if(debug) {
  1109.       sprintf(Msg,"%s: %s",text[67],hexfile);
  1110.       debuga(Msg);
  1111.    }
  1112.  
  1113.    if ((fp_ex = fopen(hexfile, "r")) == NULL) {
  1114.       fprintf(stderr, "SARG: (gethexclude) %s: %s\n",text[45],hexfile);
  1115.       exit(1);
  1116.    }
  1117.  
  1118.    nreg = lseek(fileno(fp_ex), (off_t)0, SEEK_END);
  1119.    lseek(fileno(fp_ex), (off_t)0, 0);
  1120.  
  1121.    if((excludefile=(char *) malloc(nreg+11))==NULL){
  1122.       fprintf(stderr, "SARG: %s (%ld):\n",text[59],nreg);
  1123.       exit(1);
  1124.    }
  1125.  
  1126.    bzero(excludefile,nreg+11);
  1127.  
  1128.    while(fgets(buf,300,fp_ex)!=NULL){
  1129.      if(strstr(buf,"#") != 0)
  1130.         continue;
  1131.      buf[strlen(buf)-1]='\0';
  1132.      strcat(excludefile,buf);
  1133.      strcat(excludefile," ");
  1134.    }
  1135.  
  1136.    strcat(excludefile,"*FIM* ");
  1137.  
  1138.    fclose(fp_ex);
  1139.  
  1140.    return;
  1141. }
  1142.  
  1143.  
  1144. void getuexclude(char *uexfile, int debug)
  1145. {
  1146.  
  1147.    FILE *fp_ex;
  1148.    char buf[255];
  1149.    char Msg[255];
  1150.    unsigned long int nreg=0;
  1151.  
  1152.    if(debug) {
  1153.       sprintf(Msg,"%s: %s",text[67],uexfile);
  1154.       debuga(Msg);
  1155.    }
  1156.  
  1157.    if ((fp_ex = fopen(uexfile, "r")) == NULL) {
  1158.       fprintf(stderr, "SARG: (gethexclude) %s: %s\n",text[45],uexfile);
  1159.       exit(1);
  1160.    }
  1161.  
  1162.    nreg = lseek(fileno(fp_ex), (off_t)0, SEEK_END);
  1163.    lseek(fileno(fp_ex), (off_t)0, 0);
  1164.  
  1165.    if((excludeuser=(char *) malloc(nreg+11))==NULL){
  1166.       fprintf(stderr, "SARG: %s (%ld):\n",text[59],nreg);
  1167.       exit(1);
  1168.    }
  1169.  
  1170.    bzero(excludeuser,nreg+11);
  1171.  
  1172.    while(fgets(buf,300,fp_ex)!=NULL){
  1173.      if(strstr(buf,"#") != 0)
  1174.         continue;
  1175.      buf[strlen(buf)-1]='\0';
  1176.      strcat(excludeuser,buf);
  1177.      strcat(excludeuser," ");
  1178.    }
  1179.  
  1180.    strcat(excludeuser,"*FIM* ");
  1181.  
  1182.    fclose(fp_ex);
  1183.  
  1184.    return;
  1185. }
  1186.