You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by je...@apache.org on 2008/09/16 22:41:45 UTC

svn commit: r696047 - in /httpd/flood/trunk: flood_subst_file.c flood_subst_file.h

Author: jerenkrantz
Date: Tue Sep 16 13:41:45 2008
New Revision: 696047

URL: http://svn.apache.org/viewvc?rev=696047&view=rev
Log:
Fix up flood_subst_file implementation so that we compile again on Mac OS X.

Also fix up various nits, add licensing blocks, and reformat to better follow
coding standards.

* flood_subst_file.c, flood_subst_file.h: Misc. fixes.

Modified:
    httpd/flood/trunk/flood_subst_file.c
    httpd/flood/trunk/flood_subst_file.h

Modified: httpd/flood/trunk/flood_subst_file.c
URL: http://svn.apache.org/viewvc/httpd/flood/trunk/flood_subst_file.c?rev=696047&r1=696046&r2=696047&view=diff
==============================================================================
--- httpd/flood/trunk/flood_subst_file.c (original)
+++ httpd/flood/trunk/flood_subst_file.c Tue Sep 16 13:41:45 2008
@@ -1,14 +1,31 @@
-#include <assert.h>
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 #include <apr_general.h>
 #include <apr_file_io.h>
+
 #include "flood_subst_file.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
 #define IS_NUM(c)       (('0' <= (c)) && ('9' >= (c)))
 
-apr_file_t* subst_file = NULL;
 extern apr_file_t *local_stdout;
 extern apr_file_t *local_stderr;
-apr_off_t fsize;
-char * pp = "thisis\nmytest";
 
 void subst_list_init(subst_rec_t *subst_list, int subst_list_size) {
   int i;
@@ -23,43 +40,20 @@
   }
 }
 
-void subst_list_make(subst_rec_t *subst_list) {
-  int i2 = 0;
-
-  subst_list[0].subst_var = "name";
-  subst_list[0].subst_file_name = "/pmalab1/temphome/guyf/work/replace_mc5/flood_stuff/build/flood-0.4/test";
-  subst_list[0].subst_mode = 0;
-  subst_list[0].valid = 1;
-  i2++;
-
-  subst_list[i2].subst_var = "foot";
-  subst_list[i2].subst_file_name = "/pmalab1/temphome/guyf/work/replace_mc5/flood_stuff/build/flood-0.4/blort";
-  subst_list[i2].subst_mode = 0;
-  subst_list[i2].valid = 1;
-
-  i2++;
-  subst_list[i2].subst_var = "nerve";
-  subst_list[i2].subst_file_name = "/pmalab1/temphome/guyf/work/replace_mc5/flood_stuff/build/flood-0.4/cavort";
-  subst_list[i2].subst_mode = 0;
-  subst_list[i2].valid = 1;
-}
-
 subst_rec_t* subst_file_get(const char* varname, subst_rec_t* subst_list) {
   int i;
 
   for (i = 0; i < SUBST_FILE_ARR_MAX; i++) {
     if ((strcmp(subst_list[i].subst_var, varname) == 0)
-	&& subst_list[i].valid) {
+        && subst_list[i].valid) {
       return &(subst_list[i]);
     }
   }
   return NULL;
 }
 
-
 void subst_file_err(const char* msgtext, const char* vartext, apr_status_t errcode) {
   char errtext[SUBST_FILE_ERROR_BUF];
-  apr_file_t* local_stderr;
   apr_pool_t *err_pool;
 
   if (apr_pool_create(&err_pool, NULL) != APR_SUCCESS) {
@@ -68,25 +62,23 @@
   }
 
   apr_strerror(errcode, (char *) &errtext, SUBST_FILE_ERROR_BUF);
-  apr_file_open_stderr(&local_stderr, err_pool);
 
   apr_file_printf(local_stderr, "%s %s %s\n", msgtext, vartext, errtext);
-  apr_file_close(local_stderr);
 
   apr_pool_destroy(err_pool);
 }
 
