1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 22:06:38 +02:00

Channel can be specified at the end of command line URL with /channel

This commit is contained in:
Sebastien Helleu
2004-01-24 21:53:22 +00:00
parent 69cb87251e
commit c9a469f51b
10 changed files with 146 additions and 50 deletions
+2
View File
@@ -6,8 +6,10 @@ ChangeLog - 2004-01-24
Version 0.0.5 (under dev!):
* /set command to modify config options when WeeChat is running
* fixed look_nicklist config option, now enables/disables nicklist
* secured code to prevent buffer overflows and memory leaks
* fixed QUIT IRC command: now sent to all connected servers (not only current)
* URL command line parameter to connect to server(s)
* new Perl script function to display message in info bar ("IRC::print_infobar")
* info bar highlight notifications
* info bar timestamp is added to config ("look_infobar_timestamp")
+2 -2
View File
@@ -203,7 +203,7 @@ wee_parse_args (int argc, char *argv[])
else if ((strcmp (argv[i], "-h") == 0)
|| (strcmp (argv[i], "--help") == 0))
{
printf ("\n" WEE_USAGE1, argv[0]);
printf ("\n" WEE_USAGE1, argv[0], argv[0]);
printf ("%s", WEE_USAGE2);
exit (EXIT_SUCCESS);
}
@@ -232,7 +232,7 @@ wee_parse_args (int argc, char *argv[])
server_tmp.address, server_tmp.port,
server_tmp.password, server_tmp.nick1,
server_tmp.nick2, server_tmp.nick3,
NULL, NULL, NULL, NULL))
NULL, NULL, NULL, server_tmp.autojoin))
fprintf (stderr, _("%s unable to create server ('%s'), ignored\n"),
WEECHAT_WARNING, argv[i]);
server_destroy (&server_tmp);
+2 -1
View File
@@ -79,7 +79,8 @@
#define WEE_USAGE1 \
PACKAGE_STRING " (c) Copyright 2004, compiled on " __DATE__ " " __TIME__ \
"\nDeveloped by FlashCode, Bounga and Xahlexx - " WEECHAT_WEBSITE "\n\n" \
"Usage: %s [options ...] [irc://nick[:passwd]@irc.example.org[:port] ...]\n\n"
"Usage: %s [options ...]\n" \
" or: %s [irc://[nickname[:password]@]irc.example.org[:port][/channel] ...]\n\n"
#define WEE_USAGE2 \
" -c, --config config file help (list of options)\n" \
+58 -21
View File
@@ -26,9 +26,11 @@
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -91,42 +93,77 @@ server_init (t_irc_server *server)
int
server_init_with_url (char *irc_url, t_irc_server *server)
{
char *url, *pos_address, *pos, *pos2;
char *url, *pos_server, *pos_channel, *pos, *pos2;
struct passwd *my_passwd;
server_init (server);
if (strncasecmp (irc_url, "irc://", 6) != 0)
return -1;
url = strdup (irc_url);
pos_address = strchr (url, '@');
if (!pos_address || !pos_address[1])
pos_server = strchr (url, '@');
if (pos_server)
{
pos_server[0] = '\0';
pos_server++;
pos = url + 6;
if (!pos[0])
{
free (url);
return -1;
}
pos2 = strchr (pos, ':');
if (pos2)
{
pos2[0] = '\0';
server->password = strdup (pos2 + 1);
}
server->nick1 = strdup (pos);
}
else
{
if ((my_passwd = getpwuid (geteuid ())) != NULL)
server->nick1 = strdup (my_passwd->pw_name);
else
{
fprintf (stderr, "%s: %s (%s).",
WEECHAT_WARNING,
_("Unable to get user's name"),
strerror (errno));
free (url);
return -1;
}
pos_server = url + 6;
}
if (!pos_server[0])
{
free (url);
return -1;
}
pos_address[0] = '\0';
pos_address++;
pos = url + 6;
if (!pos[0])
pos_channel = strchr (pos_server, '/');
if (pos_channel)
{
free (url);
return -1;
pos_channel[0] = '\0';
pos_channel++;
}
pos2 = strchr (pos, ':');
if (pos2)
pos = strchr (pos_server, ':');
if (pos)
{
pos2[0] = '\0';
server->password = strdup (pos2 + 1);
pos[0] = '\0';
server->port = atoi (pos + 1);
}
server->nick1 = strdup (pos);
pos2 = strchr (pos_address, ':');
if (pos2)
server->name = strdup (pos_server);
server->address = strdup (pos_server);
if (pos_channel && pos_channel[0])
{
pos2[0] = '\0';
server->port = atoi (pos2 + 1);
if (string_is_channel (pos_channel))
server->autojoin = strdup (pos_channel);
else
{
server->autojoin = (char *) malloc (strlen (pos_channel) + 2);
strcpy (server->autojoin, "#");
strcat (server->autojoin, pos_channel);
}
}
server->name = strdup (pos_address);
server->address = strdup (pos_address);
free (url);
+9 -1
View File
@@ -5,7 +5,9 @@ weechat \- Wee Enhanced Environment for Chat
.SH SYNOPSIS
.B weechat
.RI [ options ]
.RI [ options... ]
or
.RI [ url... ]
.br
.SH DESCRIPTION
@@ -33,6 +35,12 @@ display program license
.br
display WeeChat version
.SH URL
WeeChat can use an URL (Uniform Resource Locator) to automatically connect
to an IRC server. These are in the following form:
.TP
.B irc://[[nickname][:password]@]server[:port]
.SH FILES
.TP
.B $HOME/.weechat/weechat.rc
+2
View File
@@ -6,8 +6,10 @@ ChangeLog - 2004-01-24
Version 0.0.5 (under dev!):
* /set command to modify config options when WeeChat is running
* fixed look_nicklist config option, now enables/disables nicklist
* secured code to prevent buffer overflows and memory leaks
* fixed QUIT IRC command: now sent to all connected servers (not only current)
* URL command line parameter to connect to server(s)
* new Perl script function to display message in info bar ("IRC::print_infobar")
* info bar highlight notifications
* info bar timestamp is added to config ("look_infobar_timestamp")
+2 -2
View File
@@ -203,7 +203,7 @@ wee_parse_args (int argc, char *argv[])
else if ((strcmp (argv[i], "-h") == 0)
|| (strcmp (argv[i], "--help") == 0))
{
printf ("\n" WEE_USAGE1, argv[0]);
printf ("\n" WEE_USAGE1, argv[0], argv[0]);
printf ("%s", WEE_USAGE2);
exit (EXIT_SUCCESS);
}
@@ -232,7 +232,7 @@ wee_parse_args (int argc, char *argv[])
server_tmp.address, server_tmp.port,
server_tmp.password, server_tmp.nick1,
server_tmp.nick2, server_tmp.nick3,
NULL, NULL, NULL, NULL))
NULL, NULL, NULL, server_tmp.autojoin))
fprintf (stderr, _("%s unable to create server ('%s'), ignored\n"),
WEECHAT_WARNING, argv[i]);
server_destroy (&server_tmp);
+2 -1
View File
@@ -79,7 +79,8 @@
#define WEE_USAGE1 \
PACKAGE_STRING " (c) Copyright 2004, compiled on " __DATE__ " " __TIME__ \
"\nDeveloped by FlashCode, Bounga and Xahlexx - " WEECHAT_WEBSITE "\n\n" \
"Usage: %s [options ...] [irc://nick[:passwd]@irc.example.org[:port] ...]\n\n"
"Usage: %s [options ...]\n" \
" or: %s [irc://[nickname[:password]@]irc.example.org[:port][/channel] ...]\n\n"
#define WEE_USAGE2 \
" -c, --config config file help (list of options)\n" \
+58 -21
View File
@@ -26,9 +26,11 @@
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -91,42 +93,77 @@ server_init (t_irc_server *server)
int
server_init_with_url (char *irc_url, t_irc_server *server)
{
char *url, *pos_address, *pos, *pos2;
char *url, *pos_server, *pos_channel, *pos, *pos2;
struct passwd *my_passwd;
server_init (server);
if (strncasecmp (irc_url, "irc://", 6) != 0)
return -1;
url = strdup (irc_url);
pos_address = strchr (url, '@');
if (!pos_address || !pos_address[1])
pos_server = strchr (url, '@');
if (pos_server)
{
pos_server[0] = '\0';
pos_server++;
pos = url + 6;
if (!pos[0])
{
free (url);
return -1;
}
pos2 = strchr (pos, ':');
if (pos2)
{
pos2[0] = '\0';
server->password = strdup (pos2 + 1);
}
server->nick1 = strdup (pos);
}
else
{
if ((my_passwd = getpwuid (geteuid ())) != NULL)
server->nick1 = strdup (my_passwd->pw_name);
else
{
fprintf (stderr, "%s: %s (%s).",
WEECHAT_WARNING,
_("Unable to get user's name"),
strerror (errno));
free (url);
return -1;
}
pos_server = url + 6;
}
if (!pos_server[0])
{
free (url);
return -1;
}
pos_address[0] = '\0';
pos_address++;
pos = url + 6;
if (!pos[0])
pos_channel = strchr (pos_server, '/');
if (pos_channel)
{
free (url);
return -1;
pos_channel[0] = '\0';
pos_channel++;
}
pos2 = strchr (pos, ':');
if (pos2)
pos = strchr (pos_server, ':');
if (pos)
{
pos2[0] = '\0';
server->password = strdup (pos2 + 1);
pos[0] = '\0';
server->port = atoi (pos + 1);
}
server->nick1 = strdup (pos);
pos2 = strchr (pos_address, ':');
if (pos2)
server->name = strdup (pos_server);
server->address = strdup (pos_server);
if (pos_channel && pos_channel[0])
{
pos2[0] = '\0';
server->port = atoi (pos2 + 1);
if (string_is_channel (pos_channel))
server->autojoin = strdup (pos_channel);
else
{
server->autojoin = (char *) malloc (strlen (pos_channel) + 2);
strcpy (server->autojoin, "#");
strcat (server->autojoin, pos_channel);
}
}
server->name = strdup (pos_address);
server->address = strdup (pos_address);
free (url);
+9 -1
View File
@@ -5,7 +5,9 @@ weechat \- Wee Enhanced Environment for Chat
.SH SYNOPSIS
.B weechat
.RI [ options ]
.RI [ options... ]
or
.RI [ url... ]
.br
.SH DESCRIPTION
@@ -33,6 +35,12 @@ display program license
.br
display WeeChat version
.SH URL
WeeChat can use an URL (Uniform Resource Locator) to automatically connect
to an IRC server. These are in the following form:
.TP
.B irc://[[nickname][:password]@]server[:port]
.SH FILES
.TP
.B $HOME/.weechat/weechat.rc