Exemple #1
0
//Android
void FSinOscUGenInternal::processBlock(bool& shouldDelete, const unsigned int blockID, const int channel) throw()
{	
	float* outputSamples = uGenOutput.getSampleData();
	float newFreq = *(inputs[Freq].processBlock(shouldDelete, blockID, channel));
	double y0;
	
	LOCAL_DECLARE(double, b1);
	LOCAL_DECLARE(double, y1);
	LOCAL_DECLARE(double, y2);
	
	if(newFreq != currentFreq)
	{
		currentFreq = newFreq;
		
		double initialPhase;
		
		if((1.0-abs(y1)) < 0.00001)
		{
			initialPhase = y1 > 0.0 ? piOverTwo : -piOverTwo;
		}
		else
		{
			initialPhase = asin(y1);
			// based on the trajectory predict which solution of asin(y1) is correct..
			if(y2 >= y1)
			{
				double piVersion = y1 > 0.0 ? pi : -pi;			
				initialPhase = piVersion - initialPhase;
			}
		}
		
		double w = currentFreq * twoPi * UGen::getReciprocalSampleRate();
		
		b1 = zap(2. * cos(w));
		y1 = zap(sin(initialPhase));
		y2 = zap(sin(initialPhase-w));
	}
	
	int numSamplesToProcess = uGenOutput.getBlockSize();
	for(int i = 0; i < numSamplesToProcess; ++i)
	{
		y0 = b1 * y1 - y2;
		outputSamples[i] = y0;// = b1 * y1 - y2; 
		y2 = y1; 
		y1 = y0;
	}
	
	y1 = zap(y1);
	y2 = zap(y2);
	LOCAL_COPY(b1);
	LOCAL_COPY(y1);
	LOCAL_COPY(y2);
}
Exemple #2
0
/*
 * mr_capab - CAPAB message handler
 *      parv[1] = space-separated list of capabilities
 *
 */
static int
mr_capab(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	struct Capability *cap;
	int i;
	char *p;
	char *s;
	/* ummm, this shouldn't happen. Could argue this should be logged etc. */
	if (client_p->localClient == NULL)
		return 0;
	if (client_p->user)
		return 0;
	/* CAP_TS6 is set in PASS, so is valid.. */
	if ((client_p->localClient->caps & ~CAP_TS6) != 0) {
		exit_client(client_p, client_p, client_p, "CAPAB received twice");
		return 0;
	} else
		client_p->localClient->caps |= CAP_CAP;
	rb_free(client_p->localClient->fullcaps);
	client_p->localClient->fullcaps = rb_strdup(parv[1]);
	for (i = 1; i < parc; i++) {
		char *t = LOCAL_COPY(parv[i]);
		for (s = rb_strtok_r(t, " ", &p); s; s = rb_strtok_r(NULL, " ", &p)) {
			for (cap = captab; cap->name; cap++) {
				if (!irccmp(cap->name, s)) {
					client_p->localClient->caps |= cap->cap;
					break;
				}
			}
		}
	}
	return 0;
}
Exemple #3
0
static int
me_gcap(struct Client *client_p, struct Client *source_p,
        int parc, const char *parv[])
{
	struct Capability *cap;
	char *t = LOCAL_COPY(parv[1]);
	char *s;
	char *p;
	if (!IsServer(source_p))
		return 0;
	/* already had GCAPAB?! */
	if (!EmptyString(source_p->serv->fullcaps)) {
		source_p->serv->caps = 0;
		rb_free(source_p->serv->fullcaps);
	}
	source_p->serv->fullcaps = rb_strdup(parv[1]);
	for (s = rb_strtok_r(t, " ", &p); s; s = rb_strtok_r(NULL, " ", &p)) {
		for (cap = captab; cap->name; cap++) {
			if (!irccmp(cap->name, s)) {
				source_p->serv->caps |= cap->cap;
				break;
			}
		}
	}
	return 0;
}
Exemple #4
0
/*
 * create_timer_ref:  returns the lowest unused reference number for a timer
 * All refnums that are not already in use are valid.
 *
 * The user is allowed to use any string as a refnum, we dont really care.
 * Automatically assigned refnums (when the user doesnt specify one) will
 * always be one more than the highest pending refnum.
 *
 * "refnum_gets" must be REFNUM_MAX + 1 bytes by definition of API.
 */
