aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-09-25 16:21:38 +0000
committerMike Frysinger <vapier@gentoo.org>2007-09-25 16:21:38 +0000
commit284286004e024dd240cc08d84ebd8b6748d311c8 (patch)
treee8fcd489e28c5bb8dee70d340099c8095938b393 /src
parent17f430c0b911ef243599b0dc7388b166d5365539 (diff)
Add support for describing the options in the C programs.
Diffstat (limited to 'src')
-rw-r--r--src/_usage.c3
-rw-r--r--src/_usage.h8
-rw-r--r--src/checkown.c8
-rw-r--r--src/env-update.c9
-rw-r--r--src/fstabinfo.c7
-rw-r--r--src/mountinfo.c14
-rw-r--r--src/rc-status.c7
-rw-r--r--src/rc-update.c9
-rw-r--r--src/rc.c5
-rw-r--r--src/runscript.c10
-rw-r--r--src/start-stop-daemon.c24
11 files changed, 97 insertions, 7 deletions
diff --git a/src/_usage.c b/src/_usage.c
index 66ae8df0..be41e313 100644
--- a/src/_usage.c
+++ b/src/_usage.c
@@ -16,7 +16,8 @@ static void usage (int exit_status)
#endif
printf ("\n\nOptions: [" getoptstring "]\n");
for (i = 0; longopts[i].name; ++i)
- printf (" -%c, --%s\n", longopts[i].val, longopts[i].name);
+ printf (" -%c, --%-15s %s\n", longopts[i].val, longopts[i].name,
+ longopts_help[i]);
exit (exit_status);
}
diff --git a/src/_usage.h b/src/_usage.h
index 6f48cf8a..83b4f999 100644
--- a/src/_usage.h
+++ b/src/_usage.h
@@ -8,10 +8,16 @@
*/
#define getoptstring_COMMON "Chq"
+
#define longopts_COMMON \
{ "help", 0, NULL, 'h'}, \
{ "nocolor", 0, NULL, 'C'}, \
- { "quiet", 0, NULL, 'q'},
+ { "quiet", 0, NULL, 'q'},
+
+#define longopts_help_COMMON \
+ "Display this help output (duh)", \
+ "Disable color output", \
+ "Run quietly"
#define case_RC_COMMON_GETOPT \
case 'C': setenv ("RC_NOCOLOR", "yes", 1); break; \
diff --git a/src/checkown.c b/src/checkown.c
index d9294dac..c979bfbe 100644
--- a/src/checkown.c
+++ b/src/checkown.c
@@ -143,6 +143,14 @@ static struct option longopts[] = {
longopts_COMMON
{ NULL, 0, NULL, 0}
};
+static const char * const longopts_help[] = {
+ "",
+ "",
+ "",
+ "",
+ "",
+ longopts_help_COMMON
+};
#include "_usage.c"
int checkown (int argc, char **argv)
diff --git a/src/env-update.c b/src/env-update.c
index fba671b4..c9739a78 100644
--- a/src/env-update.c
+++ b/src/env-update.c
@@ -65,7 +65,7 @@ static const char *colon_separated[] = {
NULL
};
-static const char *space_separated[] = {
+static const char *space_separated[] = {
"CONFIG_PROTECT",
"CONFIG_PROTECT_MASK",
NULL,
@@ -81,6 +81,11 @@ static struct option longopts[] = {
longopts_COMMON
{ NULL, 0, NULL, 0}
};
+static const char * const longopts_help[] = {
+ "Fork ldconfig into the background",
+ "Skip execution of ldconfig",
+ longopts_help_COMMON
+};
#include "_usage.c"
int env_update (int argc, char **argv)
@@ -103,7 +108,7 @@ int env_update (int argc, char **argv)
bool ldconfig = true;
bool fork_ldconfig = false;
int nents = 0;
-
+
applet = argv[0];
while ((opt = getopt_long (argc, argv, getoptstring,
diff --git a/src/fstabinfo.c b/src/fstabinfo.c
index e06a490b..2d2a5bba 100644
--- a/src/fstabinfo.c
+++ b/src/fstabinfo.c
@@ -67,6 +67,13 @@ static struct option longopts[] = {
longopts_COMMON
{ NULL, 0, NULL, 0}
};
+static const char * const longopts_help[] = {
+ "Construct the arguments to give to mount",
+ "Extract the options field",
+ "Extract the pass number field",
+ "Extract the file system type",
+ longopts_help_COMMON
+};
#include "_usage.c"
int fstabinfo (int argc, char **argv)
diff --git a/src/mountinfo.c b/src/mountinfo.c
index 2b361d14..a0250e83 100644
--- a/src/mountinfo.c
+++ b/src/mountinfo.c
@@ -263,6 +263,20 @@ static struct option longopts[] = {
longopts_COMMON
{ NULL, 0, NULL, 0}
};
+static const char * const longopts_help[] = {
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ longopts_help_COMMON
+};
#include "_usage.c"
int mountinfo (int argc, char **argv)
diff --git a/src/rc-status.c b/src/rc-status.c
index cd4a24f8..9ebd56c8 100644
--- a/src/rc-status.c
+++ b/src/rc-status.c
@@ -65,6 +65,13 @@ static const struct option longopts[] = {
longopts_COMMON
{NULL, 0, NULL, 0}
};
+static const char * const longopts_help[] = {
+ "Show services from all run levels",
+ "Show list of run levels",
+ "Show service list",
+ "Show services not assigned to any run level",
+ longopts_help_COMMON
+};
#include "_usage.c"
int rc_status (int argc, char **argv)
diff --git a/src/rc-update.c b/src/rc-update.c
index 34f10b91..f5d8855f 100644
--- a/src/rc-update.c
+++ b/src/rc-update.c
@@ -113,9 +113,16 @@ static struct option longopts[] = {
longopts_COMMON
{ NULL, 0, NULL, 0}
};
+static const char * const longopts_help[] = {
+ "Add the init.d to runlevels",
+ "Delete init.d from runlevels",
+ "Show init.d's in runlevels",
+ "Be verbose!",
+ longopts_help_COMMON
+};
#include "_usage.c"
-#define DOADD (1 << 0)
+#define DOADD (1 << 0)
#define DODELETE (1 << 1)
#define DOSHOW (1 << 2)
diff --git a/src/rc.c b/src/rc.c
index c84c49e5..da805ccb 100644
--- a/src/rc.c
+++ b/src/rc.c
@@ -710,11 +710,14 @@ static void run_script (const char *script) {
}
#include "_usage.h"
-#define getoptstring getoptstring_COMMON
+#define getoptstring getoptstring_COMMON
static struct option longopts[] = {
longopts_COMMON
{ NULL, 0, NULL, 0}
};
+static const char * const longopts_help[] = {
+ longopts_help_COMMON
+};
#include "_usage.c"
int main (int argc, char **argv)
diff --git a/src/runscript.c b/src/runscript.c
index 550653ab..4bbc0dab 100644
--- a/src/runscript.c
+++ b/src/runscript.c
@@ -972,7 +972,7 @@ static void svc_restart (bool deps)
}
#include "_usage.h"
-#define getoptstring "dDqsv" getoptstring_COMMON
+#define getoptstring "dDqsv" getoptstring_COMMON
static struct option longopts[] = {
{ "debug", 0, NULL, 'd'},
{ "ifstarted", 0, NULL, 's'},
@@ -982,6 +982,14 @@ static struct option longopts[] = {
longopts_COMMON
{ NULL, 0, NULL, 0}
};
+static const char * const longopts_help[] = {
+ "",
+ "",
+ "",
+ "",
+ "",
+ longopts_help_COMMON
+};
#include "_usage.c"
int runscript (int argc, char **argv)
diff --git a/src/start-stop-daemon.c b/src/start-stop-daemon.c
index 8c43a407..1b4c7f28 100644
--- a/src/start-stop-daemon.c
+++ b/src/start-stop-daemon.c
@@ -487,6 +487,30 @@ static struct option longopts[] = {
longopts_COMMON
{ NULL, 0, NULL, 0}
};
+static const char * const longopts_help[] = {
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ longopts_help_COMMON
+};
#include "_usage.c"
int start_stop_daemon (int argc, char **argv)