1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

/RAWQUOTE: like /QUOTE, but don't add line feed after the command, and don't

truncate line to 512 bytes.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1410 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-03-18 23:00:53 +00:00 committed by cras
parent 4a967a5d5c
commit 93141c3a86
3 changed files with 38 additions and 16 deletions

View File

@ -571,6 +571,16 @@ static void cmd_quote(const char *data, IRC_SERVER_REC *server)
irc_send_cmd(server, data); irc_send_cmd(server, data);
} }
/* SYNTAX: RAWQUOTE <data> */
static void cmd_rawquote(const char *data, IRC_SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (server == NULL || !IS_IRC_SERVER(server))
cmd_return_error(CMDERR_NOT_CONNECTED);
irc_send_cmd_full(server, data, FALSE, FALSE, TRUE);
}
static void cmd_wall_hash(gpointer key, NICK_REC *nick, GSList **nicks) static void cmd_wall_hash(gpointer key, NICK_REC *nick, GSList **nicks)
{ {
if (nick->op) *nicks = g_slist_append(*nicks, nick); if (nick->op) *nicks = g_slist_append(*nicks, nick);
@ -1045,6 +1055,7 @@ void irc_commands_init(void)
/* SYNTAX: USERHOST <nicks> */ /* SYNTAX: USERHOST <nicks> */
command_bind("userhost", NULL, (SIGNAL_FUNC) command_self); command_bind("userhost", NULL, (SIGNAL_FUNC) command_self);
command_bind("quote", NULL, (SIGNAL_FUNC) cmd_quote); command_bind("quote", NULL, (SIGNAL_FUNC) cmd_quote);
command_bind("rawquote", NULL, (SIGNAL_FUNC) cmd_rawquote);
command_bind("wall", NULL, (SIGNAL_FUNC) cmd_wall); command_bind("wall", NULL, (SIGNAL_FUNC) cmd_wall);
command_bind("wait", NULL, (SIGNAL_FUNC) cmd_wait); command_bind("wait", NULL, (SIGNAL_FUNC) cmd_wait);
/* SYNTAX: WALLOPS <message> */ /* SYNTAX: WALLOPS <message> */
@ -1118,6 +1129,7 @@ void irc_commands_deinit(void)
command_unbind("uping", (SIGNAL_FUNC) command_self); command_unbind("uping", (SIGNAL_FUNC) command_self);
command_unbind("userhost", (SIGNAL_FUNC) command_self); command_unbind("userhost", (SIGNAL_FUNC) command_self);
command_unbind("quote", (SIGNAL_FUNC) cmd_quote); command_unbind("quote", (SIGNAL_FUNC) cmd_quote);
command_unbind("rawquote", (SIGNAL_FUNC) cmd_rawquote);
command_unbind("wall", (SIGNAL_FUNC) cmd_wall); command_unbind("wall", (SIGNAL_FUNC) cmd_wall);
command_unbind("wait", (SIGNAL_FUNC) cmd_wait); command_unbind("wait", (SIGNAL_FUNC) cmd_wait);
command_unbind("wallops", (SIGNAL_FUNC) command_1self); command_unbind("wallops", (SIGNAL_FUNC) command_1self);

View File

@ -42,25 +42,32 @@ static int signal_server_incoming;
# define MAX_SOCKET_READS 5 # define MAX_SOCKET_READS 5
#endif #endif
static void cmd_send(IRC_SERVER_REC *server, const char *cmd, int send_now, int immediate) /* The core of the irc_send_cmd* functions. If `raw' is TRUE, the `cmd'
won't be checked at all if it's 512 bytes or not, or if it contains
line feeds or not. Use with extreme caution! */
void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd,
int send_now, int immediate, int raw)
{ {
char str[513], *ptr; char str[513];
int len; int len;
len = strlen(cmd);
server->cmdcount++; server->cmdcount++;
if (send_now) if (send_now)
rawlog_output(server->rawlog, cmd); rawlog_output(server->rawlog, cmd);
/* just check that we don't send any longer commands than 512 bytes.. */ if (!raw) {
strncpy(str, cmd, 510); /* check that we don't send any longer commands
len = strlen(cmd); than 512 bytes. also add the line feed. */
if (len > 510) len = 510; strncpy(str, cmd, 510);
str[len++] = 13; str[len++] = 10; str[len] = '\0'; if (len > 510) len = 510;
str[len++] = 13; str[len++] = 10; str[len] = '\0';
cmd = str;
}
ptr = str;
if (send_now) { if (send_now) {
if (net_sendbuffer_send(server->handle, str, len) == -1) { if (net_sendbuffer_send(server->handle, cmd, len) == -1) {
/* something bad happened */ /* something bad happened */
server->connection_lost = TRUE; server->connection_lost = TRUE;
server_disconnect(SERVER(server)); server_disconnect(SERVER(server));
@ -72,11 +79,9 @@ static void cmd_send(IRC_SERVER_REC *server, const char *cmd, int send_now, int
} }
/* add to queue */ /* add to queue */
ptr = g_strdup(ptr); server->cmdqueue = immediate ?
if (!immediate) g_slist_prepend(server->cmdqueue, g_strdup(cmd)) :
server->cmdqueue = g_slist_append(server->cmdqueue, ptr); g_slist_append(server->cmdqueue, g_strdup(cmd));
else
server->cmdqueue = g_slist_prepend(server->cmdqueue, ptr);
} }
/* Send command to IRC server */ /* Send command to IRC server */
@ -93,7 +98,7 @@ void irc_send_cmd(IRC_SERVER_REC *server, const char *cmd)
(server->cmdcount < server->max_cmds_at_once || (server->cmdcount < server->max_cmds_at_once ||
server->cmd_queue_speed <= 0); server->cmd_queue_speed <= 0);
cmd_send(server, cmd, send_now, FALSE); irc_send_cmd_full(server, cmd, send_now, FALSE, FALSE);
} }
/* Send command to IRC server */ /* Send command to IRC server */
@ -118,7 +123,7 @@ void irc_send_cmd_now(IRC_SERVER_REC *server, const char *cmd)
g_return_if_fail(cmd != NULL); g_return_if_fail(cmd != NULL);
if (server == NULL) return; if (server == NULL) return;
cmd_send(server, cmd, TRUE, TRUE); irc_send_cmd_full(server, cmd, TRUE, TRUE, FALSE);
} }
static char *split_nicks(const char *cmd, char **pre, char **nicks, char **post, int arg) static char *split_nicks(const char *cmd, char **pre, char **nicks, char **post, int arg)

View File

@ -44,6 +44,11 @@ void irc_send_cmd_split(IRC_SERVER_REC *server, const char *cmd,
/* Send command to server immediately bypassing all flood protections /* Send command to server immediately bypassing all flood protections
and queues. */ and queues. */
void irc_send_cmd_now(IRC_SERVER_REC *server, const char *cmd); void irc_send_cmd_now(IRC_SERVER_REC *server, const char *cmd);
/* The core of the irc_send_cmd* functions. If `raw' is TRUE, the `cmd'
won't be checked at all if it's 512 bytes or not, or if it contains
line feeds or not. Use with extreme caution! */
void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd,
int send_now, int immediate, int raw);
#include "commands.h" /* contains the generic PARAM_FLAG_xxx defines */ #include "commands.h" /* contains the generic PARAM_FLAG_xxx defines */