From: Ken Coar
Date: Wed, 15 Apr 2015 06:01:00 +0000 (+0000)
Subject: Don't use " in code.
X-Git-Tag: 2.5.0-alpha~3300
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=955c79386bf83527c8497f471dd01228eced1dc6;p=thirdparty%2Fapache%2Fhttpd.git
Don't use " in code.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1673651 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/docs/manual/developer/modguide.xml b/docs/manual/developer/modguide.xml
index 28c8242402d..3857e00c559 100644
--- a/docs/manual/developer/modguide.xml
+++ b/docs/manual/developer/modguide.xml
@@ -121,7 +121,7 @@ For now, we're only concerned with the first purpose of the module name,
which comes into play when we need to load the module:
-LoadModule example_module modules/mod_example.so
+LoadModule example_module "modules/mod_example.so"
In essence, this tells the server to open up mod_example.so and look for a module
@@ -165,15 +165,15 @@ our example case, we want every request ending with .sum to be served by
the server to do just that:
-AddHandler example-handler .sum
+AddHandler example-handler ".sum"
What this tells the server is the following: Whenever we receive a request
for a URI ending in .sum, we are to let all modules know that we are
looking for whoever goes by the name of "example-handler" .
Thus, when a request is being served that ends in .sum, the server will let all
-modules know, that this request should be served by "example-handler
-". As you will see later, when we start building mod_example, we will
+modules know, that this request should be served by "example-handler".
+As you will see later, when we start building mod_example, we will
check for this handler tag relayed by AddHandler and reply to
the server based on the value of this tag.
@@ -337,22 +337,22 @@ Let's try out some of these variables in another example handler:
static int example_handler(request_rec *r)
{
/* Set the appropriate content type */
- ap_set_content_type(r, "text/html");
+ ap_set_content_type(r, "text/html");
/* Print out the IP address of the client connecting to us: */
- ap_rprintf(r, "<h2>Hello, %s!</h2>", r->useragent_ip);
+ ap_rprintf(r, "<h2>Hello, %s!</h2>", r->useragent_ip);
/* If we were reached through a GET or a POST request, be happy, else sad. */
- if ( !strcmp(r->method, "POST") || !strcmp(r->method, "GET") ) {
- ap_rputs("You used a GET or a POST method, that makes us happy!<br/>", r);
+ if ( !strcmp(r->method, "POST") || !strcmp(r->method, "GET") ) {
+ ap_rputs("You used a GET or a POST method, that makes us happy!<br/>", r);
}
else {
- ap_rputs("You did not use POST or GET, that makes us sad :(<br/>", r);
+ ap_rputs("You did not use POST or GET, that makes us sad :(<br/>", r);
}
/* Lastly, if there was a query string, let's print that too! */
if (r->args) {
- ap_rprintf(r, "Your query string was: %s", r->args);
+ ap_rprintf(r, "Your query string was: %s", r->args);
}
return OK;
}
@@ -611,8 +611,8 @@ static int example_handler(request_rec *r)
const char *digestType;
- /* Check that the "example-handler" handler is being called. */
- if (!r->handler || strcmp(r->handler, "example-handler")) return (DECLINED);
+ /* Check that the "example-handler" handler is being called. */
+ if (!r->handler || strcmp(r->handler, "example-handler")) return (DECLINED);
/* Figure out which file is being requested by removing the .sum from it */
filename = apr_pstrdup(r->pool, r->filename);
@@ -637,22 +637,22 @@ static int example_handler(request_rec *r)
ap_parse_form_data(r, NULL, &POST, -1, 8192);
/* Set the appropriate content type */
- ap_set_content_type(r, "text/html");
+ ap_set_content_type(r, "text/html");
/* Print a title and some general information */
- ap_rprintf(r, "<h2>Information on %s:</h2>", filename);
- ap_rprintf(r, "<b>Size:</b> %u bytes<br/>", finfo.size);
+ ap_rprintf(r, "<h2>Information on %s:</h2>", filename);
+ ap_rprintf(r, "<b>Size:</b> %u bytes<br/>", finfo.size);
/* Get the digest type the client wants to see */
- digestType = apr_table_get(GET, "digest");
- if (!digestType) digestType = "MD5";
+ digestType = apr_table_get(GET, "digest");
+ if (!digestType) digestType = "MD5";
rc = apr_file_open(&file, filename, APR_READ, APR_OS_DEFAULT, r->pool);
if (rc == APR_SUCCESS) {
/* Are we trying to calculate the MD5 or the SHA1 digest? */
- if (!strcasecmp(digestType, "md5")) {
+ if (!strcasecmp(digestType, "md5")) {
/* Calculate the MD5 sum of the file */
union {
char chr[16];
@@ -667,13 +667,13 @@ static int example_handler(request_rec *r)
apr_md5_final(digest.chr, &md5);
/* Print out the MD5 digest */
- ap_rputs("<b>MD5: </b><code>", r);
+ ap_rputs("<b>MD5: </b><code>", r);
for (n = 0; n < APR_MD5_DIGESTSIZE/4; n++) {
- ap_rprintf(r, "%08x", digest.num[n]);
+ ap_rprintf(r, "%08x", digest.num[n]);
}
- ap_rputs("</code>", r);
+ ap_rputs("</code>", r);
/* Print a link to the SHA1 version */
- ap_rputs("<br/><a href='?digest=sha1'>View the SHA1 hash instead</a>", r);
+ ap_rputs("<br/><a href='?digest=sha1'>View the SHA1 hash instead</a>", r);
}
else {
/* Calculate the SHA1 sum of the file */
@@ -690,14 +690,14 @@ static int example_handler(request_rec *r)
apr_sha1_final(digest.chr, &sha1);
/* Print out the SHA1 digest */
- ap_rputs("<b>SHA1: </b><code>", r);
+ ap_rputs("<b>SHA1: </b><code>", r);
for (n = 0; n < APR_SHA1_DIGESTSIZE/4; n++) {
- ap_rprintf(r, "%08x", digest.num[n]);
+ ap_rprintf(r, "%08x", digest.num[n]);
}
- ap_rputs("</code>", r);
+ ap_rputs("</code>", r);
/* Print a link to the MD5 version */
- ap_rputs("<br/><a href='?digest=md5'>View the MD5 hash instead</a>", r);
+ ap_rputs("<br/><a href='?digest=md5'>View the MD5 hash instead</a>", r);
}
apr_file_close(file);
@@ -735,8 +735,8 @@ these directives control how mod_rewrite works:
RewriteEngine On
-RewriteCond %{REQUEST_URI} ^/foo/bar
-RewriteRule ^/foo/bar/(.*)$ /foobar?page=$1
+RewriteCond "%{REQUEST_URI}" "^/foo/bar"
+RewriteRule "^/foo/bar/(.*)$" "/foobar?page=$1"
Each of these configuration directives are handled by a separate function,
@@ -776,18 +776,18 @@ static example_config config;
static int example_handler(request_rec *r)
{
- if (!r->handler || strcmp(r->handler, "example-handler")) return(DECLINED);
- ap_set_content_type(r, "text/plain");
- ap_rprintf(r, "Enabled: %u\n", config.enabled);
- ap_rprintf(r, "Path: %s\n", config.path);
- ap_rprintf(r, "TypeOfAction: %x\n", config.typeOfAction);
+ if (!r->handler || strcmp(r->handler, "example-handler")) return(DECLINED);
+ ap_set_content_type(r, "text/plain");
+ ap_rprintf(r, "Enabled: %u\n", config.enabled);
+ ap_rprintf(r, "Path: %s\n", config.path);
+ ap_rprintf(r, "TypeOfAction: %x\n", config.typeOfAction);
return OK;
}
static void register_hooks(apr_pool_t *pool)
{
config.enabled = 1;
- config.path = "/foo/bar";
+ config.path = "/foo/bar";
config.typeOfAction = 0x00;
ap_hook_handler(example_handler, NULL, NULL, APR_HOOK_LAST);
}
@@ -812,7 +812,7 @@ So far so good. To access our new handler, we could add the following to
our configuration:
-<Location /example>
+<Location "/example">
SetHandler example-handler
</Location>
@@ -972,30 +972,30 @@ static example_config config;
Our directive handlers:
==============================================================================
*/
-/* Handler for the "exampleEnabled" directive */
+/* Handler for the "exampleEnabled" directive */
const char *example_set_enabled(cmd_parms *cmd, void *cfg, const char *arg)
{
- if(!strcasecmp(arg, "on")) config.enabled = 1;
+ if(!strcasecmp(arg, "on")) config.enabled = 1;
else config.enabled = 0;
return NULL;
}
-/* Handler for the "examplePath" directive */
+/* Handler for the "examplePath" directive */
const char *example_set_path(cmd_parms *cmd, void *cfg, const char *arg)
{
config.path = arg;
return NULL;
}
-/* Handler for the "exampleAction" directive */
+/* Handler for the "exampleAction" directive */
/* Let's pretend this one takes one argument (file or db), and a second (deny or allow), */
/* and we store it in a bit-wise manner. */
const char *example_set_action(cmd_parms *cmd, void *cfg, const char *arg1, const char *arg2)
{
- if(!strcasecmp(arg1, "file")) config.typeOfAction = 0x01;
+ if(!strcasecmp(arg1, "file")) config.typeOfAction = 0x01;
else config.typeOfAction = 0x02;
- if(!strcasecmp(arg2, "deny")) config.typeOfAction += 0x10;
+ if(!strcasecmp(arg2, "deny")) config.typeOfAction += 0x10;
else config.typeOfAction += 0x20;
return NULL;
}
@@ -1007,9 +1007,9 @@ const char *example_set_action(cmd_parms *cmd, void *cfg, const char *arg1, cons
*/
static const command_rec example_directives[] =
{
- AP_INIT_TAKE1("exampleEnabled", example_set_enabled, NULL, RSRC_CONF, "Enable or disable mod_example"),
- AP_INIT_TAKE1("examplePath", example_set_path, NULL, RSRC_CONF, "The path to whatever"),
- AP_INIT_TAKE2("exampleAction", example_set_action, NULL, RSRC_CONF, "Special action value!"),
+ AP_INIT_TAKE1("exampleEnabled", example_set_enabled, NULL, RSRC_CONF, "Enable or disable mod_example"),
+ AP_INIT_TAKE1("examplePath", example_set_path, NULL, RSRC_CONF, "The path to whatever"),
+ AP_INIT_TAKE2("exampleAction", example_set_action, NULL, RSRC_CONF, "Special action value!"),
{ NULL }
};
/*
@@ -1019,11 +1019,11 @@ static const command_rec example_directives[] =
*/
static int example_handler(request_rec *r)
{
- if(!r->handler || strcmp(r->handler, "example-handler")) return(DECLINED);
- ap_set_content_type(r, "text/plain");
- ap_rprintf(r, "Enabled: %u\n", config.enabled);
- ap_rprintf(r, "Path: %s\n", config.path);
- ap_rprintf(r, "TypeOfAction: %x\n", config.typeOfAction);
+ if(!r->handler || strcmp(r->handler, "example-handler")) return(DECLINED);
+ ap_set_content_type(r, "text/plain");
+ ap_rprintf(r, "Enabled: %u\n", config.enabled);
+ ap_rprintf(r, "Path: %s\n", config.path);
+ ap_rprintf(r, "TypeOfAction: %x\n", config.typeOfAction);
return OK;
}
@@ -1035,7 +1035,7 @@ static int example_handler(request_rec *r)
static void register_hooks(apr_pool_t *pool)
{
config.enabled = 1;
- config.path = "/foo/bar";
+ config.path = "/foo/bar";
config.typeOfAction = 3;
ap_hook_handler(example_handler, NULL, NULL, APR_HOOK_LAST);
}
@@ -1086,12 +1086,12 @@ within which modules must operate. For example, let's assume you have this
configuration set up for mod_rewrite:
-<Directory "/var/www">
- RewriteCond %{HTTP_HOST} ^example.com$
- RewriteRule (.*) http://www.example.com/$1
+<Directory "/var/www">
+ RewriteCond "%{HTTP_HOST}" "^example.com$"
+ RewriteRule "(.*)" "http://www.example.com/$1"
</Directory>
-<Directory "/var/www/sub">
- RewriteRule ^foobar$ index.php?foobar=true
+<Directory "/var/www/sub">
+ RewriteRule "^foobar$" "index.php?foobar=true"
</Directory>
@@ -1259,12 +1259,12 @@ configurations. This part of the process particularly applies to scenarios
where you have a parent configuration and a child, such as the following:
-<Directory "/var/www">
+<Directory "/var/www">
ExampleEnabled On
- ExamplePath /foo/bar
+ ExamplePath "/foo/bar"
ExampleAction file allow
</Directory>
-<Directory "/var/www/subdir">
+<Directory "/var/www/subdir">
ExampleAction file deny
</Directory>
@@ -1315,21 +1315,21 @@ context aware. First off, we'll create a configuration that lets us test
how the module works:
-<Location "/a">
+<Location "/a">
SetHandler example-handler
ExampleEnabled on
- ExamplePath "/foo/bar"
+ ExamplePath "/foo/bar"
ExampleAction file allow
</Location>
-<Location "/a/b">
+<Location "/a/b">
ExampleAction file deny
ExampleEnabled off
</Location>
-<Location "/a/b/c">
+<Location "/a/b/c">
ExampleAction db deny
- ExamplePath "/foo/bar/baz"
+ ExamplePath "/foo/bar/baz"
ExampleEnabled on
</Location>
@@ -1395,9 +1395,9 @@ static void register_hooks(apr_pool_t *pool);
static const command_rec directives[] =
{
- AP_INIT_TAKE1("exampleEnabled", example_set_enabled, NULL, ACCESS_CONF, "Enable or disable mod_example"),
- AP_INIT_TAKE1("examplePath", example_set_path, NULL, ACCESS_CONF, "The path to whatever"),
- AP_INIT_TAKE2("exampleAction", example_set_action, NULL, ACCESS_CONF, "Special action value!"),
+ AP_INIT_TAKE1("exampleEnabled", example_set_enabled, NULL, ACCESS_CONF, "Enable or disable mod_example"),
+ AP_INIT_TAKE1("examplePath", example_set_path, NULL, ACCESS_CONF, "The path to whatever"),
+ AP_INIT_TAKE2("exampleAction", example_set_action, NULL, ACCESS_CONF, "Special action value!"),
{ NULL }
};
@@ -1435,23 +1435,23 @@ static void register_hooks(apr_pool_t *pool)
*/
static int example_handler(request_rec *r)
{
- if(!r->handler || strcmp(r->handler, "example-handler")) return(DECLINED);
+ if(!r->handler || strcmp(r->handler, "example-handler")) return(DECLINED);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
example_config *config = (example_config *) ap_get_module_config(r->per_dir_config, &example_module);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- ap_set_content_type(r, "text/plain");
- ap_rprintf(r, "Enabled: %u\n", config->enabled);
- ap_rprintf(r, "Path: %s\n", config->path);
- ap_rprintf(r, "TypeOfAction: %x\n", config->typeOfAction);
- ap_rprintf(r, "Context: %s\n", config->context);
+ ap_set_content_type(r, "text/plain");
+ ap_rprintf(r, "Enabled: %u\n", config->enabled);
+ ap_rprintf(r, "Path: %s\n", config->path);
+ ap_rprintf(r, "TypeOfAction: %x\n", config->typeOfAction);
+ ap_rprintf(r, "Context: %s\n", config->context);
return OK;
}
/*
=======================================================================================================================
- Handler for the "exampleEnabled" directive
+ Handler for the "exampleEnabled" directive
=======================================================================================================================
*/
const char *example_set_enabled(cmd_parms *cmd, void *cfg, const char *arg)
@@ -1462,7 +1462,7 @@ const char *example_set_enabled(cmd_parms *cmd, void *cfg, const char *arg)
if(conf)
{
- if(!strcasecmp(arg, "on"))
+ if(!strcasecmp(arg, "on"))
conf->enabled = 1;
else
conf->enabled = 0;
@@ -1473,7 +1473,7 @@ const char *example_set_enabled(cmd_parms *cmd, void *cfg, const char *arg)
/*
=======================================================================================================================
- Handler for the "examplePath" directive
+ Handler for the "examplePath" directive
=======================================================================================================================
*/
const char *example_set_path(cmd_parms *cmd, void *cfg, const char *arg)
@@ -1492,7 +1492,7 @@ const char *example_set_path(cmd_parms *cmd, void *cfg, const char *arg)
/*
=======================================================================================================================
- Handler for the "exampleAction" directive ;
+ Handler for the "exampleAction" directive ;
Let's pretend this one takes one argument (file or db), and a second (deny or allow), ;
and we store it in a bit-wise manner.
=======================================================================================================================
@@ -1506,11 +1506,11 @@ const char *example_set_action(cmd_parms *cmd, void *cfg, const char *arg1, cons
if(conf)
{
{
- if(!strcasecmp(arg1, "file"))
+ if(!strcasecmp(arg1, "file"))
conf->typeOfAction = 0x01;
else
conf->typeOfAction = 0x02;
- if(!strcasecmp(arg2, "deny"))
+ if(!strcasecmp(arg2, "deny"))
conf->typeOfAction += 0x10;
else
conf->typeOfAction += 0x20;
@@ -1527,7 +1527,7 @@ const char *example_set_action(cmd_parms *cmd, void *cfg, const char *arg1, cons
*/
void *create_dir_conf(apr_pool_t *pool, char *context)
{
- context = context ? context : "Newly created configuration";
+ context = context ? context : "Newly created configuration";
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
example_config *cfg = apr_pcalloc(pool, sizeof(example_config));
@@ -1557,7 +1557,7 @@ void *merge_dir_conf(apr_pool_t *pool, void *BASE, void *ADD)
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
example_config *base = (example_config *) BASE;
example_config *add = (example_config *) ADD;
- example_config *conf = (example_config *) create_dir_conf(pool, "Merged configuration");
+ example_config *conf = (example_config *) create_dir_conf(pool, "Merged configuration");
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
conf->enabled = (add->enabled == 0) ? base->enabled : add->enabled;
@@ -1634,11 +1634,11 @@ static int example_handler(request_rec *r)
int i;
for (i = 0; &formData[i]; i++) {
if (formData[i].key && formData[i].value) {
- ap_rprintf(r, "%s = %s\n", formData[i].key, formData[i].value);
+ ap_rprintf(r, "%s = %s\n", formData[i].key, formData[i].value);
} else if (formData[i].key) {
- ap_rprintf(r, "%s\n", formData[i].key);
+ ap_rprintf(r, "%s\n", formData[i].key);
} else if (formData[i].value) {
- ap_rprintf(r, "= %s\n", formData[i].value);
+ ap_rprintf(r, "= %s\n", formData[i].value);
} else {
break;
}
@@ -1668,7 +1668,7 @@ static int example_handler(request_rec *r)
fields = apr_table_elts(r->headers_in);
e = (apr_table_entry_t *) fields->elts;
for(i = 0; i < fields->nelts; i++) {
- ap_rprintf(r, "%s: %s\n", e[i].key, e[i].val);
+ ap_rprintf(r, "%s: %s\n", e[i].key, e[i].val);
}
return OK;
}
@@ -1726,7 +1726,7 @@ static int example_handler(request_rec *r)
/*~~~~~~~~~~~~~~~~*/
if(util_read(r, &buffer, &size) == OK) {
- ap_rprintf(r, "We read a request body that was %" APR_OFF_T_FMT " bytes long", size);
+ ap_rprintf(r, "We read a request body that was %" APR_OFF_T_FMT " bytes long", size);
}
return OK;
}