comparison src/gaim-client-example.c @ 14035:8bda65b88e49

[gaim-migrate @ 16638] A bunch of small changes. Mostly remove "if not null" checks before calling g_free, g_list_free, g_slist_free and g_strdup. Also use g_list_foreach() to call g_free to free strings in an array. And some whitespace changes here and there. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 05 Aug 2006 08:27:39 +0000
parents c9312177821a
children
comparison
equal deleted inserted replaced
14034:0839a7b71325 14035:8bda65b88e49
3 #include <stdio.h> 3 #include <stdio.h>
4 #include <stdlib.h> 4 #include <stdlib.h>
5 5
6 #include "gaim-client.h" 6 #include "gaim-client.h"
7 7
8 /* 8 /*
9 This example demonstrates how to use libgaim-client to communicate 9 This example demonstrates how to use libgaim-client to communicate
10 with gaim. The names and signatures of functions provided by 10 with gaim. The names and signatures of functions provided by
11 libgaim-client are the same as those in gaim. However, all 11 libgaim-client are the same as those in gaim. However, all
12 structures (such as GaimAccount) are opaque, that is, you can only 12 structures (such as GaimAccount) are opaque, that is, you can only
13 use pointer to them. In fact, these pointers DO NOT actually point 13 use pointer to them. In fact, these pointers DO NOT actually point
19 portable. 19 portable.
20 */ 20 */
21 21
22 int main (int argc, char **argv) 22 int main (int argc, char **argv)
23 { 23 {
24 GList *alist, *node; 24 GList *alist, *node;
25 25
26 gaim_init(); 26 gaim_init();
27
28 alist = gaim_accounts_get_all();
29 for (node = alist; node; node = node->next) {
30 GaimAccount *account = (GaimAccount*) node->data;
31 char *name = gaim_account_get_username(account);
32 g_print("Name: %s\n", name);
33 g_free(name);
34 }
35 27
36 g_list_free(alist); 28 alist = gaim_accounts_get_all();
29 for (node = alist; node != NULL; node = node->next)
30 {
31 GaimAccount *account = (GaimAccount*) node->data;
32 char *name = gaim_account_get_username(account);
33 g_print("Name: %s\n", name);
34 g_free(name);
35 }
36 g_list_free(alist);
37 37
38 return 0; 38 return 0;
39 } 39 }