--- plugins/perl/perl.c 2010-03-03 14:20:38.000000000 +0100 +++ plugins/perl/perl.c 2010-03-03 14:28:30.377966927 +0100 @@ -1191,6 +1191,36 @@ } static +XS (XS_Xchat_user_info) +{ + SV *nick; + xchat_list *list; + const char *const *fields; + dXSARGS; + + if (items != 1) { + xchat_print (ph, "Usage: Xchat::Internal::user_info(nick)"); + } else { + SP -= items; /*remove the argument list from the stack */ + + nick = ST (0); + + list = xchat_user_info (ph, SvPV_nolen (nick)); + + if (list == NULL) { + XSRETURN_UNDEF; + } + + fields = xchat_list_fields (ph, "users"); + XPUSHs (list_item_to_sv (list, fields)); + xchat_list_free (ph, list); + + PUTBACK; + return; + } +} + +static XS (XS_Xchat_Embed_plugingui_remove) { void *gui_entry; @@ -1228,6 +1258,7 @@ newXS ("Xchat::Internal::get_info", XS_Xchat_get_info, __FILE__); newXS ("Xchat::Internal::context_info", XS_Xchat_context_info, __FILE__); newXS ("Xchat::Internal::get_list", XS_Xchat_get_list, __FILE__); + newXS ("Xchat::Internal::user_info", XS_Xchat_user_info, __FILE__); newXS ("Xchat::find_context", XS_Xchat_find_context, __FILE__); newXS ("Xchat::get_context", XS_Xchat_get_context, __FILE__); --- plugins/perl/Xchat.pm 2010-03-03 14:20:38.000000000 +0100 +++ plugins/perl/Xchat.pm 2010-03-03 14:23:25.773965564 +0100 @@ -400,14 +400,7 @@ sub user_info { my $nick = Xchat::strip_code(shift @_ || Xchat::get_info( "nick" )); - my $user; - for (Xchat::get_list( "users" ) ) { - if ( Xchat::nickcmp( $_->{nick}, $nick ) == 0 ) { - $user = $_; - last; - } - } - return $user; + return Xchat::Internal::user_info( $nick ); } sub context_info { --- plugins/xchat-plugin.h 2010-03-03 14:20:38.000000000 +0100 +++ plugins/xchat-plugin.h 2010-03-03 14:23:25.773965564 +0100 @@ -137,6 +137,8 @@ int flags); void (*xchat_free) (xchat_plugin *ph, void *ptr); + xchat_list * (*xchat_user_info) (xchat_plugin *ph, + const char *nick); }; #endif @@ -292,6 +294,10 @@ xchat_free (xchat_plugin *ph, void *ptr); +xchat_list * +xchat_user_info (xchat_plugin *ph, + const char *nick); + #if !defined(PLUGIN_C) && defined(WIN32) #ifndef XCHAT_PLUGIN_HANDLE #define XCHAT_PLUGIN_HANDLE (ph) @@ -326,6 +332,7 @@ #define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) #define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) #define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) +#define xchat_user_info ((XCHAT_PLUGIN_HANDLE)->xchat_user_info) #endif #ifdef __cplusplus --- src/common/plugin.c 2010-03-03 14:20:41.000000000 +0100 +++ src/common/plugin.c 2010-03-03 14:32:04.102943061 +0100 @@ -262,9 +262,9 @@ pl->xchat_send_modes = xchat_send_modes; pl->xchat_strip = xchat_strip; pl->xchat_free = xchat_free; + pl->xchat_user_info = xchat_user_info; /* incase new plugins are loaded on older xchat */ - pl->xchat_dummy4 = xchat_dummy; pl->xchat_dummy3 = xchat_dummy; pl->xchat_dummy2 = xchat_dummy; pl->xchat_dummy1 = xchat_dummy; @@ -1484,6 +1484,26 @@ return -1; } +xchat_list * +xchat_user_info (xchat_plugin *ph, const char *nick) +{ + GSList *l; + xchat_list *list; + + if (!is_session (ph->context)) + return NULL; + + l = userlist_find_list (ph->context, nick); + if (!l) + return NULL; + + list = malloc (sizeof (xchat_list)); + list->type = LIST_USERS; + list->head = list->next = list->pos = l; + + return list; +} + void * xchat_plugingui_add (xchat_plugin *ph, const char *filename, const char *name, const char *desc, --- src/common/plugin.h 2010-03-03 14:20:41.000000000 +0100 +++ src/common/plugin.h 2010-03-03 14:23:25.777966797 +0100 @@ -98,7 +98,8 @@ int flags); void (*xchat_free) (xchat_plugin *ph, void *ptr); - void *(*xchat_dummy4) (xchat_plugin *ph); + xchat_list * (*xchat_user_info) (xchat_plugin *ph, + const char *nick); void *(*xchat_dummy3) (xchat_plugin *ph); void *(*xchat_dummy2) (xchat_plugin *ph); void *(*xchat_dummy1) (xchat_plugin *ph); --- src/common/userlist.c 2010-03-03 14:20:41.000000000 +0100 +++ src/common/userlist.c 2010-03-03 14:32:30.742624071 +0100 @@ -203,6 +203,15 @@ return NULL; } +GSList * +userlist_find_list (session *sess, char *name) +{ + struct User *user; + + user = userlist_find (sess, name); + return user ? g_slist_prepend (NULL, user) : NULL; +} + struct User * userlist_find_global (struct server *serv, char *name) { --- src/common/userlist.h 2010-03-03 14:20:41.000000000 +0100 +++ src/common/userlist.h 2010-03-03 14:23:25.777966797 +0100 @@ -27,6 +27,7 @@ char *servername, unsigned int away); void userlist_set_away (session *sess, char *nick, unsigned int away); struct User *userlist_find (session *sess, char *name); +GSList *userlist_find_list (session *sess, char *name); struct User *userlist_find_global (server *serv, char *name); void userlist_clear (session *sess); void userlist_free (session *sess); --- src/common/xchat-plugin.h 2010-03-03 14:20:41.000000000 +0100 +++ src/common/xchat-plugin.h 2010-03-03 14:23:25.777966797 +0100 @@ -137,6 +137,8 @@ int flags); void (*xchat_free) (xchat_plugin *ph, void *ptr); + xchat_list * (*xchat_user_info) (xchat_plugin *ph, + const char *nick); }; #endif @@ -292,6 +294,10 @@ xchat_free (xchat_plugin *ph, void *ptr); +xchat_list * +xchat_user_info (xchat_plugin *ph, + const char *nick); + #if !defined(PLUGIN_C) && defined(WIN32) #ifndef XCHAT_PLUGIN_HANDLE #define XCHAT_PLUGIN_HANDLE (ph) @@ -326,6 +332,7 @@ #define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) #define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) #define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) +#define xchat_user_info ((XCHAT_PLUGIN_HANDLE)->xchat_user_info) #endif #ifdef __cplusplus --- src/version-script 2010-03-03 14:20:42.000000000 +0100 +++ src/version-script 2010-03-03 14:23:25.777966797 +0100 @@ -30,5 +30,6 @@ xchat_send_modes; xchat_strip; xchat_free; + xchat_user_info; local: *; };