All pastes #919603 Raw Edit

Someone

public c v1 · immutable
#919603 ·published 2008-02-26 21:55 UTC
rendered paste body
/* * m_notice - generic message handler */int m_notice(struct Client* cptr, struct Client* sptr, int parc, char* parv[]){  char*           name;  char*           server;  char*		  temp; /* added by Vadtec 02/25/2008 */  char*		  parv_temp; /* added by Vadtec 02/26/2008 */  int             found_g = 0; /* added by Vadtec 02/26/2008 */  int             i;  int             j;  int             fd = 0;  int             count;  char*           vector[MAXTARGETS];  struct User*     user = cli_user(sptr);  struct Client *acptr;  assert(0 != cptr);  assert(cptr == sptr);  ClrFlag(sptr, FLAG_TS8);  if (parc < 2 || EmptyString(parv[1]))    return send_reply(sptr, ERR_NORECIPIENT, MSG_NOTICE);  if (parc < 3 || EmptyString(parv[parc - 1]))    return send_reply(sptr, ERR_NOTEXTTOSEND);  if (parv[1][0] == '@' && IsChannelPrefix(parv[1][1])) {    parv[1]++;                        /* Get rid of '@' */    return m_wallchops(cptr, sptr, parc, parv);  }  count = unique_name_vector(parv[1], ',', vector, MAXTARGETS);  for (i = 0; i < count; ++i) {    name = vector[i];    if (feature_bool(FEAT_CTCP_VERSIONING) && MyConnect(sptr)) {       /*          Added by Vadtec 02/25/2008.          This is so that we can do version checking (and banning) of connecting clients.          Rules: Only one really. CTCP VERSION is not part of the RFC and therefore clients are not required to respond to          a request for their version.          NOTE: If we are lucky enough to have _GNU_SOURCE, we will use it over the standard strstr because its case insensetive.          TODO: Write a function (clean_control_codes) to strip out all control codes to remove formatting from the string.       */	for (fd = HighestFd; fd >= 0; --fd) {		/*		 * get the users!		*/		if ((acptr = LocalClientArray[fd])) {			if (!cli_user(acptr))				continue;			#ifdef _GNU_SOURCE			if ((temp = strcasestr(parv[2], "VERSION"))) {			#else			if ((temp = strstr(parv[2], "VERSION")) || (temp = strstr(parv[2], "version"))) {			#endif				temp = strchr(parv[2], ' ');				parv_temp = parv[2];				j = 0;				while (j <= (temp - parv[2])) { parv_temp++; j++; }				ircd_strncpy(sptr->cli_version, parv_temp, VERSIONLEN);				sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :CTCP REPLY PARSED: %s", sptr, cli_version(sptr));				char* buff[] = {					name,					cli_name(sptr),					name				};				if ((found_g = find_kill(acptr))) {					/*sendto_opmask_butone(0, found_g == -2 ? SNO_GLINE : SNO_OPERKILL,							       found_g == -2 ? "G-line active for %s%s" :							       "K-line active for %s%s",							       IsUnknown(sptr) ? "Unregistered Client ":"",							       get_client_name(sptr, SHOW_IP));*/					/*if (exit_client(cptr, acptr, &me, found_g == -2 ? "G-lined - Version Ban" :					      "K-lined - Version Ban") == CPTR_KILLED)*/					if (exit_client_msg(sptr, acptr, &me, "K-lined (%s)", cli_version(acptr)) == CPTR_KILLED)					/*if (ms_kill((struct Client *)&me, sptr, 3, buff))*/					/*if (do_kill(cptr, sptr, acptr, name, name, "K-lined - Version Ban") == CPTR_KILLED)*/						return 0;				}			}		}	}    }    /*     * channel msg?     */    if (IsChannelPrefix(*name)) {      relay_channel_notice(sptr, name, parv[parc - 1], count);    }    /*     * we have to check for the '@' at least once no matter what we do     * handle it first so we don't have to do it twice     */    else if ((server = strchr(name, '@')))      relay_directed_notice(sptr, name, server, parv[parc - 1]);    else       relay_private_notice(sptr, name, parv[parc - 1]);  }  return 0;}