]> git.sur5r.net Git - ngadmin/blobdiff - cli/com_password.c
Code reorganized.
[ngadmin] / cli / com_password.c
diff --git a/cli/com_password.c b/cli/com_password.c
new file mode 100644 (file)
index 0000000..4b1f184
--- /dev/null
@@ -0,0 +1,60 @@
+
+#include "common.h"
+
+
+
+
+static bool do_password_change (const struct TreeNode *tn UNUSED, int nb, const char **com, struct ngadmin *nga) {
+ int i;
+ const struct swi_attr *sa;
+ if ( nb!=1 ) {
+  printf("Usage: password set <value>\n");
+  return false;
+ }
+ if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
+  printf("must be logged\n");
+  return false;
+ }
+ i=ngadmin_changePassword(nga, com[0]);
+ printErrCode(i);
+ return true;
+}
+
+
+
+static bool do_password_set (const struct TreeNode *tn UNUSED, int nb, const char **com, struct ngadmin *nga) {
+ int i;
+ if ( nb!=1 ) {
+  printf("Usage: password set <value>\n");
+  return false;
+ }
+ i=ngadmin_setPassword(nga, com[0]);
+ printErrCode(i);
+ return true;
+}
+
+
+
+
+static const struct TreeNode com_password_change=COM("change", do_password_change, true, NULL);
+static const struct TreeNode com_password_set=COM("set", do_password_set, true, NULL);
+
+const struct TreeNode com_password=COM("password", NULL, false, &com_password_change, &com_password_set, NULL);
+
+
+