unix/fiss

formatting files to match .clang-format (1a096e6ac2b36aae65d7dd0e6ac3cc9f5668479e)
Repositories | LICENSE

commit 1a096e6ac2b36aae65d7dd0e6ac3cc9f5668479e
parent b5e2d533cd35cbd0ff103d959dc71fc216947e0c
Author: Friedel Schön <[email protected]>
Date:   Wed, 10 May 2023 01:19:15 +0200

formatting files to match .clang-format

Diffstat:
Minclude/service.h112++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/exec/seedrng.c2+-
Msrc/register.c18+++++++++---------
Msrc/service.c26+++++++++++++-------------
Msrc/util.c6+++---
5 files changed, 82 insertions(+), 82 deletions(-)

diff --git a/include/service.h b/include/service.h @@ -7,26 +7,26 @@ #include <stdint.h> #include <time.h> -#define SV_SERIAL_LEN 17 +#define SV_SERIAL_LEN 17 #define SV_HAS_LOGSERVICE ((void*) 1) -#define EBADCMD 1 // command not found -#define ENOSV 2 // service required -#define EBADSV 3 // no matching services -#define EBEXT 4 // invalid extra +#define EBADCMD 1 // command not found +#define ENOSV 2 // service required +#define EBADSV 3 // no matching services +#define EBEXT 4 // invalid extra typedef enum { - S_START = 'u', // start if not running and restart if failed - S_STOP = 'd', // stop if running and not restart if failed - S_SEND = 'k', // + signal | send signal to service - S_PAUSE = 'p', // pause service (send SIGSTOP) - S_RESUME = 'c', // unpause service (send SIGCONT) - S_REVIVE = 'v', // revive died service - S_EXIT = 'x', // kill the fsvs instance - S_STATUS = 'a', // get status of all services - S_SWITCH = 'l', // change runlevel - S_ENABLE = 'E', // of extra disable - S_DISABLE = 'D', // of extra disable + S_START = 'u', // start if not running and restart if failed + S_STOP = 'd', // stop if running and not restart if failed + S_SEND = 'k', // + signal | send signal to service + S_PAUSE = 'p', // pause service (send SIGSTOP) + S_RESUME = 'c', // unpause service (send SIGCONT) + S_REVIVE = 'v', // revive died service + S_EXIT = 'x', // kill the fsvs instance + S_STATUS = 'a', // get status of all services + S_SWITCH = 'l', // change runlevel + S_ENABLE = 'E', // of extra disable + S_DISABLE = 'D', // of extra disable } sv_command_t; typedef enum service_state { @@ -50,25 +50,25 @@ typedef enum service_exit { typedef enum service_restart { S_DOWN, - S_FORCE_DOWN, // force down (manual) + S_FORCE_DOWN, // force down (manual) S_ONCE, S_RESTART, } service_restart_t; typedef struct service { - char name[SV_NAME_MAX]; // name of service - service_state_t state; - pid_t pid; // pid of run - time_t status_change; // last status change - pipe_t log_pipe; // pipe for logging - service_restart_t restart_manual; // should restart on exit - service_restart_t restart_file; // should restart on exit - service_exit_t last_exit; // stopped signaled or exited - int return_code; // return code or signal - uint8_t fail_count; // current fail cound - bool is_log_service; // is a log service - bool paused; - struct service* log_service; + char name[SV_NAME_MAX]; // name of service + service_state_t state; + pid_t pid; // pid of run + time_t status_change; // last status change + pipe_t log_pipe; // pipe for logging + service_restart_t restart_manual; // should restart on exit + service_restart_t restart_file; // should restart on exit + service_exit_t last_exit; // stopped signaled or exited + int return_code; // return code or signal + uint8_t fail_count; // current fail cound + bool is_log_service; // is a log service + bool paused; + struct service* log_service; } service_t; typedef struct dependency { @@ -80,33 +80,33 @@ typedef struct dependency { extern const char* command_error[]; extern const char* command_string[]; -extern service_t services[]; -extern int services_size; -extern char runlevel[]; -extern const char* service_dir; -extern int null_fd; -extern int control_socket; -extern bool daemon_running; -extern bool verbose; +extern service_t services[]; +extern int services_size; +extern char runlevel[]; +extern const char* service_dir; +extern int null_fd; +extern int control_socket; +extern bool daemon_running; +extern bool verbose; extern dependency_t depends[]; -extern int depends_size; +extern int depends_size; -char service_get_command(const char* command); -int service_command(char command, char extra, const char* service, service_t* response, int response_max); -int service_handle_command(void* s, sv_command_t command, uint8_t extra, service_t** response); -int service_pattern(const char* name, service_t** dest, int dest_max); -int service_refresh(); -int service_supervise(const char* service_dir, const char* runlevel, bool force_socket); +char service_get_command(const char* command); +int service_command(char command, char extra, const char* service, service_t* response, int response_max); +int service_handle_command(void* s, sv_command_t command, uint8_t extra, service_t** response); +int service_pattern(const char* name, service_t** dest, int dest_max); +int service_refresh(); +int service_supervise(const char* service_dir, const char* runlevel, bool force_socket); service_t* service_get(const char* name); service_t* service_register(const char* name, bool is_log_service); -void service_check_state(service_t* s, bool signaled, int return_code); -void service_handle_socket(int client); -void service_load(service_t* s, const uint8_t* buffer); // for fsvc -void service_send(service_t* s, int signal); -void service_start(service_t* s, bool* changed); -void service_stop(service_t* s, bool* changed); -void service_store(service_t* s, uint8_t* buffer); // for fsvs -void service_update_dependency(service_t* s); -bool service_need_restart(service_t* s); -void service_run(service_t* s); -\ No newline at end of file +void service_check_state(service_t* s, bool signaled, int return_code); +void service_handle_socket(int client); +void service_load(service_t* s, const uint8_t* buffer); // for fsvc +void service_send(service_t* s, int signal); +void service_start(service_t* s, bool* changed); +void service_stop(service_t* s, bool* changed); +void service_store(service_t* s, uint8_t* buffer); // for fsvs +void service_update_dependency(service_t* s); +bool service_need_restart(service_t* s); +void service_run(service_t* s); +\ No newline at end of file diff --git a/src/exec/seedrng.c b/src/exec/seedrng.c @@ -4,6 +4,7 @@ #include <errno.h> #include <fcntl.h> #include <linux/random.h> +#include <poll.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> @@ -11,7 +12,6 @@ #include <string.h> #include <sys/file.h> #include <sys/ioctl.h> -#include <poll.h> #include <sys/random.h> #include <sys/stat.h> #include <time.h> diff --git a/src/register.c b/src/register.c @@ -12,16 +12,16 @@ service_t* service_register(const char* name, bool is_log_service) { service_t* s; if ((s = service_get(name)) == NULL) { - s = &services[services_size++]; - s->state = STATE_INACTIVE; + s = &services[services_size++]; + s->state = STATE_INACTIVE; s->status_change = time(NULL); s->restart_manual = S_DOWN; - s->restart_file = S_DOWN; - s->last_exit = EXIT_NONE; - s->return_code = 0; - s->fail_count = 0; - s->log_service = NULL; - s->paused = false; + s->restart_file = S_DOWN; + s->last_exit = EXIT_NONE; + s->return_code = 0; + s->fail_count = 0; + s->log_service = NULL; + s->paused = false; s->log_pipe.read = 0; s->log_pipe.write = 0; s->is_log_service = is_log_service; @@ -46,7 +46,7 @@ service_t* service_register(const char* name, bool is_log_service) { bool autostart, autostart_once; - autostart = S_ISREG(stat_mode("%s/%s/up-%s", service_dir, s->name, runlevel)); + autostart = S_ISREG(stat_mode("%s/%s/up-%s", service_dir, s->name, runlevel)); autostart_once = S_ISREG(stat_mode("%s/%s/once-%s", service_dir, s->name, runlevel)); s->restart_file = S_DOWN; diff --git a/src/service.c b/src/service.c @@ -11,15 +11,15 @@ #include <sys/wait.h> -service_t services[SV_SERVICE_MAX]; -int services_size = 0; -char runlevel[SV_NAME_MAX]; -const char* service_dir; -int control_socket; -int null_fd; -bool verbose = false; +service_t services[SV_SERVICE_MAX]; +int services_size = 0; +char runlevel[SV_NAME_MAX]; +const char* service_dir; +int control_socket; +int null_fd; +bool verbose = false; dependency_t depends[SV_DEPENDENCY_MAX]; -int depends_size; +int depends_size; service_t* service_get(const char* name) { @@ -40,7 +40,7 @@ int service_pattern(const char* name, service_t** dest, int dest_max) { } int service_refresh() { - DIR* dp; + DIR* dp; struct dirent* ep; dp = opendir(service_dir); if (dp == NULL) { @@ -95,8 +95,8 @@ bool service_need_restart(service_t* s) { if (s->restart_manual == S_FORCE_DOWN) return is_dependency(s); return s->restart_file == S_ONCE || - s->restart_file == S_RESTART || - s->restart_manual == S_ONCE || - s->restart_manual == S_RESTART || - is_dependency(s); + s->restart_file == S_RESTART || + s->restart_manual == S_ONCE || + s->restart_manual == S_RESTART || + is_dependency(s); } \ No newline at end of file diff --git a/src/util.c b/src/util.c @@ -10,7 +10,7 @@ ssize_t dgetline(int fd, char* line, size_t line_buffer) { ssize_t line_size = 0; ssize_t rc; - char c; + char c; while (line_size < (ssize_t) line_buffer - 1 && (rc = read(fd, &c, 1)) == 1) { if (c == '\r') continue; @@ -26,7 +26,7 @@ ssize_t dgetline(int fd, char* line, size_t line_buffer) { ssize_t readstr(int fd, char* str) { ssize_t len = 0; - int rc; + int rc; while ((rc = read(fd, &str[len], 1)) == 1 && str[len] != '\0') len++; @@ -42,7 +42,7 @@ ssize_t writestr(int fd, const char* str) { } unsigned int stat_mode(const char* format, ...) { - char path[PATH_MAX]; + char path[PATH_MAX]; struct stat st; va_list args;