Indentation, CRLF->LF, Tab-> Space
authoroes <oes@users.sourceforge.net>
Fri, 29 Jun 2001 21:45:41 +0000 (21:45 +0000)
committeroes <oes@users.sourceforge.net>
Fri, 29 Jun 2001 21:45:41 +0000 (21:45 +0000)
15 files changed:
actionsfile
cgi.c
cgi.h
config
configure
filters.c
jbsockets.c
jcc.c
list.c
loaders.c
miscutil.c
parsers.c
pcrs.c
project.h
showargs.c

index 3247ca4..83b541d 100755 (executable)
@@ -3,7 +3,7 @@
 #
 # For information, see http://ijbswa.sourceforge.net/
 #
 #
 # For information, see http://ijbswa.sourceforge.net/
 #
-# $Id: permissionsfile,v 1.10 2001/06/09 14:15:11 swa Exp $
+# $Id: actionsfile,v 1.1 2001/06/29 13:17:24 oes Exp $
 #
 #############################################################################
 # Syntax
 #
 #############################################################################
 # Syntax
@@ -429,7 +429,7 @@ a196.g.akamai.net/7/196/2670/000[12]/images.gmx.net/i4/images/.*/
 /.*/werb\..*
 /.*/werbebanner/
 /.*/werbung/.*\.(gif|jpe?g)
 /.*/werb\..*
 /.*/werbebanner/
 /.*/werbung/.*\.(gif|jpe?g)
-/.*/adv\.      # www.telegraaf.nl
+/.*/adv\.   # www.telegraaf.nl
 /.*/advert[0-9]+\.jpg
 /.*bann\.gif
 /Media/Images/Adds/
 /.*/advert[0-9]+\.jpg
 /.*bann\.gif
 /Media/Images/Adds/
@@ -837,8 +837,8 @@ www.news.com/Midas/Images/
 www.newscientist.com/houseads
 www.nextcard.com/affiliates/
 www.nikkeibp.asiabiztech.com/image/NAIS4\.gif
 www.newscientist.com/houseads
 www.nextcard.com/affiliates/
 www.nikkeibp.asiabiztech.com/image/NAIS4\.gif
-www.nordlys.no/imaker/.*/.*/.*/.....\.gif      # alvin brattli
-www.nordlys.no/imaker/.*/.*/.*/..003           # alvin brattli
+www.nordlys.no/imaker/.*/.*/.*/.....\.gif   # alvin brattli
+www.nordlys.no/imaker/.*/.*/.*/..003           # alvin brattli
 www.oanda.com/server/banner
 .omdispatch.co.uk
 www.oneandonlynetwork.com
 www.oanda.com/server/banner
 .omdispatch.co.uk
 www.oneandonlynetwork.com
diff --git a/cgi.c b/cgi.c
index 00cbc3b..55935c2 100644 (file)
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-const char cgi_rcs[] = "$Id: cgi.c,v 1.7 2001/06/09 10:51:58 jongfoster Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 1.8 2001/06/29 13:21:46 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgi.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgi.c,v $
@@ -36,6 +36,60 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.7 2001/06/09 10:51:58 jongfoster Exp $";
  *
  * Revisions   :
  *    $Log: cgi.c,v $
  *
  * Revisions   :
  *    $Log: cgi.c,v $
+ *    Revision 1.8  2001/06/29 13:21:46  oes
+ *    - Cosmetics: renamed and reordered functions, variables,
+ *      texts, improved comments  etc
+ *
+ *    - Removed ij_untrusted_url() The relevant
+ *      info is now part of the "untrusted" page,
+ *      which is generated by filters.c:trust_url()
+ *
+ *    - Generators of content now call finish_http_response()
+ *      themselves, making jcc.c:chat() a little less
+ *      cluttered
+ *
+ *    - Removed obsolete "Pragma: no-cache" from our headers
+ *
+ *    - http_responses now know their head length
+ *
+ *    - fill_template now uses the new interface to pcrs, so that
+ *       - long jobs (like whole files) no longer have to be assembled
+ *         in a fixed size buffer
+ *       - the new T (trivial) option is used, and the replacement may
+ *         contain Perl syntax backrefs without confusing pcrs
+ *
+ *    - Introduced default_exports() which generates a set of exports
+ *      common to all CGIs and other content generators
+ *
+ *    - Introduced convenience function map_block_killer()
+ *
+ *    - Introduced convenience function make_menu()
+ *
+ *    - Introduced CGI-like function error_response() which generates
+ *      the "No such domain" and "Connect failed" messages using the
+ *      CGI platform
+ *
+ *    - cgi_show_url_info:
+ *      - adapted to new CGI features
+ *      - form and answers now generated from same template
+ *      - http:// prefix in URL now OK
+ *
+ *    - cgi_show_status:
+ *      - adapted to new CGI features
+ *      - no longer uses csp->init_proxy_args
+ *
+ *    - cgi_default:
+ *      - moved menu generation to make_menu()
+ *
+ *    - add_stats now writes single export map entries instead
+ *      of a fixed string
+ *
+ *    - Moved redirect_url() to filters.c
+ *
+ *    - Fixed mem leak in free_http_response(), map_block_killer(),
+ *
+ *    - Removed logentry from cancelled commit
+ *
  *    Revision 1.7  2001/06/09 10:51:58  jongfoster
  *    Changing "show URL info" handler to new style.
  *    Changing BUFSIZ ==> BUFFER_SIZE
  *    Revision 1.7  2001/06/09 10:51:58  jongfoster
  *    Changing "show URL info" handler to new style.
  *    Changing BUFSIZ ==> BUFFER_SIZE
@@ -175,12 +229,12 @@ struct http_response *dispatch_cgi(struct client_state *csp)
       {
          param_list = parse_cgi_parameters(argstring + d->name_length);
          if ((d->handler)(csp, rsp, param_list))
       {
          param_list = parse_cgi_parameters(argstring + d->name_length);
          if ((d->handler)(csp, rsp, param_list))
-        {
-           freez(rsp);
-        }
+         {
+            freez(rsp);
+         }
 
 
-        free_map(param_list);
-        return(finish_http_response(rsp));
+         free_map(param_list);
+         return(finish_http_response(rsp));
       }
    }
 
       }
    }
 
