httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@hyperreal.com>
Subject cvs commit: apache/src alloc.c alloc.h httpd.h util.c
Date Sun, 13 Oct 1996 13:35:32 GMT
ben         96/10/13 06:35:32

  Modified:    src       alloc.c alloc.h httpd.h util.c
  Log:
  More constification and hiding of internal functions.
  
  Revision  Changes    Path
  1.16      +8 -8      apache/src/alloc.c
  
  Index: alloc.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/alloc.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -C3 -r1.15 -r1.16
  *** alloc.c	1996/10/06 17:29:55	1.15
  --- alloc.c	1996/10/13 13:35:28	1.16
  ***************
  *** 50,56 ****
     *
     */
    
  ! /* $Id: alloc.c,v 1.15 1996/10/06 17:29:55 ben Exp $ */
    
    
    /*
  --- 50,56 ----
     *
     */
    
  ! /* $Id: alloc.c,v 1.16 1996/10/13 13:35:28 ben Exp $ */
    
    
    /*
  ***************
  *** 681,687 ****
      }
    }
    
  ! void run_cleanup (pool *p, void *data, void (*cleanup)(void *))
    {
      block_alarms();		/* Run cleanup only once! */
      (*cleanup)(data);
  --- 681,687 ----
      }
    }
    
  ! static void run_cleanup (pool *p, void *data, void (*cleanup)(void *))
    {
      block_alarms();		/* Run cleanup only once! */
      (*cleanup)(data);
  ***************
  *** 738,744 ****
        kill_cleanup(p,(void *)fd,fd_cleanup);
        }
    
  ! int popenf(struct pool *a, char *name, int flg, int mode)
    {
      int fd;
    
  --- 738,744 ----
        kill_cleanup(p,(void *)fd,fd_cleanup);
        }
    
  ! int popenf(pool *a, const char *name, int flg, int mode)
    {
      int fd;
    
  ***************
  *** 749,755 ****
      return fd;
    }
    
  ! int pclosef(struct pool *a, int fd)
    {
      int res;
      
  --- 749,755 ----
      return fd;
    }
    
  ! int pclosef(pool *a, int fd)
    {
      int res;
      
  ***************
  *** 768,778 ****
    static void file_cleanup (void *fpv) { fclose ((FILE *)fpv); }
    static void file_child_cleanup (void *fpv) { close (fileno ((FILE *)fpv)); }
    
  ! void note_cleanups_for_file (struct pool *p, FILE *fp) {
      register_cleanup (p, (void *)fp, file_cleanup, file_child_cleanup);
    }
    
  ! FILE *pfopen(struct pool *a, char *name, char *mode)
    {
      FILE *fd = NULL;
      int baseFlag, desc;
  --- 768,778 ----
    static void file_cleanup (void *fpv) { fclose ((FILE *)fpv); }
    static void file_child_cleanup (void *fpv) { close (fileno ((FILE *)fpv)); }
    
  ! void note_cleanups_for_file (pool *p, FILE *fp) {
      register_cleanup (p, (void *)fp, file_cleanup, file_child_cleanup);
    }
    
  ! FILE *pfopen(pool *a, const char *name, const char *mode)
    {
      FILE *fd = NULL;
      int baseFlag, desc;
  ***************
  *** 796,802 ****
      return fd;
    }
    
  ! FILE *pfdopen(struct pool *a,int fd,char *mode)
    {
      FILE *f;
    
  --- 796,802 ----
      return fd;
    }
    
  ! FILE *pfdopen(pool *a,int fd, const char *mode)
    {
      FILE *f;
    
  ***************
  *** 809,815 ****
    }
    
    
  ! int pfclose(struct pool *a, FILE *fd)
    {
      int res;
      
  --- 809,815 ----
    }
    
    
  ! int pfclose(pool *a, FILE *fd)
    {
      int res;
      
  
  
  
  1.12      +4 -4      apache/src/alloc.h
  
  Index: alloc.h
  ===================================================================
  RCS file: /export/home/cvs/apache/src/alloc.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -C3 -r1.11 -r1.12
  *** alloc.h	1996/10/06 17:29:55	1.11
  --- alloc.h	1996/10/13 13:35:29	1.12
  ***************
  *** 51,57 ****
     *
     */
    
  ! /* $Id: alloc.h,v 1.11 1996/10/06 17:29:55 ben Exp $ */
    
    /*
     * Resource allocation routines...
  --- 51,57 ----
     *
     */
    
  ! /* $Id: alloc.h,v 1.12 1996/10/13 13:35:29 ben Exp $ */
    
    /*
     * Resource allocation routines...
  ***************
  *** 201,209 ****
     * the note_cleanups_for_foo routines are for 
     */
    
  ! FILE *pfopen(struct pool *, char *name, char *fmode);
  ! FILE *pfdopen(struct pool *, int fd, char *fmode);
  ! int popenf(struct pool *, char *name, int flg, int mode); 
    
    void note_cleanups_for_file (pool *, FILE *);
    void note_cleanups_for_fd (pool *, int);
  --- 201,209 ----
     * the note_cleanups_for_foo routines are for 
     */
    
  ! FILE *pfopen(struct pool *, const char *name, const char *fmode);
  ! FILE *pfdopen(struct pool *, int fd, const char *fmode);
  ! int popenf(struct pool *, const char *name, int flg, int mode); 
    
    void note_cleanups_for_file (pool *, FILE *);
    void note_cleanups_for_fd (pool *, int);
  
  
  
  1.54      +21 -21    apache/src/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /export/home/cvs/apache/src/httpd.h,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -C3 -r1.53 -r1.54
  *** httpd.h	1996/10/10 09:02:43	1.53
  --- httpd.h	1996/10/13 13:35:29	1.54
  ***************
  *** 50,56 ****
     *
     */
    
  ! /* $Id: httpd.h,v 1.53 1996/10/10 09:02:43 fielding Exp $ */
    
    /*
     * httpd.h: header for simple (ha! not anymore) http daemon
  --- 50,56 ----
     *
     */
    
  ! /* $Id: httpd.h,v 1.54 1996/10/13 13:35:29 ben Exp $ */
    
    /*
     * httpd.h: header for simple (ha! not anymore) http daemon
  ***************
  *** 590,596 ****
    
    struct tm *get_gmtoff(long *tz);
    char *get_time();
  ! char *ht_time (pool *p, time_t t, char *fmt, int gmt);     
    char *gm_timestr_822(pool *p, time_t t);
         
    /* String handling */     
  --- 590,596 ----
    
    struct tm *get_gmtoff(long *tz);
    char *get_time();
  ! char *ht_time (pool *p, time_t t, const char *fmt, int gmt);     
    char *gm_timestr_822(pool *p, time_t t);
         
    /* String handling */     
  ***************
  *** 601,628 ****
    char *getword_conf (pool *p, char **line);      
    
    char *get_token (pool *p, char **accept_line, int accept_white);
  ! int find_token (pool *p, char *line, char *tok);
         
  ! int is_url(char *u);
    extern int unescape_url(char *url);
    void no2slash(char *name);
    void getparents(char *name);
    char *escape_path_segment(pool *p, const char *s);
    char *os_escape_path(pool *p,const char *path,int partial);
  ! char *escape_uri (pool *p, char *s);
    extern char *escape_html(pool *p, const char *s);
  ! char *construct_server(pool *p, char *hostname, int port);
  ! char *construct_url (pool *p, char *path, server_rec *s);     
  ! char *escape_shell_cmd (pool *p, char *s);
         
  ! int count_dirs(char *path);
  ! char *make_dirstr(pool *a, char *s, int n);
  ! char *make_full_path(pool *a, char *dir, char *f);
         
  ! int is_matchexp(char *str);
  ! int strcmp_match(char *str, char *exp);
  ! int strcasecmp_match(char *str, char *exp);
  ! char *uudecode (pool *, char *);
    
    char *pregsub(pool *p, const char *input, const char *source,
    	      size_t nmatch, regmatch_t pmatch[]);
  --- 601,628 ----
    char *getword_conf (pool *p, char **line);      
    
    char *get_token (pool *p, char **accept_line, int accept_white);
  ! int find_token (pool *p, const char *line, const char *tok);
         
  ! int is_url(const char *u);
    extern int unescape_url(char *url);
    void no2slash(char *name);
    void getparents(char *name);
    char *escape_path_segment(pool *p, const char *s);
    char *os_escape_path(pool *p,const char *path,int partial);
  ! char *escape_uri (pool *p, const char *s);
    extern char *escape_html(pool *p, const char *s);
  ! char *construct_server(pool *p, const char *hostname, int port);
  ! char *construct_url (pool *p, const char *path, const server_rec *s);     
  ! char *escape_shell_cmd (pool *p, const char *s);
         
  ! int count_dirs(const char *path);
  ! char *make_dirstr(pool *a, const char *s, int n);
  ! char *make_full_path(pool *a, const char *dir, const char *f);
         
  ! int is_matchexp(const char *str);
  ! int strcmp_match(const char *str, const char *exp);
  ! int strcasecmp_match(const char *str, const char *exp);
  ! char *uudecode (pool *, const char *);
    
    char *pregsub(pool *p, const char *input, const char *source,
    	      size_t nmatch, regmatch_t pmatch[]);
  ***************
  *** 635,647 ****
         
    /* Misc system hackery */
         
  ! uid_t uname2id(char *name);
  ! gid_t gname2id(char *name);
  ! int is_directory(char *name);
  ! int can_exec(struct stat *);     
  ! void chdir_file(char *file);
         
    char *get_local_host(pool *);
  ! unsigned long get_virthost_addr (char *hostname, short int *port);
    
    extern time_t restart_time;
  --- 635,647 ----
         
    /* Misc system hackery */
         
  ! uid_t uname2id(const char *name);
  ! gid_t gname2id(const char *name);
  ! int is_directory(const char *name);
  ! int can_exec(const struct stat *);     
  ! void chdir_file(const char *file);
         
    char *get_local_host(pool *);
  ! unsigned long get_virthost_addr (const char *hostname, short int *port);
    
    extern time_t restart_time;
  
  
  
  1.23      +35 -30    apache/src/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/util.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -C3 -r1.22 -r1.23
  *** util.c	1996/10/02 00:31:52	1.22
  --- util.c	1996/10/13 13:35:30	1.23
  ***************
  *** 50,56 ****
     *
     */
    
  ! /* $Id: util.c,v 1.22 1996/10/02 00:31:52 jim Exp $ */
    
    /*
     * str.c: string utility things
  --- 50,56 ----
     *
     */
    
  ! /* $Id: util.c,v 1.23 1996/10/13 13:35:30 ben Exp $ */
    
    /*
     * str.c: string utility things
  ***************
  *** 76,82 ****
        return (time_string);
    }
    
  ! char *ht_time(pool *p, time_t t, char *fmt, int gmt) {
        char ts[MAX_STRING_LEN];
        struct tm *tms;
    
  --- 76,82 ----
        return (time_string);
    }
    
  ! char *ht_time(pool *p, time_t t, const char *fmt, int gmt) {
        char ts[MAX_STRING_LEN];
        struct tm *tms;
    
  ***************
  *** 134,140 ****
    /* Based loosely on sections of wildmat.c by Rich Salz
     * Hmmm... shouldn't this really go component by component?
     */
  ! int strcmp_match(char *str, char *exp) {
        int x,y;
    
        for(x=0,y=0;exp[y];++y,++x) {
  --- 134,140 ----
    /* Based loosely on sections of wildmat.c by Rich Salz
     * Hmmm... shouldn't this really go component by component?
     */
  ! int strcmp_match(const char *str, const char *exp) {
        int x,y;
    
        for(x=0,y=0;exp[y];++y,++x) {
  ***************
  *** 157,163 ****
        return (str[x] != '\0');
    }
    
  ! int strcasecmp_match(char *str, char *exp) {
        int x,y;
    
        for(x=0,y=0;exp[y];++y,++x) {
  --- 157,163 ----
        return (str[x] != '\0');
    }
    
  ! int strcasecmp_match(const char *str, const char *exp) {
        int x,y;
    
        for(x=0,y=0;exp[y];++y,++x) {
  ***************
  *** 180,186 ****
        return (str[x] != '\0');
    }
    
  ! int is_matchexp(char *str) {
        register int x;
    
        for(x=0;str[x];x++)
  --- 180,186 ----
        return (str[x] != '\0');
    }
    
  ! int is_matchexp(const char *str) {
        register int x;
    
        for(x=0;str[x];x++)
  ***************
  *** 189,195 ****
        return 0;
    }
    
  ! /* This function substitues for $0-$9, filling in regular expression
     * submatches. Pass it the same nmatch and pmatch arguments that you
     * passed regexec(). pmatch should not be greater than the maximum number
     * of subexpressions - i.e. one more than the re_nsub member of regex_t.
  --- 189,195 ----
        return 0;
    }
    
  ! /* This function substitutes for $0-$9, filling in regular expression
     * submatches. Pass it the same nmatch and pmatch arguments that you
     * passed regexec(). pmatch should not be greater than the maximum number
     * of subexpressions - i.e. one more than the re_nsub member of regex_t.
  ***************
  *** 335,341 ****
    	else x++;
    }
    
  ! char *make_dirstr(pool *p, char *s, int n) {
        register int x,f;
        char *res;
    
  --- 335,341 ----
    	else x++;
    }
    
  ! char *make_dirstr(pool *p, const char *s, int n) {
        register int x,f;
        char *res;
    
  ***************
  *** 356,362 ****
            return pstrcat (p, s, "/", NULL);
    }
    
  ! int count_dirs(char *path) {
        register int x,n;
    
        for(x=0,n=0;path[x];x++)
  --- 356,362 ----
            return pstrcat (p, s, "/", NULL);
    }
    
  ! int count_dirs(const char *path) {
        register int x,n;
    
        for(x=0,n=0;path[x];x++)
  ***************
  *** 365,378 ****
    }
    
    
  ! void chdir_file(char *file) {
        int i;
    
        if((i = rind(file,'/')) == -1)
            return;
  !     file[i] = '\0';
        chdir(file);
  !     file[i] = '/';
    }
    
    char *getword(pool* atrans, char **line, char stop) {
  --- 365,378 ----
    }
    
    
  ! void chdir_file(const char *file) {
        int i;
    
        if((i = rind(file,'/')) == -1)
            return;
  !     ((char *)file)[i] = '\0';
        chdir(file);
  !     ((char *)file)[i] = '/';
    }
    
    char *getword(pool* atrans, char **line, char stop) {
  ***************
  *** 449,455 ****
     * all honored
     */
    
  ! char *substring_conf (pool *p, char *start, int len, char quote)
    {
        char *result = palloc (p, len + 2);
        char *resp = result;
  --- 449,455 ----
     * all honored
     */
    
  ! static char *substring_conf (pool *p, char *start, int len, char quote)
    {
        char *result = palloc (p, len + 2);
        char *resp = result;
  ***************
  *** 502,507 ****
  --- 502,510 ----
        return res;
    }
    
  + #ifdef UNDEF
  + /* this function is dangerous, and superceded by getword_white, so don't use it
  +  */
    void cfg_getword(char *word, char *line) {
        int x=0,y;
        
  ***************
  *** 520,525 ****
  --- 523,529 ----
        while(line[x] && isspace(line[x])) ++x;
        for(y=0;(line[y] = line[x]);++x,++y);
    }
  + #endif
    
    int
    cfg_getline(char *s, int n, FILE *f) {
  ***************
  *** 632,644 ****
        return ret;
    }
    
  ! int find_token (pool *p, char *line, char *tok) {
        char *ltok;
    
        if (!line) return 0;
    
  !     line = pstrdup (p, line);
  !     while ((ltok = next_token (&line)))
            if (!strcasecmp (ltok, tok))
                return 1;
    
  --- 636,649 ----
        return ret;
    }
    
  ! int find_token (pool *p, const char *line, const char *tok) {
        char *ltok;
  +     char *lcopy;
    
        if (!line) return 0;
    
  !     lcopy = pstrdup (p, line);
  !     while ((ltok = next_token (&lcopy)))
            if (!strcasecmp (ltok, tok))
                return 1;
    
  ***************
  *** 646,652 ****
    }
    
    
  ! char *escape_shell_cmd(pool *p, char *s) {
        register int x,y,l;
        char *cmd;
    
  --- 651,657 ----
    }
    
    
  ! char *escape_shell_cmd(pool *p, const char *s) {
        register int x,y,l;
        char *cmd;
    
  ***************
  *** 688,694 ****
        for(x=0;str[x];x++) if(str[x] == ' ') str[x] = '+';
    }
    
  ! char x2c(char *what) {
        register char digit;
    
        digit = ((what[0] >= 'A') ? ((what[0] & 0xdf) - 'A')+10 : (what[0] - '0'));
  --- 693,699 ----
        for(x=0;str[x];x++) if(str[x] == ' ') str[x] = '+';
    }
    
  ! static char x2c(const char *what) {
        register char digit;
    
        digit = ((what[0] >= 'A') ? ((what[0] & 0xdf) - 'A')+10 : (what[0] - '0'));
  ***************
  *** 735,752 ****
        else return OK;
    }
    
  ! char *construct_server(pool *p, char *hostname, int port) {
        char portnum[10];		/* Long enough.  Really! */
      
        if (port == 80)
  ! 	return hostname;
        else {
            sprintf (portnum, "%d", port);
    	return pstrcat (p, hostname, ":", portnum, NULL);
        }
    }
    
  ! char *construct_url(pool *p, char *uri, server_rec *s) {
        return pstrcat (p, "http://",
    		    construct_server(p, s->server_hostname, s->port),
    		    uri, NULL);
  --- 740,757 ----
        else return OK;
    }
    
  ! char *construct_server(pool *p, const char *hostname, int port) {
        char portnum[10];		/* Long enough.  Really! */
      
        if (port == 80)
  ! 	return (char *)hostname;
        else {
            sprintf (portnum, "%d", port);
    	return pstrcat (p, hostname, ":", portnum, NULL);
        }
    }
    
  ! char *construct_url(pool *p, const char *uri, const server_rec *s) {
        return pstrcat (p, "http://",
    		    construct_server(p, s->server_hostname, s->port),
    		    uri, NULL);
  ***************
  *** 819,825 ****
      return copy;
    }
    
  ! char *escape_uri(pool *p, char *uri) {
        register int x,y;
        char *copy = palloc (p, 3 * strlen (uri) + 1);
                
  --- 824,830 ----
      return copy;
    }
    
  ! char *escape_uri(pool *p, const char *uri) {
        register int x,y;
        char *copy = palloc (p, 3 * strlen (uri) + 1);
                
  ***************
  *** 887,893 ****
    
    #endif
    
  ! int is_directory(char *path) {
        struct stat finfo;
    
        if(stat(path,&finfo) == -1)
  --- 892,898 ----
    
    #endif
    
  ! int is_directory(const char *path) {
        struct stat finfo;
    
        if(stat(path,&finfo) == -1)
  ***************
  *** 896,902 ****
        return(S_ISDIR(finfo.st_mode));
    }
    
  ! char *make_full_path(pool *a, char *src1,char *src2) {
        register int x;
    
        x = strlen(src1);
  --- 901,907 ----
        return(S_ISDIR(finfo.st_mode));
    }
    
  ! char *make_full_path(pool *a, const char *src1, const char *src2) {
        register int x;
    
        x = strlen(src1);
  ***************
  *** 906,912 ****
        else return pstrcat (a, src1, src2, NULL);
    }
    
  ! int is_url(char *u) {
        register int x;
    
        for(x=0;u[x] != ':';x++)
  --- 911,917 ----
        else return pstrcat (a, src1, src2, NULL);
    }
    
  ! int is_url(const char *u) {
        register int x;
    
        for(x=0;u[x] != ':';x++)
  ***************
  *** 918,924 ****
        else return 0;
    }
    
  ! int can_exec(struct stat *finfo) {
    #ifdef MULTIPLE_GROUPS
      int cnt;
    #endif
  --- 923,929 ----
        else return 0;
    }
    
  ! int can_exec(const struct stat *finfo) {
    #ifdef MULTIPLE_GROUPS
      int cnt;
    #endif
  ***************
  *** 944,950 ****
    }
    
    #ifdef NEED_STRDUP
  ! char *strdup (char *str)
    {
      char *dup;
    
  --- 949,955 ----
    }
    
    #ifdef NEED_STRDUP
  ! char *strdup (const char *str)
    {
      char *dup;
    
  ***************
  *** 1068,1074 ****
        }
    }
            
  ! uid_t uname2id(char *name) {
        struct passwd *ent;
    
        if(name[0] == '#') 
  --- 1073,1079 ----
        }
    }
            
  ! uid_t uname2id(const char *name) {
        struct passwd *ent;
    
        if(name[0] == '#') 
  ***************
  *** 1081,1087 ****
        return(ent->pw_uid);
    }
    
  ! gid_t gname2id(char *name) {
        struct group *ent;
    
        if(name[0] == '#') 
  --- 1086,1092 ----
        return(ent->pw_uid);
    }
    
  ! gid_t gname2id(const char *name) {
        struct group *ent;
    
        if(name[0] == '#') 
  ***************
  *** 1124,1130 ****
     * Parses a host of the form <address>[:port]
     * :port is permitted if 'port' is not NULL
     */
  ! unsigned long get_virthost_addr (char *w, short int *ports) {
        struct hostent *hep;
        unsigned long my_addr;
        char *p;
  --- 1129,1135 ----
     * Parses a host of the form <address>[:port]
     * :port is permitted if 'port' is not NULL
     */
  ! unsigned long get_virthost_addr (const char *w, short int *ports) {
        struct hostent *hep;
        unsigned long my_addr;
        char *p;
  ***************
  *** 1246,1252 ****
        64,64,64,64,64,64,64,64,64,64,64,64,64
    };
    
  ! char *uudecode(pool *p, char *bufcoded) {
        int nbytesdecoded;
        register unsigned char *bufin;
        register char *bufplain;
  --- 1251,1257 ----
        64,64,64,64,64,64,64,64,64,64,64,64,64
    };
    
  ! char *uudecode(pool *p, const char *bufcoded) {
        int nbytesdecoded;
        register unsigned char *bufin;
        register char *bufplain;
  
  
  

Mime
View raw message