From c9a800017c40ef620f3bbbcc3dc49b831429dfd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Wed, 18 Sep 2019 07:40:18 +0800 Subject: Initialise user earlier --- user.c | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/user.c b/user.c index ff50319..1219044 100644 --- a/user.c +++ b/user.c @@ -14,31 +14,6 @@ static size_t show_callback(void *contents, size_t size, size_t nmemb rtclient_user **userptr = (rtclient_user **)writedata; rtclient_user *user = *userptr; - user->id = NULL; - user->name = NULL; - user->password = NULL; - user->emailaddress = NULL; - user->realname = NULL; - user->nickname = NULL; - user->organization = NULL; - user->address1 = NULL; - user->address2 = NULL; - user->city = NULL; - user->state = NULL; - user->zip = NULL; - user->country = NULL; - user->homephone = NULL; - user->workphone = NULL; - user->mobilephone = NULL; - user->pagerphone = NULL; - user->contactinfo = NULL; - user->comments = NULL; - user->signature = NULL; - user->gecos = NULL; - user->lang = RTCLIENT_LANG_NONE; - user->timezone = RTCLIENT_TIMEZONE_NONE; - user->privileged = false; - user->disabled = true; char *linesaveptr = NULL; char *line = strtok_r(response, "\n", &linesaveptr); @@ -153,6 +128,32 @@ static size_t show_callback(void *contents, size_t size, size_t nmemb void rtclient_user_show(rtclient_user **userptr, const char *name) { *userptr = malloc(sizeof(rtclient_user)); + rtclient_user *user = *userptr; + user->id = NULL; + user->name = NULL; + user->password = NULL; + user->emailaddress = NULL; + user->realname = NULL; + user->nickname = NULL; + user->organization = NULL; + user->address1 = NULL; + user->address2 = NULL; + user->city = NULL; + user->state = NULL; + user->zip = NULL; + user->country = NULL; + user->homephone = NULL; + user->workphone = NULL; + user->mobilephone = NULL; + user->pagerphone = NULL; + user->contactinfo = NULL; + user->comments = NULL; + user->signature = NULL; + user->gecos = NULL; + user->lang = RTCLIENT_LANG_NONE; + user->timezone = RTCLIENT_TIMEZONE_NONE; + user->privileged = false; + user->disabled = true; request("/REST/1.0/user/", name, show_callback, (void *)userptr, NULL); } -- cgit v1.2.3