-
-int subst_file_open(apr_file_t** subst_file, const char* fname, apr_off_t* fsize, apr_pool_t* pool) {
+int subst_file_open(apr_file_t** subst_file, const char* fname,
+                    apr_off_t* fsize, apr_pool_t* pool) {
   apr_finfo_t finfo;
   apr_status_t rc = 0;
   apr_int32_t wanted = APR_FINFO_SIZE;
 
-  rc  = apr_file_open(subst_file, fname, APR_READ, APR_OS_DEFAULT, pool);
+  rc = apr_file_open(subst_file, fname, APR_READ, APR_OS_DEFAULT, pool);
 
   if (rc) {
     subst_file_err("Couldn't open file", fname, rc);
-    exit(-1 );
+    exit(-1);
   }
 
   rc = 0;
@@ -100,17 +92,6 @@
   return 0;
 }
 
-
-int close_subst_file(apr_file_t* subst_file) {
-  apr_status_t rc = 0;
-
-  if (subst_file) {
-    rc = apr_file_close(subst_file);
-  }
-  return rc;
-}
-
- 
 char* subst_file_entry_get(apr_file_t** subst_file, apr_off_t *fsize, char* line, int line_size) {
   apr_off_t seek_val;
   apr_off_t zero = 0;
@@ -142,7 +123,6 @@
   return line;
 }
 
-
 /* a substitution file entry (nomimally a single line) can now contain */
 /* escaped characters such as \n, \t, \012 so that the entry can be */
 /* a multi-line POST payload */
@@ -161,26 +141,26 @@
     if (*from == '\\') {
       ++from;
       if (IS_NUM(*from)) {
-	num = *from++ - '0';
-	if (IS_NUM(*from))
-	  num = num*10 + (*from++ - '0');
-	if (IS_NUM(*from))
-	  num = num*10 + (*from++ - '0');
-	if (num != 0) {
-	  *to++ = num;
-	} else {
-	  *to++ = '\\';
-	  *to++ = '0';
-	}
+          num = *from++ - '0';
+          if (IS_NUM(*from))
+              num = num*10 + (*from++ - '0');
+          if (IS_NUM(*from))
+              num = num*10 + (*from++ - '0');
+          if (num != 0) {
+              *to++ = num;
+          } else {
+              *to++ = '\\';
+              *to++ = '0';
+          }
       } else {
-	switch (*from) {
-	case '\0': continue;
-	case 'n': *to++ = '\n'; break;
-	case 'r': *to++ = '\r'; break;
-	case 't': *to++ = '\t'; break;
-	default: *to++ = *from; break;
-	}
-	++from;
+        switch (*from) {
+        case '\0': continue;
+        case 'n': *to++ = '\n'; break;
+        case 'r': *to++ = '\r'; break;
+        case 't': *to++ = '\t'; break;
+        default: *to++ = *from; break;
+        }
+        ++from;
       }
     } else {
       *to++ = *from++;
@@ -192,8 +172,41 @@
 }
 
 #ifdef SUBST_MAIN
+subst_rec_t subst_list[SUBST_FILE_ARR_MAX];
+
+void subst_list_make(subst_rec_t *subst_list) {
+  int i2 = 0;
+
+  subst_list[0].subst_var = "name";
+  subst_list[0].subst_file_name = "/pmalab1/temphome/guyf/work/replace_mc5/flood_stuff/build/flood-0.4/test";
+  subst_list[0].subst_mode = 0;
+  subst_list[0].valid = 1;
+  i2++;
+
+  subst_list[i2].subst_var = "foot";
+  subst_list[i2].subst_file_name = "/pmalab1/temphome/guyf/work/replace_mc5/flood_stuff/build/flood-0.4/blort";
+  subst_list[i2].subst_mode = 0;
+  subst_list[i2].valid = 1;
+
+  i2++;
+  subst_list[i2].subst_var = "nerve";
+  subst_list[i2].subst_file_name = "/pmalab1/temphome/guyf/work/replace_mc5/flood_stuff/build/flood-0.4/cavort";
+  subst_list[i2].subst_mode = 0;
+  subst_list[i2].valid = 1;
+}
+
+int close_subst_file(apr_file_t* subst_file) {
+  apr_status_t rc = 0;
+
+  if (subst_file) {
+    rc = apr_file_close(subst_file);
+  }
+  return rc;
+}
+
 int main(int argc, char** argv) {
-  char line[SUBST_FILE_MAX_URL_SIZE];    # why mess around, therefore static
+  //# why mess around, therefore static
+  char line[SUBST_FILE_MAX_URL_SIZE];
   int i = 20;
   int list = 0;
   char* the_name;
@@ -202,6 +215,8 @@
   apr_initialize();
   atexit(apr_terminate);
 
+  apr_file_open_stderr(&local_stderr, err_pool);
+
   if (apr_pool_create(&pool, NULL) != APR_SUCCESS) {
     printf("Failed apr_pool_create\n");
     exit(-1);

Modified: httpd/flood/trunk/flood_subst_file.h
URL: http://svn.apache.org/viewvc/httpd/flood/trunk/flood_subst_file.h?rev=696047&r1=696046&r2=696047&view=diff
==============================================================================
--- httpd/flood/trunk/flood_subst_file.h (original)
+++ httpd/flood/trunk/flood_subst_file.h Tue Sep 16 13:41:45 2008
@@ -1,3 +1,19 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 #ifndef _SUBST_FILE_H
 #define _SUBST_FILE_H 1
 
@@ -13,8 +29,6 @@
   int valid;
 };
 typedef struct subst_rec_t subst_rec_t;
-subst_rec_t subst_list[SUBST_FILE_ARR_MAX];
-//int subst_list_size = sizeof(subst_list)/sizeof(subst_rec_t);
 
 void subst_file_err(const char*, const char*, apr_status_t);
 int subst_file_open(apr_file_t**, const char*, apr_off_t*, apr_pool_t*);



Re: svn commit: r696047 - in /httpd/flood/trunk: flood_subst_file.c flood_subst_file.h

Posted by Guy Ferraiolo <gu...@cbs.com>.
I'll fix that!  And the stub code.  WRT to gcc-4.2.3-2ubuntu7 of Sept
3, 2008, I don't have access to that environment but it looks correct to
me.  I'll be able to get gcc-4.2.3 but only on Mandriva.

sorry,

Guy

On Tue, 2008-09-16 at 14:41 -0700, Justin Erenkrantz wrote:
> On Tue, Sep 16, 2008 at 2:36 PM, William A. Rowe, Jr.
> <wr...@rowe-clan.net> wrote:
> > I suppose the proper answer then is
> >
> > /* //# why mess around, therefore static */
> >
> > ? ;-)  Justin, I think you could have dropped the #
> 
> Hey, bub, you're the one who committed this code - not me.  =)  -- justin
-- 
Guy Ferraiolo                                   mailto:guy.ferraiolo@cbs.com
Monitoring and Performance Management           http://CNET.com
CBS Interactive                                 tel: 1.908.541.3739
1200 Route 22 East                              fax: 1.908.575.7474
Bridgewater, NJ 08807                           cel: 1.732.618.0250

Re: svn commit: r696047 - in /httpd/flood/trunk: flood_subst_file.c flood_subst_file.h

Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On Tue, Sep 16, 2008 at 2:36 PM, William A. Rowe, Jr.
<wr...@rowe-clan.net> wrote:
> I suppose the proper answer then is
>
> /* //# why mess around, therefore static */
>
> ? ;-)  Justin, I think you could have dropped the #

