doc: Update maximum message size
[libisds.git] / client / getsenderbyid.c
blobcd63c443cb78748143c80717b2a56c26d1565025
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"
11 int main(int argc, char **argv) {
12 struct isds_ctx *ctx = NULL;
13 isds_error err;
15 setlocale(LC_ALL, "");
17 if (argc < 2) {
18 fprintf(stderr, "Usage: program YOUR_MESSAGE_ID\n");
19 exit(EXIT_FAILURE);
22 err = isds_init();
23 if (err) {
24 printf("isds_init() failed: %s\n", isds_strerror(err));
25 exit(EXIT_FAILURE);
28 isds_set_logging(ILF_ALL & ~ILF_HTTP, ILL_ALL);
30 ctx = isds_ctx_create();
31 if (!ctx) {
32 printf("isds_ctx_create() failed");
35 err = isds_set_timeout(ctx, 10000);
36 if (err) {
37 printf("isds_set_timeout() failed: %s\n", isds_strerror(err));
40 err = isds_login(ctx, url, username(), password(), NULL, NULL);
41 if (err) {
42 printf("isds_login() failed: %s: %s\n", isds_strerror(err),
43 isds_long_message(ctx));
44 } else {
45 printf("Logged in :)\n");
49 /* Get sender of message selected by message ID */
50 if (argv[1]) {
51 isds_sender_type *type = NULL;
52 char *raw_type = NULL;
53 char *name = NULL;
55 printf("Getting sender of message with ID: %s\n",
56 argv[1]);
57 err = isds_get_message_sender(ctx, argv[1], &type, &raw_type, &name);
58 if (err)
59 printf("isds_get_message_sender() failed: %s: %s\n",
60 isds_strerror(err), isds_long_message(ctx));
61 else {
62 printf("isds_get_message_sender() succeeded:\n");
63 printf("type = ");
64 print_sender_type(type);
65 printf("raw_type = %s\n"
66 "name = %s\n", raw_type, name);
69 free(type);
70 free(raw_type);
71 free(name);
75 err = isds_logout(ctx);
76 if (err) {
77 printf("isds_logout() failed: %s\n", isds_strerror(err));
80 err = isds_ctx_free(&ctx);
81 if (err) {
82 printf("isds_ctx_free() failed: %s\n", isds_strerror(err));
85 err = isds_cleanup();
86 if (err) {
87 printf("isds_cleanup() failed: %s\n", isds_strerror(err));
90 exit (EXIT_SUCCESS);