00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdinc.h"
00026 #include "tools.h"
00027 #include "client.h"
00028 #include "hash.h"
00029 #include "common.h"
00030 #include "hash.h"
00031 #include "irc_string.h"
00032 #include "ircd.h"
00033 #include "list.h"
00034 #include "numeric.h"
00035 #include "s_serv.h"
00036 #include "send.h"
00037 #include "handlers.h"
00038 #include "msg.h"
00039 #include "parse.h"
00040 #include "modules.h"
00041
00042
00043 static void ms_llnick(struct Client*, struct Client*, int, char**);
00044
00045 struct Message llnick_msgtab = {
00046 "LLNICK", 0, 0, 3, 0, MFLG_SLOW | MFLG_UNREG, 0L,
00047 {m_unregistered, m_ignore, ms_llnick, m_ignore, m_ignore, m_ignore}
00048 };
00049 #ifndef STATIC_MODULES
00050
00051 void
00052 _modinit(void)
00053 {
00054 mod_add_cmd(&llnick_msgtab);
00055 }
00056
00057 void
00058 _moddeinit(void)
00059 {
00060 mod_del_cmd(&llnick_msgtab);
00061 }
00062
00063 const char *_version = "$Revision: 33 $";
00064 #endif
00065
00066
00067
00068
00069
00070
00071
00072
00073 static void
00074 ms_llnick(struct Client *client_p, struct Client *source_p,
00075 int parc, char *parv[])
00076 {
00077 char *nick;
00078 char *nick_old = NULL;
00079 struct Client *target_p = NULL;
00080 int exists = 0;
00081 int new = 0;
00082 dlink_node *ptr;
00083
00084 if(!IsCapable(client_p,CAP_LL) || !IsCapable(client_p, CAP_HUB))
00085 {
00086 sendto_realops_flags(UMODE_ALL, L_ALL,
00087 "*** LLNICK requested from non LL server %s",
00088 client_p->name);
00089 return;
00090 }
00091
00092 if (parc < 4)
00093 return;
00094
00095 if (*parv[1] == 'Y')
00096 exists = 1;
00097
00098 nick = parv[2];
00099 nick_old = parv[3];
00100
00101 if (*nick_old == '!')
00102 new = 1;
00103
00104 if (new)
00105 {
00106 nick_old++;
00107
00108 DLINK_FOREACH(ptr, unknown_list.head)
00109 {
00110 if( !strcmp(nick_old, ((struct Client *)ptr->data)->llname) )
00111 {
00112 target_p = ptr->data;
00113 *target_p->llname = '\0';
00114 break;
00115 }
00116 }
00117 if (!target_p)
00118 return;
00119 }
00120 else
00121 {
00122
00123 target_p = find_client(nick_old);
00124
00125 if (!target_p)
00126 return;
00127 }
00128
00129
00130 if (!MyConnect(target_p))
00131 return;
00132
00133 if(find_client(nick) || exists)
00134 {
00135
00136 sendto_one(target_p, form_str(ERR_NICKNAMEINUSE), me.name,
00137 new ? "*" : nick_old,
00138 nick);
00139 return;
00140 }
00141
00142 if(new)
00143 set_initial_nick(target_p, target_p, nick);
00144 else
00145 change_local_nick(target_p, target_p, nick);
00146 }