static	int	create_timer_ref (const char *refnum_wanted, char *refnum_gets)
{
	Timer	*tmp;
	int 	refnum = 0;
	char	*refnum_want;

	/* Max of 10 characters. */
	refnum_want = LOCAL_COPY(refnum_wanted);
	if (strlen(refnum_want) > REFNUM_MAX)
		refnum_want[REFNUM_MAX] = 0;

	/* If the user doesnt care */
	if (*refnum_want == 0)
	{
		/* Find the lowest refnum available */
		for (tmp = PendingTimers; tmp; tmp = tmp->next)
		{
			if (refnum < my_atol(tmp->ref))
				refnum = my_atol(tmp->ref);
		}
		strlcpy(refnum_gets, ltoa(refnum+1), REFNUM_MAX + 1);
	}
	else
	{
		/* See if the refnum is available */
		if (get_timer(refnum_want))
			return -1;		/* Already in use */

		strlcpy(refnum_gets, refnum_want, REFNUM_MAX + 1);
	}

	return 0;
}
Exemple #5
0
static int
me_gcap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
		int parc, const char *parv[])
{
	char *t = LOCAL_COPY(parv[1]);
	char *s;
	char *p;

	if(!IsServer(source_p))
		return 0;

	/* already had GCAPAB?! */
	if(!EmptyString(source_p->serv->fullcaps))
	{
		source_p->serv->caps = 0;
		rb_free(source_p->serv->fullcaps);
	}

	source_p->serv->fullcaps = rb_strdup(parv[1]);

	for (s = rb_strtok_r(t, " ", &p); s; s = rb_strtok_r(NULL, " ", &p))
		source_p->serv->caps |= capability_get(serv_capindex, s);

	return 0;
}
Exemple #6
0
/*
 * do_notify: This simply goes through the notify list, sending out a WHOIS
 * for each person on it.  This uses the fancy whois stuff in whois.c to
 * figure things out.
 */
void do_notify(void)
{
	int	old_from_server = from_server;
	int	servnum;
	static	time_t		last_notify = 0;
	int		interval = get_int_var(NOTIFY_INTERVAL_VAR);
	time_t current_time = time(NULL);

	if (current_time < last_notify)
		last_notify = current_time;
	else if (!interval || interval > (current_time - last_notify))
		return;		/* Not yet */

	last_notify = current_time;

	if (!server_list_size() || !get_int_var(NOTIFY_VAR))
		return;
	for (servnum = 0; servnum < server_list_size(); servnum++)
	{
		if (is_server_connected(servnum) && !get_server_watch(servnum))
		{
			from_server = servnum;
			if (NOTIFY_LIST(servnum)->ison && *NOTIFY_LIST(servnum)->ison)
			{
				char *lame = LOCAL_COPY(NOTIFY_LIST(servnum)->ison);
				isonbase(lame, ison_notify);
			}
		}
	}
	from_server = old_from_server;
	return;
}
Exemple #7
0
/*
 * create_timer_ref:  returns the lowest unused reference number for a timer
 * All refnums that are not already in use are valid.
 *
 * The user is allowed to use any string as a refnum, we dont really care.
 * Automatically assigned refnums (when the user doesnt specify one) will
 * always be one more than the highest pending refnum.
 *
 * "refnum_gets" must be REFNUM_MAX + 1 bytes by definition of API.
 */
