cbasename -> basename_c

This commit is contained in:
Roy Marples 2007-12-19 13:53:52 +00:00
parent b3df16a03e
commit 4022522a81
10 changed files with 27 additions and 27 deletions

View File

@ -187,7 +187,7 @@ int checkown (int argc, char **argv)
struct group *gr = NULL; struct group *gr = NULL;
bool file = 0; bool file = 0;
applet = cbasename (argv[0]); applet = basename_c (argv[0]);
int retval = EXIT_SUCCESS; int retval = EXIT_SUCCESS;
while ((opt = getopt_long (argc, argv, getoptstring, while ((opt = getopt_long (argc, argv, getoptstring,

View File

@ -128,7 +128,7 @@ int fstabinfo (int argc, char **argv)
char *file; char *file;
bool filtered = false; bool filtered = false;
applet = cbasename (argv[0]); applet = basename_c (argv[0]);
/* Ensure that we are only quiet when explicitly told to be */ /* Ensure that we are only quiet when explicitly told to be */
unsetenv ("EINFO_QUIET"); unsetenv ("EINFO_QUIET");

View File

@ -331,7 +331,7 @@ bool rc_service_daemon_set (const char *service, const char *exec,
} }
dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", dirpath = rc_strcatpaths (RC_SVCDIR, "daemons",
cbasename (service), (char *) NULL); basename_c (service), (char *) NULL);
if (exec) { if (exec) {
i = strlen (exec) + 6; i = strlen (exec) + 6;
@ -421,7 +421,7 @@ bool rc_service_started_daemon (const char *service, const char *exec,
if (! service || ! exec) if (! service || ! exec)
return (false); return (false);
dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", cbasename (service), dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename_c (service),
(char *) NULL); (char *) NULL);
i = strlen (exec) + 6; i = strlen (exec) + 6;
@ -473,7 +473,7 @@ bool rc_service_daemons_crashed (const char *service)
if (! service) if (! service)
return (false); return (false);
dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", cbasename (service), dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename_c (service),
(char *) NULL); (char *) NULL);
if (! (dp = opendir (dirpath))) { if (! (dp = opendir (dirpath))) {

View File

@ -382,7 +382,7 @@ bool rc_service_in_runlevel (const char *service, const char *runlevel)
if (! runlevel || ! service) if (! runlevel || ! service)
return (false); return (false);
file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, cbasename (service), file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service),
(char *) NULL); (char *) NULL);
retval = exists (file); retval = exists (file);
free (file); free (file);
@ -403,7 +403,7 @@ bool rc_service_mark (const char *service, const rc_service_state_t state)
if (! init) if (! init)
return (false); return (false);
base = cbasename (service); base = basename_c (service);
if (state != RC_SERVICE_STOPPED) { if (state != RC_SERVICE_STOPPED) {
if (! exists (init)) { if (! exists (init)) {
@ -520,7 +520,7 @@ rc_service_state_t rc_service_state (const char *service)
for (i = 0; rc_service_state_names[i].name; i++) { for (i = 0; rc_service_state_names[i].name; i++) {
char *file = rc_strcatpaths (RC_SVCDIR, rc_service_state_names[i].name, char *file = rc_strcatpaths (RC_SVCDIR, rc_service_state_names[i].name,
cbasename (service), (char*) NULL); basename_c (service), (char*) NULL);
if (exists (file)) { if (exists (file)) {
if (rc_service_state_names[i].state <= 0x10) if (rc_service_state_names[i].state <= 0x10)
state = rc_service_state_names[i].state; state = rc_service_state_names[i].state;
@ -601,7 +601,7 @@ static pid_t _exec_service (const char *service, const char *arg)
} }
/* We create a fifo so that other services can wait until we complete */ /* We create a fifo so that other services can wait until we complete */
fifo = rc_strcatpaths (RC_SVCDIR, "exclusive", cbasename (service), fifo = rc_strcatpaths (RC_SVCDIR, "exclusive", basename_c (service),
(char *) NULL); (char *) NULL);
if (mkfifo (fifo, 0600) != 0 && errno != EEXIST) { if (mkfifo (fifo, 0600) != 0 && errno != EEXIST) {
@ -666,7 +666,7 @@ bool rc_service_schedule_start (const char *service,
if (! service || ! rc_service_exists (service_to_start)) if (! service || ! rc_service_exists (service_to_start))
return (false); return (false);
dir = rc_strcatpaths (RC_SVCDIR, "scheduled", cbasename (service), dir = rc_strcatpaths (RC_SVCDIR, "scheduled", basename_c (service),
(char *) NULL); (char *) NULL);
if (mkdir (dir, 0755) != 0 && errno != EEXIST) { if (mkdir (dir, 0755) != 0 && errno != EEXIST) {
free (dir); free (dir);
@ -674,7 +674,7 @@ bool rc_service_schedule_start (const char *service,
} }
init = rc_service_resolve (service_to_start); init = rc_service_resolve (service_to_start);
file = rc_strcatpaths (dir, cbasename (service_to_start), (char *) NULL); file = rc_strcatpaths (dir, basename_c (service_to_start), (char *) NULL);
retval = (exists (file) || symlink (init, file) == 0); retval = (exists (file) || symlink (init, file) == 0);
free (init); free (init);
free (file); free (file);
@ -686,7 +686,7 @@ librc_hidden_def(rc_service_schedule_start)
bool rc_service_schedule_clear (const char *service) bool rc_service_schedule_clear (const char *service)
{ {
char *dir = rc_strcatpaths (RC_SVCDIR, "scheduled", cbasename (service), char *dir = rc_strcatpaths (RC_SVCDIR, "scheduled", basename_c (service),
(char *) NULL); (char *) NULL);
bool retval; bool retval;
@ -792,7 +792,7 @@ bool rc_service_add (const char *runlevel, const char *service)
} }
} }
file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, cbasename (service), file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service),
(char *) NULL); (char *) NULL);
retval = (symlink (init, file) == 0); retval = (symlink (init, file) == 0);
free (init); free (init);
@ -809,7 +809,7 @@ bool rc_service_delete (const char *runlevel, const char *service)
if (! runlevel || ! service) if (! runlevel || ! service)
return (false); return (false);
file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, cbasename (service), file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service),
(char *) NULL); (char *) NULL);
if (unlink (file) == 0) if (unlink (file) == 0)
retval = true; retval = true;
@ -841,7 +841,7 @@ librc_hidden_def(rc_services_scheduled_by)
char **rc_services_scheduled (const char *service) char **rc_services_scheduled (const char *service)
{ {
char *dir = rc_strcatpaths (RC_SVCDIR, "scheduled", cbasename (service), char *dir = rc_strcatpaths (RC_SVCDIR, "scheduled", basename_c (service),
(char *) NULL); (char *) NULL);
char **list = NULL; char **list = NULL;

View File

@ -96,7 +96,7 @@ int rc_depend (int argc, char **argv)
int opt; int opt;
char *token; char *token;
applet = cbasename (argv[0]); applet = basename_c (argv[0]);
while ((opt = getopt_long (argc, argv, getoptstring, while ((opt = getopt_long (argc, argv, getoptstring,
longopts, (int *) 0)) != -1) longopts, (int *) 0)) != -1)

View File

@ -119,14 +119,14 @@ bool rc_conf_yesno (const char *var);
char **env_filter (void); char **env_filter (void);
char **env_config (void); char **env_config (void);
/* cbasename never modifies the argument. As such, if there is a trailing /* basename_c never modifies the argument. As such, if there is a trailing
* slash then an empty string is returned. */ * slash then an empty string is returned. */
static inline const char *cbasename (const char *argv0) { static inline const char *basename_c (const char *path) {
char *l = strrchr (argv0, '/'); const char *slash = strrchr (path, '/');
if (l) if (slash)
return (++l); return (++slash);
return (argv0); return (path);
} }
#endif #endif

View File

@ -159,7 +159,7 @@ int rc_update (int argc, char **argv)
int opt; int opt;
int retval = EXIT_FAILURE; int retval = EXIT_FAILURE;
applet = cbasename (argv[0]); applet = basename_c (argv[0]);
while ((opt = getopt_long (argc, argv, getoptstring, while ((opt = getopt_long (argc, argv, getoptstring,
longopts, (int *) 0)) != -1) longopts, (int *) 0)) != -1)

View File

@ -809,7 +809,7 @@ int main (int argc, char **argv)
bool parallel; bool parallel;
int regen = 0; int regen = 0;
applet = cbasename (argv[0]); applet = basename_c (argv[0]);
atexit (cleanup); atexit (cleanup);
if (! applet) if (! applet)
eerrorx ("arguments required"); eerrorx ("arguments required");

View File

@ -519,7 +519,7 @@ static bool svc_wait (rc_depinfo_t *depinfo, const char *svc)
} }
rc_strlist_free (keywords); rc_strlist_free (keywords);
fifo = rc_strcatpaths (RC_SVCDIR, "exclusive", cbasename (svc), (char *) NULL); fifo = rc_strcatpaths (RC_SVCDIR, "exclusive", basename_c (svc), (char *) NULL);
ts.tv_sec = 0; ts.tv_sec = 0;
ts.tv_nsec = WAIT_INTERVAL; ts.tv_nsec = WAIT_INTERVAL;
@ -1046,7 +1046,7 @@ int runscript (int argc, char **argv)
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
applet = cbasename (argv[1]); applet = basename_c (argv[1]);
if (argc < 3) if (argc < 3)
usage (EXIT_FAILURE); usage (EXIT_FAILURE);

View File

@ -572,7 +572,7 @@ int start_stop_daemon (int argc, char **argv)
char *svcname = getenv ("SVCNAME"); char *svcname = getenv ("SVCNAME");
char *env; char *env;
applet = cbasename (argv[0]); applet = basename_c (argv[0]);
atexit (cleanup); atexit (cleanup);
signal (SIGINT, handle_signal); signal (SIGINT, handle_signal);