diff options
Diffstat (limited to 'vchat-user.c')
-rwxr-xr-x | vchat-user.c | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/vchat-user.c b/vchat-user.c index 868fcc5..5f073a6 100755 --- a/vchat-user.c +++ b/vchat-user.c | |||
@@ -20,8 +20,20 @@ | |||
20 | #include <string.h> | 20 | #include <string.h> |
21 | #include <sys/types.h> | 21 | #include <sys/types.h> |
22 | #include <regex.h> | 22 | #include <regex.h> |
23 | #include <time.h> | ||
24 | #include <readline/readline.h> | ||
23 | #include "vchat.h" | 25 | #include "vchat.h" |
24 | 26 | ||
27 | struct user | ||
28 | { | ||
29 | unsigned char *nick; /* nick of user */ | ||
30 | int chan; /* channel user is on */ | ||
31 | int chan_valid; /* are we sure he is? */ | ||
32 | int client_pv; /* client protocol version */ | ||
33 | int messaged; /* did we message with this user? */ | ||
34 | struct user *next; /* next user in linked list */ | ||
35 | }; | ||
36 | |||
25 | /* version of this module */ | 37 | /* version of this module */ |
26 | unsigned char *vchat_us_version = "$Id$"; | 38 | unsigned char *vchat_us_version = "$Id$"; |
27 | 39 | ||
@@ -79,6 +91,7 @@ ul_add (unsigned char *name, int ignored) | |||
79 | } | 91 | } |
80 | } | 92 | } |
81 | } | 93 | } |
94 | rl_last_func = NULL; | ||
82 | } | 95 | } |
83 | 96 | ||
84 | /* delete user from userlist */ | 97 | /* delete user from userlist */ |
@@ -119,6 +132,7 @@ ul_del (unsigned char *name, int ignored) | |||
119 | ltmp = tmp; | 132 | ltmp = tmp; |
120 | tmp = tmp->next; | 133 | tmp = tmp->next; |
121 | } | 134 | } |
135 | rl_last_func = NULL; | ||
122 | } | 136 | } |
123 | 137 | ||
124 | /* let user join a channel */ | 138 | /* let user join a channel */ |
@@ -131,6 +145,7 @@ ul_join (unsigned char *name, int channel) | |||
131 | ownjoin (channel); | 145 | ownjoin (channel); |
132 | return; | 146 | return; |
133 | } else ul_moveuser(name,channel); | 147 | } else ul_moveuser(name,channel); |
148 | rl_last_func = NULL; | ||
134 | } | 149 | } |
135 | 150 | ||
136 | user * | 151 | user * |
@@ -169,20 +184,39 @@ ul_matchuser( unsigned char *regex) { | |||
169 | return tmpstr; | 184 | return tmpstr; |
170 | } | 185 | } |
171 | 186 | ||
187 | static void | ||
188 | ul_usertofront( user *who ) { | ||
189 | user *tmp = nicks; | ||
190 | |||
191 | while( tmp->next && ( tmp->next != who ) ) | ||
192 | tmp = tmp->next; | ||
193 | |||
194 | if( tmp->next == who ) { | ||
195 | tmp->next = tmp->next->next; | ||
196 | who->next = nicks; | ||
197 | nicks = who; | ||
198 | } | ||
199 | rl_last_func = NULL; | ||
200 | } | ||
201 | |||
172 | void | 202 | void |
173 | ul_msgto (unsigned char *name) { | 203 | ul_msgto (unsigned char *name) { |
174 | user *tmp = ul_finduser(name); | 204 | user *tmp = ul_finduser(name); |
175 | 205 | ||
176 | if (tmp) | 206 | if (tmp) { |
177 | tmp->messaged |= 1; | 207 | tmp->messaged |= 1; |
208 | ul_usertofront( tmp ); | ||
209 | } | ||
178 | } | 210 | } |
179 | 211 | ||
180 | void | 212 | void |
181 | ul_msgfrom (unsigned char *name) { | 213 | ul_msgfrom (unsigned char *name) { |
182 | user *tmp = ul_finduser(name); | 214 | user *tmp = ul_finduser(name); |
183 | 215 | ||
184 | if (tmp) | 216 | if (tmp) { |
185 | tmp->messaged |= 2; | 217 | tmp->messaged |= 2; |
218 | ul_usertofront( tmp ); | ||
219 | } | ||
186 | } | 220 | } |
187 | 221 | ||
188 | /* set channel of user */ | 222 | /* set channel of user */ |
@@ -195,6 +229,7 @@ ul_moveuser (unsigned char *name, int channel) { | |||
195 | tmp->chan = channel; | 229 | tmp->chan = channel; |
196 | tmp->chan_valid = 1; | 230 | tmp->chan_valid = 1; |
197 | } | 231 | } |
232 | rl_last_func = NULL; | ||
198 | } | 233 | } |
199 | 234 | ||
200 | /* let user leave a channel */ | 235 | /* let user leave a channel */ |
@@ -215,6 +250,7 @@ ul_leave (unsigned char *name, int channel) | |||
215 | tmp->chan_valid = 0; | 250 | tmp->chan_valid = 0; |
216 | return; | 251 | return; |
217 | } | 252 | } |
253 | rl_last_func = NULL; | ||
218 | } | 254 | } |
219 | 255 | ||
220 | /* let user change nick */ | 256 | /* let user change nick */ |
@@ -235,6 +271,7 @@ ul_nickchange (unsigned char *oldnick, unsigned char *newnick) | |||
235 | tmp->nick = strdup (newnick); | 271 | tmp->nick = strdup (newnick); |
236 | return; | 272 | return; |
237 | } | 273 | } |
274 | rl_last_func = NULL; | ||
238 | } | 275 | } |
239 | 276 | ||
240 | /* clear userlist */ | 277 | /* clear userlist */ |
@@ -254,6 +291,7 @@ ul_clear (void) | |||
254 | } | 291 | } |
255 | /* mark list empty */ | 292 | /* mark list empty */ |
256 | nicks = NULL; | 293 | nicks = NULL; |
294 | rl_last_func = NULL; | ||
257 | } | 295 | } |
258 | 296 | ||
259 | int ulnc_casenick(user *tmp, const unsigned char *text, int len, int value) { | 297 | int ulnc_casenick(user *tmp, const unsigned char *text, int len, int value) { |