mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 12:56:37 +02:00
make possible to run more than one command when connecting to server
This commit is contained in:
+48
-5
@@ -2431,7 +2431,8 @@ irc_cmd_recv_topic (t_irc_server *server, char *host, char *nick, char *argument
|
||||
int
|
||||
irc_cmd_recv_004 (t_irc_server *server, char *host, char *nick, char *arguments)
|
||||
{
|
||||
char *pos;
|
||||
char *pos, *buffer, *s, *q;
|
||||
int i, f;
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
pos = strchr (arguments, ' ');
|
||||
@@ -2454,11 +2455,53 @@ irc_cmd_recv_004 (t_irc_server *server, char *host, char *nick, char *arguments)
|
||||
/* execute command once connected */
|
||||
if (server->command && server->command[0])
|
||||
{
|
||||
user_command (server, NULL, server->command);
|
||||
if (server->command_delay > 0)
|
||||
sleep (server->command_delay);
|
||||
/* splitting command on ';' which can be escaped with '\;' */
|
||||
buffer = (char *) malloc ( (strlen(server->command) + 1) * sizeof (char));
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
s = server->command;
|
||||
i = 0;
|
||||
while(*s != '\0')
|
||||
{
|
||||
f = 0;
|
||||
if (*s == ';')
|
||||
{
|
||||
if (s == server->command)
|
||||
f = 1;
|
||||
else if ( *(s-1) != '\\')
|
||||
f = 1;
|
||||
else if ( *(s-1) == '\\')
|
||||
f = 2;
|
||||
}
|
||||
if (f == 1)
|
||||
{
|
||||
buffer[i] = '\0';
|
||||
i = -1;
|
||||
q = buffer;
|
||||
while (*q == ' ') q++;
|
||||
if (q && q[0])
|
||||
user_command (server, NULL, q);
|
||||
}
|
||||
else if (f == 2)
|
||||
buffer[--i] = *s;
|
||||
else
|
||||
buffer[i] = *s;
|
||||
i++; s++;
|
||||
}
|
||||
buffer[i] = '\0';
|
||||
q = buffer;
|
||||
while (*q == ' ') q++;
|
||||
if (q && q[0])
|
||||
user_command (server, NULL, q);
|
||||
|
||||
free (buffer);
|
||||
}
|
||||
|
||||
if (server->command_delay > 0)
|
||||
sleep (server->command_delay);
|
||||
}
|
||||
|
||||
|
||||
/* auto-join after disconnection (only rejoins opened channels) */
|
||||
if (server->reconnect_join && server->channels)
|
||||
{
|
||||
|
||||
@@ -2431,7 +2431,8 @@ irc_cmd_recv_topic (t_irc_server *server, char *host, char *nick, char *argument
|
||||
int
|
||||
irc_cmd_recv_004 (t_irc_server *server, char *host, char *nick, char *arguments)
|
||||
{
|
||||
char *pos;
|
||||
char *pos, *buffer, *s, *q;
|
||||
int i, f;
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
pos = strchr (arguments, ' ');
|
||||
@@ -2454,11 +2455,53 @@ irc_cmd_recv_004 (t_irc_server *server, char *host, char *nick, char *arguments)
|
||||
/* execute command once connected */
|
||||
if (server->command && server->command[0])
|
||||
{
|
||||
user_command (server, NULL, server->command);
|
||||
if (server->command_delay > 0)
|
||||
sleep (server->command_delay);
|
||||
/* splitting command on ';' which can be escaped with '\;' */
|
||||
buffer = (char *) malloc ( (strlen(server->command) + 1) * sizeof (char));
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
s = server->command;
|
||||
i = 0;
|
||||
while(*s != '\0')
|
||||
{
|
||||
f = 0;
|
||||
if (*s == ';')
|
||||
{
|
||||
if (s == server->command)
|
||||
f = 1;
|
||||
else if ( *(s-1) != '\\')
|
||||
f = 1;
|
||||
else if ( *(s-1) == '\\')
|
||||
f = 2;
|
||||
}
|
||||
if (f == 1)
|
||||
{
|
||||
buffer[i] = '\0';
|
||||
i = -1;
|
||||
q = buffer;
|
||||
while (*q == ' ') q++;
|
||||
if (q && q[0])
|
||||
user_command (server, NULL, q);
|
||||
}
|
||||
else if (f == 2)
|
||||
buffer[--i] = *s;
|
||||
else
|
||||
buffer[i] = *s;
|
||||
i++; s++;
|
||||
}
|
||||
buffer[i] = '\0';
|
||||
q = buffer;
|
||||
while (*q == ' ') q++;
|
||||
if (q && q[0])
|
||||
user_command (server, NULL, q);
|
||||
|
||||
free (buffer);
|
||||
}
|
||||
|
||||
if (server->command_delay > 0)
|
||||
sleep (server->command_delay);
|
||||
}
|
||||
|
||||
|
||||
/* auto-join after disconnection (only rejoins opened channels) */
|
||||
if (server->reconnect_join && server->channels)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user