static	int	create_timer_ref (const char *refnum_wanted, char **refnum_gets)
{
	Timer	*tmp;
	int 	refnum = 0;
	char	*refnum_want;

	refnum_want = LOCAL_COPY(refnum_wanted);

	/* If the user doesnt care */
	if (*refnum_want == 0)
	{
		/* Find the lowest refnum available */
		for (tmp = PendingTimers; tmp; tmp = tmp->next)
		{
			if (refnum < my_atol(tmp->ref))
				refnum = my_atol(tmp->ref);
		}
		malloc_sprintf(refnum_gets, "%d", refnum + 1);
	}
	else
	{
		/* See if the refnum is available */
		if (get_timer(refnum_want))
			return -1;		/* Already in use */

		malloc_strcpy(refnum_gets, refnum_want);
	}

	return 0;
}
/*
** m_part
**      parv[0] = sender prefix
**      parv[1] = channel
**      parv[2] = reason
*/
static int
m_part(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	char *p, *name;
	char reason[REASONLEN + 1];
	char *s = LOCAL_COPY(parv[1]);

	reason[0] = '\0';

	if(parc > 2)
		strlcpy(reason, parv[2], sizeof(reason));

	name = strtoken(&p, s, ",");

	/* Finish the flood grace period... */
	if(MyClient(source_p) && !IsFloodDone(source_p))
		flood_endgrace(source_p);

	while (name)
	{
		part_one_client(client_p, source_p, name, reason);
		name = strtoken(&p, NULL, ",");
	}
	return 0;
}
Exemple #9
0
void SchmidtUGenInternal::processBlock(bool& shouldDelete, const unsigned int blockID, const int channel) throw()
{
	int numSamplesToProcess = uGenOutput.getBlockSize();
	float* outputSamples = uGenOutput.getSampleData();
	float* inputSamples = inputs[Input].processBlock(shouldDelete, blockID, channel);
	float* loSamples = inputs[Lo].processBlock(shouldDelete, blockID, channel);
	float* hiSamples = inputs[Hi].processBlock(shouldDelete, blockID, channel);
	
	LOCAL_DECLARE(float, state);
	
	while(numSamplesToProcess--)
	{
		float input = *inputSamples++;
		float lo = *loSamples++;
		float hi = *hiSamples++;
		
		if(state > 0.f)
		{
			if(input < lo) state = 0.f;
		}
		else
		{
			if(input > hi) state = 1.f;
		}
		
		*outputSamples++ = state;
	}
	
	LOCAL_COPY(state);
}
Exemple #10
0
/*
** m_quit
**      parv[1] = comment
*/
static int
m_quit(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
    char *comment = LOCAL_COPY((parc > 1 && parv[1]) ? parv[1] : client_p->name);
    char reason[REASONLEN + 1];

    source_p->flags |= FLAGS_NORMALEX;

    if(strlen(comment) > (size_t) REASONLEN)
        comment[REASONLEN] = '\0';

    strip_colour(comment);

    if(ConfigFileEntry.client_exit && comment[0]) {
        rb_snprintf(reason, sizeof(reason), "Quit: %s", comment);
        comment = reason;
    }

    if(!IsOper(source_p) && !EmptyString(ConfigFileEntry.static_quit)) {
        exit_client(client_p, source_p, source_p, ConfigFileEntry.static_quit);
        return 0;
    }

    if(!IsOper(source_p) &&
       (source_p->localClient->firsttime + ConfigFileEntry.anti_spam_exit_message_time) >
       rb_current_time()) {
        exit_client(client_p, source_p, source_p, "Client Quit");
        return 0;
    }

    exit_client(client_p, source_p, source_p, comment);

    return 0;
}
Exemple #11
0
/*
 * mr_capab - CAPAB message handler
 *      parv[1] = space-separated list of capabilities
 *
 */
static int
mr_capab(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	int i;
	char *p;
	char *s;

	/* ummm, this shouldn't happen. Could argue this should be logged etc. */
	if(client_p->localClient == NULL)
		return 0;

	if(client_p->user)
		return 0;

	/* CAP_TS6 is set in PASS, so is valid.. */
	if((client_p->localClient->caps & ~CAP_TS6) != 0)
	{
		exit_client(client_p, client_p, client_p, "CAPAB received twice");
		return 0;
	}
	else
		client_p->localClient->caps |= CAP_CAP;

	rb_free(client_p->localClient->fullcaps);
	client_p->localClient->fullcaps = rb_strdup(parv[1]);

	for (i = 1; i < parc; i++)
	{
		char *t = LOCAL_COPY(parv[i]);
		for (s = rb_strtok_r(t, " ", &p); s; s = rb_strtok_r(NULL, " ", &p))
			client_p->localClient->caps |= capability_get(serv_capindex, s);
	}

	return 0;
}
Exemple #12
0
char	*make_string_var(const char *var_name)
{
	int	cnt,
		msv_index;
	char	*ret = NULL;
	char	*copy;
	
	copy = LOCAL_COPY(var_name);
	upper(copy);

	if ((find_fixed_array_item (irc_variable, sizeof(IrcVariable), NUMBER_OF_VARIABLES, copy, &cnt, &msv_index) == NULL))
		return NULL;
	if (cnt >= 0)
		return NULL;
	switch (irc_variable[msv_index].type)
	{
		case STR_TYPE_VAR:
			ret = m_strdup(irc_variable[msv_index].string);
			break;
		case INT_TYPE_VAR:
			ret = m_strdup(ltoa(irc_variable[msv_index].integer));
			break;
		case BOOL_TYPE_VAR:
			ret = m_strdup(var_settings[irc_variable[msv_index].integer]);
			break;
		case CHAR_TYPE_VAR:
			ret = m_dupchar(irc_variable[msv_index].integer);
			break;
	}
	return ret;
}
Exemple #13
0
char *get_help_topic(char *args, int helpfunc)
{
char *new_comm = NULL;
int found = 0, i;
char *others = NULL;

	new_comm = LOCAL_COPY(args);

	for (i = 0; helpfunc ? script_help[i] : help_index[i]; i++)
	{
		if (!my_strnicmp(helpfunc?script_help[i]->title:help_index[i]->title, new_comm, strlen(new_comm)))
		{
			int j;
			char *text = NULL;
			if (found++)
			{
				m_s3cat(&others, " , ", helpfunc?script_help[i]->title:help_index[i]->title);
				continue;
			}
			if (args && *args && do_hook(HELPTOPIC_LIST, "%s", args))
				put_it("%s",convert_output_format("$G \002$0\002: Help on Topic: \002$1\002", version, args));
			for (j = 0; ; j++)
			{
				if (helpfunc && (script_help[i] && script_help[i]->contents[j]))
					text = script_help[i]->contents[j];
				else if (!helpfunc && (help_index[i] && help_index[i]->contents[j]))
					text = help_index[i]->contents[j];
				else 
					break;

				if (text && do_hook(HELPSUBJECT_LIST, "%s %s", new_comm, text))
				{
					in_chelp++;
					put_it("%s", convert_output_format(text, NULL));
					in_chelp--;
				}
			}		
			text = helpfunc ?script_help[i]->relates:help_index[i]->relates;
			if (text && do_hook(HELPTOPIC_LIST, "%s", text))
				put_it("%s", convert_output_format(text, NULL));
		}
		else if (found)
			break;
	}
	if (!found)
	{
		if (do_hook(HELPTOPIC_LIST, "%s", args))
			bitchsay("No help on %s", args);
	}

	if (others && found)
	{
		if (do_hook(HELPTOPIC_LIST, "%d %s", found, others))
			put_it("Other %d subjects: %s", found - 1, others);
	}
	new_free(&others);
	if (helpfunc)
		return m_strdup(empty_string);
	return NULL;
}
Exemple #14
0
static int
m_ison(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	struct Client *target_p;
	char *nick;
	char *p;
	char buf[IRCD_BUFSIZE];
	int i;

	memset(buf, 0, sizeof(buf));

	for(i = 1; i < parc; i++)
	{
		char *cs = LOCAL_COPY(parv[i]);
		for(nick = rb_strtok_r(cs, " ", &p); nick; nick = rb_strtok_r(NULL, " ", &p))
		{
			target_p = find_named_client(nick);

			if(target_p != NULL)
			{
				rb_strlcat(buf, target_p->name, sizeof(buf));
				rb_strlcat(buf, " ", sizeof(buf));
			}
		}
	}
	sendto_one_numeric(source_p, s_RPL(RPL_ISON), buf);
	return 0;

}
Exemple #15
0
/*
 * m_ison added by Darren Reed 13/8/91 to act as an efficent user indicator
 * with respect to cpu/bandwidth used. Implemented for NOTIFY feature in
 * clients. Designed to reduce number of whois requests. Can process
 * nicknames in batches as long as the maximum buffer length.
 *
 * format:
 * ISON :nicklist
 */
