diff options
Diffstat (limited to 'src/tools/irm')
-rw-r--r-- | src/tools/irm/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/tools/irm/irm.c | 10 | ||||
-rw-r--r-- | src/tools/irm/irm_bind.c | 22 | ||||
-rw-r--r-- | src/tools/irm/irm_bind_ipcp.c | 11 | ||||
-rw-r--r-- | src/tools/irm/irm_bind_process.c (renamed from src/tools/irm/irm_bind_api.c) | 21 | ||||
-rw-r--r-- | src/tools/irm/irm_bind_program.c (renamed from src/tools/irm/irm_bind_ap.c) | 38 | ||||
-rw-r--r-- | src/tools/irm/irm_ipcp_bootstrap.c | 39 | ||||
-rw-r--r-- | src/tools/irm/irm_ipcp_connect.c | 12 | ||||
-rw-r--r-- | src/tools/irm/irm_ipcp_create.c | 6 | ||||
-rw-r--r-- | src/tools/irm/irm_ipcp_destroy.c | 8 | ||||
-rw-r--r-- | src/tools/irm/irm_ipcp_disconnect.c | 12 | ||||
-rw-r--r-- | src/tools/irm/irm_ipcp_enroll.c | 32 | ||||
-rw-r--r-- | src/tools/irm/irm_ops.h | 16 | ||||
-rw-r--r-- | src/tools/irm/irm_unbind.c | 22 | ||||
-rw-r--r-- | src/tools/irm/irm_unbind_ipcp.c | 8 | ||||
-rw-r--r-- | src/tools/irm/irm_unbind_process.c (renamed from src/tools/irm/irm_unbind_api.c) | 21 | ||||
-rw-r--r-- | src/tools/irm/irm_unbind_program.c (renamed from src/tools/irm/irm_unbind_ap.c) | 21 | ||||
-rw-r--r-- | src/tools/irm/irm_utils.c | 3 | ||||
-rw-r--r-- | src/tools/irm/irm_utils.h | 5 |
19 files changed, 165 insertions, 150 deletions
diff --git a/src/tools/irm/CMakeLists.txt b/src/tools/irm/CMakeLists.txt index 03c1490a..08bf5487 100644 --- a/src/tools/irm/CMakeLists.txt +++ b/src/tools/irm/CMakeLists.txt @@ -7,8 +7,8 @@ include_directories(${CMAKE_BINARY_DIR}/include) set(SOURCE_FILES # Add source files here irm.c - irm_bind_ap.c - irm_bind_api.c + irm_bind_program.c + irm_bind_process.c irm_bind_ipcp.c irm_ipcp_create.c irm_ipcp_destroy.c @@ -16,8 +16,8 @@ set(SOURCE_FILES irm_ipcp_enroll.c irm_ipcp_connect.c irm_ipcp_disconnect.c - irm_unbind_ap.c - irm_unbind_api.c + irm_unbind_program.c + irm_unbind_process.c irm_unbind_ipcp.c irm_unbind.c irm_bind.c diff --git a/src/tools/irm/irm.c b/src/tools/irm/irm.c index 6ca902b0..ccadc0f8 100644 --- a/src/tools/irm/irm.c +++ b/src/tools/irm/irm.c @@ -53,7 +53,8 @@ static void usage(void) " register unregister}\n"); } -static int do_help(int argc, char **argv) +static int do_help(int argc, + char **argv) { (void) argc; (void) argv; @@ -76,8 +77,8 @@ static const struct cmd { }; static int do_cmd(const char * argv0, - int argc, - char ** argv) + int argc, + char ** argv) { const struct cmd * c; @@ -91,7 +92,8 @@ static int do_cmd(const char * argv0, return -1; } -int main(int argc, char ** argv) +int main(int argc, + char ** argv) { int ret = 0; diff --git a/src/tools/irm/irm_bind.c b/src/tools/irm/irm_bind.c index 023b5c3a..6b73f83f 100644 --- a/src/tools/irm/irm_bind.c +++ b/src/tools/irm/irm_bind.c @@ -47,10 +47,11 @@ static void usage(void) { printf("Usage: irm bind [OPERATION]\n" "\n" - "where OPERATION = {ap api ipcp help}\n"); + "where OPERATION = {program process ipcp help}\n"); } -static int do_help(int argc, char **argv) +static int do_help(int argc, + char **argv) { (void) argc; (void) argv; @@ -63,16 +64,16 @@ static const struct cmd { const char * cmd; int (* func)(int argc, char ** argv); } cmds[] = { - { "ap", do_bind_ap }, - { "api", do_bind_api }, - { "ipcp", do_bind_ipcp }, - { "help", do_help }, - { NULL, NULL } + { "program", do_bind_program }, + { "process", do_bind_process }, + { "ipcp", do_bind_ipcp }, + { "help", do_help }, + { NULL, NULL } }; static int do_cmd(const char * argv0, - int argc, - char ** argv) + int argc, + char ** argv) { const struct cmd * c; @@ -86,7 +87,8 @@ static int do_cmd(const char * argv0, return -1; } -int bind_cmd(int argc, char ** argv) +int bind_cmd(int argc, + char ** argv) { if (argc < 1) { usage(); diff --git a/src/tools/irm/irm_bind_ipcp.c b/src/tools/irm/irm_bind_ipcp.c index 375be03c..6299ca2b 100644 --- a/src/tools/irm/irm_bind_ipcp.c +++ b/src/tools/irm/irm_bind_ipcp.c @@ -50,12 +50,13 @@ static void usage(void) printf("Usage: irm bind ipcp <name> name <name>\n"); } -int do_bind_ipcp(int argc, char ** argv) +int do_bind_ipcp(int argc, + char ** argv) { char * ipcp = NULL; char * name = NULL; - pid_t * apis = NULL; + pid_t * pids = NULL; ssize_t len = 0; int i; @@ -84,12 +85,12 @@ int do_bind_ipcp(int argc, char ** argv) return -1; } - len = irm_list_ipcps(ipcp, &apis); + len = irm_list_ipcps(ipcp, &pids); for (i = 0; i < len; ++i) - irm_bind_api(apis[i], name); + irm_bind_process(pids[i], name); - free(apis); + free(pids); return 0; } diff --git a/src/tools/irm/irm_bind_api.c b/src/tools/irm/irm_bind_process.c index d441852d..b1d36163 100644 --- a/src/tools/irm/irm_bind_api.c +++ b/src/tools/irm/irm_bind_process.c @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2017 * - * Bind AP-I to a name + * Bind a process to a name * * Dimitri Staessens <dimitri.staessens@ugent.be> * Sander Vrijders <sander.vrijders@ugent.be> @@ -51,12 +51,13 @@ static void usage(void) { - printf("Usage: irm bind api <pid> name <name>\n"); + printf("Usage: irm bind process <pid> name <name>\n"); } -int do_bind_api(int argc, char ** argv) +int do_bind_process(int argc, + char ** argv) { - pid_t api = -1; + pid_t pid = -1; char * name = NULL; char * t; @@ -65,9 +66,9 @@ int do_bind_api(int argc, char ** argv) name = *(argv + 1); ++argv; --argc; - } else if (matches(*argv, "api") == 0) { - api = strtol(*(argv + 1), &t, 10); - if (*(argv + 1) == t || *t != '\0' || kill(api, 0)) { + } else if (matches(*argv, "process") == 0) { + pid = strtol(*(argv + 1), &t, 10); + if (*(argv + 1) == t || *t != '\0' || kill(pid, 0)) { printf("\"%s\" is not a valid process id.\n", *(argv + 1)); return -1; @@ -76,7 +77,7 @@ int do_bind_api(int argc, char ** argv) --argc; } else { printf("\"%s\" is unknown, try \"irm " - "bind api\".\n", *argv); + "bind process\".\n", *argv); return -1; } @@ -84,10 +85,10 @@ int do_bind_api(int argc, char ** argv) --argc; } - if (argc == 1 || api < 0 || name == NULL) { + if (argc == 1 || pid < 0 || name == NULL) { usage(); return -1; } - return irm_bind_api(api, name); + return irm_bind_process(pid, name); } diff --git a/src/tools/irm/irm_bind_ap.c b/src/tools/irm/irm_bind_program.c index ae213ab0..3fc8dbd4 100644 --- a/src/tools/irm/irm_bind_ap.c +++ b/src/tools/irm/irm_bind_program.c @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2017 * - * Bind AP to a name + * Bind programs to a name * * Dimitri Staessens <dimitri.staessens@ugent.be> * Sander Vrijders <sander.vrijders@ugent.be> @@ -51,46 +51,43 @@ static void usage(void) { - printf("Usage: irm bind ap <ap>\n" + printf("Usage: irm bind program <program>\n" " name <name>\n" - " [auto] (instantiate apn if not running)\n" - " [loc] (location-dependent application)\n" - " [unique] (there can only be one instantiation)\n" + " [auto] (instantiate program if not running)\n" " [-- <application arguments>]\n"); } -int do_bind_ap(int argc, char ** argv) +int do_bind_program(int argc, + char ** argv) { - char * name = NULL; - char * ap_name = NULL; + char * name = NULL; + char * prog = NULL; uint16_t flags = 0; - int ret = 0; - char * temp = NULL; + int ret = 0; + char * temp = NULL; while (argc > 0) { if (matches(*argv, "name") == 0) { name = *(argv + 1); ++argv; --argc; - } else if (matches(*argv, "ap") == 0) { + } else if (matches(*argv, "program") == 0) { ++argv; temp = realpath(*argv, NULL); if (temp != NULL) *argv = temp; - ap_name = *argv; + prog = *argv; --argc; } else if (strcmp(*argv, "auto") == 0) { - flags |= BIND_AP_AUTO; - } else if (strcmp(*argv, "unique") == 0) { - flags |= BIND_AP_UNIQUE; + flags |= BIND_AUTO; } else if (strcmp(*argv, "--") == 0) { ++argv; --argc; break; } else { printf("\"%s\" is unknown, try \"irm " - "bind\".\n", *argv); + "bind program\".\n", *argv); return -1; } @@ -98,20 +95,19 @@ int do_bind_ap(int argc, char ** argv) --argc; } - if (name == NULL || ap_name == NULL) { + if (name == NULL || prog == NULL) { usage(); return -1; } - ret = irm_bind_ap(ap_name, name, flags, argc, argv); + ret = irm_bind_program(prog, name, flags, argc, argv); if (ret == -ENOENT) { - printf("%s does not exist.\n", ap_name); + printf("%s does not exist.\n", prog); return ret; } if (ret == -EPERM) { - printf("Cannot execute %s, please check permissions.\n", - ap_name); + printf("Cannot execute %s, please check permissions.\n", prog); return ret; } diff --git a/src/tools/irm/irm_ipcp_bootstrap.c b/src/tools/irm/irm_ipcp_bootstrap.c index 3da78a2b..acd3779e 100644 --- a/src/tools/irm/irm_ipcp_bootstrap.c +++ b/src/tools/irm/irm_ipcp_bootstrap.c @@ -107,10 +107,11 @@ static void usage(void) LINK_STATE_ROUTING, SIMPLE_PFF, SHA3_256); } -int do_bootstrap_ipcp(int argc, char ** argv) +int do_bootstrap_ipcp(int argc, + char ** argv) { char * name = NULL; - pid_t api; + pid_t pid; struct ipcp_config conf; uint8_t addr_size = DEFAULT_ADDR_SIZE; uint8_t fd_size = DEFAULT_FD_SIZE; @@ -124,7 +125,7 @@ int do_bootstrap_ipcp(int argc, char ** argv) char * ipcp_type = NULL; char * dif_name = NULL; char * if_name = NULL; - pid_t * apis = NULL; + pid_t * pids = NULL; ssize_t len = 0; int i = 0; bool autobind = false; @@ -239,39 +240,39 @@ int do_bootstrap_ipcp(int argc, char ** argv) autobind = false; } - len = irm_list_ipcps(name, &apis); + len = irm_list_ipcps(name, &pids); if (len <= 0) { - api = irm_create_ipcp(name, conf.type); - if (api == 0) + pid = irm_create_ipcp(name, conf.type); + if (pid== 0) return -1; - len = irm_list_ipcps(name, &apis); + len = irm_list_ipcps(name, &pids); } for (i = 0; i < len; i++) { - if (autobind && irm_bind_api(apis[i], name)) { - printf("Failed to bind %d to %s.\n", apis[i], name); - free(apis); + if (autobind && irm_bind_process(pids[i], name)) { + printf("Failed to bind %d to %s.\n", pids[i], name); + free(pids); return -1; } - if (autobind && irm_bind_api(apis[i], dif_name)) { - printf("Failed to bind %d to %s.\n", apis[i], dif_name); - irm_unbind_api(apis[i], name); - free(apis); + if (autobind && irm_bind_process(pids[i], dif_name)) { + printf("Failed to bind %d to %s.\n", pids[i], dif_name); + irm_unbind_process(pids[i], name); + free(pids); return -1; } - if (irm_bootstrap_ipcp(apis[i], &conf)) { + if (irm_bootstrap_ipcp(pids[i], &conf)) { if (autobind) { - irm_unbind_api(apis[i], name); - irm_unbind_api(apis[i], dif_name); + irm_unbind_process(pids[i], name); + irm_unbind_process(pids[i], dif_name); } - free(apis); + free(pids); return -1; } } - free(apis); + free(pids); return 0; diff --git a/src/tools/irm/irm_ipcp_connect.c b/src/tools/irm/irm_ipcp_connect.c index 0f52d71b..a874afc2 100644 --- a/src/tools/irm/irm_ipcp_connect.c +++ b/src/tools/irm/irm_ipcp_connect.c @@ -63,7 +63,7 @@ int do_connect_ipcp(int argc, char * name = NULL; char * dst_name = NULL; char * comp_name = NULL; - pid_t * apis = NULL; + pid_t * pids = NULL; ssize_t len = 0; while (argc > 0) { @@ -88,7 +88,7 @@ int do_connect_ipcp(int argc, return -1; } - len = irm_list_ipcps(name, &apis); + len = irm_list_ipcps(name, &pids); if (len != 1) return -1; @@ -98,13 +98,13 @@ int do_connect_ipcp(int argc, if (!strcmp(comp_name , MGMT)) comp_name = MGMT_AE; - if (irm_connect_ipcp(apis[0], dst_name, comp_name)) { - free(apis); + if (irm_connect_ipcp(pids[0], dst_name, comp_name)) { + free(pids); return -1; } - if (apis != NULL) - free(apis); + if (pids != NULL) + free(pids); return 0; } diff --git a/src/tools/irm/irm_ipcp_create.c b/src/tools/irm/irm_ipcp_create.c index 99da0a51..bad62aed 100644 --- a/src/tools/irm/irm_ipcp_create.c +++ b/src/tools/irm/irm_ipcp_create.c @@ -63,7 +63,7 @@ int do_create_ipcp(int argc, char ** argv) char * ipcp_type = NULL; char * ipcp_name = NULL; enum ipcp_type type = 0; - pid_t api; + pid_t pid; while (argc > 0) { if (matches(*argv, "type") == 0) { @@ -98,8 +98,8 @@ int do_create_ipcp(int argc, char ** argv) return -1; } - api = irm_create_ipcp(ipcp_name, type); - if (api == 0) + pid = irm_create_ipcp(ipcp_name, type); + if (pid == 0) return -1; return 0; diff --git a/src/tools/irm/irm_ipcp_destroy.c b/src/tools/irm/irm_ipcp_destroy.c index 2a44c59b..f9d7fcc3 100644 --- a/src/tools/irm/irm_ipcp_destroy.c +++ b/src/tools/irm/irm_ipcp_destroy.c @@ -53,7 +53,7 @@ static void usage(void) int do_destroy_ipcp(int argc, char ** argv) { char * name = NULL; - pid_t * apis; + pid_t * pids; ssize_t len = 0; int i = 0; @@ -75,15 +75,15 @@ int do_destroy_ipcp(int argc, char ** argv) return -1; } - len = irm_list_ipcps(name, &apis); + len = irm_list_ipcps(name, &pids); if (len <= 0) return -1; for (i = 0; i < len; i++) - if (irm_destroy_ipcp(apis[i])) + if (irm_destroy_ipcp(pids[i])) return -1; - free(apis); + free(pids); return 0; } diff --git a/src/tools/irm/irm_ipcp_disconnect.c b/src/tools/irm/irm_ipcp_disconnect.c index 0fc4d01c..2b8c69dd 100644 --- a/src/tools/irm/irm_ipcp_disconnect.c +++ b/src/tools/irm/irm_ipcp_disconnect.c @@ -63,7 +63,7 @@ int do_disconnect_ipcp(int argc, char * name = NULL; char * dst_name = NULL; char * comp_name = NULL; - pid_t * apis = NULL; + pid_t * pids = NULL; ssize_t len = 0; while (argc > 0) { @@ -88,7 +88,7 @@ int do_disconnect_ipcp(int argc, return -1; } - len = irm_list_ipcps(name, &apis); + len = irm_list_ipcps(name, &pids); if (len != 1) return -1; @@ -98,13 +98,13 @@ int do_disconnect_ipcp(int argc, if (!strcmp(comp_name , MGMT)) comp_name = MGMT_AE; - if (irm_disconnect_ipcp(apis[0], dst_name, comp_name)) { - free(apis); + if (irm_disconnect_ipcp(pids[0], dst_name, comp_name)) { + free(pids); return -1; } - if (apis != NULL) - free(apis); + if (pids != NULL) + free(pids); return 0; } diff --git a/src/tools/irm/irm_ipcp_enroll.c b/src/tools/irm/irm_ipcp_enroll.c index 1ebe9a6d..4beb6754 100644 --- a/src/tools/irm/irm_ipcp_enroll.c +++ b/src/tools/irm/irm_ipcp_enroll.c @@ -56,8 +56,8 @@ int do_enroll_ipcp(int argc, char ** argv) { char * name = NULL; char * dif_name = NULL; - pid_t * apis = NULL; - pid_t api; + pid_t * pids = NULL; + pid_t pid; ssize_t len = 0; int i = 0; bool autobind = false; @@ -87,36 +87,36 @@ int do_enroll_ipcp(int argc, char ** argv) return -1; } - len = irm_list_ipcps(name, &apis); + len = irm_list_ipcps(name, &pids); if (len <= 0) { - api = irm_create_ipcp(name, IPCP_NORMAL); - if (api == 0) + pid = irm_create_ipcp(name, IPCP_NORMAL); + if (pid == 0) return -1; - len = irm_list_ipcps(name, &apis); + len = irm_list_ipcps(name, &pids); } for (i = 0; i < len; i++) { - if (autobind && irm_bind_api(apis[i], name)) { - free(apis); + if (autobind && irm_bind_process(pids[i], name)) { + free(pids); return -1; } - if (irm_enroll_ipcp(apis[i], dif_name)) { + if (irm_enroll_ipcp(pids[i], dif_name)) { if (autobind) - irm_unbind_api(apis[i], name); - free(apis); + irm_unbind_process(pids[i], name); + free(pids); return -1; } - if (autobind && irm_bind_api(apis[i], dif_name)) { - printf("Failed to bind %d to %s.\n", apis[i], dif_name); - free(apis); + if (autobind && irm_bind_process(pids[i], dif_name)) { + printf("Failed to bind %d to %s.\n", pids[i], dif_name); + free(pids); return -1; } } - if (apis != NULL) - free(apis); + if (pids != NULL) + free(pids); return 0; } diff --git a/src/tools/irm/irm_ops.h b/src/tools/irm/irm_ops.h index 7a8127a1..d3cb8d21 100644 --- a/src/tools/irm/irm_ops.h +++ b/src/tools/irm/irm_ops.h @@ -60,11 +60,11 @@ int do_disconnect_ipcp(int argc, int bind_cmd(int argc, char ** argv); -int do_bind_ap(int argc, - char ** argv); +int do_bind_program(int argc, + char ** argv); -int do_bind_api(int argc, - char ** argv); +int do_bind_process(int argc, + char ** argv); int do_bind_ipcp(int argc, char ** argv); @@ -72,11 +72,11 @@ int do_bind_ipcp(int argc, int unbind_cmd(int argc, char ** argv); -int do_unbind_ap(int argc, - char ** argv); +int do_unbind_program(int argc, + char ** argv); -int do_unbind_api(int argc, - char ** argv); +int do_unbind_process(int argc, + char ** argv); int do_unbind_ipcp(int argc, char ** argv); diff --git a/src/tools/irm/irm_unbind.c b/src/tools/irm/irm_unbind.c index a4d780b8..fb66e456 100644 --- a/src/tools/irm/irm_unbind.c +++ b/src/tools/irm/irm_unbind.c @@ -47,10 +47,11 @@ static void usage(void) { printf("Usage: irm unbind [OPERATION]\n" "\n" - "where OPERATION = {ap api ipcp help}\n"); + "where OPERATION = {program process ipcp help}\n"); } -static int do_help(int argc, char **argv) +static int do_help(int argc, + char ** argv) { (void) argc; (void) argv; @@ -63,14 +64,16 @@ static const struct cmd { const char * cmd; int (* func)(int argc, char ** argv); } cmds[] = { - { "ap", do_unbind_ap }, - { "api", do_unbind_api }, - { "ipcp", do_unbind_ipcp }, - { "help", do_help }, - { NULL, NULL } + { "program", do_unbind_program }, + { "process", do_unbind_process }, + { "ipcp", do_unbind_ipcp }, + { "help", do_help }, + { NULL, NULL } }; -static int do_cmd(const char * argv0, int argc, char ** argv) +static int do_cmd(const char * argv0, + int argc, + char ** argv) { const struct cmd * c; @@ -83,7 +86,8 @@ static int do_cmd(const char * argv0, int argc, char ** argv) return -1; } -int unbind_cmd(int argc, char ** argv) +int unbind_cmd(int argc, + char ** argv) { if (argc < 1) { usage(); diff --git a/src/tools/irm/irm_unbind_ipcp.c b/src/tools/irm/irm_unbind_ipcp.c index 9f5b98b9..1a442cd4 100644 --- a/src/tools/irm/irm_unbind_ipcp.c +++ b/src/tools/irm/irm_unbind_ipcp.c @@ -57,7 +57,7 @@ int do_unbind_ipcp(int argc, char ** argv) char * ipcp = NULL; char * name = NULL; - pid_t * apis = NULL; + pid_t * pids = NULL; ssize_t len = 0; int i; @@ -86,12 +86,12 @@ int do_unbind_ipcp(int argc, char ** argv) return -1; } - len = irm_list_ipcps(ipcp, &apis); + len = irm_list_ipcps(ipcp, &pids); for (i = 0; i < len; ++i) - irm_unbind_api(apis[i], name); + irm_unbind_process(pids[i], name); - free(apis); + free(pids); return 0; } diff --git a/src/tools/irm/irm_unbind_api.c b/src/tools/irm/irm_unbind_process.c index 0213737a..840be750 100644 --- a/src/tools/irm/irm_unbind_api.c +++ b/src/tools/irm/irm_unbind_process.c @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2017 * - * Unbind AP-I names + * Unbind process names * * Dimitri Staessens <dimitri.staessens@ugent.be> * Sander Vrijders <sander.vrijders@ugent.be> @@ -47,14 +47,15 @@ static void usage(void) { - printf("Usage: irm unbind api <pid>\n" - " [name <name> (default: remove all AP-I info)]" + printf("Usage: irm unbind process <pid>\n" + " [name <name> (default: unbind all names)]" "\n"); } -int do_unbind_api(int argc, char ** argv) +int do_unbind_process(int argc, + char ** argv) { - pid_t api = -1; + pid_t pid = -1; char * name = NULL; while (argc > 1) { @@ -62,13 +63,13 @@ int do_unbind_api(int argc, char ** argv) name = *(argv + 1); ++argv; --argc; - } else if (matches(*argv, "api") == 0) { - api = strtol(*(argv + 1), NULL, 10); + } else if (matches(*argv, "process") == 0) { + pid = strtol(*(argv + 1), NULL, 10); ++argv; --argc; } else { printf("\"%s\" is unknown, try \"irm " - "unbind api\".\n", *argv); + "unbind process\".\n", *argv); return -1; } @@ -76,10 +77,10 @@ int do_unbind_api(int argc, char ** argv) --argc; } - if (api < 0) { + if (pid < 0) { usage(); return -1; } - return irm_unbind_api(api, name); + return irm_unbind_process(pid, name); } diff --git a/src/tools/irm/irm_unbind_ap.c b/src/tools/irm/irm_unbind_program.c index 46a147db..22c8bd57 100644 --- a/src/tools/irm/irm_unbind_ap.c +++ b/src/tools/irm/irm_unbind_program.c @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2017 * - * Unbind AP names + * Unbind programs * * Dimitri Staessens <dimitri.staessens@ugent.be> * Sander Vrijders <sander.vrijders@ugent.be> @@ -46,28 +46,29 @@ static void usage(void) { - printf("Usage: irm unbind ap <ap>\n" - " [name <name> (default: remove all AP info)]" + printf("Usage: irm unbind program <program>\n" + " [name <name> (default: unbind all names)]" "\n"); } -int do_unbind_ap(int argc, char ** argv) +int do_unbind_program(int argc, + char ** argv) { char * name = NULL; - char * ap_name = NULL; + char * prog = NULL; while (argc > 0) { if (matches(*argv, "name") == 0) { name = *(argv + 1); ++argv; --argc; - } else if (matches(*argv, "ap") == 0) { - ap_name = *(argv + 1); + } else if (matches(*argv, "program") == 0) { + prog = *(argv + 1); ++argv; --argc; } else { printf("\"%s\" is unknown, try \"irm " - "unbind ap\".\n", *argv); + "unbind program\".\n", *argv); return -1; } @@ -75,10 +76,10 @@ int do_unbind_ap(int argc, char ** argv) --argc; } - if (ap_name == NULL) { + if (prog == NULL) { usage(); return -1; } - return irm_unbind_ap(ap_name, name); + return irm_unbind_program(prog, name); } diff --git a/src/tools/irm/irm_utils.c b/src/tools/irm/irm_utils.c index 524f4dff..4f3c7e21 100644 --- a/src/tools/irm/irm_utils.c +++ b/src/tools/irm/irm_utils.c @@ -42,7 +42,8 @@ #include "irm_utils.h" -int matches(const char * cmd, const char * pattern) +int matches(const char * cmd, + const char * pattern) { size_t len = strlen(cmd); diff --git a/src/tools/irm/irm_utils.h b/src/tools/irm/irm_utils.h index 1d222554..458ec34e 100644 --- a/src/tools/irm/irm_utils.h +++ b/src/tools/irm/irm_utils.h @@ -36,5 +36,10 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef OUROBOROS_TOOLS_IRM_UTILS_H +#define OUROBOROS_TOOLS_IRM_UTILS_H + int matches(const char * cmd, const char * pattern); + +#endif /* OUROBOROS_TOOLS_IRM_UTILS_H */ |