@@ -297,18 +351,19 @@ int cgi_send_banner(struct client_state *csp, struct http_response *rsp,
 {
    if(strcmp(lookup(parameters, "type"), "trans"))
    {
 {
    if(strcmp(lookup(parameters, "type"), "trans"))
    {
-     rsp->body = bindup(JBGIF, sizeof(JBGIF));
-     rsp->content_length = sizeof(JBGIF);
+      rsp->body = bindup(JBGIF, sizeof(JBGIF));
+      rsp->content_length = sizeof(JBGIF);
    }
    else
    {
    }
    else
    {
-     rsp->body = bindup(BLANKGIF, sizeof(BLANKGIF));
-     rsp->content_length = sizeof(BLANKGIF);
+      rsp->body = bindup(BLANKGIF, sizeof(BLANKGIF));
+      rsp->content_length = sizeof(BLANKGIF);
    }   
 
    enlist(rsp->headers, "Content-Type: image/gif");
 
    return(0);
    }   
 
    enlist(rsp->headers, "Content-Type: image/gif");
 
    return(0);
+
 }
 
 
 }
 
 
@@ -462,11 +517,11 @@ int cgi_show_status(struct client_state *csp, struct http_response *rsp,
    if (csp->tlist)
    {
       exports = map(exports, "trust-filename", 1,  csp->tlist->filename, 1);
    if (csp->tlist)
    {
       exports = map(exports, "trust-filename", 1,  csp->tlist->filename, 1);
-       }
+   }
    else
    else
-       {
-          exports = map(exports, "trust-filename", 1, "None specified", 1);
-       }
+   {
+       exports = map(exports, "trust-filename", 1, "None specified", 1);
+   }
 #else
    exports = map_block_killer(exports, "trust-support");
 #endif /* ndef TRUST_FILES */
 #else
    exports = map_block_killer(exports, "trust-support");
 #endif /* ndef TRUST_FILES */
@@ -524,8 +579,8 @@ int cgi_show_status(struct client_state *csp, struct http_response *rsp,
  * Returns     :  0
  *
  *********************************************************************/
  * Returns     :  0
  *
  *********************************************************************/
-int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,\r
-                      struct map *parameters)\r
+int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,
+                      struct map *parameters)
 {
    struct map *exports = default_exports(csp, "show-url-info");
    char *url_param, *host = NULL;
 {
    struct map *exports = default_exports(csp, "show-url-info");
    char *url_param, *host = NULL;
@@ -550,28 +605,28 @@ int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,
       host = url_param;
       host += (strncmp(url_param, "http://", 7)) ? 0 : 7;
 
       host = url_param;
       host += (strncmp(url_param, "http://", 7)) ? 0 : 7;
 
-      exports = map(exports, "url", 1, host, 1);\r
-      exports = map(exports, "url-html", 1, html_encode(host), 0);\r\r
+      exports = map(exports, "url", 1, host, 1);
+      exports = map(exports, "url-html", 1, html_encode(host), 0);
 
       init_current_action(action);
 
       s = current_action_to_text(action);
 
       init_current_action(action);
 
       s = current_action_to_text(action);
-      exports = map(exports, "default", 1, s , 0);\r
-
-      if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))\r
-      {\r
-         exports = map(exports, "matches", 1, "none" , 1);\r
-         exports = map(exports, "final", 1, lookup(exports, "default"), 1);\r
-\r
-         freez(url_param);\r
-         free_current_action(action);\r
-\r
-         rsp->body = fill_template(csp, "show-url-info", exports);\r
-         free_map(exports);\r
-\r
-         return 0;\r
-      }\r
-\r
+      exports = map(exports, "default", 1, s , 0);
+
+      if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))
+      {
+         exports = map(exports, "matches", 1, "none" , 1);
+         exports = map(exports, "final", 1, lookup(exports, "default"), 1);
+
+         freez(url_param);
+         free_current_action(action);
+
+         rsp->body = fill_template(csp, "show-url-info", exports);
+         free_map(exports);
+
+         return 0;
+      }
+
       s = strchr(host, '/');
       if (s != NULL)
       {
       s = strchr(host, '/');
       if (s != NULL)
       {
@@ -587,7 +642,7 @@ int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,
       {
          *s++ = '\0';
          port = atoi(s);
       {
          *s++ = '\0';
          port = atoi(s);
-         s = NULL;\r
+         s = NULL;
       }
 
       *url = dsplit(host);
       }
 
       *url = dsplit(host);
@@ -595,17 +650,17 @@ int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,
       /* if splitting the domain fails, punt */
       if (url->dbuf == NULL)
       {
       /* if splitting the domain fails, punt */
       if (url->dbuf == NULL)
       {
-         exports = map(exports, "matches", 1, "none" , 1);\r
-         exports = map(exports, "final", 1, lookup(exports, "default"), 1);\r
-\r
-         freez(url_param);\r
-         freez(path);\r
-         free_current_action(action);\r
-\r
-         rsp->body = fill_template(csp, "show-url-info", exports);\r
-         free_map(exports);\r
-\r
-         return 0;\r
+         exports = map(exports, "matches", 1, "none" , 1);
+         exports = map(exports, "final", 1, lookup(exports, "default"), 1);
+
+         freez(url_param);
+         freez(path);
+         free_current_action(action);
+
+         rsp->body = fill_template(csp, "show-url-info", exports);
+         free_map(exports);
+
+         return 0;
       }
 
       for (b = b->next; NULL != b; b = b->next)
       }
 
       for (b = b->next; NULL != b; b = b->next)
@@ -645,23 +700,23 @@ int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,
       {
          exports = map(exports, "matches", 1, "none", 1);
       }
       {
          exports = map(exports, "matches", 1, "none", 1);
       }
-      matches = NULL;\r
-\r
+      matches = NULL;
+
       freez(url->dbuf);
       freez(url->dvec);
 
       freez(url_param);
       freez(path);
       freez(url->dbuf);
       freez(url->dvec);
 
       freez(url_param);
       freez(path);
-\r
+
       s = current_action_to_text(action);
       s = current_action_to_text(action);
-      exports = map(exports, "final", 1, s, 0);\r
-      s = NULL;\r
+      exports = map(exports, "final", 1, s, 0);
+      s = NULL;
 
       free_current_action(action);
    }
 
 
       free_current_action(action);
    }
 
-   rsp->body = fill_template(csp, "show-url-info", exports);\r
-   free_map(exports);\r
+   rsp->body = fill_template(csp, "show-url-info", exports);
+   free_map(exports);
    return 0;
 
 }
    return 0;
 
 }
@@ -731,44 +786,44 @@ struct http_response *error_response(struct client_state *csp, const char *templ
  *********************************************************************/
 struct http_response *finish_http_response(struct http_response *rsp)
 {
  *********************************************************************/
 struct http_response *finish_http_response(struct http_response *rsp)
 {
-  char buf[BUFFER_SIZE];
-
-  /* 
-   * Fill in the HTTP Status
-   */
-  sprintf(buf, "HTTP/1.0 %s", rsp->status ? rsp->status : "200 OK");
-  enlist_first(rsp->headers, buf);
-
-  /* 
-   * Set the Content-Length
-   */
-  if (rsp->content_length == 0)
-  {
-     rsp->content_length = rsp->body ? strlen(rsp->body) : 0;
-  }
-  sprintf(buf, "Content-Length: %d", rsp->content_length);
-  enlist(rsp->headers, buf);
-
-  /* 
-   * Fill in the default headers FIXME: Are these correct? sequence OK? check rfc!
-   */
-  enlist_unique(rsp->headers, "Last-Modified: Thu Jul 31, 1997 07:42:22 pm GMT", 14);
-  enlist_unique(rsp->headers, "Expires:       Thu Jul 31, 1997 07:42:22 pm GMT", 8);
-  enlist_unique(rsp->headers, "Content-Type: text/html", 13);
-  enlist(rsp->headers, "");
+   char buf[BUFFER_SIZE];
+
+   /* 
+    * Fill in the HTTP Status
+    */
+   sprintf(buf, "HTTP/1.0 %s", rsp->status ? rsp->status : "200 OK");
+   enlist_first(rsp->headers, buf);
+
+   /* 
+    * Set the Content-Length
+    */
+   if (rsp->content_length == 0)
+   {
+      rsp->content_length = rsp->body ? strlen(rsp->body) : 0;
+   }
+   sprintf(buf, "Content-Length: %d", rsp->content_length);
+   enlist(rsp->headers, buf);
+
+   /* 
+    * Fill in the default headers FIXME: Are these correct? sequence OK? check rfc!
+    */
+   enlist_unique(rsp->headers, "Last-Modified: Thu Jul 31, 1997 07:42:22 pm GMT", 14);
+   enlist_unique(rsp->headers, "Expires:       Thu Jul 31, 1997 07:42:22 pm GMT", 8);
+   enlist_unique(rsp->headers, "Content-Type: text/html", 13);
+   enlist(rsp->headers, "");
   
 
   
 
-  /* 
-   * Write the head
-   */
-  if (NULL == (rsp->head = list_to_text(rsp->headers)))
-  {
-    free_http_response(rsp);
-    return(NULL);
-  }
-  rsp->head_length = strlen(rsp->head);
+   /* 
+    * Write the head
+    */
+   if (NULL == (rsp->head = list_to_text(rsp->headers)))
+   {
+      free_http_response(rsp);
+      return(NULL);
+   }
+   rsp->head_length = strlen(rsp->head);
 
 
-  return(rsp);
+   return(rsp);
 
 }
   
 
 }
   
@@ -837,7 +892,7 @@ char *fill_template(struct client_state *csp, const char *template, struct map *
       log_error(LOG_LEVEL_ERROR, "error loading template %s: %E", buf);
       return NULL;
    }
       log_error(LOG_LEVEL_ERROR, "error loading template %s: %E", buf);
       return NULL;
    }
-       
+   
 
    /* 
     * Assemble pcrs joblist from exports map
 
    /* 
     * Assemble pcrs joblist from exports map
@@ -869,7 +924,7 @@ char *fill_template(struct client_state *csp, const char *template, struct map *
    {
       /* skip lines starting with '#' */
       if(*buf == '#') continue;
    {
       /* skip lines starting with '#' */
       if(*buf == '#') continue;
-       
+   
       old = strsav(old, buf);
    }
    fclose(fp);
       old = strsav(old, buf);
    }
    fclose(fp);
