tests: Adapt utf8locale to musl
[libisds.git] / client / progressbar.c
blob2b7d98ef164c6915c85df5fed1cdd7eae51f848b
1 #define _XOPEN_SOURCE 500
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <locale.h>
5 #include <time.h>
6 #include <string.h>
7 #include <isds.h>
8 #include "common.h"
10 int main(void) {
11 struct isds_ctx *ctx = NULL;
12 isds_error err;
14 setlocale(LC_ALL, "");
16 err = isds_init();
17 if (err) {
18 printf("isds_init() failed: %s\n", isds_strerror(err));
19 exit(EXIT_FAILURE);
22 isds_set_logging(ILF_ALL & ~ILF_HTTP & ~ILF_SOAP, ILL_ALL);
24 ctx = isds_ctx_create();
25 if (!ctx) {
26 printf("isds_ctx_create() failed");
29 err = isds_set_timeout(ctx, 10000);
30 if (err) {
31 printf("isds_set_timeout() failed: %s\n", isds_strerror(err));
35 /* Register progresbar */
36 err = isds_set_progress_callback(ctx, progressbar, NULL);
37 if (err) {
38 printf("isds_set_progress_callback() failed: %s: %s\n",
39 isds_strerror(err), isds_long_message(ctx));
40 } else {
41 printf("isds_set_progress_callback() succeeded.\n");
44 err = isds_login(ctx, url, username(), password(), NULL, NULL);
45 if (err) {
46 printf("isds_login() failed: %s: %s\n", isds_strerror(err),
47 isds_long_message(ctx));
48 } else {
49 printf("Logged in :)\n");
53 /* Register aborting progresbar */
54 printf("\nTesting aborting progress callback\n");
55 err = isds_set_progress_callback(ctx, progressbar, (void *)1);
56 if (err) {
57 printf("isds_set_progress_callback() failed: %s: %s\n",
58 isds_strerror(err), isds_long_message(ctx));
59 } else {
60 printf("isds_set_progress_callback() succeeded.\n");
62 err = isds_ping(ctx);
63 if (err) {
64 printf("isds_ping() failed: %s: %s\n", isds_strerror(err),
65 isds_long_message(ctx));
66 } else {
67 printf("Ping succeded\n");
71 /* Register normal progresbar */
72 printf("\nTesting non-aborting progress callback\n");
73 err = isds_set_progress_callback(ctx, progressbar, NULL);
74 if (err) {
75 printf("isds_set_progress_callback() failed: %s: %s\n",
76 isds_strerror(err), isds_long_message(ctx));
77 } else {
78 printf("isds_set_progress_callback() succeeded.\n");
80 err = isds_ping(ctx);
81 if (err) {
82 printf("isds_ping() failed: %s: %s\n", isds_strerror(err),
83 isds_long_message(ctx));
84 } else {
85 printf("Ping succeded\n");
89 err = isds_logout(ctx);
90 if (err) {
91 printf("isds_logout() failed: %s\n", isds_strerror(err));
95 err = isds_ctx_free(&ctx);
96 if (err) {
97 printf("isds_ctx_free() failed: %s\n", isds_strerror(err));
101 err = isds_cleanup();
102 if (err) {
103 printf("isds_cleanup() failed: %s\n", isds_strerror(err));
106 exit (EXIT_SUCCESS);