static int
m_ison(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	struct Client *target_p;
	char *nick;
	char *p;
	char *current_insert_point, *current_insert_point2;
	int len;
	int i;
	int done = 0;

	current_insert_point2 = buf2;
	*buf2 = '\0';

	rb_sprintf(buf, form_str(RPL_ISON), me.name, source_p->name);
	len = strlen(buf);
	current_insert_point = buf + len;

	/* rfc1489 is ambigious about how to handle ISON
	 * this should handle both interpretations.
	 */
	for(i = 1; i < parc; i++)
	{
		char *cs = LOCAL_COPY(parv[i]);
		for(nick = rb_strtok_r(cs, " ", &p); nick; nick = rb_strtok_r(NULL, " ", &p))
		{
			target_p = find_named_client(nick);

			if(target_p != NULL)
			{
				len = strlen(target_p->name);
				if((current_insert_point + (len + 5)) < (buf + sizeof(buf)))
				{
					memcpy(current_insert_point, target_p->name, len);
					current_insert_point += len;
					*current_insert_point++ = ' ';
				}
				else
				{
					done = 1;
					break;
				}
			}
		}
		if(done)
			break;
	}

	/*  current_insert_point--;
	 *  Do NOT take out the trailing space, it breaks ircII
	 *  --Rodder */

	*current_insert_point = '\0';
	*current_insert_point2 = '\0';

	sendto_one_buffer(source_p, buf);

	return 0;
}
Exemple #16
0
/*
 * me_forcenick
 *      parv[1] = forcenick victim
 *      parv[2] = new nickname 
 */
