home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / analg211.zip / analform.c < prev    next >
C/C++ Source or Header  |  1997-09-08  |  17KB  |  720 lines

  1. /* analform.c 2.1 -- parse the output of the analog form interface */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7.  
  8. #ifdef _WIN32  /* so it can pick it up automatically */
  9. #undef WIN32
  10. #define WIN32
  11. #endif
  12. #ifdef WIN32
  13. #define popen _popen
  14. #define pclose _pclose
  15. #endif
  16. extern FILE *popen();  /* to stop gcc complaining */
  17. extern int pclose();
  18. extern int putenv();
  19.  
  20. /* You must change the next line to indicate where the analog program lives */
  21.  
  22. #define COMMAND "analog"
  23. #define MAXARGLENGTH (2048)   /* should be plenty */
  24. #define OK (0)
  25. #define ERR (-1)
  26. #define STRLENGTH (64)
  27.  
  28. typedef int flag;
  29.  
  30. int unhttp(char *url)     /* converts back all http special characters */
  31. {
  32.   char *tempp;
  33.   char tempstr[MAXARGLENGTH];
  34.   int i;
  35.  
  36.   /* firstly, change +'s into spaces */
  37.  
  38.   for (i = strlen(url) - 1; i >= 0; i--) {
  39.     if (url[i] == '+')
  40.       url[i] = ' ';
  41.   }
  42.  
  43.   /* secondly change %7E to ~, etc. */
  44.  
  45.   tempp = url;
  46.   while ((tempp = strchr(tempp, '%')) != NULL) {
  47.     sscanf(tempp + 1, "%2x", &i);
  48.     if (i >= 0x20 && i < 0x7F) {
  49.       *tempp = i;
  50.       strcpy(tempstr, tempp + 3);
  51.       strcpy(tempp + 1, tempstr);
  52.       /* strcpy(tempp + 1, tempp + 3) may not be safe on all machines
  53.      (overlapping arguments) */
  54.     }
  55.     tempp++;
  56.   }
  57.  
  58.   /* Finally, check no unsafe characters. */
  59.  
  60.   for (tempp = url; *tempp != '\0'; tempp++) {
  61.     if (*tempp == ';' || *tempp == '\n' || *tempp == '\r' || *tempp == '`' ||
  62.     *tempp == '|' || *tempp == '<' || *tempp == '>')
  63.       return(ERR);
  64.   }
  65.  
  66.   return(OK);
  67. }
  68.  
  69. void genopts(FILE *thepipe, char name[9], int sortby, char *astr, char *cstr)
  70. {
  71.   if (sortby <= 4 && sortby >= 0) {
  72.     fprintf(thepipe, "%sSORTBY ", name);
  73.     if (sortby == 4)
  74.       fprintf(thepipe, "PAGES\n");
  75.     else if (sortby == 3)
  76.       fprintf(thepipe, "RANDOM\n");
  77.     else if (sortby == 2)
  78.       fprintf(thepipe, "ALPHABETICAL\n");
  79.     else if (sortby == 1)
  80.       fprintf(thepipe, "BYTES\n");
  81.     else if (sortby == 0)
  82.       fprintf(thepipe, "REQUESTS\n");
  83.     if (sortby == 1) {
  84.       if (cstr[0] != '\0')
  85.     fprintf(thepipe, "%sMINBYTES %s\n", name, cstr);
  86.     }
  87.     else if (sortby == 4) {
  88.       if (astr[0] != '\0')
  89.     fprintf(thepipe, "%sMINPAGES %s\n", name, astr);
  90.     }
  91.     else {
  92.       if (astr[0] != '\0')
  93.     fprintf(thepipe, "%sMINREQS %s\n", name, astr);
  94.     }
  95.   }
  96. }
  97.  
  98. int main()
  99. {
  100.   extern void exit();
  101.  
  102.   /* the input */
  103.   char *argstring;
  104.   char *nextarg;
  105.   char *nextval;
  106.  
  107.   /* the variables that can be read in */
  108.   int xq = 2, mq = 2, Wq = 2, dq = 2, Dq = 2, hq = 2, oq = 2, Sq = 2, tq = 2;
  109.   int iq = 2, rq = 2, fq = 2, bq = 2, Bq = 2, cq = 2, eq = 2, Hq = 2, Vq = 0;
  110.   char mg = '\0', Wg = '\0', dg = '\0', Dg = '\0', hg = '\0', Hg = '\0';
  111.   int os = 6, Ss = 6, is = 6, rs = 6, fs = 6, Bs = 6, bs = 6, ts = 6;
  112.   int ou = 0, ch = 3, gr = 2;
  113.   char oa[STRLENGTH], Sa[STRLENGTH], ia[STRLENGTH], ra[STRLENGTH];
  114.   char ta[STRLENGTH], fa[STRLENGTH], Ba[STRLENGTH], ba[STRLENGTH];
  115.   char oc[STRLENGTH], Sc[STRLENGTH], ic[STRLENGTH], rc[STRLENGTH];
  116.   char tc[STRLENGTH], fc[STRLENGTH], Bc[STRLENGTH], bc[STRLENGTH];
  117.   int dirlevel = 0;
  118.   char reqtype = 'd', reqlinks = 'd';
  119.   char *from = NULL, *to = NULL;
  120.   char *fonly = NULL, *fign = NULL;
  121.   char *honly = NULL, *hign = NULL;
  122.   char *org = NULL, *home = NULL;
  123.   char *logfile = NULL, *reflog = NULL, *browlog = NULL;
  124.   char *errlog = NULL, *cachefile = NULL, *cg = NULL, *cm = NULL;
  125.   char *TZ = NULL;
  126.   char TZenv[STRLENGTH];
  127.   int wa = 1;
  128.  
  129.   FILE *thepipe;
  130.   int ret;
  131.  
  132.   oa[0] = '\0';
  133.   Sa[0] = '\0';
  134.   ia[0] = '\0';
  135.   ra[0] = '\0';
  136.   fa[0] = '\0';
  137.   ba[0] = '\0';
  138.   Ba[0] = '\0';
  139.   oc[0] = '\0';
  140.   Sc[0] = '\0';
  141.   ic[0] = '\0';
  142.   rc[0] = '\0';
  143.   fc[0] = '\0';
  144.   bc[0] = '\0';
  145.   Bc[0] = '\0';
  146.  
  147.   if ((argstring = getenv("QUERY_STRING")) == NULL) {
  148.     printf("Content-type: text/plain\n\n");
  149.     printf("Error: cannot find environment variable QUERY_STRING\n");
  150.     exit(ERR);
  151.   }
  152.  
  153.   if (strlen(argstring) >= MAXARGLENGTH - 1) {
  154.     fprintf(stderr, "Analog form interface: Security warning on request from %s (%s): QUERY_STRING too long\n",
  155.      (getenv("REMOTE_HOST") == NULL)?"unknown host":getenv("REMOTE_HOST"),
  156.      (getenv("REMOTE_ADDR") == NULL)?"unknown address":getenv("REMOTE_ADDR"));
  157.     printf("Content-type: text/plain\n\n");
  158.     printf("Error in QUERY_STRING\n");
  159.     exit(ERR);
  160.   }
  161.  
  162.   ret = unhttp(argstring);
  163.   if (ret == ERR) {      /* suspicious characters in argstring */
  164.     fprintf(stderr, "Analog form interface: Security warning on request from %s (%s): QUERY_STRING contains unusual characters\n",
  165.      (getenv("REMOTE_HOST") == NULL)?"unknown host":getenv("REMOTE_HOST"),
  166.      (getenv("REMOTE_ADDR") == NULL)?"unknown address":getenv("REMOTE_ADDR"));
  167.     printf("Content-type: text/plain\n\n");
  168.     printf("Error in QUERY_STRING\n");
  169.     exit(ERR);
  170.   }
  171.  
  172.   nextarg = strtok(argstring, "&");
  173.  
  174.   while (nextarg != NULL) {
  175.     nextval = strchr(nextarg, '=') + 1;
  176.     if (nextval[0] != '\0') {
  177.       switch(nextarg[0]) {
  178.       case 'b':
  179.     switch(nextarg[1]) {
  180.     case 'a':
  181.       strncpy(ba, nextval, STRLENGTH - 1);
  182.       break;
  183.     case 'b':
  184.       strcpy(ba, "-");
  185.       strncat(ba, nextval, STRLENGTH - 2);
  186.       break;
  187.     case 'c':
  188.       strncpy(bc, nextval, STRLENGTH - 1);
  189.       break;
  190.     case 'd':
  191.       strcpy(bc, "-");
  192.       strncat(bc, nextval, STRLENGTH - 2);
  193.       break;
  194.     case 'q':
  195.       bq = atoi(nextval);
  196.       break;
  197.     case 's':
  198.       bs = atoi(nextval);
  199.       break;
  200.     }
  201.     break;
  202.       case 'B':
  203.     switch(nextarg[1]) {
  204.     case 'a':
  205.       strncpy(Ba, nextval, STRLENGTH - 1);
  206.       break;
  207.     case 'b':
  208.       strcpy(Ba, "-");
  209.       strncat(Ba, nextval, STRLENGTH - 2);
  210.       break;
  211.     case 'c':
  212.       strncpy(Bc, nextval, STRLENGTH - 1);
  213.       break;
  214.     case 'd':
  215.       strcpy(Bc, "-");
  216.       strncat(Bc, nextval, STRLENGTH - 2);
  217.       break;
  218.     case 'q':
  219.       Bq = atoi(nextval);
  220.       break;
  221.     case 's':
  222.       Bs = atoi(nextval);
  223.       break;
  224.     }
  225.     break;
  226.       case 'c':
  227.     switch (nextarg[1]) {
  228.     case 'g':
  229.       cg = nextval;
  230.       break;
  231.     case 'h':
  232.       ch = atoi(nextval);
  233.       break;
  234.     case 'm':
  235.       cm = nextval;
  236.       break;
  237.     case 'q':
  238.       cq = atoi(nextval);
  239.       break;
  240.     }
  241.     break;
  242.       case 'd':
  243.     switch(nextarg[1]) {
  244.     case 'g':
  245.       dg = nextval[0];
  246.       break;
  247.     case 'q':
  248.       dq = atoi(nextval);
  249.       break;
  250.     }
  251.     break;
  252.       case 'D':
  253.     switch(nextarg[1]) {
  254.     case 'g':
  255.       Dg = nextval[0];
  256.       break;
  257.     case 'q':
  258.       Dq = atoi(nextval);
  259.       break;
  260.     }
  261.     break;
  262.       case 'e':
  263.     eq = atoi(nextval);
  264.     break;
  265.       case 'f':
  266.     switch(nextarg[1]) {
  267.     case 'a':
  268.       strncpy(fa, nextval, STRLENGTH - 1);
  269.       break;
  270.     case 'b':
  271.       strcpy(fa, "-");
  272.       strncat(fa, nextval, STRLENGTH - 2);
  273.       break;
  274.     case 'c':
  275.       strncpy(fc, nextval, STRLENGTH - 1);
  276.       break;
  277.     case 'd':
  278.       strcpy(fc, "-");
  279.       strncat(fc, nextval, STRLENGTH - 2);
  280.       break;
  281.     case 'i':
  282.       fign = nextval;
  283.       break;
  284.     case 'q':
  285.       fq = atoi(nextval);
  286.       break;
  287.     case 'r':
  288.       from = nextval;
  289.       break;
  290.     case 's':
  291.       fs = atoi(nextval);
  292.       break;
  293.     case 'y':
  294.       fonly = nextval;
  295.       break;
  296.     }
  297.     break;
  298.       case 'g':
  299.     gr = atoi(nextval);
  300.     break;
  301.       case 'h':
  302.     switch(nextarg[1]) {
  303.     case 'g':
  304.       hg = nextval[0];
  305.       break;
  306.     case 'i':
  307.       hign = nextval;
  308.       break;
  309.     case 'o':
  310.       home = nextval;
  311.       break;
  312.     case 'q':
  313.       hq = atoi(nextval);
  314.       break;
  315.     case 'y':
  316.       honly = nextval;
  317.       break;
  318.     }
  319.     break;
  320.       case 'H':
  321.     switch(nextarg[1]) {
  322.     case 'g':
  323.       Hg = nextval[0];
  324.       break;
  325.     case 'q':
  326.       Hq = atoi(nextval);
  327.       break;
  328.     }
  329.     break;
  330.       case 'i':
  331.     switch(nextarg[1]) {
  332.     case 'a':
  333.       strncpy(ia, nextval, STRLENGTH - 1);
  334.       break;
  335.     case 'b':
  336.       strcpy(ia, "-");
  337.       strncat(ia, nextval, STRLENGTH - 2);
  338.       break;
  339.     case 'c':
  340.       strncpy(ic, nextval, STRLENGTH - 1);
  341.       break;
  342.     case 'd':
  343.       strcpy(ic, "-");
  344.       strncat(ic, nextval, STRLENGTH - 2);
  345.       break;
  346.     case 'e':
  347.       dirlevel = atoi(nextval);
  348.       break;
  349.     case 'q':
  350.       iq = atoi(nextval);
  351.       break;
  352.     case 's':
  353.       is = atoi(nextval);
  354.       break;
  355.     }
  356.     break;
  357.       case 'l':
  358.     switch(nextarg[1]) {
  359.     case 'b':
  360.       browlog = nextval;
  361.       break;
  362.     case 'c':
  363.       cachefile = nextval;
  364.       break;
  365.     case 'e':
  366.       errlog = nextval;
  367.       break;
  368.     case 'f':
  369.       reflog = nextval;
  370.       break;
  371.     case 'o':
  372.       logfile = nextval;
  373.       break;
  374.     }
  375.     break;
  376.       case 'm':
  377.     switch(nextarg[1]) {
  378.     case 'g':
  379.       mg = nextval[0];
  380.       break;
  381.     case 'q':
  382.       mq = atoi(nextval);
  383.       break;
  384.     }
  385.     break;
  386.       case 'o':
  387.     switch(nextarg[1]) {
  388.     case 'a':
  389.       strncpy(oa, nextval, STRLENGTH - 1);
  390.       break;
  391.     case 'b':
  392.       strcpy(oa, "-");
  393.       strncat(oa, nextval, STRLENGTH - 2);
  394.       break;
  395.     case 'c':
  396.       strncpy(oc, nextval, STRLENGTH - 1);
  397.       break;
  398.     case 'd':
  399.       strcpy(oc, "-");
  400.       strncat(oc, nextval, STRLENGTH - 2);
  401.       break;
  402.     case 'q':
  403.       oq = atoi(nextval);
  404.       break;
  405.     case 'r':
  406.       org = nextval;
  407.       break;
  408.     case 's':
  409.       os = atoi(nextval);
  410.       break;
  411.     case 'u':
  412.       ou = atoi(nextval);
  413.       break;
  414.     }
  415.     break;
  416.       case 'r':
  417.     switch(nextarg[1]) {
  418.     case 'a':
  419.       strncpy(ra, nextval, STRLENGTH - 1);
  420.       break;
  421.     case 'b':
  422.       strcpy(ra, "-");
  423.       strncat(ra, nextval, STRLENGTH - 2);
  424.       break;
  425.     case 'c':
  426.       strncpy(rc, nextval, STRLENGTH - 1);
  427.       break;
  428.     case 'd':
  429.       strcpy(rc, "-");
  430.       strncat(rc, nextval, STRLENGTH - 2);
  431.       break;
  432.     case 'l':
  433.       reqlinks = nextval[0];
  434.       break;
  435.     case 'q':
  436.       rq = atoi(nextval);
  437.       break;
  438.     case 's':
  439.       rs = atoi(nextval);
  440.       break;
  441.     case 't':
  442.       reqtype = nextval[0];
  443.       break;
  444.     }
  445.     break;
  446.       case 'S':
  447.     switch(nextarg[1]) {
  448.     case 'a':
  449.       strncpy(Sa, nextval, STRLENGTH - 1);
  450.       break;
  451.     case 'b':
  452.       strcpy(Sa, "-");
  453.       strncat(Sa, nextval, STRLENGTH - 2);
  454.       break;
  455.     case 'c':
  456.       strncpy(Sc, nextval, STRLENGTH - 1);
  457.       break;
  458.     case 'd':
  459.       strcpy(Sc, "-");
  460.       strncat(Sc, nextval, STRLENGTH - 2);
  461.       break;
  462.     case 'q':
  463.       Sq = atoi(nextval);
  464.       break;
  465.     case 's':
  466.       Ss = atoi(nextval);
  467.       break;
  468.     }
  469.     break;
  470.       case 't':
  471.     switch(nextarg[1]) {
  472.     case 'a':
  473.       strncpy(ta, nextval, STRLENGTH - 1);
  474.       break;
  475.     case 'b':
  476.       strcpy(ta, "-");
  477.       strncat(ta, nextval, STRLENGTH - 2);
  478.       break;
  479.     case 'c':
  480.       strncpy(tc, nextval, STRLENGTH - 1);
  481.       break;
  482.     case 'd':
  483.       strcpy(tc, "-");
  484.       strncat(tc, nextval, STRLENGTH - 2);
  485.       break;
  486.     case 'o':
  487.       to = nextval;
  488.       break;
  489.     case 'q':
  490.       tq = atoi(nextval);
  491.       break;
  492.     case 's':
  493.       ts = atoi(nextval);
  494.       break;
  495.     }
  496.     break;
  497.       case 'T':
  498.     TZ = nextval;
  499.     break;
  500.       case 'V':
  501.     Vq = atoi(nextval);
  502.     break;
  503.       case 'w':
  504.     wa = atoi(nextval);
  505.     break;
  506.       case 'W':
  507.     switch(nextarg[1]) {
  508.     case 'g':
  509.       Wg = nextval[0];
  510.       break;
  511.     case 'q':
  512.       Wq = atoi(nextval);
  513.       break;
  514.     }
  515.     break;
  516.       case 'x':
  517.     xq = 1;
  518.     break;
  519.       }
  520.     }
  521.     nextarg = strtok((char *)NULL, "&");
  522.   }
  523.  
  524.   /* OK, so we've read everything in, now send it to the program */
  525.   
  526.   if (TZ != NULL) {
  527.     strcpy(TZenv, "TZ=");
  528.     strcat(TZenv, TZ);
  529.     putenv(TZenv);
  530.   }
  531.  
  532.   if (Vq)
  533.     thepipe = stdout;
  534.  
  535.   if (!Vq && (thepipe = popen(COMMAND " +g-", "w")) == NULL) {
  536.     printf("Content-type: text/plain\n\n");
  537.     printf("Error: cannot start analog program at %s\n", COMMAND);
  538.   }
  539.  
  540.   else {
  541.     printf("Content-type: text/%s\n\n", (Vq || ou)?"plain":"html");
  542.     fflush(stdout);
  543.  
  544.     fprintf(thepipe, "OUTFILE stdout\n");
  545.  
  546.     if (cg != NULL)
  547.       fprintf(thepipe, "CONFIGFILE %s\n", cg);
  548.     if (xq < 2)
  549.       fprintf(thepipe, "GENERAL %s\n", xq?"ON":"OFF");
  550.     if (mq < 2)
  551.       fprintf(thepipe, "MONTHLY %s\n", mq?"ON":"OFF");
  552.     if (Wq < 2)
  553.       fprintf(thepipe, "WEEKLY %s\n", Wq?"ON":"OFF");
  554.     if (dq < 2)
  555.       fprintf(thepipe, "DAILY %s\n", dq?"ON":"OFF");
  556.     if (Dq < 2)
  557.       fprintf(thepipe, "FULLDAILY %s\n", Dq?"ON":"OFF");
  558.     if (hq < 2)
  559.       fprintf(thepipe, "HOURLY %s\n", hq?"ON":"OFF");
  560.     if (Hq < 2)
  561.       fprintf(thepipe, "FULLHOURLY %s\n", Hq?"ON":"OFF");
  562.     if (oq < 2)
  563.       fprintf(thepipe, "DOMAIN %s\n", oq?"ON":"OFF");
  564.     if (Sq < 2)
  565.       fprintf(thepipe, "FULLHOSTS %s\n", Sq?"ON":"OFF");
  566.     if (iq < 2)
  567.       fprintf(thepipe, "DIRECTORY %s\n", iq?"ON":"OFF");
  568.     if (rq < 2)
  569.       fprintf(thepipe, "REQUEST %s\n", rq?"ON":"OFF");
  570.     if (bq < 2)
  571.       fprintf(thepipe, "BROWSER %s\n", bq?"ON":"OFF");
  572.     if (Bq < 2)
  573.       fprintf(thepipe, "FULLBROWSER %s\n", Bq?"ON":"OFF");
  574.     if (cq < 2)
  575.       fprintf(thepipe, "STATUS %s\n", cq?"ON":"OFF");
  576.     if (eq < 2)
  577.       fprintf(thepipe, "ERROR %s\n", eq?"ON":"OFF");
  578.     if (fq < 2)
  579.       fprintf(thepipe, "REFERRER %s\n", fq?"ON":"OFF");
  580.     if (tq < 2)
  581.       fprintf(thepipe, "FILETYPE %s\n", tq?"ON":"OFF");
  582.     if (ch < 3)
  583.       fprintf(thepipe, "COUNTHOSTS %s\n",
  584.           (ch == 2)?"APPROX":(ch?"ON":"OFF"));
  585.     if (gr < 2)
  586.       fprintf(thepipe, "GRAPHICAL %s\n", gr?"ON":"OFF");
  587.  
  588.     if (mq && mg != '\0')
  589.       fprintf(thepipe, "MONTHGRAPH %c", mg);
  590.     if (Wq && Wg != '\0')
  591.       fprintf(thepipe, "WEEKGRAPH %c", Wg);
  592.     if (hq && hg != '\0')
  593.       fprintf(thepipe, "HOURGRAPH %c", hg);
  594.     if (Hq && Hg != '\0')
  595.       fprintf(thepipe, "FULLHOURGRAPH %c", Hg);
  596.     if (dq && dg != '\0')
  597.       fprintf(thepipe, "DAYGRAPH %c", dg);
  598.     if (Dq && Dg != '\0')
  599.       fprintf(thepipe, "FULLDAYGRAPH %c", Dg);
  600.  
  601.     if (oq)
  602.       genopts(thepipe, "DOM", os, oa, oc);
  603.     if (Sq)
  604.       genopts(thepipe, "HOST", Ss, Sa, Sc);
  605.     if (iq) {
  606.       genopts(thepipe, "DIR", is, ia, ic);
  607.       fprintf(thepipe, "DIRLEVEL %d\n", dirlevel);
  608.     }
  609.     if (rq) {
  610.       genopts(thepipe, "REQ", rs, ra, rc);
  611.       if (reqtype != 'd')
  612.     fprintf(thepipe, "REQINCLUDE %s\n", (reqtype == 'f')?"*":"pages");
  613.       if (reqlinks == 'n')
  614.     fprintf(thepipe, "LINKEXCLUDE *\n");
  615.       else if (reqlinks != 'd')
  616.     fprintf(thepipe, "LINKINCLUDE %s\n", (reqlinks == 'f')?"*":"pages");
  617.     }
  618.     if (bq)
  619.       genopts(thepipe, "BROW", bs, ba, bc);
  620.     if (Bq)
  621.       genopts(thepipe, "FULLBROW", Bs, Ba, Bc);
  622.     if (fq)
  623.       genopts(thepipe, "REF", fs, fa, fc);
  624.     if (tq)
  625.       genopts(thepipe, "TYPE", ts, ta, tc);
  626.  
  627.     if (ou < 3)
  628.       fprintf(thepipe, "OUTPUT %s\n",
  629.           (ou == 2)?"PREFORMATTED":((ou == 1)?"ASCII":"HTML"));
  630.  
  631.     fprintf(thepipe, "WARNINGS %s\n", wa?"ON":"OFF");
  632.  
  633.     if (from != NULL)
  634.       fprintf(thepipe, "FROM %s\n", from);
  635.     if (to != NULL)
  636.       fprintf(thepipe, "TO %s\n", to);
  637.     if (org != NULL)
  638.       fprintf(thepipe, "HOSTNAME \"%s\"\n", org);
  639.     if (home != NULL)
  640.       fprintf(thepipe, "HOSTURL %s\n", home);
  641.     else
  642.       fprintf(thepipe, "HOSTURL -\n");
  643.     
  644.     /* That just leaves the only's and ignore's and logfiles, which are a bit
  645.        more complicated as we have to parse them still. Recycle 'nextarg'. */
  646.  
  647.     nextarg = strtok(fonly, " ,");   /* split at spaces and commas */
  648.     while (nextarg != NULL) {
  649.       fprintf(thepipe, "FILEINCLUDE %s\n", nextarg);
  650.       nextarg = strtok((char *)NULL, " ,");
  651.     }
  652.  
  653.     nextarg = strtok(fign, " ,");
  654.     while (nextarg != NULL) {
  655.       fprintf(thepipe, "FILEEXCLUDE %s\n", nextarg);
  656.       nextarg = strtok((char *)NULL, " ,");
  657.     }
  658.  
  659.     nextarg = strtok(honly, " ,");
  660.     while (nextarg != NULL) {
  661.       fprintf(thepipe, "HOSTINCLUDE %s\n", nextarg);
  662.       nextarg = strtok((char *)NULL, " ,");
  663.     }
  664.  
  665.     nextarg = strtok(hign, " ,");
  666.     while (nextarg != NULL) {
  667.       fprintf(thepipe, "HOSTEXCLUDE %s\n", nextarg);
  668.       nextarg = strtok((char *)NULL, " ,");
  669.     }
  670.  
  671.     nextarg = strtok(browlog, " ,");
  672.     while (nextarg != NULL) {
  673.       fprintf(thepipe, "BROWLOG %s\n", nextarg);
  674.       nextarg = strtok((char *)NULL, " ,");
  675.     }
  676.  
  677.     nextarg = strtok(errlog, " ,");
  678.     while (nextarg != NULL) {
  679.       fprintf(thepipe, "ERRLOG %s\n", nextarg);
  680.       nextarg = strtok((char *)NULL, " ,");
  681.     }
  682.  
  683.     nextarg = strtok(reflog, " ,");
  684.     while (nextarg != NULL) {
  685.       fprintf(thepipe, "REFLOG %s\n", nextarg);
  686.       nextarg = strtok((char *)NULL, " ,");
  687.     }
  688.  
  689.     nextarg = strtok(logfile, " ,");
  690.     while (nextarg != NULL) {
  691.       fprintf(thepipe, "LOGFILE %s\n", nextarg);
  692.       nextarg = strtok((char *)NULL, " ,");
  693.     }
  694.  
  695.     nextarg = strtok(cachefile, " ,");
  696.     while (nextarg != NULL) {
  697.       fprintf(thepipe, "CACHEFILE %s\n", nextarg);
  698.       nextarg = strtok((char *)NULL, " ,");
  699.     }
  700.  
  701.     if (cm != NULL)
  702.       fprintf(thepipe, "CONFIGFILE %s\n", cm);
  703.  
  704.   }
  705.  
  706.   if (Vq)
  707.     ret = 0;
  708.   else {
  709.     fflush(thepipe);
  710.     ret = pclose(thepipe);
  711.     if (ret != 0) {
  712.       printf("Analog failed to run or returned an error code.\n");
  713.       printf("Maybe your server's error log will give a clue why.\n");
  714.     }
  715.   }
  716.   fflush(stdout);
  717.   return(ret);
  718.  
  719. }
  720.