music.c: cosmetix
[k8lowj.git] / src / liblj / serveruser.c
blobe1ffa25ce042972e5ea6d14a56cb9ab9ee858f5d
1 /* liblivejournal - a client library for LiveJournal.
2 * Copyright (C) 2003 Evan Martin <evan@livejournal.com>
4 * vim: tabstop=4 shiftwidth=4 noexpandtab :
5 */
7 #include <glib.h>
8 #include "liblj/types.h"
9 #include "liblj/serveruser.h"
11 LJUser*
12 lj_user_new(LJServer *server) {
13 LJUser *u = g_new0(LJUser, 1);
14 u->server = server;
15 return u;
18 gint
19 lj_user_compare(gconstpointer a, gconstpointer b) {
20 return g_ascii_strcasecmp(((LJUser*)a)->username, ((LJUser*)b)->username);
23 LJServer*
24 lj_server_new(const char *url) {
25 LJServer *s = g_new0(LJServer, 1);
26 s->protocolversion = 1; /* default to protocol version 1. */
27 if (url)
28 s->url = g_strdup(url);
29 return s;
32 int
33 lj_server_get_last_cached_moodid(LJServer *server) {
34 GSList *l;
35 int max = 0;
36 for (l = server->moods; l != NULL; l = l->next) {
37 if (((LJMood*)l->data)->id > max)
38 max = ((LJMood*)l->data)->id;
40 return max;
43 static void
44 webmenuitem_free(LJWebMenuItem *wmi) {
45 g_free(wmi->text);
46 g_free(wmi->url);
47 g_slist_foreach(wmi->subitems, (GFunc)webmenuitem_free, NULL);
48 g_slist_free(wmi->subitems);
49 g_free(wmi);
52 void
53 lj_webmenu_free(GSList *l) {
54 if (!l) return;
55 g_slist_foreach(l, (GFunc)webmenuitem_free, NULL);
56 g_slist_free(l);