summaryrefslogtreecommitdiff
path: root/lib/src
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-03-25 12:14:06 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-03-25 12:14:06 +0200
commita71c92b33dc69bc6cbc5eae161f82a5bca27a82f (patch)
tree917eaeb4b2460345e122a00cbc32c7398f438d39 /lib/src
parenta108beaaf7b19198acbcc5435708d4ff0c8fb5df (diff)
Unify naming of service to shorthand svc
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'lib/src')
-rw-r--r--lib/src/del_svc_list.c (renamed from lib/src/del_srv_list.c)10
-rw-r--r--lib/src/delsvc.c (renamed from lib/src/delsrv.c)28
-rw-r--r--lib/src/rdsvc.c (renamed from lib/src/rdsrv.c)86
-rw-r--r--lib/src/svc_tsort.c (renamed from lib/src/srv_tsort.c)2
-rw-r--r--lib/src/svcscan.c (renamed from lib/src/srvscan.c)14
5 files changed, 70 insertions, 70 deletions
diff --git a/lib/src/del_srv_list.c b/lib/src/del_svc_list.c
index d54c40b..553a701 100644
--- a/lib/src/del_srv_list.c
+++ b/lib/src/del_svc_list.c
@@ -19,17 +19,17 @@
#include "service.h"
-void del_srv_list(service_list_t *list)
+void del_svc_list(service_list_t *list)
{
- service_t *srv;
+ service_t *svc;
int i;
for (i = 0; i < TGT_MAX; ++i) {
while (list->targets[i] != NULL) {
- srv = list->targets[i];
- list->targets[i] = srv->next;
+ svc = list->targets[i];
+ list->targets[i] = svc->next;
- delsrv(srv);
+ delsvc(svc);
}
}
}
diff --git a/lib/src/delsrv.c b/lib/src/delsvc.c
index 87b65bc..3e077fb 100644
--- a/lib/src/delsrv.c
+++ b/lib/src/delsvc.c
@@ -19,24 +19,24 @@
#include "service.h"
-void delsrv(service_t *srv)
+void delsvc(service_t *svc)
{
size_t i;
- for (i = 0; i < srv->num_exec; ++i)
- free(srv->exec[i]);
+ for (i = 0; i < svc->num_exec; ++i)
+ free(svc->exec[i]);
- for (i = 0; i < srv->num_before; ++i)
- free(srv->before[i]);
+ for (i = 0; i < svc->num_before; ++i)
+ free(svc->before[i]);
- for (i = 0; i < srv->num_after; ++i)
- free(srv->after[i]);
+ for (i = 0; i < svc->num_after; ++i)
+ free(svc->after[i]);
- free(srv->before);
- free(srv->after);
- free(srv->name);
- free(srv->desc);
- free(srv->exec);
- free(srv->ctty);
- free(srv);
+ free(svc->before);
+ free(svc->after);
+ free(svc->name);
+ free(svc->desc);
+ free(svc->exec);
+ free(svc->ctty);
+ free(svc);
}
diff --git a/lib/src/rdsrv.c b/lib/src/rdsvc.c
index 88d41e8..972f7e4 100644
--- a/lib/src/rdsrv.c
+++ b/lib/src/rdsvc.c
@@ -27,34 +27,34 @@
#include "service.h"
#include "util.h"
-static int srv_name(service_t *srv, char *arg,
+static int svc_name(service_t *svc, char *arg,
const char *filename, size_t lineno)
{
(void)filename; (void)lineno;
- srv->name = arg;
+ svc->name = arg;
return 0;
}
-static int srv_desc(service_t *srv, char *arg,
+static int svc_desc(service_t *svc, char *arg,
const char *filename, size_t lineno)
{
(void)filename; (void)lineno;
- srv->desc = arg;
+ svc->desc = arg;
return 0;
}
-static int srv_tty(service_t *srv, char *arg,
+static int svc_tty(service_t *svc, char *arg,
const char *filename, size_t lineno)
{
(void)filename; (void)lineno;
- srv->ctty = arg;
+ svc->ctty = arg;
return 0;
}
-static int srv_exec(service_t *srv, char *arg,
+static int svc_exec(service_t *svc, char *arg,
const char *filename, size_t lineno)
{
- char **new = realloc(srv->exec, sizeof(char*) * (srv->num_exec + 1));
+ char **new = realloc(svc->exec, sizeof(char*) * (svc->num_exec + 1));
if (new == NULL) {
fprintf(stderr, "%s: %zu: out of memory\n", filename, lineno);
@@ -62,16 +62,16 @@ static int srv_exec(service_t *srv, char *arg,
return -1;
}
- srv->exec = new;
- srv->exec[srv->num_exec++] = arg;
+ svc->exec = new;
+ svc->exec[svc->num_exec++] = arg;
return 0;
}
-static int srv_before(service_t *srv, char *arg,
+static int svc_before(service_t *svc, char *arg,
const char *filename, size_t lineno)
{
- char **new = realloc(srv->before,
- sizeof(char*) * (srv->num_before + 1));
+ char **new = realloc(svc->before,
+ sizeof(char*) * (svc->num_before + 1));
if (new == NULL) {
fprintf(stderr, "%s: %zu: out of memory\n", filename, lineno);
@@ -79,15 +79,15 @@ static int srv_before(service_t *srv, char *arg,
return -1;
}
- srv->before = new;
- srv->before[srv->num_before++] = arg;
+ svc->before = new;
+ svc->before[svc->num_before++] = arg;
return 0;
}
-static int srv_after(service_t *srv, char *arg,
+static int svc_after(service_t *svc, char *arg,
const char *filename, size_t lineno)
{
- char **new = realloc(srv->after, sizeof(char*) * (srv->num_after + 1));
+ char **new = realloc(svc->after, sizeof(char*) * (svc->num_after + 1));
if (new == NULL) {
fprintf(stderr, "%s: %zu: out of memory\n", filename, lineno);
@@ -95,12 +95,12 @@ static int srv_after(service_t *srv, char *arg,
return -1;
}
- srv->after = new;
- srv->after[srv->num_after++] = arg;
+ svc->after = new;
+ svc->after[svc->num_after++] = arg;
return 0;
}
-static int srv_type(service_t *srv, char *arg,
+static int svc_type(service_t *svc, char *arg,
const char *filename, size_t lineno)
{
int type = svc_type_from_string(arg);
@@ -111,12 +111,12 @@ static int srv_type(service_t *srv, char *arg,
return -1;
}
- srv->type = type;
+ svc->type = type;
free(arg);
return 0;
}
-static int srv_target(service_t *srv, char *arg,
+static int svc_target(service_t *svc, char *arg,
const char *filename, size_t lineno)
{
int target = svc_target_from_string(arg);
@@ -127,7 +127,7 @@ static int srv_target(service_t *srv, char *arg,
return -1;
}
- srv->target = target;
+ svc->target = target;
free(arg);
return 0;
}
@@ -136,26 +136,26 @@ static int srv_target(service_t *srv, char *arg,
static const struct {
const char *key;
- int (*handle)(service_t *srv, char *arg,
+ int (*handle)(service_t *svc, char *arg,
const char *filename, size_t lineno);
-} srv_params[] = {
- { "name", srv_name },
- { "description", srv_desc },
- { "exec", srv_exec },
- { "type", srv_type },
- { "target", srv_target },
- { "tty", srv_tty },
- { "before", srv_before },
- { "after", srv_after },
+} svc_params[] = {
+ { "name", svc_name },
+ { "description", svc_desc },
+ { "exec", svc_exec },
+ { "type", svc_type },
+ { "target", svc_target },
+ { "tty", svc_tty },
+ { "before", svc_before },
+ { "after", svc_after },
};
-service_t *rdsrv(int dirfd, const char *filename)
+service_t *rdsvc(int dirfd, const char *filename)
{
const char *arg, *args[1];
char *line, *key, *value;
size_t i, argc, lineno;
- service_t *srv;
+ service_t *svc;
int fd;
fd = openat(dirfd, filename, O_RDONLY);
@@ -172,8 +172,8 @@ service_t *rdsrv(int dirfd, const char *filename)
argc = 0;
}
- srv = calloc(1, sizeof(*srv));
- if (srv == NULL) {
+ svc = calloc(1, sizeof(*svc));
+ if (svc == NULL) {
fputs("out of memory\n", stderr);
close(fd);
return NULL;
@@ -215,12 +215,12 @@ service_t *rdsrv(int dirfd, const char *filename)
continue;
}
- for (i = 0; i < ARRAY_SIZE(srv_params); ++i) {
- if (!strcmp(srv_params[i].key, key))
+ for (i = 0; i < ARRAY_SIZE(svc_params); ++i) {
+ if (!strcmp(svc_params[i].key, key))
break;
}
- if (i >= ARRAY_SIZE(srv_params)) {
+ if (i >= ARRAY_SIZE(svc_params)) {
fprintf(stderr, "%s: %zu: unknown parameter '%s'\n",
filename, lineno, key);
goto fail_line;
@@ -232,7 +232,7 @@ service_t *rdsrv(int dirfd, const char *filename)
goto fail_line;
}
- if (srv_params[i].handle(srv, value, filename, lineno)) {
+ if (svc_params[i].handle(svc, value, filename, lineno)) {
free(value);
goto fail_line;
}
@@ -241,11 +241,11 @@ service_t *rdsrv(int dirfd, const char *filename)
}
close(fd);
- return srv;
+ return svc;
fail_line:
free(line);
fail:
close(fd);
- delsrv(srv);
+ delsvc(svc);
return NULL;
}
diff --git a/lib/src/srv_tsort.c b/lib/src/svc_tsort.c
index d375c4f..50517f2 100644
--- a/lib/src/srv_tsort.c
+++ b/lib/src/svc_tsort.c
@@ -43,7 +43,7 @@ static bool has_dependencies(service_t *list, service_t *svc)
return false;
}
-service_t *srv_tsort(service_t *list)
+service_t *svc_tsort(service_t *list)
{
service_t *nl = NULL, *end = NULL;
service_t *svc, *prev;
diff --git a/lib/src/srvscan.c b/lib/src/svcscan.c
index 69d0b91..32c1dee 100644
--- a/lib/src/srvscan.c
+++ b/lib/src/svcscan.c
@@ -27,12 +27,12 @@
#include "service.h"
-int srvscan(const char *directory, service_list_t *list)
+int svcscan(const char *directory, service_list_t *list)
{
int i, dfd, type, ret = 0;
struct dirent *ent;
const char *ptr;
- service_t *srv;
+ service_t *svc;
struct stat sb;
DIR *dir;
@@ -82,14 +82,14 @@ int srvscan(const char *directory, service_list_t *list)
if (type != S_IFREG && type != S_IFLNK)
continue;
- srv = rdsrv(dfd, ent->d_name);
- if (srv == NULL) {
+ svc = rdsvc(dfd, ent->d_name);
+ if (svc == NULL) {
ret = -1;
continue;
}
- srv->next = list->targets[srv->target];
- list->targets[srv->target] = srv;
+ svc->next = list->targets[svc->target];
+ list->targets[svc->target] = svc;
}
for (i = 0; i < TGT_MAX; ++i) {
@@ -97,7 +97,7 @@ int srvscan(const char *directory, service_list_t *list)
continue;
errno = 0;
- list->targets[i] = srv_tsort(list->targets[i]);
+ list->targets[i] = svc_tsort(list->targets[i]);
if (errno != 0) {
fprintf(stderr, "sorting services read from %s: %s\n",