@@ -1002,7 +1057,7 @@ char *make_menu(const char *self)
       if (strncmp(d->description, "HIDE", 4) && strcmp(d->name, self))
       {
          snprintf(buf, BUFFER_SIZE, "<li><a href=%s/config/%s>%s</a></li>\n",
       if (strncmp(d->description, "HIDE", 4) && strcmp(d->name, self))
       {
          snprintf(buf, BUFFER_SIZE, "<li><a href=%s/config/%s>%s</a></li>\n",
-                      HOME_PAGE_URL, d->name, d->description);
+              HOME_PAGE_URL, d->name, d->description);
          tmp = strsav(tmp, buf);
       }
    }
          tmp = strsav(tmp, buf);
       }
    }
@@ -1028,7 +1083,6 @@ char *dump_map(struct map *map)
    struct map *p = map;
    char *ret = NULL;
 
    struct map *p = map;
    char *ret = NULL;
 
-
    ret = strsav(ret, "<table>\n");
 
    while (p)
    ret = strsav(ret, "<table>\n");
 
    while (p)
diff --git a/cgi.h b/cgi.h
index c76696a..fb6f574 100644 (file)
--- a/cgi.h
+++ b/cgi.h
@@ -1,6 +1,6 @@
 #ifndef _CGI_H
 #define _CGI_H
 #ifndef _CGI_H
 #define _CGI_H
-#define CGI_H_VERSION "$Id: cgi.h,v 1.4 2001/06/09 10:50:58 jongfoster Exp $"
+#define CGI_H_VERSION "$Id: cgi.h,v 1.5 2001/06/29 13:22:44 oes Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgi.h,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgi.h,v $
  *
  * Revisions   :
  *    $Log: cgi.h,v $
  *
  * Revisions   :
  *    $Log: cgi.h,v $
+ *    Revision 1.5  2001/06/29 13:22:44  oes
+ *    - Cleaned up
+ *    - Added new functions: default_exports(), make_menu(),
+ *      error_response() etc, ranamed others and changed
+ *      param and return types.
+ *    - Removed HTTP/HTML snipplets
+ *    - Removed logentry from cancelled commit
+ *
  *    Revision 1.4  2001/06/09 10:50:58  jongfoster
  *    Changing "show URL info" handler to new style.
  *    Adding "extern" to some function prototypes.
  *    Revision 1.4  2001/06/09 10:50:58  jongfoster
  *    Changing "show URL info" handler to new style.
  *    Adding "extern" to some function prototypes.
@@ -69,10 +77,10 @@ extern int cgi_default(struct client_state *csp, struct http_response *rsp,
                        struct map *parameters);
 extern int cgi_show_status(struct client_state *csp, struct http_response *rsp,
                            struct map *parameters);
                        struct map *parameters);
 extern int cgi_show_status(struct client_state *csp, struct http_response *rsp,
                            struct map *parameters);
-extern int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,\r
+extern int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,
                              struct map *parameters);
 extern int cgi_send_banner(struct client_state *csp, struct http_response *rsp,
                              struct map *parameters);
 extern int cgi_send_banner(struct client_state *csp, struct http_response *rsp,
-                                         struct map *parameters);
+                                 struct map *parameters);
 
 /* Not exactly a CGI */
 extern struct http_response *error_response(struct client_state *csp, const char *template, int err);
 
 /* Not exactly a CGI */
 extern struct http_response *error_response(struct client_state *csp, const char *template, int err);
diff --git a/config b/config
index 02811ae..871b259 100644 (file)
--- a/config
+++ b/config
@@ -1,7 +1,7 @@
 #  Sample Configuration file for the Internet Junkbuster 2.9.x
 
 #
 #  Sample Configuration file for the Internet Junkbuster 2.9.x
 
 #
-# $Id: config,v 1.14 2001/06/08 00:25:01 jongfoster Exp $
+# $Id: config,v 1.15 2001/06/29 13:23:20 oes Exp $
 #
 
 #  Table of Contents
 #
 
 #  Table of Contents
@@ -423,7 +423,7 @@ toggle 1
 # There is an implicit line equivalent to the following, which specifies that
 # anything not finding a match on the list is to go out without forwarding
 # or gateway protocol; like so:
 # There is an implicit line equivalent to the following, which specifies that
 # anything not finding a match on the list is to go out without forwarding
 # or gateway protocol; like so:
-#    forward .*        .  # implicit
+#    forward .*   .  # implicit
 #
 # In the following common configuration, everything goes to Lucent's LPWA,
 # except SSL on port 443 (which it doesn't handle)
 #
 # In the following common configuration, everything goes to Lucent's LPWA,
 # except SSL on port 443 (which it doesn't handle)
index e78edb1..e06d48a 100755 (executable)
--- a/configure
+++ b/configure
@@ -467,7 +467,7 @@ do
   | --no-cr | --no-c) ;;
   -no-recursion | --no-recursion | --no-recursio | --no-recursi \
   | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
   | --no-cr | --no-c) ;;
   -no-recursion | --no-recursion | --no-recursio | --no-recursi \
   | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
-  *" "*|*"     "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+  *" "*|*"   "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
   ac_configure_args="$ac_configure_args '$ac_arg'" ;;
   *) ac_configure_args="$ac_configure_args $ac_arg" ;;
   esac
   ac_configure_args="$ac_configure_args '$ac_arg'" ;;
   *) ac_configure_args="$ac_configure_args $ac_arg" ;;
   esac
@@ -551,7 +551,7 @@ if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
     ac_n= ac_c='
   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
     ac_n= ac_c='
-' ac_t='       '
+' ac_t='   '
   else
     ac_n=-n ac_c= ac_t=
   fi
   else
     ac_n=-n ac_c= ac_t=
   fi
@@ -602,7 +602,7 @@ else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  IFS="${IFS=    }"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
   for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
   ac_dummy="$PATH"
   for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
@@ -632,7 +632,7 @@ else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  IFS="${IFS=    }"; ac_save_ifs="$IFS"; IFS=":"
   ac_prog_rejected=no
   ac_dummy="$PATH"
   for ac_dir in $ac_dummy; do
   ac_prog_rejected=no
   ac_dummy="$PATH"
   for ac_dir in $ac_dummy; do
@@ -640,7 +640,7 @@ else
     if test -f $ac_dir/$ac_word; then
       if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
         ac_prog_rejected=yes
     if test -f $ac_dir/$ac_word; then
       if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
         ac_prog_rejected=yes
-       continue
+   continue
       fi
       ac_cv_prog_CC="cc"
       break
       fi
       ac_cv_prog_CC="cc"
       break
@@ -683,7 +683,7 @@ else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  IFS="${IFS=    }"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
   for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
   ac_dummy="$PATH"
   for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
@@ -1685,7 +1685,7 @@ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
 # the first set of double-colon rules, so remove it if not needed.
 # If there is a colon in the path, we need to keep it.
 if test "x$srcdir" = x.; then
 # the first set of double-colon rules, so remove it if not needed.
 # If there is a colon in the path, we need to keep it.
 if test "x$srcdir" = x.; then
-  ac_vpsub='/^[        ]*VPATH[        ]*=[^:]*$/d'
+  ac_vpsub='/^[    ]*VPATH[    ]*=[^:]*$/d'
 fi
 
 trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
 fi
 
 trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
@@ -1874,17 +1874,17 @@ rm -f conftest.s*
 # NAME is the cpp macro being defined and VALUE is the value it is being given.
 #
 # ac_d sets the value in "#define NAME VALUE" lines.
 # NAME is the cpp macro being defined and VALUE is the value it is being given.
 #
 # ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s%^\([  ]*\)#\([        ]*define[       ][      ]*\)'
-ac_dB='\([     ][      ]*\)[^  ]*%\1#\2'
+ac_dA='s%^\([    ]*\)#\([      ]*define[       ][      ]*\)'
+ac_dB='\([    ][       ]*\)[^  ]*%\1#\2'
 ac_dC='\3'
 ac_dD='%g'
 # ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
 ac_dC='\3'
 ac_dD='%g'
 # ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