Hey, bub, you're the one who committed this code - not me.  =)  -- justin

Re: svn commit: r696047 - in /httpd/flood/trunk: flood_subst_file.c flood_subst_file.h

Posted by Guy Ferraiolo <gu...@cnet.com>.
Sorry, that's called 'too much Perl'.

Guy

On Tue, 2008-09-16 at 16:36 -0500, William A. Rowe, Jr. wrote:
> Ruediger Pluem wrote:
> > 
> > C++ style comments are not liked by all C compilers.
> 
> I suppose the proper answer then is
> 
> /* //# why mess around, therefore static */
> 
> ? ;-)  Justin, I think you could have dropped the #
-- 
Guy Ferraiolo                                   mailto:guy.ferraiolo@cbs.com
Monitoring and Performance Management           http://CNET.com
CBS Interactive                                 tel: 1.908.541.3739
1200 Route 22 East                              fax: 1.908.575.7474
Bridgewater, NJ 08807                           cel: 1.732.618.0250

Re: svn commit: r696047 - in /httpd/flood/trunk: flood_subst_file.c flood_subst_file.h

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Ruediger Pluem wrote:
> 
> C++ style comments are not liked by all C compilers.

I suppose the proper answer then is

/* //# why mess around, therefore static */

? ;-)  Justin, I think you could have dropped the #

Re: svn commit: r696047 - in /httpd/flood/trunk: flood_subst_file.c flood_subst_file.h

