Exemple #1
0
void		my_cmd2(char **com, int const cfd)
{
  if (strcmp(com[0], "/part") == 0)
    cmd_part(com, cfd);
  else if (strcmp(com[0], "/list") == 0)
    cmd_list(com, cfd);
  else if (strcmp(com[0], "/quit") == 0)
    cmd_quit(com, cfd);
  else if (strcmp(com[0], "/users") == 0)
    cmd_users(com, cfd);
  else if (strcmp(com[0], "/msg") == 0)
    cmd_mp(com, cfd);
  else if (strcmp(com[0], "/topic") == 0)
    cmd_topic(com, cfd);
  else if (strcmp(com[0], "/kick") == 0)
    cmd_kick(com, cfd);
  else if (strcmp(com[0], "/kill") == 0)
    cmd_kill(com, cfd);
  else if (strcmp(com[0], "/ping") == 0)
    dprintf(cfd, "PING \r\n");
  else
    cmd_msg(com, cfd);
}
Exemple #2
0
/* chatbuf points to the auto array in rcv_chat + 1 */
void
command_chat (struct htlc_conn *htlc, u_int32_t cid, char *chatbuf)
{
	if (!chatbuf[0])
		return;
	switch (chatbuf[0]) {
		case '0':
			if (!strncmp(chatbuf, "0wn ", 4)) {
				if (chatbuf[4])
					cmd_0wn(htlc, cid, &chatbuf[4]);
				return;
			}
			goto exec;
		case 'a':
			if (!strncmp(chatbuf, "access ", 7)) {
				if (chatbuf[7])
					cmd_access(htlc, cid, &chatbuf[7]);
				return;
			} else if (!strncmp(chatbuf, "away", 4)) {
				if (htlc->flags.away == AWAY_INTERRUPTED)
					return;
				toggle_away(htlc);
				if (!htlc->flags.away)
					htlc->flags.away = AWAY_PERM;
				else
					htlc->flags.away = 0;
				if (hxd_cfg.options.away_time) {
					timer_delete_ptr(htlc);
					if (!htlc->flags.away)
						timer_add_secs(hxd_cfg.options.away_time, away_timer, htlc);
				}
				return;
			} else if (!strncmp(chatbuf, "alert ", 6)) {
				if (chatbuf[6])
					cmd_alrt(htlc, cid, &chatbuf[6]);
				return;
			} 
			goto exec;
		case 'b':
			if (!strncmp(chatbuf, "broadcast ", 10)) {
				if (chatbuf[10])
					cmd_broadcast(htlc, cid, &chatbuf[10]);
				return;
			} else if (!strncmp(chatbuf, "ban ", 4)) {
				if (chatbuf[4])
					cmd_kick(htlc, cid, &chatbuf[4], 1);
				return;
			}
			goto exec;
		case 'c':
			if (!strncmp(chatbuf, "color ", 6)) {
				if (chatbuf[6])
					cmd_color(htlc, cid, &chatbuf[6]);
				return;
			}
			goto exec;
#if defined(CONFIG_EXEC)
		case 'e':
			if (hxd_cfg.operation.exec) {
				if (!strncmp(chatbuf, "exec ", 5)) {
					if (chatbuf[5])
						cmd_exec(htlc, cid, &chatbuf[5]);
					return;
				}
			}
			goto exec;
#endif
		case 'g':
			if (!strncmp(chatbuf, "g0away", 6)) {
				cmd_visible(htlc, cid);
				return;
			}
			goto exec;
		case 'k':
			if (!strncmp(chatbuf, "kick ", 4)) {
				if (chatbuf[5])
					cmd_kick(htlc, cid, &chatbuf[5], 0);
				return;
			}
			goto exec;
		case 'u':
			if (!strncmp(chatbuf, "users", 5)) {
				cmd_users(htlc, cid);
				return;
			}
			goto exec;
		case 'v':
			if (!strncmp(chatbuf, "visible", 7)) {
				cmd_visible(htlc, cid);
				return;
			} else if (!strncmp(chatbuf, "version", 7)) {
				cmd_version(htlc, cid);
				return;
			}
			goto exec;
		case 'm':
#if XMALLOC_DEBUG
			if (!strncmp(chatbuf, "maltbl", 6) && htlc->access_extra.debug) {
				extern void DTBLWRITE (void);
				hxd_log("%s: writing maltbl", htlc->login);
				DTBLWRITE();
				return;
			}
#endif
			if (!strncmp(chatbuf, "me ", 3)) {
				if (chatbuf[3])
					cmd_me(htlc, cid, &chatbuf[3]);
				return;
			} else if (!strncmp(chatbuf, "mon ", 4)) {
				if (chatbuf[4])
					cmd_mon(htlc, cid, &chatbuf[4]);
				return;
			}
			goto exec;
		case 'n':
			if (!strncmp(chatbuf, "nick ", 5) && (htlc->access.use_any_name && !htlc->access_extra.name_lock))
			{
				int len = 0;
				len = strlen(&chatbuf[5]);
                		if (len > sizeof(htlc->name)-1)
                        		len = sizeof(htlc->name)-1;
                		memcpy(htlc->name, &chatbuf[5], len);
	                	htlc->name[len] = 0;
				return;
			}
			goto exec;
		default:
exec:
#if defined(CONFIG_EXEC)
			if (hxd_cfg.operation.exec) {
				cmd_exec(htlc, cid, chatbuf);
			} else 
#endif
				cmd_notfound(htlc, cid, chatbuf);
			break;
	}
}