ekg2  GIT master
 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 void userlist_write(session_t *session);
159 void userlist_clear_status(session_t *session, const char *uid);
160 userlist_t *userlist_add(session_t *session, const char *uid, const char *nickname);
161 userlist_t *userlist_add_u(userlist_t **userlist, const char *uid, const char *nickname);
162 void userlist_add_entry(session_t *session,const char *line);
163 int userlist_remove(session_t *session, userlist_t *u);
165 int userlist_replace(session_t *session, userlist_t *u);
166 userlist_t *userlist_find(session_t *session, const char *uid);
167 userlist_t *userlist_find_u(userlist_t **userlist, const char *uid);
168 #define userlist_find_n(a, b) userlist_find(session_find(a), b)
169 void userlist_free(session_t *session);
171 
173 
174 /* u->resource */
175 ekg_resource_t *userlist_resource_add(userlist_t *u, const char *name, int prio);
178 
179 int ignored_add(session_t *session, const char *uid, ignore_t level);
180 int ignored_remove(session_t *session, const char *uid);
181 int ignored_check(session_t *session, const char *uid);
182 int ignore_flags(const char *str);
183 const char *ignore_format(int level);
184 
185 int ekg_group_add(userlist_t *u, const char *group);
186 int ekg_group_remove(userlist_t *u, const char *group);
187 int ekg_group_member(userlist_t *u, const char *group);
188 char *group_to_string(struct ekg_group *l, int meta, int sep);
189 struct ekg_group *group_init(const char *groups);
190 
191 int valid_nick(const char *nick);
192 int valid_plugin_uid(plugin_t *plugin, const char *uid);
193 const char *format_user(session_t *session, const char *uid);
194 const char *get_uid(session_t *session, const char *text);
195 const char *get_uid_any(session_t *session, const char *text);
196 const char *get_nickname(session_t *session, const char *text);
197 char *get_user_name(userlist_t *u);
198 
199 #endif
200 
201 #define user_private_item_get_safe(user, name, result) \
202  private_item_get_safe(&(user)->priv_list, name, result)
203 #define user_private_item_get(user, name) \
204  private_item_get(&(user)->priv_list, name)
205 #define user_private_item_get_int_safe(user, name, result) \
206  private_item_get_int_safe(&(user)->priv_list), name, int *result)
207 #define user_private_item_get_int(user, name) \
208  private_item_get_int(&(user)->priv_list, name)
209 #define user_private_item_set(user, name, value) \
210  private_item_set(&(user)->priv_list, name, value)
211 #define user_private_item_set_int(user, name, value) \
212  private_item_set_int(&(user)->priv_list, name, value)
213 
214 #define user_private_items_destroy(user) \
215  private_items_destroy(&(user)->priv_list);
216 
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #endif /* __EKG_USERLIST_H */
222 
223 /*
224  * Local Variables:
225  * mode: c
226  * c-file-style: "k&r"
227  * c-basic-offset: 8
228  * indent-tabs-mode: t
229  * End:
230  */