ekg2
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje Grupay Strony
userlist.h
Idź do dokumentacji tego pliku.
1 /* $Id$ */
2 
3 /*
4  * (C) Copyright 2001-2003 Wojtek Kaniewski <wojtekka@irc.pl>
5  * Robert J. Woźny <speedy@ziew.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License Version 2 as
9  * published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20 
21 #ifndef __EKG_USERLIST_H
22 #define __EKG_USERLIST_H
23 
24 #include "ekg2-config.h"
25 #include "win32.h"
26 
27 #include <sys/types.h>
28 
29 #ifndef NO_POSIX_SYSTEM
30 #include <sys/socket.h>
31 #include <netinet/in.h>
32 #endif
33 
34 #include <stdio.h>
35 #include <stdarg.h>
36 #include <time.h>
37 
38 #include "dynstuff.h"
39 #include "sessions.h"
40 #include "plugins.h"
41 #include "windows.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
54 typedef struct userlist {
55  struct userlist *next;
56 
57  const char *uid;
58  char *nickname;
59  struct ekg_group *groups;
64  char *descr;
65  char *descr1line;
68  time_t last_seen;
70  char *foreign;
72  void *priv;
74  unsigned int blink : 1;
75  unsigned int typing : 1;
78  char *last_descr;
79  time_t status_time;
80  void *priv_data;
81  private_data_t *priv_list; /* New user private data */
82 } userlist_t;
83 
84 typedef enum {
87 } xstate_t;
88 
94 typedef enum {
108 
114 typedef struct ekg_resource {
116 
117  char *name;
119  char *descr;
120  int prio;
121  void *priv_data;
123 
128 struct ekg_group {
129  struct ekg_group *next;
130 
131  char *name;
132 };
133 
134 typedef enum {
137  IGNORE_MSG = 0x04,
138  IGNORE_DCC = 0x08,
141  IGNORE_XOSD = 0x40,
142  IGNORE_LOG = 0x80,
143 
144  IGNORE_ALL = 0xFF
145 } ignore_t;
146 
147 struct ignore_label {
149  char *name;
150 };
151 
152 #define IGNORE_LABELS_MAX 9
154 
155 #ifndef EKG2_WIN32_NOFUNCTION
156 
157 int userlist_read(session_t* session);
158 int userlist_write(session_t *session);
159 void userlist_write_crash();
160 void userlist_clear_status(session_t *session, const char *uid);
161 userlist_t *userlist_add(session_t *session, const char *uid, const char *nickname);
162 userlist_t *userlist_add_u(userlist_t **userlist, const char *uid, const char *nickname);
163 void userlist_add_entry(session_t *session,const char *line);
164 int userlist_remove(session_t *session, userlist_t *u);
166 int userlist_replace(session_t *session, userlist_t *u);
167 userlist_t *userlist_find(session_t *session, const char *uid);
169 #define userlist_find_n(a, b) userlist_find(session_find(a), b)
170 void userlist_free(session_t *session);
172 
174 
175 /* u->resource */
176 ekg_resource_t *userlist_resource_add(userlist_t *u, const char *name, int prio);
179 
180 int ignored_add(session_t *session, const char *uid, ignore_t level);
181 int ignored_remove(session_t *session, const char *uid);
182 int ignored_check(session_t *session, const char *uid);
183 int ignore_flags(const char *str);
184 const char *ignore_format(int level);
185 
186 int ekg_group_add(userlist_t *u, const char *group);
187 int ekg_group_remove(userlist_t *u, const char *group);
188 int ekg_group_member(userlist_t *u, const char *group);
189 char *group_to_string(struct ekg_group *l, int meta, int sep);
190 struct ekg_group *group_init(const char *groups);
191 
192 int valid_nick(const char *nick);
193 int valid_plugin_uid(plugin_t *plugin, const char *uid);
194 const char *format_user(session_t *session, const char *uid);
195 const char *get_uid(session_t *session, const char *text);
196 const char *get_uid_any(session_t *session, const char *text);
197 const char *get_nickname(session_t *session, const char *text);
198 char *get_user_name(userlist_t *u);
199 
200 #endif
201 
202 #define user_private_item_get_safe(user, name, result) \
203  private_item_get_safe(&(user)->priv_list, name, result)
204 #define user_private_item_get(user, name) \
205  private_item_get(&(user)->priv_list, name)
206 #define user_private_item_get_int_safe(user, name, result) \
207  private_item_get_int_safe(&(user)->priv_list), name, int *result)
208 #define user_private_item_get_int(user, name) \
209  private_item_get_int(&(user)->priv_list, name)
210 #define user_private_item_set(user, name, value) \
211  private_item_set(&(user)->priv_list, name, value)
212 #define user_private_item_set_int(user, name, value) \
213  private_item_set_int(&(user)->priv_list, name, value)
214 
215 #define user_private_items_destroy(user) \
216  private_items_destroy(&(user)->priv_list);
217 
218 #ifdef __cplusplus
219 }
220 #endif
221 
222 #endif /* __EKG_USERLIST_H */
223 
224 /*
225  * Local Variables:
226  * mode: c
227  * c-file-style: "k&r"
228  * c-basic-offset: 8
229  * indent-tabs-mode: t
230  * End:
231  */