diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | src/net_set.c | 79 |
2 files changed, 0 insertions, 81 deletions
diff --git a/Makefile.am b/Makefile.am index 5d30019..c848034 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,7 +71,6 @@ sbin_PROGRAMS += src/my_commit sbin_PROGRAMS += src/exe_action sbin_PROGRAMS += src/dump sbin_PROGRAMS += src/check_tmpl -sbin_PROGRAMS += src/net_set sbin_PROGRAMS += src/my_cli_bin sbin_PROGRAMS += src/my_cli_shell_api @@ -80,7 +79,6 @@ src_my_commit_SOURCES = src/commit2.c src_exe_action_SOURCES = src/exe_action.c src_dump_SOURCES = src/dump_session.c src_check_tmpl_SOURCES = src/check_tmpl.c -src_net_set_SOURCES = src/net_set.c src_my_cli_bin_SOURCES = src/cli_bin.cpp src_my_cli_shell_api_SOURCES = src/cli_shell_api.cpp diff --git a/src/net_set.c b/src/net_set.c deleted file mode 100644 index a84cea4..0000000 --- a/src/net_set.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Program to set sysfs value - similar to sysctl commmand - */ - -#include <stdio.h> -#include <limits.h> -#include <stdlib.h> -#include <errno.h> -#include <string.h> - -#define SYS "/sys" - -static void get(const char *name) -{ - char path[PATH_MAX]; - char buf[BUFSIZ]; - FILE *f; - - snprintf(path, PATH_MAX, SYS "/%s", name); - f = fopen(path, "r"); - if (f == NULL) { - fprintf(stderr, "%s : %s\n", path, strerror(errno)); - exit(1); - } - - while (fgets(buf, BUFSIZ, f) != NULL) - fputs(buf, stdout); - - if (ferror(f)) { - fprintf(stderr, "%s : read %s\n", path, strerror(errno)); - exit(1); - } - fclose(f); -} - -static void set(const char *name, const char *val) -{ - FILE *f; - char path[PATH_MAX]; - - snprintf(path, PATH_MAX, SYS "/%s", name); - f = fopen(path, "w"); - if (f == NULL) { - fprintf(stderr, "%s : %s\n", path, strerror(errno)); - exit(1); - } - - fprintf(f, "%s\n", val); - fflush(f); - - if (ferror(f)) { - fprintf(stderr, "%s : read %s\n", path, strerror(errno)); - exit(1); - } - fclose(f); -} - -int main(int argc, char **argv) -{ - if (argc == 1) { - fprintf(stderr, "Usage: %s variable\n", argv[0]); - fprintf(stderr, " %s variable=value\n", argv[0]); - return 1; - } - - while (--argc) { - char *ep, *arg = *++argv; - - ep = strchr(arg, '='); - if (!ep) - get(arg); - else { - *ep++ = '\0'; - set(arg, ep); - } - } - - return 0; -} |