httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaillet...@apache.org
Subject svn commit: r1682979 - in /httpd/httpd/trunk/modules/examples: mod_case_filter.c mod_case_filter_in.c mod_example_hooks.c mod_example_ipc.c
Date Mon, 01 Jun 2015 19:35:25 GMT
Author: jailletc36
Date: Mon Jun  1 19:35:25 2015
New Revision: 1682979

URL: http://svn.apache.org/r1682979
Log:
Improve style in examples.

Modified:
    httpd/httpd/trunk/modules/examples/mod_case_filter.c
    httpd/httpd/trunk/modules/examples/mod_case_filter_in.c
    httpd/httpd/trunk/modules/examples/mod_example_hooks.c
    httpd/httpd/trunk/modules/examples/mod_example_ipc.c

Modified: httpd/httpd/trunk/modules/examples/mod_case_filter.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/examples/mod_case_filter.c?rev=1682979&r1=1682978&r2=1682979&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/examples/mod_case_filter.c (original)
+++ httpd/httpd/trunk/modules/examples/mod_case_filter.c Mon Jun  1 19:35:25 2015
@@ -24,43 +24,43 @@
 
 #include <ctype.h>
 
-static const char s_szCaseFilterName[]="CaseFilter";
+static const char s_szCaseFilterName[] = "CaseFilter";
 module AP_MODULE_DECLARE_DATA case_filter_module;
 
 typedef struct
-    {
+{
     int bEnabled;
-    } CaseFilterConfig;
+} CaseFilterConfig;
 
-static void *CaseFilterCreateServerConfig(apr_pool_t *p,server_rec *s)
-    {
-    CaseFilterConfig *pConfig=apr_pcalloc(p,sizeof *pConfig);
+static void *CaseFilterCreateServerConfig(apr_pool_t *p, server_rec *s)
+{
+    CaseFilterConfig *pConfig = apr_pcalloc(p,sizeof *pConfig);
 
-    pConfig->bEnabled=0;
+    pConfig->bEnabled = 0;
 
     return pConfig;
-    }
+}
 
 static void CaseFilterInsertFilter(request_rec *r)
-    {
-    CaseFilterConfig *pConfig=ap_get_module_config(r->server->module_config,
-                                                   &case_filter_module);
+{
+    CaseFilterConfig *pConfig = ap_get_module_config(r->server->module_config,
+                                                     &case_filter_module);
 
-    if(!pConfig->bEnabled)
+    if (!pConfig->bEnabled)
         return;
 
-    ap_add_output_filter(s_szCaseFilterName,NULL,r,r->connection);
-    }
+    ap_add_output_filter(s_szCaseFilterName, NULL, r, r->connection);
+}
 
 static apr_status_t CaseFilterOutFilter(ap_filter_t *f,
                                         apr_bucket_brigade *pbbIn)
-    {
+{
     request_rec *r = f->r;
     conn_rec *c = r->connection;
     apr_bucket *pbktIn;
     apr_bucket_brigade *pbbOut;
 
-    pbbOut=apr_brigade_create(r->pool, c->bucket_alloc);
+    pbbOut = apr_brigade_create(r->pool, c->bucket_alloc);
     for (pbktIn = APR_BRIGADE_FIRST(pbbIn);
          pbktIn != APR_BRIGADE_SENTINEL(pbbIn);
          pbktIn = APR_BUCKET_NEXT(pbktIn))
@@ -71,25 +71,25 @@ static apr_status_t CaseFilterOutFilter(
         apr_size_t n;
         apr_bucket *pbktOut;
 
-        if(APR_BUCKET_IS_EOS(pbktIn))
-            {
-            apr_bucket *pbktEOS=apr_bucket_eos_create(c->bucket_alloc);
-            APR_BRIGADE_INSERT_TAIL(pbbOut,pbktEOS);
+        if (APR_BUCKET_IS_EOS(pbktIn)) {
+            apr_bucket *pbktEOS = apr_bucket_eos_create(c->bucket_alloc);
+            APR_BRIGADE_INSERT_TAIL(pbbOut, pbktEOS);
             continue;
-            }
+        }
 
         /* read */
-        apr_bucket_read(pbktIn,&data,&len,APR_BLOCK_READ);
+        apr_bucket_read(pbktIn, &data, &len, APR_BLOCK_READ);
 
         /* write */
         buf = apr_bucket_alloc(len, c->bucket_alloc);
-        for(n=0 ; n < len ; ++n)
+        for (n=0 ; n < len ; ++n) {
             buf[n] = apr_toupper(data[n]);
+        }
 
         pbktOut = apr_bucket_heap_create(buf, len, apr_bucket_free,
                                          c->bucket_alloc);
-        APR_BRIGADE_INSERT_TAIL(pbbOut,pbktOut);
-        }
+        APR_BRIGADE_INSERT_TAIL(pbbOut, pbktOut);
+    }
 
     /* Q: is there any advantage to passing a brigade for each bucket?
      * A: obviously, it can cut down server resource consumption, if this
@@ -101,31 +101,31 @@ static apr_status_t CaseFilterOutFilter(
      * don't let our caller pass the same buckets to us, twice;
      */
     apr_brigade_cleanup(pbbIn);
-    return ap_pass_brigade(f->next,pbbOut);
-    }
+    return ap_pass_brigade(f->next, pbbOut);
+}
 
 static const char *CaseFilterEnable(cmd_parms *cmd, void *dummy, int arg)