-ac_uA='s%^\([  ]*\)#\([        ]*\)undef\([    ][      ]*\)'
-ac_uB='\([     ]\)%\1#\2define\3'
+ac_uA='s%^\([    ]*\)#\([      ]*\)undef\([    ][      ]*\)'
+ac_uB='\([    ]\)%\1#\2define\3'
 ac_uC=' '
 ac_uD='\4%g'
 # ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
 ac_uC=' '
 ac_uD='\4%g'
 # ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_eA='s%^\([  ]*\)#\([        ]*\)undef\([    ][      ]*\)'
+ac_eA='s%^\([    ]*\)#\([      ]*\)undef\([    ][      ]*\)'
 ac_eB='$%\1#\2define\3'
 ac_eC=' '
 ac_eD='%g'
 ac_eB='$%\1#\2define\3'
 ac_eC=' '
 ac_eD='%g'
@@ -1931,7 +1931,7 @@ rm -f conftest.hdr
 # example, in the case of _POSIX_SOURCE, which is predefined and required
 # on some systems where configure will not decide to define it.
 cat >> conftest.vals <<\EOF
 # example, in the case of _POSIX_SOURCE, which is predefined and required
 # on some systems where configure will not decide to define it.
 cat >> conftest.vals <<\EOF
-s%^[   ]*#[    ]*undef[        ][      ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+s%^[    ]*#[   ]*undef[        ][      ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
 EOF
 
 # Break up conftest.vals because some shells have a limit on
 EOF
 
 # Break up conftest.vals because some shells have a limit on
index 3586be0..129efbf 100644 (file)
--- a/filters.c
+++ b/filters.c
@@ -1,4 +1,4 @@
-const char filters_rcs[] = "$Id: filters.c,v 1.17 2001/06/09 10:55:28 jongfoster Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.18 2001/06/29 13:27:38 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/filters.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/filters.c,v $
@@ -38,6 +38,32 @@ const char filters_rcs[] = "$Id: filters.c,v 1.17 2001/06/09 10:55:28 jongfoster
  *
  * Revisions   :
  *    $Log: filters.c,v $
  *
  * Revisions   :
  *    $Log: filters.c,v $
+ *    Revision 1.18  2001/06/29 13:27:38  oes
+ *    - Cleaned up, renamed and reorderd functions
+ *      and improved comments
+ *
+ *    - block_url:
+ *      - Ported to CGI platform. Now delivers
+ *        http_response or NULL
+ *      - Unified HTML and GIF generation (moved image detection
+ *        and GIF generation here from jcc.c:chat())
+ *      - Fixed HTTP status to:
+ *       -  403 (Forbidden) for the "blocked" HTML message
+ *       -  200 (OK) for GIF answers
+ *       -  302 (Redirect) for redirect to GIF
+ *
+ *    - trust_url:
+ *      - Ported to CGI platform. Now delivers
+ *        http_response or NULL
+ *      - Separated detection of untrusted URL into
+ *        (bool)is_untrusted_url
+ *      - Added enforcement of untrusted requests
+ *
+ *    - Moved redirect_url() from cgi.c to here
+ *      and ported it to the CGI platform
+ *
+ *    - Removed logentry from cancelled commit
+ *
  *    Revision 1.17  2001/06/09 10:55:28  jongfoster
  *    Changing BUFSIZ ==> BUFFER_SIZE
  *
  *    Revision 1.17  2001/06/09 10:55:28  jongfoster
  *    Changing BUFSIZ ==> BUFFER_SIZE
  *