static int
me_forcenick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	struct Client *target_p, *exist_p;
	const char *user;
	const char *newnick;

	user = parv[1];

	/* We're supposed to drop servers over protocol violations, but shit happens... */

	if(EmptyString(parv[2]))
		return 0;
	else
	{
		char *s;
		s = LOCAL_COPY(parv[2]);
		if(strlen(s) > (size_t) NICKLEN)
			s[NICKLEN] = '\0';
		newnick = s;
	}

	if(!clean_nick(newnick))
		return 0;

	if((target_p = find_person(user)) == NULL)
		return 0;

	if(IsServer(target_p) || IsMe(target_p))
		return 0;

	if(!MyClient(target_p) && !IsOperGlobalForce(source_p))
		return 0;

	if((exist_p = find_person(newnick)) != NULL)
	{
		/* Could just be a case shift */
		if(irccmp(target_p->name, newnick))
			return 0;
		/* If it's the same nick, f**k it */
		else if(!strcmp(target_p->name, newnick))
			return 0;
	}

	ilog(L_MAIN, "FORCENICK called for [%s] by %s!%s@%s",
	     target_p->name, source_p->name, source_p->username, source_p->host);

	if(!MyClient(target_p))
	{
		struct Client *cptr = target_p->servptr;
		sendto_one(cptr, ":%s ENCAP %s FORCENICK %s :%s", 
				 get_id(source_p, cptr), cptr->name, get_id(target_p, cptr), newnick);
		return 0;
	}
	
	change_nick(target_p, newnick);

	return 0;
}
Exemple #17
0
static int
m_cycle(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
    char *p, *name;
    char *s = LOCAL_COPY(parv[1]);
    struct Channel *chptr;
    struct membership *msptr;

    name = rb_strtok_r(s, ",", &p);

    /* Finish the flood grace period... */
    if(MyClient(source_p) && !IsFloodDone(source_p))
        flood_endgrace(source_p);

    while(name) {
        if((chptr = find_channel(name)) == NULL) {
            sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
            return 0;
        }

        msptr = find_channel_membership(chptr, source_p);
        if(msptr == NULL) {
            sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), name);
            return 0;
        }

        if(MyConnect(source_p) && !IsOper(source_p) && !IsExemptSpambot(source_p))
            check_spambot_warning(source_p, NULL);

        if((is_any_op(msptr) || !MyConnect(source_p) ||
            ((can_send(chptr, source_p, msptr) > 0 &&
              (source_p->localClient->firsttime +
               ConfigFileEntry.anti_spam_exit_message_time) < rb_current_time())))) {
            sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
                          ":%s PART %s :Cycling", use_id(source_p), chptr->chname);
            sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :Cycling",
                                 source_p->name, source_p->username,
                                 source_p->host, chptr->chname);
        } else {
            sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
                          ":%s PART %s", use_id(source_p), chptr->chname);
            sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s",
                                 source_p->name, source_p->username,
                                 source_p->host, chptr->chname);
        }

        remove_user_from_channel(msptr);

        chptr = NULL;
        msptr = NULL;

        name = rb_strtok_r(NULL, ",", &p);
    }

    user_join(client_p, source_p, parv[1], parc > 2 ? parv[2] : NULL);

    return 0;
}
Exemple #18
0
/*
** ms_quit
**      parv[1] = comment
*/
static void
ms_quit(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	char *comment = LOCAL_COPY((parc > 1 && parv[1]) ? parv[1] : client_p->name);

	source_p->flags |= FLAGS_NORMALEX;
	if(strlen(comment) > (size_t) REASONLEN)
		comment[REASONLEN] = '\0';

	exit_client(client_p, source_p, source_p, comment);
}
Exemple #19
0
/*
 * create_timer_ref:  returns the lowest unused reference number for a timer
 * All refnums that are not already in use are valid.
 *
 * The user is allowed to use any string as a refnum, we dont really care.
 * Automatically assigned refnums (when the user doesnt specify one) will
 * always be one more than the highest pending refnum.
 *
 * "refnum_gets" must be REFNUM_MAX + 1 bytes by definition of API.
 */
static	int	create_timer_ref (const char *refnum_wanted, char **refnum_gets)
{
	Timer	*tmp;
	int 	refnum = 0;
	char	*refnum_want;
	int	i, pts;

	refnum_want = LOCAL_COPY(refnum_wanted);

	/* If the user doesnt care */
	if (*refnum_want == 0)
	{
		/* So ... we count the number of times that exist. */
		for (pts = 0, tmp = PendingTimers; tmp; tmp = tmp->next)
			pts++;

		/* 
		 * Now, for all the numbers (0 .. [timer count + 1]), 
		 * at least one of those numbers *has* to be available,
		 */ 
		for (i = 0; i <= pts + 1; i++)
		{
			/* Are any timers named 'i'? */
			for (tmp = PendingTimers; tmp; tmp = tmp->next)
			{
				if (!is_number(tmp->ref))
					continue;
				if (i == my_atol(tmp->ref))
					break;
			}

			/* 
			 * If 'tmp' is null, then we didn't find a refnum 'i'.
			 * So 'i' is our winner!
			 */
			if (tmp == NULL)
			{
				malloc_sprintf(refnum_gets, "%d", i);
				break;
			}
		}
	}
	else
	{
		/* See if the refnum is available */
		if (get_timer(refnum_want))
			return -1;		/* Already in use */

		malloc_strcpy(refnum_gets, refnum_want);
	}

	return 0;
}
Exemple #20
0
static void	add_user_end (int refnum, const char *from, const char *comm, const char **ArgList)
{
	char *	copy;
	char *	channel;

	if (!ArgList[0])
		{ rfc1459_odd(from, "*", ArgList); return; }

	copy = LOCAL_COPY(ArgList[0]);
	channel = next_arg(copy, &copy);
	channel_not_waiting(channel, refnum);
}
Exemple #21
0
/*
 * lookup_function:  When you want to convert a "binding" name (such as
 * BACKSPACE or SELF_INSERT) over to its offset in the binding lookup table,
 * you must call this function to retreive that offset.  The first argument
 * is the name you want to look up, and the second argument is where the
 * offset is to be stored.  
 *
 * Return value: (its tricky)
 *	-1	  -- The name is a META binding that is invalid.
 *	Zero	  -- The name is not a valid binding name.
 *	One	  -- The name is a valid, unambiguous binding name.
 *		     If it is a META binding, lf_index will be negative,
 *		     Otherwise, lf_index will be positive.
 *	Other	  -- The name is an ambiguous (therefore invalid) binding name.
 *
 * In the case of a return value of any positive value, "lf_index" will be
 * set to the first item that matches the 'name'.  For all other return
 * values, "lf_index" will have the value -1.
 */
