mirror of
https://github.com/troglobit/finit.git
synced 2026-11-09 16:21:24 +00:00
Minor refactor, break out new fn svc_find_by_str()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
9cb6a54493
commit
ed383eaaa6
2 files changed
+28
-9
No files matched your search
@@ -371,6 +371,32 @@ svc_t *svc_find(char *name, char *id)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* svc_find_by_str - Find a service object by name:id
|
||||||
|
* @str: name[:id]
|
||||||
|
*
|
||||||
|
* Like svc_find() but takes 'name[:id]' argument
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* A pointer to an &svc_t object, or %NULL if not found.
|
||||||
|
*/
|
||||||
|
svc_t *svc_find_by_str(const char *str)
|
||||||
|
{
|
||||||
|
char *name, *id;
|
||||||
|
|
||||||
|
if (!str)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
name = strdupa(str);
|
||||||
|
id = strchr(name, ':');
|
||||||
|
if (id)
|
||||||
|
*id++ = 0;
|
||||||
|
else
|
||||||
|
id = "";
|
||||||
|
|
||||||
|
return svc_find(name, id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* svc_find_by_pid - Find a service object by its PID
|
* svc_find_by_pid - Find a service object by its PID
|
||||||
* @pid: Process ID to match
|
* @pid: Process ID to match
|
||||||
@@ -644,17 +670,9 @@ int svc_conflicts(svc_t *svc)
|
|||||||
|
|
||||||
nm = strtok(ptr, ",");
|
nm = strtok(ptr, ",");
|
||||||
while (nm) {
|
while (nm) {
|
||||||
char *name, *id;
|
|
||||||
svc_t *s;
|
svc_t *s;
|
||||||
|
|
||||||
name = strdupa(nm);
|
s = svc_find_by_str(nm);
|
||||||
id = strchr(name, ':');
|
|
||||||
if (id)
|
|
||||||
id++ = 0;
|
|
||||||
else
|
|
||||||
id = "";
|
|
||||||
|
|
||||||
s = svc_find(name, id);
|
|
||||||
if (s) {
|
if (s) {
|
||||||
if (s->state >= SVC_STOPPING_STATE)
|
if (s->state >= SVC_STOPPING_STATE)
|
||||||
rc = 1;
|
rc = 1;
|
||||||
|
|||||||
@@ -210,6 +210,7 @@ int svc_del (svc_t *svc);
|
|||||||
void svc_validate (svc_t *svc);
|
void svc_validate (svc_t *svc);
|
||||||
|
|
||||||
svc_t *svc_find (char *name, char *id);
|
svc_t *svc_find (char *name, char *id);
|
||||||
|
svc_t *svc_find_by_str (const char *str);
|
||||||
svc_t *svc_find_by_pid (pid_t pid);
|
svc_t *svc_find_by_pid (pid_t pid);
|
||||||
svc_t *svc_find_by_cond (const char *cond);
|
svc_t *svc_find_by_cond (const char *cond);
|
||||||
svc_t *svc_find_by_jobid (int job, char *id);
|
svc_t *svc_find_by_jobid (int job, char *id);
|
||||||
|
|||||||
Reference in new issue
Block a user