httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgau...@hyperreal.org
Subject cvs commit: apache-1.3/src/main gen_test_char.c gen_uri_delims.c .cvsignore Makefile.tmpl util.c util_uri.c
Date Thu, 26 Mar 1998 04:58:42 GMT
dgaudet     98/03/25 20:58:42

  Modified:    src      Makefile.tmpl
               src/main .cvsignore Makefile.tmpl util.c util_uri.c
  Added:       src/main gen_test_char.c gen_uri_delims.c
  Log:
  Generate test_char_table and uri_delims at compile time so that they can
  be marked const and save on per-child memory requirements.
  
  WIN32 folks, Ben said you could handle this... you've got to compile
  something and then run it to generate the tables.
  
  Revision  Changes    Path
  1.87      +6 -6      apache-1.3/src/Makefile.tmpl
  
  Index: Makefile.tmpl
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/Makefile.tmpl,v
  retrieving revision 1.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- Makefile.tmpl	1998/03/25 11:40:46	1.86
  +++ Makefile.tmpl	1998/03/26 04:58:37	1.87
  @@ -85,9 +85,9 @@
   $(OBJS): Makefile
   
   # DO NOT REMOVE
  -buildmark.o: buildmark.c $(INCDIR)/conf.h os/unix/os.h $(INCDIR)/hide.h \
  - $(INCDIR)/hsregex.h $(INCDIR)/httpd.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \
  - $(INCDIR)/ap.h $(INCDIR)/util_uri.h
  -modules.o: modules.c $(INCDIR)/httpd.h $(INCDIR)/conf.h os/unix/os.h \
  - $(INCDIR)/hide.h $(INCDIR)/hsregex.h $(INCDIR)/alloc.h $(INCDIR)/buff.h \
  - $(INCDIR)/ap.h $(INCDIR)/util_uri.h $(INCDIR)/http_config.h
  +buildmark.o: buildmark.c include/conf.h os/unix/os.h include/hide.h \
  + include/hsregex.h include/httpd.h include/alloc.h include/buff.h \
  + include/ap.h include/util_uri.h
  +modules.o: modules.c include/httpd.h include/conf.h os/unix/os.h \
  + include/hide.h include/hsregex.h include/alloc.h include/buff.h \
  + include/ap.h include/util_uri.h include/http_config.h
  
  
  
  1.4       +4 -0      apache-1.3/src/main/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/.cvsignore,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- .cvsignore	1998/01/11 07:06:18	1.3
  +++ .cvsignore	1998/03/26 04:58:38	1.4
  @@ -1 +1,5 @@
   Makefile
  +uri_delims.h
  +gen_uri_delims
  +test_char.h
  +gen_test_char
  
  
  
  1.20      +24 -3     apache-1.3/src/main/Makefile.tmpl
  
  Index: Makefile.tmpl
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/Makefile.tmpl,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Makefile.tmpl	1998/03/17 15:42:27	1.19
  +++ Makefile.tmpl	1998/03/26 04:58:39	1.20
  @@ -27,12 +27,28 @@
   	$(RANLIB) $@
   
   clean:
  -	rm -f *.o $(LIB)
  +	rm -f *.o $(LIB) uri_delims.h gen_uri_delims test_char.h gen_test_char
   
   # Work around broken compilers
   http_bprintf.o: http_bprintf.c
   	$(CC) -c $(INCLUDES) $(CFLAGS) $(BROKEN_BPRINTF_FLAGS) http_bprintf.c
   
  +uri_delims.h: gen_uri_delims
  +	./gen_uri_delims >uri_delims.h
  +
  +util_uri.o: uri_delims.h
  +
  +gen_uri_delims: gen_uri_delims.o
  +	$(CC) $(CFLAGS) $(LDFLAGS) -o gen_uri_delims gen_uri_delims.o $(LIBS)
  +
  +test_char.h: gen_test_char
  +	./gen_test_char >test_char.h
  +
  +util.o: test_char.h
  +
  +gen_test_char: gen_test_char.o
  +	$(CC) $(CFLAGS) $(LDFLAGS) -o gen_test_char gen_test_char.o $(LIBS)
  +
   # We really don't expect end users to use this rule.  It works only with
   # gcc, and rebuilds Makefile.tmpl.  You have to re-run Configure after
   # using it.
  @@ -59,6 +75,11 @@
    $(INCDIR)/http_main.h $(INCDIR)/http_log.h
   fnmatch.o: fnmatch.c $(INCDIR)/conf.h ../os/unix/os.h \
    $(INCDIR)/hide.h $(INCDIR)/hsregex.h $(INCDIR)/fnmatch.h
  +gen_test_char.o: gen_test_char.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \
  + ../os/unix/os.h $(INCDIR)/hide.h $(INCDIR)/hsregex.h \
  + $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  + $(INCDIR)/util_uri.h
  +gen_uri_delims.o: gen_uri_delims.c
   http_bprintf.o: http_bprintf.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \
    ../os/unix/os.h $(INCDIR)/hide.h $(INCDIR)/hsregex.h \
    $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
  @@ -124,7 +145,7 @@
   util.o: util.c $(INCDIR)/httpd.h $(INCDIR)/conf.h ../os/unix/os.h \
    $(INCDIR)/hide.h $(INCDIR)/hsregex.h $(INCDIR)/alloc.h \
    $(INCDIR)/buff.h $(INCDIR)/ap.h $(INCDIR)/util_uri.h \
  - $(INCDIR)/http_conf_globals.h $(INCDIR)/http_log.h
  + $(INCDIR)/http_conf_globals.h $(INCDIR)/http_log.h test_char.h
   util_date.o: util_date.c $(INCDIR)/conf.h ../os/unix/os.h \
    $(INCDIR)/hide.h $(INCDIR)/hsregex.h $(INCDIR)/util_date.h
   util_md5.o: util_md5.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \
  @@ -143,4 +164,4 @@
    ../os/unix/os.h $(INCDIR)/hide.h $(INCDIR)/hsregex.h \
    $(INCDIR)/alloc.h $(INCDIR)/buff.h $(INCDIR)/ap.h \
    $(INCDIR)/util_uri.h $(INCDIR)/http_log.h \
  - $(INCDIR)/http_conf_globals.h
  + $(INCDIR)/http_conf_globals.h uri_delims.h
  
  
  
  1.108     +6 -39     apache-1.3/src/main/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/util.c,v
  retrieving revision 1.107
  retrieving revision 1.108
  diff -u -r1.107 -r1.108
  --- util.c	1998/03/18 08:26:39	1.107
  +++ util.c	1998/03/26 04:58:40	1.108
  @@ -75,14 +75,10 @@
   #endif
   
   /* A bunch of functions in util.c scan strings looking for certain characters.
  - * To make that more efficient we encode a lookup table.
  + * To make that more efficient we encode a lookup table.  The test_char_table
  + * is generated automatically by gen_test_char.c.
    */
  -#define T_ESCAPE_SHELL_CMD	(0x01)
  -#define T_ESCAPE_PATH_SEGMENT	(0x02)
  -#define T_OS_ESCAPE_PATH	(0x04)
  -#define T_HTTP_TOKEN_STOP	(0x08)
  -
  -static unsigned char test_char_table[256];
  +#include "test_char.h"
   
   /* we assume the folks using this ensure 0 <= c < 256... which means
    * you need a cast to (unsigned char) first, you can't just plug a
  @@ -91,40 +87,11 @@
    */
   #define TEST_CHAR(c, f)	(test_char_table[(unsigned)(c)] & (f))
   
  -/* XXX: this should be compile-time initialized so that test_char_table can
  - * live in read-only memory and not require backing store across fork(). 
  - */
   void util_init(void)
   {
  -    unsigned c;
  -    unsigned char flags;
  -
  -    /* explicitly deal with NUL in case some strchr() do bogosity with it */
  -    test_char_table[0] = 0;
  -
  -    for (c = 1; c < 256; ++c) {
  -	flags = 0;
  -
  -	/* escape_shell_cmd */
  -	if (strchr("&;`'\"|*?~<>^()[]{}$\\\n", c)) {
  -	    flags |= T_ESCAPE_SHELL_CMD;
  -	}
  -
  -	if (!isalnum(c) && !strchr("$-_.+!*'(),:@&=~", c)) {
  -	    flags |= T_ESCAPE_PATH_SEGMENT;
  -	}
  -
  -	if (!isalnum(c) && !strchr("$-_.+!*'(),:@&=/~", c)) {
  -	    flags |= T_OS_ESCAPE_PATH;
  -	}
  -
  -	/* these are the "tspecials" from RFC2068 */
  -	if (iscntrl(c) || strchr(" \t()<>@,;:\\/[]?={}", c)) {
  -	    flags |= T_HTTP_TOKEN_STOP;
  -	}
  -
  -	test_char_table[c] = flags;
  -    }
  +    /* nothing to do... previously there was run-time initialization of
  +     * test_char_table here
  +     */
   }
   
   
  
  
  
  1.15      +5 -7      apache-1.3/src/main/util_uri.c
  
  Index: util_uri.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/util_uri.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- util_uri.c	1998/03/25 18:14:55	1.14
  +++ util_uri.c	1998/03/26 04:58:41	1.15
  @@ -392,7 +392,10 @@
   #define T_HASH		0x08	/* '#' */
   #define T_NUL		0x80	/* '\0' */
   
  -static unsigned char uri_delims[256];
  +/* the uri_delims.h file is autogenerated by gen_uri_delims.c */
  +static const unsigned char uri_delims[256] = {
  +#include "uri_delims.h"
  +};
   
   /* it works like this:
       if (uri_delims[ch] & NOTEND_foobar) {
  @@ -409,12 +412,7 @@
   
   void util_uri_init(void)
   {
  -    memset(uri_delims, 0, sizeof(uri_delims));
  -    uri_delims[':'] = T_COLON;
  -    uri_delims['/'] = T_SLASH;
  -    uri_delims['?'] = T_QUESTION;
  -    uri_delims['#'] = T_HASH;
  -    uri_delims['\0'] = T_NUL;
  +    /* nothing to do */
   }
   
   /* parse_uri_components():
  
  
  
  1.1                  apache-1.3/src/main/gen_test_char.c
  
  Index: gen_test_char.c
  ===================================================================
  /* we need some of the portability definitions... for strchr */
  #include "httpd.h"
  
  /* A bunch of functions in util.c scan strings looking for certain characters.
   * To make that more efficient we encode a lookup table.
   */
  #define T_ESCAPE_SHELL_CMD	(0x01)
  #define T_ESCAPE_PATH_SEGMENT	(0x02)
  #define T_OS_ESCAPE_PATH	(0x04)
  #define T_HTTP_TOKEN_STOP	(0x08)
  
  void main(void)
  {
      unsigned c;
      unsigned char flags;
  
      printf(
  "/* this file is automatically generated by gen_test_char, do not edit */\n"
  "#define T_ESCAPE_SHELL_CMD	(%u)\n"
  "#define T_ESCAPE_PATH_SEGMENT	(%u)\n"
  "#define T_OS_ESCAPE_PATH	(%u)\n"
  "#define T_HTTP_TOKEN_STOP	(%u)\n"
  "\n"
  "static const unsigned char test_char_table[256] = {\n"
  "0,\n",
  	T_ESCAPE_SHELL_CMD,
  	T_ESCAPE_PATH_SEGMENT,
  	T_OS_ESCAPE_PATH,
  	T_HTTP_TOKEN_STOP);
  
      /* we explicitly dealt with NUL above
       * in case some strchr() do bogosity with it */
  
      for (c = 1; c < 256; ++c) {
  	flags = 0;
  
  	/* escape_shell_cmd */
  	if (strchr("&;`'\"|*?~<>^()[]{}$\\\n", c)) {
  	    flags |= T_ESCAPE_SHELL_CMD;
  	}
  
  	if (!isalnum(c) && !strchr("$-_.+!*'(),:@&=~", c)) {
  	    flags |= T_ESCAPE_PATH_SEGMENT;
  	}
  
  	if (!isalnum(c) && !strchr("$-_.+!*'(),:@&=/~", c)) {
  	    flags |= T_OS_ESCAPE_PATH;
  	}
  
  	/* these are the "tspecials" from RFC2068 */
  	if (iscntrl(c) || strchr(" \t()<>@,;:\\/[]?={}", c)) {
  	    flags |= T_HTTP_TOKEN_STOP;
  	}
  	printf("%u%c\n", flags, (c < 255) ? ',' : ' ');
      }
      printf("};\n");
      exit(0);
  }
  
  
  
  1.1                  apache-1.3/src/main/gen_uri_delims.c
  
  Index: gen_uri_delims.c
  ===================================================================
  #include <stdio.h>
  
  /* generate a table of 256 values, where certain characters are
   * marked "interesting"... for the uri parsing process.
   */
  
  void main(void)
  {
      int i;
      char *value;
  
      printf("/* this file is automatically generated by "
  	    "gen_uri_delims, do not edit */\n");
      for (i = 0; i < 256; ++i) {
  	switch (i) {
  	case ':': 	value = "T_COLON";	break;
  	case '/': 	value = "T_SLASH";	break;
  	case '?': 	value = "T_QUESTION";	break;
  	case '#': 	value = "T_HASH";	break;
  	case '\0': 	value = "T_NUL";	break;
  	default:	value = "0";		break;
  	}
  	printf("%s%c\n", value, (i < 255) ? ',' : ' ');
      }
      exit(0);
  }
  
  
  

Mime
View raw message