Posted by Guy Ferraiolo <gu...@cnet.com>.
I'll fix that.

Guy


On Tue, 2008-09-16 at 14:40 -0700, Justin Erenkrantz wrote:
> On Tue, Sep 16, 2008 at 2:19 PM, Ruediger Pluem <rp...@apache.org> wrote:
> >> +  //# why mess around, therefore static
> >
> > C++ style comments are not liked by all C compilers.
> 
> True, but if you look at the hardcoded paths a few lines up, well, ya,
> there's a lot of work that would need to be done to make this stub
> code even run.
> 
> Anyway, I removed the comment in r696077.  =)  -- justin
-- 
Guy Ferraiolo                                   mailto:guy.ferraiolo@cbs.com
Monitoring and Performance Management           http://CNET.com
CBS Interactive                                 tel: 1.908.541.3739
1200 Route 22 East                              fax: 1.908.575.7474
Bridgewater, NJ 08807                           cel: 1.732.618.0250

Re: svn commit: r696047 - in /httpd/flood/trunk: flood_subst_file.c flood_subst_file.h

Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On Tue, Sep 16, 2008 at 2:19 PM, Ruediger Pluem <rp...@apache.org> wrote:
>> +  //# why mess around, therefore static
>
> C++ style comments are not liked by all C compilers.

True, but if you look at the hardcoded paths a few lines up, well, ya,
there's a lot of work that would need to be done to make this stub
code even run.

Anyway, I removed the comment in r696077.  =)  -- justin

Re: svn commit: r696047 - in /httpd/flood/trunk: flood_subst_file.c flood_subst_file.h

Posted by Ruediger Pluem <rp...@apache.org>.

On 09/16/2008 10:41 PM, jerenkrantz@apache.org wrote:
> Author: jerenkrantz
> Date: Tue Sep 16 13:41:45 2008
> New Revision: 696047
> 
> URL: http://svn.apache.org/viewvc?rev=696047&view=rev
> Log:
> Fix up flood_subst_file implementation so that we compile again on Mac OS X.
> 
> Also fix up various nits, add licensing blocks, and reformat to better follow
> coding standards.
> 
> * flood_subst_file.c, flood_subst_file.h: Misc. fixes.
> 
> Modified:
>     httpd/flood/trunk/flood_subst_file.c
>     httpd/flood/trunk/flood_subst_file.h
> 
> Modified: httpd/flood/trunk/flood_subst_file.c
> URL: http://svn.apache.org/viewvc/httpd/flood/trunk/flood_subst_file.c?rev=696047&r1=696046&r2=696047&view=diff
> ==============================================================================


> @@ -192,8 +172,41 @@
>  }
>  
>  #ifdef SUBST_MAIN
> +subst_rec_t subst_list[SUBST_FILE_ARR_MAX];
> +
> +void subst_list_make(subst_rec_t *subst_list) {
> +  int i2 = 0;
> +
> +  subst_list[0].subst_var = "name";
> +  subst_list[0].subst_file_name = "/pmalab1/temphome/guyf/work/replace_mc5/flood_stuff/build/flood-0.4/test";
> +  subst_list[0].subst_mode = 0;
> +  subst_list[0].valid = 1;
> +  i2++;
> +
> +  subst_list[i2].subst_var = "foot";
> +  subst_list[i2].subst_file_name = "/pmalab1/temphome/guyf/work/replace_mc5/flood_stuff/build/flood-0.4/blort";
> +  subst_list[i2].subst_mode = 0;
> +  subst_list[i2].valid = 1;
> +
> +  i2++;
> +  subst_list[i2].subst_var = "nerve";
> +  subst_list[i2].subst_file_name = "/pmalab1/temphome/guyf/work/replace_mc5/flood_stuff/build/flood-0.4/cavort";
> +  subst_list[i2].subst_mode = 0;
> +  subst_list[i2].valid = 1;
> +}
> +
> +int close_subst_file(apr_file_t* subst_file) {
> +  apr_status_t rc = 0;
> +
> +  if (subst_file) {
> +    rc = apr_file_close(subst_file);
> +  }
> +  return rc;
> +}
> +
>  int main(int argc, char** argv) {
> -  char line[SUBST_FILE_MAX_URL_SIZE];    # why mess around, therefore static
> +  //# why mess around, therefore static

C++ style comments are not liked by all C compilers.

Regards

Rüdiger