summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-08 23:14:50 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-08 23:14:50 +0800
commitf81ab4be0a216ca2ffbe34e8f2821589b91a0399 (patch)
tree5b7f6a01bcc47761a04c7db6924a21e38d1e90ec
parent316a8686aac06ca326c65e624559a8f7ae8b73f1 (diff)
A small test program
-rw-r--r--.gitignore1
-rw-r--r--test.c49
2 files changed, 50 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index f3cf82c..07fcd69 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,4 +18,5 @@ configure
depcomp
install-sh
missing
+rtclient
stamp-h1
diff --git a/test.c b/test.c
new file mode 100644
index 0000000..00ebb5f
--- /dev/null
+++ b/test.c
@@ -0,0 +1,49 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "rtclient.h"
+
+int main(void)
+{
+ char *url_line = NULL, *name_line = NULL, *pass_line = NULL;
+ printf("URL: ");
+ ssize_t url_nread = getline(&url_line, &(size_t){0}, stdin);
+ printf("Name: ");
+ ssize_t name_nread = getline(&name_line, &(size_t){0}, stdin);
+ printf("Pass: ");
+ ssize_t pass_nread = getline(&pass_line, &(size_t){0}, stdin);
+
+ char *url = malloc(--url_nread + 1), *name = malloc(--name_nread + 1)
+ , *pass = malloc(--pass_nread + 1);
+ strncpy(url, url_line, url_nread);
+ free(url_line);
+ strncpy(name, name_line, name_nread);
+ free(name_line);
+ strncpy(pass, pass_line, pass_nread);
+ free(pass_line);
+
+ rtclient_init(url);
+ free(url);
+
+ rtclient_login(name, pass);
+ free(pass);
+
+ struct rt_user *user = NULL;
+ if (rtclient_get_user(&user, name))
+ printf("id: %s\npassword: %s\nname: %s\nemailaddress: %s\nrealname: %s\nnickname: %s\ngecos: %s\norganization: %s\naddress1: %s\naddress2: %s\ncity: %s\nstate: %s\nzip: %s\ncountry: %s\nhomephone: %s\nworkphone: %s\nmobilephone: %s\npagerphone: %s\ncontactinfo: %s\ncomments: %s\nsignature: %s\nlang: %s\nprivileged: %d\ndisabled: %d\n"
+ , user->id, user->password, user->name, user->emailaddress
+ , user->realname, user->nickname, user->gecos
+ , user->organization, user->address1, user->address2
+ , user->city, user->state, user->zip, user->country
+ , user->homephone, user->workphone, user->mobilephone
+ , user->pagerphone, user->contactinfo, user->comments
+ , user->signature, &user->lang[0], user->privileged
+ , user->disabled);
+ free(name);
+ if (user)
+ rtclient_user_free(user);
+
+ rtclient_cleanup();
+
+ return 0;
+}