commit 8866500a996e7d099e60df1e3a502441e06f98ba
parent 18a6052120d40a8c583180d3e9f321732cbe2b10
Author: Friedel Schön <[email protected]>
Date: Fri, 30 Jun 2023 01:23:45 +0200
removing pattern.c
Diffstat:
6 files changed, 2 insertions(+), 57 deletions(-)
diff --git a/bin/finit.c b/bin/finit.c
@@ -1,6 +1,6 @@
// +objects: message.o util.o supervise.o service.o start.o stop.o
// +objects: register.o handle_exit.o handle_command.o
-// +objects: encode.o parse.o dependency.o pattern.o status.o stage.o
+// +objects: encode.o parse.o dependency.o status.o stage.o
// +flags: -static
#include "config.h"
diff --git a/bin/fsvs.c b/bin/fsvs.c
@@ -1,6 +1,6 @@
// +objects: message.o util.o supervise.o service.o start.o stop.o
// +objects: register.o handle_exit.o handle_command.o
-// +objects: encode.o parse.o dependency.o pattern.o status.o
+// +objects: encode.o parse.o dependency.o status.o
#include "config.h"
#include "message.h"
diff --git a/include/pattern.h b/include/pattern.h
@@ -1,3 +0,0 @@
-#pragma once
-
-int pattern_test(const char* pattern, const char* match);
diff --git a/include/service.h b/include/service.h
@@ -99,7 +99,6 @@ void service_handle_command(service_t* s, char command);
void service_handle_exit(service_t* s, bool signaled, int return_code);
void service_kill(service_t* s, int signal);
bool service_need_restart(service_t* s);
-int service_pattern(const char* name, service_t** dest, int dest_max);
int service_refresh_directory(void);
service_t* service_register(int dir, const char* name, bool is_log_service);
void service_run(service_t* s);
diff --git a/src/pattern.c b/src/pattern.c
@@ -1,39 +0,0 @@
-#include "pattern.h"
-
-
-static const char* strend(const char* s) {
- while (*s)
- s++;
- return s;
-}
-
-int pattern_test(const char* pattern, const char* match) {
- int i = 0;
- const char *p, *m, *b;
-
- // if more than one '*': exit with error
- for (p = pattern; *p != '\0'; p++) {
- if (*p == '*' && i++)
- return -1;
- }
-
- m = match;
- for (p = pattern; *p != '\0' && *p != '*'; p++, m++) {
- if (*m == '\0' || (*p != *m && *p != '%'))
- return 0;
- }
-
- if (*p == '\0' && *m != '\0')
- return 0;
-
- if (*p == '*') {
- b = m;
- m = strend(match);
- for (p = strend(pattern); p >= pattern && *p != '*'; p--, m--) {
- if (m < b || (*p != *m && *p != '%'))
- return 0;
- }
- }
-
- return 1;
-}
diff --git a/src/service.c b/src/service.c
@@ -1,7 +1,5 @@
#include "service.h"
-#include "pattern.h"
-
#include <dirent.h>
#include <errno.h>
#include <limits.h>
@@ -31,16 +29,6 @@ service_t* service_get(const char* name) {
return NULL;
}
-int service_pattern(const char* name, service_t** dest, int dest_max) {
- int size = 0;
-
- for (int i = 0; i < services_size && size < dest_max; i++) {
- if (pattern_test(name, services[i].name))
- dest[size++] = &services[i];
- }
- return size;
-}
-
int service_refresh_directory(void) {
DIR* dp;
struct dirent* ep;