summaryrefslogtreecommitdiff
path: root/src/irc/core/irc.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-03-18 23:00:53 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-03-18 23:00:53 +0000
commit93141c3a869ba8e32a4aab9eb627e78d91e57e3a (patch)
treeeaf91e5feb0b8fd5638f06d8c5f7f4ca657b5bf5 /src/irc/core/irc.c
parent4a967a5d5c2fbf8e4cda3b24d79c454e0e1fea69 (diff)
downloadirssi-93141c3a869ba8e32a4aab9eb627e78d91e57e3a.zip
/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
Diffstat (limited to 'src/irc/core/irc.c')
-rw-r--r--src/irc/core/irc.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/irc/core/irc.c b/src/irc/core/irc.c
index c894adc5..7af48fe2 100644
--- a/src/irc/core/irc.c
+++ b/src/irc/core/irc.c
@@ -42,25 +42,32 @@ static int signal_server_incoming;
# define MAX_SOCKET_READS 5
#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;
+ len = strlen(cmd);
server->cmdcount++;
if (send_now)
rawlog_output(server->rawlog, cmd);
- /* just check that we don't send any longer commands than 512 bytes.. */
- strncpy(str, cmd, 510);
- len = strlen(cmd);
- if (len > 510) len = 510;
- str[len++] = 13; str[len++] = 10; str[len] = '\0';
+ if (!raw) {
+ /* check that we don't send any longer commands
+ than 512 bytes. also add the line feed. */
+ strncpy(str, cmd, 510);
+ if (len > 510) len = 510;
+ str[len++] = 13; str[len++] = 10; str[len] = '\0';
+ cmd = str;
+ }
- ptr = str;
if (send_now) {
- if (net_sendbuffer_send(server->handle, str, len) == -1) {
+ if (net_sendbuffer_send(server->handle, cmd, len) == -1) {
/* something bad happened */
server->connection_lost = TRUE;
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 */
- ptr = g_strdup(ptr);
- if (!immediate)
- server->cmdqueue = g_slist_append(server->cmdqueue, ptr);
- else
- server->cmdqueue = g_slist_prepend(server->cmdqueue, ptr);
+ server->cmdqueue = immediate ?
+ g_slist_prepend(server->cmdqueue, g_strdup(cmd)) :
+ g_slist_append(server->cmdqueue, g_strdup(cmd));
}
/* 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->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 */
@@ -118,7 +123,7 @@ void irc_send_cmd_now(IRC_SERVER_REC *server, const char *cmd)
g_return_if_fail(cmd != NULL);
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)