]> granicus.if.org Git - apache/commitdiff
Improve style in examples.
authorChristophe Jaillet <jailletc36@apache.org>
Mon, 1 Jun 2015 19:35:25 +0000 (19:35 +0000)
committerChristophe Jaillet <jailletc36@apache.org>
Mon, 1 Jun 2015 19:35:25 +0000 (19:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1682979 13f79535-47bb-0310-9956-ffa450edef68

modules/examples/mod_case_filter.c
modules/examples/mod_case_filter_in.c
modules/examples/mod_example_hooks.c
modules/examples/mod_example_ipc.c

index f0b84d2900f096c33ff6fbfc4ee8bde7a1fa4381..409f65bfa662ec15ad9ef23f3c15e195cd7566eb 100644 (file)
 
 #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(ap_filter_t *f,
         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(ap_filter_t *f,
      * 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) =
 {
index 73af077afaae0a74a7da490e1a23c7bcf65632ee..7200765b3aa896e453fde862f92c0b992878e768 100644 (file)
@@ -53,12 +53,12 @@ static void *CaseFilterInCreateServerConfig(apr_pool_t *p, server_rec *s)
 
 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(ap_filter_t *f,
             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(ap_filter_t *f,
         }
 
         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(ap_filter_t *f,
     return APR_SUCCESS;
 }
 
-
 static const char *CaseFilterInEnable(cmd_parms *cmd, void *dummy, int arg)
 {
     CaseFilterInConfig *pConfig
index 1130f7eb39679b96b941795df581aa9a08caafdb..4db0865cccb7028ee3cd4055cc7cb76c9dbc4ecf 100644 (file)
@@ -329,7 +329,8 @@ static void example_log_each(apr_pool_t *p, server_rec *s, const char *note)
 {
     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 *pconf, apr_pool_t *plog,
      * 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, void *csd)
 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_rec *r)
  */
 static int x_translate_name(request_rec *r)
 {
-
     /*
      * We don't actually *do* anything here, except note the fact that we were
      * called.
index b8ba569c067adca623700b3759fcd5448244f74b..a7cdb34d1bbc30baddc02989cd5f15f7d05dcde0 100644 (file)
@@ -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                      */
 };
-