static int 	lookup_function (const uc *orig_name, int *lf_index)
{
	int	len,
		cnt,
		i;
	uc	*name, *breakage;

	if (!orig_name)
	{
		*lf_index = 0;
		return 1;
	}

	breakage = name = LOCAL_COPY(orig_name);
	upper(name);
	len = strlen(name);

	*lf_index = -1;

	/* Handle "META" descriptions especially. */
	if (!strncmp(name, "META", 4))
	{
		const uc *	endp;
		int		meta;

		if ((meta = grok_meta(name, &endp)) < 0)
			return meta;
		else
		{
			*lf_index = -meta;
			return 1;
		}
	}

	for (cnt = 0, i = 0; i < NUMBER_OF_FUNCTIONS; i++)
	{
		if (strncmp(name, key_names[i].name, len) == 0)
		{
			cnt++;
			if (*lf_index == -1)
				*lf_index = i;
		}
	}
	if (*lf_index == -1)
		return 0;
	if (strcmp(name, key_names[*lf_index].name) == 0)
		return 1;
	else
		return cnt;
}
Exemple #22
0
static int
me_forcepart(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
    struct Client *target_p;
    const char *user, *channels, *reason;
    const char default_reason[] = "Leaving";
    int chasing = 0;

    user = parv[1];
    channels = parv[2];

    if(EmptyString(parv[2]))
        return 0;
    else
        channels = parv[2];

    if(EmptyString(parv[3]))
        reason = default_reason;
    else
    {
        char *s;
        s = LOCAL_COPY(parv[3]);
        if(strlen(s) > (size_t) REASONLEN)
            s[REASONLEN] = '\0';
        reason = s;
    }

    /* Find the user */
    if((target_p = find_chasing(source_p, user, &chasing)) == NULL)
        return 0;

    if(IsServer(target_p) || IsMe(target_p))
        return 0;

    ilog(L_MAIN, "FORCEPART called for [%s] by %s!%s@%s",
         target_p->name, source_p->name, source_p->username, source_p->host);

    if(!MyClient(target_p))
    {
        struct Client *cptr = target_p->servptr;
        sendto_one(cptr, ":%s ENCAP %s FORCEPART %s :%s",
                   get_id(source_p, cptr), cptr->name, get_id(target_p, cptr), channels);
        return 0;
    }

    forcepart_channels(client_p, source_p, target_p, channels, reason);

    return 0;
}
Exemple #23
0
char 	*make_string_var (const char *var_name)
{
	char *	(*dummy) (void);
	IrcVariable *thevar = NULL;
	char	*copy;

	copy = LOCAL_COPY(var_name);
	upper(copy);

	get_var_alias(copy, &dummy, &thevar);
	if (thevar == NULL)
		return NULL;

	return make_string_var_bydata(thevar->type, thevar->data);
}
Exemple #24
0
/*
** ms_eob
**      parv[0] = sender prefix
**      parv[1] = opt. comma separated list of SIDs for which this EOB is
**                also valid
*/
static int
ms_eob(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	char *copy, *state, *id;
	struct Client *target_p;
	int act = 0;

	if(!HasSentEob(source_p))
	{
		if(MyConnect(source_p))
		{
			sendto_realops_flags(UMODE_ALL, L_ALL,
					     "End of burst from %s (%d seconds)",
					     source_p->name,
					     (signed int)(rb_current_time() -
							  source_p->localClient->firsttime));
			sendto_one(source_p, ":%s EOBACK", me.id);
		}
		act = 1;
		SetEob(source_p);
		eob_count++;
	}
	if(parc > 1 && *parv[1] != '\0')
	{
		copy = LOCAL_COPY(parv[1]);
		for(id = rb_strtok_r(copy, ",", &state); id != NULL;
				id = rb_strtok_r(NULL, ",", &state))
		{
			target_p = find_id(id);
			if(target_p != NULL && IsServer(target_p) &&
					target_p->from == client_p &&
					!HasSentEob(target_p))
			{
				SetEob(target_p);
				eob_count++;
				act = 1;
			}
		}
	}
	if(!act)
		return 0;
	sendto_server(client_p, NULL, CAP_IRCNET, NOCAPS, ":%s EOB%s%s",
			source_p->id,
			parc > 1 ? " :" : "", parc > 1 ? parv[1] : "");

	return 0;
}
Exemple #25
0
int pub_proc(char *which, char *str, char **unused) {
	char *loc, *nick, *chan, *cmd, *serv;
	unsigned short port = 0;

	if(qbx_on == 0) return 1;
	loc = LOCAL_COPY(str);
	nick = next_arg(loc, &loc);
	chan = next_arg(loc, &loc);
	cmd = next_arg(loc, &loc);
	if(cmd && *cmd != '!') return 1;
	if(my_stricmp(cmd, Q3A_COMMAND) && my_stricmp(cmd, Q2_COMMAND) && my_stricmp(cmd, QW_COMMAND))
		return 1;
	serv = next_arg(loc, &loc);
	if(serv == NULL) {
		privmsg(chan, "%s: Give me a server to query", nick);
		return 1;
	}
	if(querying == 1) {
		privmsg(chan, "%s: A query is already in progress", nick);
		return 1;
	}
	if(strchr(serv, ':')) {
		serv = strtok(serv, ":");
		port = atoi(strtok(NULL, ""));
	}
	else
		port = 0;
	strncpy(q_chan, chan, 256);
	if(!my_stricmp(cmd, Q3A_COMMAND)) { /* quake3 server (my fav =) */
		if(port == 0) port = Q3A_GAME_PORT;
		query_q_server(serv, port, 3);
		return 1;
	}
	else if(!my_stricmp(cmd, Q2_COMMAND)) { /* quake2 server */
		if(port == 0) port = Q2_GAME_PORT;
		query_q_server(serv, port, 2);
		return 1;
	}
	else if(!my_stricmp(cmd, QW_COMMAND)) { /* quakeworld server */
		if(port == 0) port = QW_GAME_PORT;
		query_q_server(serv, port, 1);
		return 1;
	}
	return 1;
}
Exemple #26
0
void amsg(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg) {
	char *nick,*nnick,*loc;
	
	CHECK_TOC_ONLINE();
	
	/* loc = msg, nick = username to send msg to */
	loc = LOCAL_COPY(args);
	nick = new_next_arg(loc, &loc);
	
	REQUIRED_ARG(nick,command,helparg);
	
	if ( nick[0] == '#' ) {
		struct buddy_chat *b;
		nick++;
		REQUIRED_ARG(nick,command,helparg);
		b = (struct buddy_chat *) find_buddy_chat(nick);
		if ( ! b ) {
			statusprintf("Error not on buddy chat %s", nick);
			return;
		}
		/* chatprintf("sent msg %s to buddy chat %s",loc,nick); */
		serv_chat_send(b->id,loc);
	} else {
		char *ruser,*rnick;
		nnick = (char *) malloc(strlen(nick)+10);
		rnick = rm_space(nick);
		ruser = rm_space(get_dllstring_var("aim_user"));
		sprintf(nnick,"%s@AIM",rnick);
		msgprintf("%s", cparse(fget_string_var(FORMAT_SEND_MSG_FSET), 
			"%s %s %s %s",update_clock(GET_TIME), 
			nnick, ruser, loc));
		serv_send_im(nick,loc);
		RemoveFromLLByKey(msgdthem,rnick);
		AddToLL(msgdthem,rnick,NULL);
#ifdef BITCHX_PATCH
		tks.list = 0;
		tks.pos = -1;
#endif		
		free(rnick); free(ruser);
	}	
	
	debug_printf("sending msg to %s '%s'",nick,loc);	
	return;
}
Exemple #27
0
/*
 * m_pass() - Added Sat, 4 March 1989
 *
 *
 * mr_pass - PASS message handler
 *      parv[1] = password
 *      parv[2] = "TS" if this server supports TS.
 *      parv[3] = optional TS version field -- needed for TS6
 */