@@ -251,8 +277,7 @@ const char filters_h_rcs[] = FILTERS_H_VERSION;
  * Returns     : 0 = FALSE (don't block) and 1 = TRUE (do block)
  *
  *********************************************************************/
  * Returns     : 0 = FALSE (don't block) and 1 = TRUE (do block)
  *
  *********************************************************************/
-int block_acl(struct access_control_addr *dst,
-              struct client_state *csp)
+int block_acl(struct access_control_addr *dst, struct client_state *csp)
 {
    struct access_control_list *acl = csp->config->acl;
 
 {
    struct access_control_list *acl = csp->config->acl;
 
@@ -387,7 +412,7 @@ int acl_addr(char *aspec, struct access_control_addr *aca)
 struct http_response *block_url(struct client_state *csp)
 {
    char *p;
 struct http_response *block_url(struct client_state *csp)
 {
    char *p;
-       struct http_response *rsp;
+   struct http_response *rsp;
    struct map *exports = NULL;
 
    /* 
    struct map *exports = NULL;
 
    /* 
@@ -411,10 +436,10 @@ struct http_response *block_url(struct client_state *csp)
     * as specified by the relevant +image action
     */
 #ifdef IMAGE_BLOCKING
     * as specified by the relevant +image action
     */
 #ifdef IMAGE_BLOCKING
-       if (((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
+   if (((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
         && is_imageurl(csp))
         && is_imageurl(csp))
-       {
-          /* determine HOW images should be blocked */
+   {
+      /* determine HOW images should be blocked */
       p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
 
       /* and handle accordingly: */
       p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
 
       /* and handle accordingly: */
@@ -446,7 +471,7 @@ struct http_response *block_url(struct client_state *csp)
     */
    {
 
     */
    {
 
-          exports = default_exports(csp, NULL);           
+      exports = default_exports(csp, NULL);       
 #ifdef FORCE_LOAD
       exports = map(exports, "force-prefix", 1, FORCE_PREFIX, 1);
 #else
 #ifdef FORCE_LOAD
       exports = map(exports, "force-prefix", 1, FORCE_PREFIX, 1);
 #else
@@ -495,7 +520,7 @@ struct http_response *trust_url(struct client_state *csp)
     */
    if (!is_untrusted_url(csp))
    {
     */
    if (!is_untrusted_url(csp))
    {
-     return NULL;
+      return NULL;
    }
 
    /* 
    }
 
    /* 
@@ -509,7 +534,7 @@ struct http_response *trust_url(struct client_state *csp)
 
    /* 
     * Export the host, port, and referrer information
 
    /* 
     * Export the host, port, and referrer information
-        */
+    */
    exports = map(exports, "hostport", 1, csp->http->hostport, 1);
    exports = map(exports, "path", 1, csp->http->path, 1);
    exports = map(exports, "hostport-html", 1, html_encode(csp->http->hostport), 0);
    exports = map(exports, "hostport", 1, csp->http->hostport, 1);
    exports = map(exports, "path", 1, csp->http->path, 1);
    exports = map(exports, "hostport-html", 1, html_encode(csp->http->hostport), 0);
@@ -546,25 +571,23 @@ struct http_response *trust_url(struct client_state *csp)
 
       for (l = csp->config->trust_info->next; l ; l = l->next)
       {
 
       for (l = csp->config->trust_info->next; l ; l = l->next)
       {
-         sprintf(buf,
-            "<li> <a href=%s>%s</a><br>\n",
-               l->str, l->str);
+         sprintf(buf, "<li> <a href=%s>%s</a><br>\n",l->str, l->str);
          p = strsav(p, buf);
       }
       exports = map(exports, "trust-info", 1, p, 0);
    }
    else
          p = strsav(p, buf);
       }
       exports = map(exports, "trust-info", 1, p, 0);
    }
    else
-       {
-          exports = map_block_killer(exports, "have-trust-info");
-       }
+   {
+      exports = map_block_killer(exports, "have-trust-info");
+   }
    
    /*
     * Export the force prefix or the force conditional block killer
     */
 #ifdef FORCE_LOAD
    
    /*
     * Export the force prefix or the force conditional block killer
     */
 #ifdef FORCE_LOAD
-      exports = map(exports, "force-prefix", 1, FORCE_PREFIX, 1);
+   exports = map(exports, "force-prefix", 1, FORCE_PREFIX, 1);
 #else
 #else
-      exports = map_block_killer(exports, "force-support");
+   exports = map_block_killer(exports, "force-support");
 #endif /* ndef FORCE_LOAD */
 
    /*
 #endif /* ndef FORCE_LOAD */
 
    /*
@@ -744,7 +767,7 @@ int is_untrusted_url(struct client_state *csp)
    if ((csp->referrer == NULL)|| (strlen(csp->referrer) <= 9))
    {
       /* no referrer was supplied */
    if ((csp->referrer == NULL)|| (strlen(csp->referrer) <= 9))
    {
       /* no referrer was supplied */
-          return(1);
+      return(1);
    }
 
    /* forge a URL from the referrer so we can use
    }
 
    /* forge a URL from the referrer so we can use
@@ -919,6 +942,7 @@ void url_actions(struct http_request *http,
    }
 
    apply_url_actions(csp->action, http, b);
    }
 
    apply_url_actions(csp->action, http, b);
+
 }
 
 
 }
 
 
@@ -1069,12 +1093,13 @@ struct url_spec dsplit(char *domain)
 
    if (domain[strlen(domain) - 1] == '.')
    {
 
    if (domain[strlen(domain) - 1] == '.')
    {
-         ret->unanchored |= ANCHOR_RIGHT;
-       }
-       if (domain[0] == '.')
+      ret->unanchored |= ANCHOR_RIGHT;
+   }
+
+   if (domain[0] == '.')
    {
    {
-         ret->unanchored |= ANCHOR_LEFT;
-       }
+      ret->unanchored |= ANCHOR_LEFT;
+   }
 
    ret->dbuf = strdup(domain);
 
 
    ret->dbuf = strdup(domain);
 
@@ -1098,7 +1123,6 @@ struct url_spec dsplit(char *domain)
       memcpy(ret->dvec, v, size);
    }
 
       memcpy(ret->dvec, v, size);
    }
 
-
    return(*ret);
 
 }
    return(*ret);
 
 }
@@ -1136,6 +1160,7 @@ static int simple_domaincmp(char **pv, char **fv, int len)
    }
 
    return 0;
    }
 
    return 0;
+
 }
 
 
 }
 
 
@@ -1218,8 +1243,8 @@ int domaincmp(struct url_spec *pattern, struct url_spec *fqdn)
       }
       return 1;
    }
       }
       return 1;
    }
-}
 
 
+}
 
 
 /*
 
 
 /*
index bcbd818..8101fd2 100644 (file)
@@ -1,4 +1,4 @@
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.9 2001/06/07 23:06:09 jongfoster Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.10 2001/06/29 13:29:15 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
@@ -35,6 +35,11 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.9 2001/06/07 23:06:09 jongfos
  *
  * Revisions   :
  *    $Log: jbsockets.c,v $
  *
  * Revisions   :
  *    $Log: jbsockets.c,v $
+ *    Revision 1.10  2001/06/29 13:29:15  oes
+ *    - Added remote (server) host IP to csp->http->host_ip_addr_str
+ *    - Added detection of local socket IP and fqdn
+ *    - Removed logentry from cancelled commit
+ *
  *    Revision 1.9  2001/06/07 23:06:09  jongfoster
  *    The host parameter to connect_to() is now const.
  *
  *    Revision 1.9  2001/06/07 23:06:09  jongfoster
  *    The host parameter to connect_to() is now const.
  *
@@ -143,7 +148,7 @@ int connect_to(const char *host, int portnum, struct client_state *csp)
 
    if ((addr = resolve_hostname_to_ip(host)) == -1)
    {
 
    if ((addr = resolve_hostname_to_ip(host)) == -1)
    {
-          csp->http->host_ip_addr_str = strdup("unknown");
+      csp->http->host_ip_addr_str = strdup("unknown");
       return(-1);
    }
 
       return(-1);
    }
 
@@ -457,7 +462,7 @@ int accept_connection(struct client_state * csp, int fd)
     * and the hostname associated with that address
     */
    if (!getsockname(afd, &laddr, &laddrlen))
     * and the hostname associated with that address
     */
    if (!getsockname(afd, &laddr, &laddrlen))
-       {
+   {
       csp->my_ip_addr_str = strdup(inet_ntoa(lap->sin_addr));
 
       host = gethostbyaddr(laddr.sa_data + 2, 4, AF_INET);
       csp->my_ip_addr_str = strdup(inet_ntoa(lap->sin_addr));
 
       host = gethostbyaddr(laddr.sa_data + 2, 4, AF_INET);
@@ -466,16 +471,17 @@ int accept_connection(struct client_state * csp, int fd)
          log_error(LOG_LEVEL_ERROR, "Unable to get my own hostname: %s\n", hstrerror(h_errno)); 
       }
       else
          log_error(LOG_LEVEL_ERROR, "Unable to get my own hostname: %s\n", hstrerror(h_errno)); 
       }
       else
-          {
+      {
          csp->my_hostname = strdup(host->h_name);
       }
          csp->my_hostname = strdup(host->h_name);
       }
-       }
+   }
 
    csp->cfd    = afd;
    csp->ip_addr_str  = strdup(inet_ntoa(rap->sin_addr));
    csp->ip_addr_long = ntohl(rap->sin_addr.s_addr);
 
    return 1;
 
    csp->cfd    = afd;
    csp->ip_addr_str  = strdup(inet_ntoa(rap->sin_addr));
    csp->ip_addr_long = ntohl(rap->sin_addr.s_addr);
 
    return 1;
+
 }
 
 
 }
 
 
diff --git a/jcc.c b/jcc.c
index ed9b8f7..cbc88ce 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.20 2001/06/09 10:55:28 jongfoster Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.21 2001/06/29 13:29:36 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -33,6 +33,20 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.20 2001/06/09 10:55:28 jongfoster Exp $";
  *
  * Revisions   :
  *    $Log: jcc.c,v $
  *
  * Revisions   :
  *    $Log: jcc.c,v $
+ *    Revision 1.21  2001/06/29 13:29:36  oes
+ *    - Cleaned up, improved comments
+ *    - Unified all possible interceptors (CGI,
+ *      block, trust, fast_redirect) in one
+ *      place, with one (CGI) answer generation
+ *      mechansim. Much clearer now.
+ *    - Removed the GIF image generation, which
+ *      is now done in filters.c:block_url()
+ *    - Made error conditions like domain lookup
+ *      failiure or (various) problems while talking
+ *      to the server use cgi.c:error_response()
+ *      instead of generating HTML/HTTP in chat() (yuck!)
+ *    - Removed logentry from cancelled commit
+ *
  *    Revision 1.20  2001/06/09 10:55:28  jongfoster
  *    Changing BUFSIZ ==> BUFFER_SIZE
  *
  *    Revision 1.20  2001/06/09 10:55:28  jongfoster
  *    Changing BUFSIZ ==> BUFFER_SIZE
  *
@@ -333,7 +347,7 @@ static void chat(struct client_state *csp)
 
 #define IS_ENABLED_AND   IS_TOGGLED_ON_AND IS_NOT_FORCED_AND
 
 
 #define IS_ENABLED_AND   IS_TOGGLED_ON_AND IS_NOT_FORCED_AND
 
-   char buf[BUFFER_SIZE];\r
+   char buf[BUFFER_SIZE];
    char *hdr, *p, *req;
    char *err = NULL;
    fd_set rfds;
    char *hdr, *p, *req;
    char *err = NULL;
    fd_set rfds;
@@ -536,13 +550,13 @@ static void chat(struct client_state *csp)
  
    if (
        /* a CGI call was detected and answered */
  
    if (
        /* a CGI call was detected and answered */
-                (NULL != (rsp = dispatch_cgi(csp))) 
+        (NULL != (rsp = dispatch_cgi(csp))) 
 
        /* or we are enabled and... */
        || (IS_ENABLED_AND (
 
 
        /* or we are enabled and... */
        || (IS_ENABLED_AND (
 
-              /* ..the request was blocked */
-                   ( NULL != (rsp = block_url(csp)))
+            /* ..the request was blocked */
+           ( NULL != (rsp = block_url(csp)))
 
           /* ..or untrusted */
 #ifdef TRUST_FILES
 
           /* ..or untrusted */
 #ifdef TRUST_FILES
@@ -552,17 +566,17 @@ static void chat(struct client_state *csp)
           /* ..or a fast redirect kicked in */
 #ifdef FAST_REDIRECTS
           || (((csp->action->flags & ACTION_FAST_REDIRECTS) != 0) && 
           /* ..or a fast redirect kicked in */
 #ifdef FAST_REDIRECTS
           || (((csp->action->flags & ACTION_FAST_REDIRECTS) != 0) && 
-                            (NULL != (rsp = redirect_url(csp))))
+                    (NULL != (rsp = redirect_url(csp))))
 #endif /* def FAST_REDIRECTS */
 #endif /* def FAST_REDIRECTS */
-                        ))
-               )
+                ))
+       )
    {
    {
-          /* Write the answer to the client */
+      /* Write the answer to the client */
       if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
       if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
-                    || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+            || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
       { 
          log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
       { 
          log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
-          }
+      }
 
 #ifdef STATISTICS
       /* Count as a rejected request */
 
 #ifdef STATISTICS
       /* Count as a rejected request */
@@ -602,28 +616,28 @@ static void chat(struct client_state *csp)
 
       if (errno == EINVAL)
       {
 
       if (errno == EINVAL)
       {
-                  rsp = error_response(csp, "no-such-domain", errno);
+          rsp = error_response(csp, "no-such-domain", errno);
 
          log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 404 0", 
                    csp->ip_addr_str, http->cmd);
       }
       else
       {
 
          log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 404 0", 
                    csp->ip_addr_str, http->cmd);
       }
       else
       {
-                  rsp = error_response(csp, "connect-failed", errno);
+          rsp = error_response(csp, "connect-failed", errno);
 
          log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0", 
                    csp->ip_addr_str, http->cmd);
       }
 
 
          log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0", 
                    csp->ip_addr_str, http->cmd);
       }
 
-          /* Write the answer to the client */
+      /* Write the answer to the client */
       if(rsp)
       if(rsp)
-               {
+       {
          if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
          if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
-                       || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+               || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
          { 
             log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
          { 
             log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
-             }
-          }
+         }
+      }
 
       free_http_response(rsp);
       freez(hdr);
 
       free_http_response(rsp);
       freez(hdr);
@@ -651,14 +665,14 @@ static void chat(struct client_state *csp)
 
          rsp = error_response(csp, "connect-failed", errno);
 
 
          rsp = error_response(csp, "connect-failed", errno);
 
-             if(rsp)
+         if(rsp)
          {
             if ((write_socket(csp->cfd, rsp->head, n) != n)
          {
             if ((write_socket(csp->cfd, rsp->head, n) != n)
-                       || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+               || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
             { 
                log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
             { 
                log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
-                }
-             }
+            }
+         }
 
          free_http_response(rsp);
          freez(hdr);
 
          free_http_response(rsp);
          freez(hdr);
@@ -751,14 +765,14 @@ static void chat(struct client_state *csp)
 
             rsp = error_response(csp, "connect-failed", errno);
 
 
             rsp = error_response(csp, "connect-failed", errno);
 
-                if(rsp)
+            if(rsp)
             {
                if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
             {
                if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
-                           || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+                   || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
                { 
                   log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
                { 
                   log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
-                                  }
-                               }
+                          }
+                       }
 
             free_http_response(rsp);
             return;
 
             free_http_response(rsp);
             return;
@@ -1025,7 +1039,6 @@ static void serve(struct client_state *csp)
 
 
 #ifdef __BEOS__
 
 
 #ifdef __BEOS__
-
 /*********************************************************************
  *
  * Function    :  server_thread
 /*********************************************************************
  *
  * Function    :  server_thread
@@ -1044,7 +1057,6 @@ static int32 server_thread(void *data)
    return 0;
 
 }
    return 0;
 
 }
-
 #endif
 
 
 #endif
 
 
diff --git a/list.c b/list.c
index 0104a95..18e5da7 100644 (file)
--- a/list.c
+++ b/list.c
@@ -1,4 +1,4 @@
-const char list_rcs[] = "$Id: list.c,v 1.3 2001/06/03 19:12:24 oes Exp $";
+const char list_rcs[] = "$Id: list.c,v 1.4 2001/06/29 13:30:22 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/list.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/list.c,v $
@@ -34,6 +34,14 @@ const char list_rcs[] = "$Id: list.c,v 1.3 2001/06/03 19:12:24 oes Exp $";
  *
  * Revisions   :
  *    $Log: list.c,v $
  *
  * Revisions   :
  *    $Log: list.c,v $
+ *    Revision 1.4  2001/06/29 13:30:22  oes
+ *    - Added Convenience function enlist_unique_header(),
+ *      which takes the Header name and value as separate
+ *      arguments and thus saves the pain of sprintf()ing
+ *      and determining the Header name length to enlist_unique
+ *    - Improved comments
+ *    - Removed logentry from cancelled commit
+ *
  *    Revision 1.3  2001/06/03 19:12:24  oes
  *    functions for new struct map, extended enlist_unique
  *
  *    Revision 1.3  2001/06/03 19:12:24  oes
  *    functions for new struct map, extended enlist_unique
  *
@@ -226,13 +234,13 @@ void enlist_unique_header(struct list *header, const char *name, const char *val
    if (name == NULL || value == NULL) return;
 
    dummy = strdup(name);
    if (name == NULL || value == NULL) return;
 
    dummy = strdup(name);
-       dummy = strsav(dummy, ": ");
+   dummy = strsav(dummy, ": ");
    length = strlen(dummy);
 
    while (cur != NULL)
    {
       if ((cur->str != NULL) && 
    length = strlen(dummy);
 
    while (cur != NULL)
    {
       if ((cur->str != NULL) && 
-                       (0 == strncmp(dummy, cur->str, length)))
+               (0 == strncmp(dummy, cur->str, length)))
       {
          /* Already there */
          return;
       {
          /* Already there */
          return;
@@ -244,7 +252,7 @@ void enlist_unique_header(struct list *header, const char *name, const char *val
 
    if (cur != NULL)
    {
 
    if (cur != NULL)
    {
-          cur->str  = strsav(dummy, value);
+      cur->str  = strsav(dummy, value);
       cur->next = NULL;
 
       last = header->last;
       cur->next = NULL;
 
       last = header->last;
@@ -541,6 +549,7 @@ char *lookup(struct map *map, char *name)
       p = p->next;
    }
    return "";
       p = p->next;
    }
    return "";
+
 }
 
 
 }
 
 
index fb22579..7752a97 100644 (file)
--- a/loaders.c
+++ b/loaders.c
@@ -1,4 +1,4 @@
-const char loaders_rcs[] = "$Id: loaders.c,v 1.16 2001/06/09 10:55:28 jongfoster Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.17 2001/06/29 13:31:51 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/loaders.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/loaders.c,v $
@@ -35,6 +35,9 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.16 2001/06/09 10:55:28 jongfoster
  *
  * Revisions   :
  *    $Log: loaders.c,v $
  *
  * Revisions   :
  *    $Log: loaders.c,v $
+ *    Revision 1.17  2001/06/29 13:31:51  oes
+ *    Various adaptions
+ *
  *    Revision 1.16  2001/06/09 10:55:28  jongfoster
  *    Changing BUFSIZ ==> BUFFER_SIZE
  *
  *    Revision 1.16  2001/06/09 10:55:28  jongfoster
  *    Changing BUFSIZ ==> BUFFER_SIZE
  *
@@ -161,11 +164,6 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.16 2001/06/09 10:55:28 jongfoster
 #include "gateway.h"
 #include "actions.h"
 
 #include "gateway.h"
 #include "actions.h"
 
-#ifndef SPLIT_PROXY_ARGS
-/* For strsav */
-#include "showargs.h"
-#endif /* ndef SPLIT_PROXY_ARGS */
-
 const char loaders_h_rcs[] = LOADERS_H_VERSION;
 
 /* Fix a problem with Solaris.  There should be no effect on other
 const char loaders_h_rcs[] = LOADERS_H_VERSION;
 
 /* Fix a problem with Solaris.  There should be no effect on other
@@ -386,14 +384,13 @@ int create_url_spec(struct url_spec * url, char * buf)
             (REG_EXTENDED|REG_NOSUB|REG_ICASE));
       if (errcode)
       {
             (REG_EXTENDED|REG_NOSUB|REG_ICASE));
       if (errcode)
       {
-         size_t errlen =
-            regerror(errcode,
-               url->preg, buf, sizeof(buf));
+         size_t errlen = regerror(errcode,
+            url->preg, buf, sizeof(buf));
 
          buf[errlen] = '\0';
 
          log_error(LOG_LEVEL_ERROR, "error compiling %s: %s",
 
          buf[errlen] = '\0';
 
          log_error(LOG_LEVEL_ERROR, "error compiling %s: %s",
-                 url->spec, buf);
+            url->spec, buf);
 
          freez(url->spec);
          freez(url->path);
 
          freez(url->spec);
          freez(url->path);
@@ -432,6 +429,7 @@ int create_url_spec(struct url_spec * url, char * buf)
    url->unanchored = tmp_url->unanchored;
 
    return 0; /* OK */
    url->unanchored = tmp_url->unanchored;
 
    return 0; /* OK */
+
 }
 
 
 }
 
 
@@ -555,6 +553,7 @@ int check_file_changed(const struct file_list * current,
 
    *newfl = fs;
    return 1;
 
    *newfl = fs;
    return 1;
+
 }
 
 
 }
 
 
@@ -640,7 +639,7 @@ char *read_config_line(char *buf, int buflen, FILE *fp, struct file_list *fs)
       if (contflag)
       {
          contflag = 0;
       if (contflag)
       {
          contflag = 0;
-                       continue;
+               continue;
       }
 
       /* Remove leading and trailing whitespace */         
       }
 
       /* Remove leading and trailing whitespace */         
@@ -676,7 +675,7 @@ static void unload_trustfile(void *f)
    struct block_spec *b = (struct block_spec *)f;
    if (b == NULL) return;
 
    struct block_spec *b = (struct block_spec *)f;
    if (b == NULL) return;
 
-   unload_trustfile(b->next);
+   unload_trustfile(b->next); /* Stack is cheap, isn't it? */
 
    free_url(b->url);
 
 
    free_url(b->url);
 
@@ -849,11 +848,10 @@ static void unload_re_filterfile(void *f)
    if (b == NULL) return;
 
    destroy_list(b->patterns);
    if (b == NULL) return;
 
    destroy_list(b->patterns);
-
    pcrs_free_joblist(b->joblist);
    pcrs_free_joblist(b->joblist);
-
    freez(b);
 
    freez(b);
 
+   return;
 }
 
 /*********************************************************************
 }
 
 /*********************************************************************
index c149a44..ac363f4 100644 (file)
@@ -1,5 +1,5 @@
 /* vim:ts=3: */
 /* vim:ts=3: */
-const char miscutil_rcs[] = "$Id: miscutil.c,v 1.12 2001/06/09 10:55:28 jongfoster Exp $";
+const char miscutil_rcs[] = "$Id: miscutil.c,v 1.13 2001/06/29 13:32:14 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/miscutil.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/miscutil.c,v $
@@ -37,6 +37,9 @@ const char miscutil_rcs[] = "$Id: miscutil.c,v 1.12 2001/06/09 10:55:28 jongfost
  *
  * Revisions   :
  *    $Log: miscutil.c,v $
  *
  * Revisions   :
  *    $Log: miscutil.c,v $
+ *    Revision 1.13  2001/06/29 13:32:14  oes
+ *    Removed logentry from cancelled commit
+ *
  *    Revision 1.12  2001/06/09 10:55:28  jongfoster
  *    Changing BUFSIZ ==> BUFFER_SIZE
  *
  *    Revision 1.12  2001/06/09 10:55:28  jongfoster
  *    Changing BUFSIZ ==> BUFFER_SIZE
  *
@@ -111,12 +114,12 @@ const char miscutil_rcs[] = "$Id: miscutil.c,v 1.12 2001/06/09 10:55:28 jongfost
 #include <malloc.h>
 #include <ctype.h>
 
 #include <malloc.h>
 #include <ctype.h>
 
-/*\r
- * FIXME: Only need project.h for BUFFER_SIZE.  It would be nice\r
- * to remove this dependency.\r
- */\r
-#include "project.h"\r
-#include "miscutil.h"\r
+/*
+ * FIXME: Only need project.h for BUFFER_SIZE.  It would be nice
+ * to remove this dependency.
+ */
+#include "project.h"
+#include "miscutil.h"
 #include "errlog.h"
 
 const char miscutil_h_rcs[] = MISCUTIL_H_VERSION;
 #include "errlog.h"
 
 const char miscutil_h_rcs[] = MISCUTIL_H_VERSION;
@@ -564,12 +567,12 @@ char *bindup(const char *string, int n)
 
    if (NULL == (dup = (char *)malloc(n)))
    {
 
    if (NULL == (dup = (char *)malloc(n)))
    {
-          return NULL;
-       }
+      return NULL;
+   }
    else
    else
-       {
-         memcpy(dup, string, n);
-       }
+   {
+     memcpy(dup, string, n);
+   }
 
    return dup;
 
 
    return dup;
 
index e42fd56..2b2043c 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.15 2001/06/03 19:12:38 oes Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.16 2001/06/29 13:32:42 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
@@ -41,6 +41,11 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.15 2001/06/03 19:12:38 oes Exp $"
  *
  * Revisions   :
  *    $Log: parsers.c,v $
  *
  * Revisions   :
  *    $Log: parsers.c,v $
+ *    Revision 1.16  2001/06/29 13:32:42  oes
+ *    - Fixed a comment
+ *    - Adapted free_http_request
+ *    - Removed logentry from cancelled commit
+ *
  *    Revision 1.15  2001/06/03 19:12:38  oes
  *    deleted const struct interceptors
  *
  *    Revision 1.15  2001/06/03 19:12:38  oes
  *    deleted const struct interceptors
  *
@@ -741,12 +746,12 @@ char *content_type(const struct parsers *v, char *s, struct client_state *csp)
 char *content_length(const struct parsers *v, char *s, struct client_state *csp)
 {
    if (csp->content_length != 0) /* Content has been modified */
 char *content_length(const struct parsers *v, char *s, struct client_state *csp)
 {
    if (csp->content_length != 0) /* Content has been modified */
-       {
-          s = (char *) zalloc(100);
-          sprintf(s, "Content-Length: %d", csp->content_length);
-               log_error(LOG_LEVEL_HEADER, "Adjust Content-Length to %d", csp->content_length);
-          return(s);
-       }
+   {
+      s = (char *) zalloc(100);
+      sprintf(s, "Content-Length: %d", csp->content_length);
+       log_error(LOG_LEVEL_HEADER, "Adjust Content-Length to %d", csp->content_length);
+      return(s);
+   }
    else
    {
       return(strdup(s));
    else
    {
       return(strdup(s));
diff --git a/pcrs.c b/pcrs.c
index f48e3da..033268a 100644 (file)
--- a/pcrs.c
+++ b/pcrs.c
@@ -1,4 +1,4 @@
-const char pcrs_rcs[] = "$Id: pcrs.c,v 1.6 2001/06/03 19:12:45 oes Exp $";
+const char pcrs_rcs[] = "$Id: pcrs.c,v 1.7 2001/06/29 13:33:04 oes Exp $";
 
 /*********************************************************************
  *
 
 /*********************************************************************
  *
@@ -47,6 +47,28 @@ const char pcrs_rcs[] = "$Id: pcrs.c,v 1.6 2001/06/03 19:12:45 oes Exp $";
  *
  * Revisions   :
  *    $Log: pcrs.c,v $
  *
  * Revisions   :
  *    $Log: pcrs.c,v $
+ *    Revision 1.7  2001/06/29 13:33:04  oes
+ *    - Cleaned up, renamed and reordered functions,
+ *      improved comments
+ *    - Removed my_strsep
+ *    - Replaced globalflag with a general flags int
+ *      that holds PCRS_GLOBAL, PCRS_SUCCESS, and PCRS_TRIVIAL
+ *    - Introduced trivial option that will prevent pcrs
+ *      from honouring backreferences in the substitute,
+ *      which is useful for large substitutes that are
+ *      red in from somewhere and saves the pain of escaping
+ *      the backrefs
+ *    - Introduced convenience function pcrs_free_joblist()
+ *    - Split pcrs_make_job() into pcrs_compile(), which still
+ *      takes a complete s/// comand as argument and parses it,
+ *      and a new function pcrs_make_job, which takes the
+ *      three separate components. This should make for a
+ *      much friendlier frontend.
+ *    - Removed create_pcrs_job() which was useless
+ *    - Fixed a bug in pcrs_execute
+ *    - Success flag is now handled by pcrs instead of user
+ *    - Removed logentry from cancelled commit
+ *
  *    Revision 1.6  2001/06/03 19:12:45  oes
  *    added FIXME
  *
  *    Revision 1.6  2001/06/03 19:12:45  oes
  *    added FIXME
  *
@@ -172,7 +194,7 @@ int pcrs_compile_perl_options(char *optstring, int *flags)
          case 's': rc |= PCRE_DOTALL; break;
          case 'x': rc |= PCRE_EXTENDED; break;
          case 'U': rc |= PCRE_UNGREEDY; break;
          case 's': rc |= PCRE_DOTALL; break;
          case 'x': rc |= PCRE_EXTENDED; break;
          case 'U': rc |= PCRE_UNGREEDY; break;
-                  case 'T': *flags |= PCRS_TRIVIAL; break;
+          case 'T': *flags |= PCRS_TRIVIAL; break;
          default:  break;
       }
    }
          default:  break;
       }
    }
@@ -223,10 +245,10 @@ pcrs_substitute *pcrs_compile_replacement(char *replacement, int trivialflag, in
 
    if (trivialflag)
    {
 
    if (trivialflag)
    {
-          k = length;
+       k = length;
    }
    else
    }
    else
-       {
+   {
       for (i=0; i < length; i++)
       {
          /* Backslash treatment */
       for (i=0; i < length; i++)
       {
          /* Backslash treatment */
@@ -278,7 +300,7 @@ pcrs_substitute *pcrs_compile_replacement(char *replacement, int trivialflag, in
          text[k++] = replacement[i];
          quoted = 0;
       }
          text[k++] = replacement[i];
          quoted = 0;
       }
-       } /* -END- if (!trivialflag) */
+   } /* -END- if (!trivialflag) */
 
    text[k] = '\0';
    r->text = text;
 
    text[k] = '\0';
    r->text = text;
@@ -383,14 +405,14 @@ pcrs_job *pcrs_compile(char *command, int *errptr)
     */
    limit = strlen(command);
    if (limit < 4)
     */
    limit = strlen(command);
    if (limit < 4)
-       {
+   {
       *errptr = PCRS_ERR_CMDSYNTAX;
       return NULL;
    }
    else
       *errptr = PCRS_ERR_CMDSYNTAX;
       return NULL;
    }
    else
-       {
-         delimiter = command[1];
-       }
+   {
+     delimiter = command[1];
+   }
 
    tokens[l] = (char *) malloc(limit + 1);
 
 
    tokens[l] = (char *) malloc(limit + 1);
 
@@ -399,14 +421,14 @@ pcrs_job *pcrs_compile(char *command, int *errptr)
 
       if (command[i] == delimiter && !quoted)
       {
 
       if (command[i] == delimiter && !quoted)
       {
-                  if (l == 3)
-                       {
-                          l = -1;
+          if (l == 3)
+               {
+                  l = -1;
             break;
          }
             break;
          }
-             tokens[0][k++] = '\0';
+          tokens[0][k++] = '\0';
          tokens[++l] = tokens[0] + k;
          tokens[++l] = tokens[0] + k;
-             continue;
+         continue;
       }
 
       else if (command[i] == '\\' && !quoted && i+1 < limit && command[i+1] == delimiter)
       }
 
       else if (command[i] == '\\' && !quoted && i+1 < limit && command[i+1] == delimiter)
@@ -424,12 +446,12 @@ pcrs_job *pcrs_compile(char *command, int *errptr)
     */
    if (l != 3)
    {
     */
    if (l != 3)
    {
-          *errptr = PCRS_ERR_CMDSYNTAX;
+      *errptr = PCRS_ERR_CMDSYNTAX;
       free(tokens[0]);
       return NULL;
    }
 
       free(tokens[0]);
       return NULL;
    }
 
-       newjob = pcrs_make_job(tokens[1], tokens[2], tokens[3], errptr);
+   newjob = pcrs_make_job(tokens[1], tokens[2], tokens[3], errptr);
    free(tokens[0]);
    return newjob;
 
    free(tokens[0]);
    return newjob;
 
@@ -577,7 +599,7 @@ int pcrs_execute(pcrs_job *job, char *subject, int subject_length, char **result
 
    while ((submatches = pcre_exec(job->pattern, job->hints, subject, subject_length, offset, 0, offsets, 3 * PCRS_MAX_SUBMATCHES)) > 0)
    {
 
    while ((submatches = pcre_exec(job->pattern, job->hints, subject, subject_length, offset, 0, offsets, 3 * PCRS_MAX_SUBMATCHES)) > 0)
    {
-          job->flags |= PCRS_SUCCESS;
+      job->flags |= PCRS_SUCCESS;
       matches[i].submatches = submatches;
       for (k=0; k < submatches; k++)
       {
       matches[i].submatches = submatches;
       for (k=0; k < submatches; k++)
       {
index e0a5b10..7830259 100644 (file)
--- a/project.h
+++ b/project.h
@@ -1,6 +1,6 @@
 #ifndef _PROJECT_H
 #define _PROJECT_H
 #ifndef _PROJECT_H
 #define _PROJECT_H
-#define PROJECT_H_VERSION "$Id: project.h,v 1.18 2001/06/09 10:57:39 jongfoster Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.19 2001/06/29 13:33:36 oes Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/project.h,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/project.h,v $
  *
  * Revisions   :
  *    $Log: project.h,v $
  *
  * Revisions   :
  *    $Log: project.h,v $
+ *    Revision 1.19  2001/06/29 13:33:36  oes
+ *    - Improved comments
+ *    - Introduced http_request.host_ip_addr_str
+ *    - Introduced http_response.head_length
+ *    - Introduced config.my_ip_addr_str, config.my_hostname,
+ *      config.admin_address and config.proxy_info_url
+ *    - Removed config.proxy_args_header and config.proxy_args_trailer,
+ *      renamed config.proxy_args_invocation to config.proxy_args
+ *    - Removed HTML snipplets and GIFs
+ *    - Removed logentry from cancelled commit
+ *
  *    Revision 1.18  2001/06/09 10:57:39  jongfoster
  *    Adding definition of BUFFER_SIZE.
  *    Changing struct cgi_dispatcher to use "const" strings.
  *    Revision 1.18  2001/06/09 10:57:39  jongfoster
  *    Adding definition of BUFFER_SIZE.
  *    Changing struct cgi_dispatcher to use "const" strings.
 #ifdef __cplusplus
 extern "C" {
 #endif
 #ifdef __cplusplus
 extern "C" {
 #endif
-\r
-#define BUFFER_SIZE 5000\r
+
+#define BUFFER_SIZE 5000
 
 #define FOREVER 1
 
 
 #define FOREVER 1
 
index d7e9ca2..fa4163f 100644 (file)
@@ -1,4 +1,4 @@
-const char showargs_rcs[] = "$Id: showargs.c,v 1.15 2001/06/09 10:55:28 jongfoster Exp $";
+const char showargs_rcs[] = "$Id: showargs.c,v 1.16 2001/06/29 13:35:07 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/showargs.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/showargs.c,v $
@@ -34,6 +34,15 @@ const char showargs_rcs[] = "$Id: showargs.c,v 1.15 2001/06/09 10:55:28 jongfost
  *
  * Revisions   :
  *    $Log: showargs.c,v $
  *
  * Revisions   :
  *    $Log: showargs.c,v $
+ *    Revision 1.16  2001/06/29 13:35:07  oes
+ *    - Adapted
+ *    - Improved comments
+ *    - Removed init_proxy_args
+ *    - Renamed end_proxy_args(csp) to show_rcs(void)
+ *    - Removed logentry from cancelled commit
+ *    - Destroyed support for ndef SPLIT_PROXY_ARGS (Ooops)
+ *    - Separated the #define list into show_defines()
+ *
  *    Revision 1.15  2001/06/09 10:55:28  jongfoster
  *    Changing BUFSIZ ==> BUFFER_SIZE
  *
  *    Revision 1.15  2001/06/09 10:55:28  jongfoster
  *    Changing BUFSIZ ==> BUFFER_SIZE
  *
@@ -327,7 +336,7 @@ char *show_rcs(void)
 
 #undef SHOW_RCS
 
 
 #undef SHOW_RCS
 
-       return(b);
+   return(b);
 }
 
 /*********************************************************************
 }
 
 /*********************************************************************