1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <icclient/admin.h>
#include <icclient/client.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);
icclient_init(url, NULL);
free(url);
icclient_admin_login(name, pass, NULL, NULL, NULL);
free(name);
free(pass);
icclient_admin_logout();
icclient_cleanup();
}
|