From: Sebastian Harl Date: Mon, 10 Sep 2012 16:22:35 +0000 (+0200) Subject: Renamed 'command' to 'method'. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1564b261c7e0f4141a2ff8b0f9456758653d7458;p=libjunos.git Renamed 'command' to 'method'. In order to follow the nomenclature used by Juniper. --- diff --git a/doc/junosc.1.txt b/doc/junosc.1.txt index 65fba96..41c7b9c 100644 --- a/doc/junosc.1.txt +++ b/doc/junosc.1.txt @@ -10,12 +10,12 @@ junosc - a JUNOScript client application SYNOPSIS -------- -*junosc -H* '' ['options'] '' +*junosc -H* '' ['options'] '' DESCRIPTION ----------- *junosc* is a client application to connect to routers running JUNOS software. -It may be used to issue JUNOScript commands and display the response to the +It may be used to issue JUNOScript method and display the response to the user. OPTIONS diff --git a/src/junos.c b/src/junos.c index 6a0fea6..d254992 100644 --- a/src/junos.c +++ b/src/junos.c @@ -261,9 +261,9 @@ junos_disconnect(junos_t *junos) } /* junos_disconnect */ xmlDocPtr -junos_simple_command(junos_t *junos, const char *cmd) +junos_simple_method(junos_t *junos, const char *name) { - char cmd_string[1024]; + char method_string[1024]; char recv_buf[4096]; ssize_t status; @@ -271,25 +271,26 @@ junos_simple_command(junos_t *junos, const char *cmd) xmlDocPtr doc; - if ((! junos) || (! cmd)) { + if ((! junos) || (! name)) { junos_set_error(junos, JUNOS_SYS_ERROR, EINVAL, - "junos_simple_command() requires the " - "'junos' and 'cmd' arguments"); + "junos_simple_method() requires the " + "'junos' and 'name' arguments"); return NULL; } if (! junos->access) { junos_set_error(junos, JUNOS_SYS_ERROR, EINVAL, - "Please call junos_connect() before submitting commands"); + "Please call junos_connect() before invoking a method"); return NULL; } - snprintf(cmd_string, sizeof(cmd_string), - "<%s/>", cmd); - status = junos_ssh_send(junos->access, cmd_string, strlen(cmd_string)); - if (status != (ssize_t)strlen(cmd_string)) { - dprintf("Failed to send cmd '%s' (status %d)\n", - cmd_string, (int)status); + snprintf(method_string, sizeof(method_string), + "<%s/>", name); + status = junos_ssh_send(junos->access, + method_string, strlen(method_string)); + if (status != (ssize_t)strlen(method_string)) { + dprintf("Failed to send method '%s' (status %d)\n", + method_string, (int)status); return NULL; } @@ -344,7 +345,7 @@ junos_simple_command(junos_t *junos, const char *cmd) } return doc; -} /* junos_simple_command */ +} /* junos_simple_method */ /* error handling */ diff --git a/src/junos.h b/src/junos.h index a88ad76..5f31e91 100644 --- a/src/junos.h +++ b/src/junos.h @@ -104,7 +104,7 @@ int junos_connect(junos_t *junos); xmlDocPtr -junos_simple_command(junos_t *junos, const char *cmd); +junos_simple_method(junos_t *junos, const char *name); int junos_disconnect(junos_t *junos); diff --git a/src/junosc.c b/src/junosc.c index e08cc77..4b1bb6b 100644 --- a/src/junosc.c +++ b/src/junosc.c @@ -51,7 +51,7 @@ static void exit_usage(char *name, int status) { printf( -"Usage: %s -H [] \n" +"Usage: %s -H [] \n" "\nOptions:\n" " -H hostname to connect to\n" @@ -92,7 +92,7 @@ main(int argc, char **argv) char *username = NULL; char *password = NULL; - char *command = NULL; + char *method = NULL; junos_t *junos; xmlDocPtr doc; @@ -134,11 +134,11 @@ main(int argc, char **argv) } if (optind != argc - 1) { - fprintf(stderr, "Missing command name\n"); + fprintf(stderr, "Missing method name\n"); exit_usage(argv[0], 1); } - command = argv[optind]; + method = argv[optind]; ++optind; if (use_netrc @@ -187,13 +187,13 @@ main(int argc, char **argv) } junos_clear_error(junos); - doc = junos_simple_command(junos, command); + doc = junos_simple_method(junos, method); if (doc) { xmlDocFormatDump(stderr, doc, /* format = */ 1); xmlFreeDoc(doc); } else { - fprintf(stderr, "Command failed: %s\n", junos_get_errstr(junos)); + fprintf(stderr, "Method failed: %s\n", junos_get_errstr(junos)); } junos_disconnect(junos);