aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2009-06-05 10:06:16 +0000
committerStefan Bühler <stbuehler@web.de>2009-06-05 10:06:16 +0000
commit89d643387ef2ad3482dccadb197969144faae305 (patch)
treecbcd75e32bea76896de556b268d27d93c388f315
parent2b87a673264b61984ea7572e3e5dca228e10fb73 (diff)
downloadspawn-fcgi-89d643387ef2ad3482dccadb197969144faae305.tar.gz
spawn-fcgi-89d643387ef2ad3482dccadb197969144faae305.zip
Add CONST_STR_LEN and use it
git-svn-id: svn://svn.lighttpd.net/spawn-fcgi/trunk@51 4a9f3682-ca7b-49a8-9a55-ba4640e46f83
-rw-r--r--src/spawn-fcgi.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/spawn-fcgi.c b/src/spawn-fcgi.c
index 686457a..29c84b8 100644
--- a/src/spawn-fcgi.c
+++ b/src/spawn-fcgi.c
@@ -77,6 +77,7 @@ static int issetugid() {
#define PACKAGE_DESC "spawn-fcgi v" PACKAGE_VERSION PACKAGE_FEATURES " - spawns FastCGI processes\n"
+#define CONST_STR_LEN(s) s, sizeof(s) - 1
static int bind_socket(const char *addr, unsigned short port, const char *unixsocket, uid_t uid, gid_t gid, int mode) {
int fcgi_fd, socket_type, val;
@@ -271,7 +272,7 @@ static int fcgi_spawn_connection(char *appPath, char **appArgv, int fcgi_fd, int
execv(appArgv[0], appArgv);
} else {
- char *b = malloc(strlen("exec ") + strlen(appPath) + 1);
+ char *b = malloc((sizeof("exec ") - 1) + strlen(appPath) + 1);
strcpy(b, "exec ");
strcat(b, appPath);
@@ -404,41 +405,40 @@ static int find_user_group(const char *user, const char *group, uid_t *uid, gid_
}
static void show_version () {
- const char *b = PACKAGE_DESC
-"Build-Date: " __DATE__ " " __TIME__ "\n";
-;
- write(1, b, strlen(b));
+ write(1, CONST_STR_LEN(
+ PACKAGE_DESC \
+ "Build-Date: " __DATE__ " " __TIME__ "\n"
+ ));
}
static void show_help () {
- char *b = \
-"Usage: spawn-fcgi [options] [-- <fcgiapp> [fcgi app arguments]]\n" \
-"\n" \
-PACKAGE_DESC \
-"\n" \
-"Options:\n" \
-" -f <path> filename of the fcgi-application (ignored if <fcgiapp> is given)\n" \
-" -d <directory> chdir to directory before spawning\n" \
-" -a <address> bind to IPv4/IPv6 address (defaults to 0.0.0.0)\n" \
-" -p <port> bind to TCP-port\n" \
-" -s <path> bind to Unix domain socket\n" \
-" -M <mode> change Unix domain socket mode\n" \
-" -C <children> (PHP only) numbers of childs to spawn (default: not setting\n" \
-" the PHP_FCGI_CHILDREN environment variable - PHP defaults to 0)\n" \
-" -F <children> number of children to fork (default 1)\n" \
-" -P <path> name of PID-file for spawned process (ignored in no-fork mode)\n" \
-" -n no fork (for daemontools)\n" \
-" -v show version\n" \
-" -?, -h show this help\n" \
-"(root only)\n" \
-" -c <directory> chroot to directory\n" \
-" -S create socket before chroot() (default is to create the socket in the chroot)\n" \
-" -u <user> change to user-id\n" \
-" -g <group> change to group-id (default: primary group of user if -u is given)\n" \
-" -U <user> change Unix domain socket owner to user-id\n" \
-" -G <group> change Unix domain socket group to group-id\n" \
-;
- write(1, b, strlen(b));
+ write(1, CONST_STR_LEN(
+ "Usage: spawn-fcgi [options] [-- <fcgiapp> [fcgi app arguments]]\n" \
+ "\n" \
+ PACKAGE_DESC \
+ "\n" \
+ "Options:\n" \
+ " -f <path> filename of the fcgi-application (ignored if <fcgiapp> is given)\n" \
+ " -d <directory> chdir to directory before spawning\n" \
+ " -a <address> bind to IPv4/IPv6 address (defaults to 0.0.0.0)\n" \
+ " -p <port> bind to TCP-port\n" \
+ " -s <path> bind to Unix domain socket\n" \
+ " -M <mode> change Unix domain socket mode\n" \
+ " -C <children> (PHP only) numbers of childs to spawn (default: not setting\n" \
+ " the PHP_FCGI_CHILDREN environment variable - PHP defaults to 0)\n" \
+ " -F <children> number of children to fork (default 1)\n" \
+ " -P <path> name of PID-file for spawned process (ignored in no-fork mode)\n" \
+ " -n no fork (for daemontools)\n" \
+ " -v show version\n" \
+ " -?, -h show this help\n" \
+ "(root only)\n" \
+ " -c <directory> chroot to directory\n" \
+ " -S create socket before chroot() (default is to create the socket in the chroot)\n" \
+ " -u <user> change to user-id\n" \
+ " -g <group> change to group-id (default: primary group of user if -u is given)\n" \
+ " -U <user> change Unix domain socket owner to user-id\n" \
+ " -G <group> change Unix domain socket group to group-id\n" \
+ ));
}