static int
mr_pass(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
    char *pass, *buf;
    buf = LOCAL_COPY(parv[1]);

    if(client_p->localClient->passwd) {
        memset(client_p->localClient->passwd, 0,
               strlen(client_p->localClient->passwd));
        rb_free(client_p->localClient->passwd);
        client_p->localClient->passwd = NULL;
    }

    pass = buf;

    client_p->localClient->passwd = *pass ? rb_strndup(pass, PASSWDLEN) : NULL;

    /* These are for servers only */
    if(parc > 2 && client_p->user == NULL) {
        /*
         * It looks to me as if orabidoo wanted to have more
         * than one set of option strings possible here...
         * i.e. ":AABBTS" as long as TS was the last two chars
         * however, as we are now using CAPAB, I think we can
         * safely assume if there is a ":TS" then its a TS server
         * -Dianora
         */
        if(irccmp(parv[2], "TS") == 0 && client_p->tsinfo == 0)
            client_p->tsinfo = TS_DOESTS;

        if(parc == 5 && atoi(parv[3]) >= 6) {
            /* only mark as TS6 if the SID is valid.. */
            if(IsDigit(parv[4][0]) && IsIdChar(parv[4][1]) &&
               IsIdChar(parv[4][2]) && parv[4][3] == '\0' &&
               EmptyString(client_p->id)) {
                client_p->localClient->caps |= CAP_TS6;
                strcpy(client_p->id, parv[4]);
            }
        }
    }

    return 0;
}
Exemple #28
0
int 	kill_message (const char *from, const char *cline)
{
	char *poor_sap;
	char *bastard;
	const char *path_to_bastard;
	char *reason;
	char *line;

	line = LOCAL_COPY(cline);
	poor_sap = next_arg(line, &line);

	/* Dalnet kill BBC and doesnt append the period */
	if (!end_strcmp(poor_sap, ".", 1))
		chop(poor_sap, 1);

	/* dalnet kill BBC and doesnt use "From", but "from" */
	if (my_strnicmp(line, "From ", 5))
	{
		yell("Attempted to parse an ill-formed KILL request [%s %s]",
			poor_sap, line);
		return 0;
	}
	line += 5;
	bastard = next_arg(line, &line);

	/* Hybrid BBC and doesn't include the kill-path. */
	/* Fend off future BBC kills */
	if (my_strnicmp(line, "Path: ", 6))
	{
		path_to_bastard = "*";
		reason = line;		/* Hope for the best */
	}
	else
	{
		line += 6;
		path_to_bastard = next_arg(line, &line);
		reason = line;
	}

	return !do_hook(KILL_LIST, "%s %s %s %s %s", from, poor_sap, bastard,
					path_to_bastard, reason);
}
Exemple #29
0
void TableOscUGenInternal::processBlock(bool& shouldDelete, const unsigned int blockID, const int channel) throw()
{	
	float tableSizeOverSampleRate = UGen::getReciprocalSampleRate() * wavetableSize;
	int numSamplesToProcess = uGenOutput.getBlockSize();
	float* outputSamples = uGenOutput.getSampleData();
	float* freqSamples = inputs[Freq].processBlock(shouldDelete, blockID, channel);
	LOCAL_DECLARE(float, currentPhase);
	LOCAL_DECLARE(float, wavetableSize);
	
	while(numSamplesToProcess--)
	{
		*outputSamples++ = lookupIndex(currentPhase);
		currentPhase += *freqSamples++ * tableSizeOverSampleRate;
		
		if(currentPhase >= wavetableSize)	currentPhase -= wavetableSize;
		else if(currentPhase < 0.f)			currentPhase += wavetableSize;
	}
	
	LOCAL_COPY(currentPhase);
}
Exemple #30
0
static void
verify_logfile_access(const char *filename)
{
	char *dirname, *d;
	char buf[512];
	d = rb_dirname(filename);
	dirname = LOCAL_COPY(d);
	rb_free(d);
	
	if(access(dirname, F_OK) == -1)
	{
		rb_snprintf(buf, sizeof(buf), "WARNING: Unable to access logfile %s - parent directory %s does not exist", filename, dirname);
		if(testing_conf || server_state_foreground)
			fprintf(stderr, "%s\n", buf);
		sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s", buf);
		return;
	}

	if(access(filename, F_OK) == -1)
	{
		if(access(dirname, W_OK) == -1)
		{
			rb_snprintf(buf, sizeof(buf), "WARNING: Unable to access logfile %s - access to parent directory %s failed: %s", 
				    filename, dirname, strerror(errno));
			if(testing_conf || server_state_foreground)
				fprintf(stderr, "%s\n", buf);
			sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s", buf);
		}
		return;
	}
	
	if(access(filename, W_OK) == -1)
	{
		rb_snprintf(buf, sizeof(buf), "WARNING: Access denied for logfile %s: %s", filename, strerror(errno));
		if(testing_conf || server_state_foreground)
			fprintf(stderr, "%s\n", buf);	
		sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s", buf);
		return;
	}
	return;
}