/************************************************************************ * IRC - Internet Relay Chat, modules/m_user.c * * Copyright (C) 2000-2003 TR-IRCD Development * * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Co Center * * See file AUTHORS in IRC package for additional names of * the programmers. * * This program is free softwmare; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "struct.h" #include "common.h" #include "sys.h" #include "h.h" #include "msg.h" #include "numeric.h" #include "s_conf.h" static struct Message _msgtab[] = { {MSG_USER, 0, MAXPARA, M_SLOW, 0L, m_user, m_registered, m_registered, m_registered, m_ignore} }; #ifndef STATIC_MODULES char *_version = "$Revision: 1.4 $"; void _modinit(void) { mod_add_cmd(_msgtab); } void _moddeinit(void) { mod_del_cmd(_msgtab); } #else void m_user_init(void) { mod_add_cmd(_msgtab); } #endif /* * * m_user * parv[0] = sender prefix * parv[1] = username * (login name, account) * parv[2] = client host name (used only * from other servers) * parv[3] = server host name (used only * from other servers) * parv[4] = users real name info */ int m_user(aClient *cptr, aClient *sptr, int parc, char *parv[]) { char *username, *host, *server, *realname; aMaskItem *ami; if (parc > 2 && (username = (char *) strchr(parv[1], '@'))) *username = '\0'; if (parc < 5 || *parv[1] == '\0' || *parv[2] == '\0' || *parv[3] == '\0' || *parv[4] == '\0') { send_me_numeric(sptr, ERR_NEEDMOREPARAMS, MSG_USER); return 0; } /* * Copy parameters into better documenting variables */ username = (parc < 2 || BadPtr(parv[1])) ? "" : parv[1]; host = (parc < 3 || BadPtr(parv[2])) ? "" : parv[2]; server = (parc < 4 || BadPtr(parv[3])) ? "" : parv[3]; realname = (parc < 5 || BadPtr(parv[4])) ? "" : parv[4]; if ((ami = find_maskitem(realname, NULL, MASKITEM_GECOS, 1))) { /* Realname replacement */ if (ServerOpts.hide_gcos_with_sgline) { realname = ServerOpts.realname_replacement; } else { return exit_client(sptr, sptr, ami->reason); } } else if ((ami = find_maskitem(realname, NULL, MASKITEM_GECOS_CONFIG, 1))) { /* Realname replacement */ if (ServerOpts.hide_gcos_with_sgline) { realname = ServerOpts.realname_replacement; } else { return exit_client(sptr, sptr, ami->reason); } } else if (ServerOpts.use_regex && (ami = find_maskitem(realname, NULL, MASKITEM_GECOS_REGEX, 1))) { /* Realname replacement */ if (ServerOpts.hide_gcos_with_sgline) { realname = ServerOpts.realname_replacement; } else { return exit_client(sptr, sptr, ami->reason); } } return do_local_user(parv[0], cptr, sptr, username, host, NULL, server, 0, realname); }