-    {
-    CaseFilterConfig *pConfig=ap_get_module_config(cmd->server->module_config,
-                                                   &case_filter_module);
-    pConfig->bEnabled=arg;
+{
+    CaseFilterConfig *pConfig = ap_get_module_config(cmd->server->module_config,
+                                                     &case_filter_module);
+    pConfig->bEnabled = arg;
 
     return NULL;
-    }
+}
 
 static const command_rec CaseFilterCmds[] =
-    {
+{
     AP_INIT_FLAG("CaseFilter", CaseFilterEnable, NULL, RSRC_CONF,
                  "Run a case filter on this host"),
     { NULL }
-    };
+};
 
 static void CaseFilterRegisterHooks(apr_pool_t *p)
-    {
-    ap_hook_insert_filter(CaseFilterInsertFilter,NULL,NULL,APR_HOOK_MIDDLE);
-    ap_register_output_filter(s_szCaseFilterName,CaseFilterOutFilter,NULL,
+{
+    ap_hook_insert_filter(CaseFilterInsertFilter, NULL, NULL, APR_HOOK_MIDDLE);
+    ap_register_output_filter(s_szCaseFilterName, CaseFilterOutFilter, NULL,
                               AP_FTYPE_RESOURCE);
-    }
+}
 
 AP_DECLARE_MODULE(case_filter) =
 {

Modified: httpd/httpd/trunk/modules/examples/mod_case_filter_in.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/examples/mod_case_filter_in.c?rev=1682979&r1=1682978&r2=1682979&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/examples/mod_case_filter_in.c (original)
+++ httpd/httpd/trunk/modules/examples/mod_case_filter_in.c Mon Jun  1 19:35:25 2015
@@ -53,12 +53,12 @@ static void *CaseFilterInCreateServerCon
 
 static void CaseFilterInInsertFilter(request_rec *r)
 {
-    CaseFilterInConfig *pConfig=ap_get_module_config(r->server->module_config,
-                                                     &case_filter_in_module);
-    if(!pConfig->bEnabled)
+    CaseFilterInConfig *pConfig = ap_get_module_config(r->server->module_config,
+                                                       &case_filter_in_module);
+    if (!pConfig->bEnabled)
         return;
 
-    ap_add_input_filter(s_szCaseFilterName,NULL,r,r->connection);
+    ap_add_input_filter(s_szCaseFilterName, NULL, r, r->connection);
 }
 
 static apr_status_t CaseFilterInFilter(ap_filter_t *f,
@@ -84,7 +84,7 @@ static apr_status_t CaseFilterInFilter(a
             return ret;
     }
 
-    while(!APR_BRIGADE_EMPTY(pCtx->pbbTmp)) {
+    while (!APR_BRIGADE_EMPTY(pCtx->pbbTmp)) {
         apr_bucket *pbktIn = APR_BRIGADE_FIRST(pCtx->pbbTmp);
         apr_bucket *pbktOut;
         const char *data;
@@ -106,12 +106,13 @@ static apr_status_t CaseFilterInFilter(a
         }
 
         ret=apr_bucket_read(pbktIn, &data, &len, eBlock);
-        if(ret != APR_SUCCESS)
+        if (ret != APR_SUCCESS)
             return ret;
 
         buf = ap_malloc(len);
-        for(n=0 ; n < len ; ++n)
+        for (n=0 ; n < len ; ++n) {
             buf[n] = apr_toupper(data[n]);
+        }
 
         pbktOut = apr_bucket_heap_create(buf, len, 0, c->bucket_alloc);
         APR_BRIGADE_INSERT_TAIL(pbbOut, pbktOut);
@@ -121,7 +122,6 @@ static apr_status_t CaseFilterInFilter(a
     return APR_SUCCESS;
 }
 
-
 static const char *CaseFilterInEnable(cmd_parms *cmd, void *dummy, int arg)
 {
     CaseFilterInConfig *pConfig

Modified: httpd/httpd/trunk/modules/examples/mod_example_hooks.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/examples/mod_example_hooks.c?rev=1682979&r1=1682978&r2=1682979&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/examples/mod_example_hooks.c (original)
+++ httpd/httpd/trunk/modules/examples/mod_example_hooks.c Mon Jun  1 19:35:25 2015
@@ -329,7 +329,8 @@ static void example_log_each(apr_pool_t
 {
     if (s != NULL) {
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "mod_example_hooks: %s", note);
-    } else {
+    }
+    else {
         apr_file_t *out = NULL;
         apr_file_open_stderr(&out, p);
         apr_file_printf(out, "mod_example_hooks traced in non-loggable "
@@ -741,7 +742,6 @@ static int x_pre_config(apr_pool_t *pcon
      * Log the call and exit.
      */
     trace_startup(ptemp, NULL, NULL, "x_pre_config()");
-
     return OK;
 }
 
@@ -1049,7 +1049,8 @@ static int x_handler(request_rec *r)
                                     r->connection->pool);
     if ((status == APR_SUCCESS) && conn_data) {
         ap_rprintf(r, "  <OL>\n%s  </OL>\n", (char *) conn_data);
-    } else {
+    }
+    else {
         ap_rputs("  <P>No connection-specific callback information was "
                  "retrieved.</P>\n", r);
     }
@@ -1135,7 +1136,6 @@ static int x_pre_connection(conn_rec *c,
 static int x_process_connection(conn_rec *c)
 {
     trace_connection(c, "x_process_connection()");
-
     return DECLINED;
 }
 
@@ -1181,7 +1181,6 @@ static int x_post_read_request(request_r
  */
 static int x_translate_name(request_rec *r)
 {
-
     /*
      * We don't actually *do* anything here, except note the fact that we were
      * called.

Modified: httpd/httpd/trunk/modules/examples/mod_example_ipc.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/examples/mod_example_ipc.c?rev=1682979&r1=1682978&r2=1682979&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/examples/mod_example_ipc.c (original)
+++ httpd/httpd/trunk/modules/examples/mod_example_ipc.c Mon Jun  1 19:35:25 2015
@@ -91,7 +91,8 @@ typedef struct exipc_data {
  * on restarts. It assures that the new children will not talk to a stale
  * shared memory segment.
  */
-static apr_status_t shm_cleanup_wrapper(void *unused) {
+static apr_status_t shm_cleanup_wrapper(void *unused)
+{
     if (exipc_shm)
         return apr_shm_destroy(exipc_shm);
     return OK;
@@ -248,10 +249,12 @@ static int exipc_handler(request_rec *r)
         rs = apr_global_mutex_trylock(exipc_mutex);
         if (APR_STATUS_IS_EBUSY(rs)) {
             apr_sleep(CAMPOUT);
-        } else if (APR_SUCCESS == rs) {
+        }
+        else if (APR_SUCCESS == rs) {
             gotlock = 1;
             break; /* Get out of the loop */
-        } else if (APR_STATUS_IS_ENOTIMPL(rs)) {
+        }
+        else if (APR_STATUS_IS_ENOTIMPL(rs)) {
             /* If it's not implemented, just hang in the mutex. */
             startcamp = apr_time_now();
             rs = apr_global_mutex_lock(exipc_mutex);
@@ -259,21 +262,23 @@ static int exipc_handler(request_rec *r)
             if (APR_SUCCESS == rs) {
                 gotlock = 1;
                 break; /* Out of the loop */
-            } else {
+            }
+            else {
                 /* Some error, log and bail */
                 ap_log_error(APLOG_MARK, APLOG_ERR, rs, r->server,
                              "Child %ld failed to acquire lock",
                              (long int)getpid());
                 break; /* Out of the loop without having the lock */
             }
-        } else {
+        }
+        else {
             /* Some other error, log and bail */
             ap_log_error(APLOG_MARK, APLOG_ERR, rs, r->server,
                          "Child %ld failed to try and acquire lock",
                          (long int)getpid());
             break; /* Out of the loop without having the lock */
-
         }
+
         /*
          * The only way to get to this point is if the trylock worked
          * and returned BUSY. So, bump the time and try again
@@ -307,7 +312,8 @@ static int exipc_handler(request_rec *r)
             ap_rprintf(r, "<tr><td>Counter:</td><td>%u</td></tr>\n",
                        (unsigned int)base->counter);
             ap_rputs("</table>\n", r);
-        } else {
+        }
+        else {
             /*
              * Send a page saying that we couldn't get the lock. Don't say
              * what the counter is, because without the lock the value could
@@ -348,4 +354,3 @@ AP_DECLARE_MODULE(example_ipc) = {
     NULL,                  /* table of config file commands       */
     exipc_register_hooks   /* register hooks                      */
 };
-



Mime
View raw message