cbasename -> basename_c
This commit is contained in:
parent
b3df16a03e
commit
4022522a81
@ -187,7 +187,7 @@ int checkown (int argc, char **argv)
|
||||
struct group *gr = NULL;
|
||||
bool file = 0;
|
||||
|
||||
applet = cbasename (argv[0]);
|
||||
applet = basename_c (argv[0]);
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
while ((opt = getopt_long (argc, argv, getoptstring,
|
||||
|
@ -128,7 +128,7 @@ int fstabinfo (int argc, char **argv)
|
||||
char *file;
|
||||
bool filtered = false;
|
||||
|
||||
applet = cbasename (argv[0]);
|
||||
applet = basename_c (argv[0]);
|
||||
|
||||
/* Ensure that we are only quiet when explicitly told to be */
|
||||
unsetenv ("EINFO_QUIET");
|
||||
|
@ -331,7 +331,7 @@ bool rc_service_daemon_set (const char *service, const char *exec,
|
||||
}
|
||||
|
||||
dirpath = rc_strcatpaths (RC_SVCDIR, "daemons",
|
||||
cbasename (service), (char *) NULL);
|
||||
basename_c (service), (char *) NULL);
|
||||
|
||||
if (exec) {
|
||||
i = strlen (exec) + 6;
|
||||
@ -421,7 +421,7 @@ bool rc_service_started_daemon (const char *service, const char *exec,
|
||||
if (! service || ! exec)
|
||||
return (false);
|
||||
|
||||
dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", cbasename (service),
|
||||
dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename_c (service),
|
||||
(char *) NULL);
|
||||
|
||||
i = strlen (exec) + 6;
|
||||
@ -473,7 +473,7 @@ bool rc_service_daemons_crashed (const char *service)
|
||||
if (! service)
|
||||
return (false);
|
||||
|
||||
dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", cbasename (service),
|
||||
dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename_c (service),
|
||||
(char *) NULL);
|
||||
|
||||
if (! (dp = opendir (dirpath))) {
|
||||
|
20
src/librc.c
20
src/librc.c
@ -382,7 +382,7 @@ bool rc_service_in_runlevel (const char *service, const char *runlevel)
|
||||
if (! runlevel || ! service)
|
||||
return (false);
|
||||
|
||||
file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, cbasename (service),
|
||||
file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service),
|
||||
(char *) NULL);
|
||||
retval = exists (file);
|
||||
free (file);
|
||||
@ -403,7 +403,7 @@ bool rc_service_mark (const char *service, const rc_service_state_t state)
|
||||
if (! init)
|
||||
return (false);
|
||||
|
||||
base = cbasename (service);
|
||||
base = basename_c (service);
|
||||
|
||||
if (state != RC_SERVICE_STOPPED) {
|
||||
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++) {
|
||||
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 (rc_service_state_names[i].state <= 0x10)
|
||||
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 */
|
||||
fifo = rc_strcatpaths (RC_SVCDIR, "exclusive", cbasename (service),
|
||||
fifo = rc_strcatpaths (RC_SVCDIR, "exclusive", basename_c (service),
|
||||
(char *) NULL);
|
||||
|
||||
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))
|
||||
return (false);
|
||||
|
||||
dir = rc_strcatpaths (RC_SVCDIR, "scheduled", cbasename (service),
|
||||
dir = rc_strcatpaths (RC_SVCDIR, "scheduled", basename_c (service),
|
||||
(char *) NULL);
|
||||
if (mkdir (dir, 0755) != 0 && errno != EEXIST) {
|
||||
free (dir);
|
||||
@ -674,7 +674,7 @@ bool rc_service_schedule_start (const char *service,
|
||||
}
|
||||
|
||||
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);
|
||||
free (init);
|
||||
free (file);
|
||||
@ -686,7 +686,7 @@ librc_hidden_def(rc_service_schedule_start)
|
||||
|
||||
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);
|
||||
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);
|
||||
retval = (symlink (init, file) == 0);
|
||||
free (init);
|
||||
@ -809,7 +809,7 @@ bool rc_service_delete (const char *runlevel, const char *service)
|
||||
if (! runlevel || ! service)
|
||||
return (false);
|
||||
|
||||
file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, cbasename (service),
|
||||
file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service),
|
||||
(char *) NULL);
|
||||
if (unlink (file) == 0)
|
||||
retval = true;
|
||||
@ -841,7 +841,7 @@ librc_hidden_def(rc_services_scheduled_by)
|
||||
|
||||
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 **list = NULL;
|
||||
|
||||
|
@ -96,7 +96,7 @@ int rc_depend (int argc, char **argv)
|
||||
int opt;
|
||||
char *token;
|
||||
|
||||
applet = cbasename (argv[0]);
|
||||
applet = basename_c (argv[0]);
|
||||
|
||||
while ((opt = getopt_long (argc, argv, getoptstring,
|
||||
longopts, (int *) 0)) != -1)
|
||||
|
@ -119,14 +119,14 @@ bool rc_conf_yesno (const char *var);
|
||||
char **env_filter (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. */
|
||||
static inline const char *cbasename (const char *argv0) {
|
||||
char *l = strrchr (argv0, '/');
|
||||
static inline const char *basename_c (const char *path) {
|
||||
const char *slash = strrchr (path, '/');
|
||||
|
||||
if (l)
|
||||
return (++l);
|
||||
return (argv0);
|
||||
if (slash)
|
||||
return (++slash);
|
||||
return (path);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -159,7 +159,7 @@ int rc_update (int argc, char **argv)
|
||||
int opt;
|
||||
int retval = EXIT_FAILURE;
|
||||
|
||||
applet = cbasename (argv[0]);
|
||||
applet = basename_c (argv[0]);
|
||||
|
||||
while ((opt = getopt_long (argc, argv, getoptstring,
|
||||
longopts, (int *) 0)) != -1)
|
||||
|
2
src/rc.c
2
src/rc.c
@ -809,7 +809,7 @@ int main (int argc, char **argv)
|
||||
bool parallel;
|
||||
int regen = 0;
|
||||
|
||||
applet = cbasename (argv[0]);
|
||||
applet = basename_c (argv[0]);
|
||||
atexit (cleanup);
|
||||
if (! applet)
|
||||
eerrorx ("arguments required");
|
||||
|
@ -519,7 +519,7 @@ static bool svc_wait (rc_depinfo_t *depinfo, const char *svc)
|
||||
}
|
||||
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_nsec = WAIT_INTERVAL;
|
||||
|
||||
@ -1046,7 +1046,7 @@ int runscript (int argc, char **argv)
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
applet = cbasename (argv[1]);
|
||||
applet = basename_c (argv[1]);
|
||||
if (argc < 3)
|
||||
usage (EXIT_FAILURE);
|
||||
|
||||
|
@ -572,7 +572,7 @@ int start_stop_daemon (int argc, char **argv)
|
||||
char *svcname = getenv ("SVCNAME");
|
||||
char *env;
|
||||
|
||||
applet = cbasename (argv[0]);
|
||||
applet = basename_c (argv[0]);
|
||||
atexit (cleanup);
|
||||
|
||||
signal (SIGINT, handle_signal);
|
||||
|
Loading…
Reference in New Issue
Block a user