diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2004-01-24 21:53:22 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2004-01-24 21:53:22 +0000 |
commit | c9a469f51b0e65f2cc56eef13de2856dcda1fe2a (patch) | |
tree | 89ad2e92606abc055ce824d526d25b2052b6809d | |
parent | 69cb87251e20aa759675e12e72deb39899e69ee2 (diff) | |
download | weechat-c9a469f51b0e65f2cc56eef13de2856dcda1fe2a.zip |
Channel can be specified at the end of command line URL with /channel
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/common/weechat.c | 4 | ||||
-rw-r--r-- | src/common/weechat.h | 3 | ||||
-rw-r--r-- | src/irc/irc-server.c | 79 | ||||
-rw-r--r-- | weechat.1 | 10 | ||||
-rw-r--r-- | weechat/ChangeLog | 2 | ||||
-rw-r--r-- | weechat/src/common/weechat.c | 4 | ||||
-rw-r--r-- | weechat/src/common/weechat.h | 3 | ||||
-rw-r--r-- | weechat/src/irc/irc-server.c | 79 | ||||
-rw-r--r-- | weechat/weechat.1 | 10 |
10 files changed, 146 insertions, 50 deletions
@@ -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") diff --git a/src/common/weechat.c b/src/common/weechat.c index 976dd3edb..39bb39a82 100644 --- a/src/common/weechat.c +++ b/src/common/weechat.c @@ -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); diff --git a/src/common/weechat.h b/src/common/weechat.h index 8fcf09efe..51b0cf9e9 100644 --- a/src/common/weechat.h +++ b/src/common/weechat.h @@ -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" \ diff --git a/src/irc/irc-server.c b/src/irc/irc-server.c index 289d98ffb..7354adcd2 100644 --- a/src/irc/irc-server.c +++ b/src/irc/irc-server.c @@ -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) { - free (url); - return -1; + 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; } - pos_address[0] = '\0'; - pos_address++; - pos = url + 6; - if (!pos[0]) + if (!pos_server[0]) { free (url); return -1; } - pos2 = strchr (pos, ':'); - if (pos2) + pos_channel = strchr (pos_server, '/'); + if (pos_channel) { - pos2[0] = '\0'; - server->password = strdup (pos2 + 1); + pos_channel[0] = '\0'; + pos_channel++; } - server->nick1 = strdup (pos); - - pos2 = strchr (pos_address, ':'); - if (pos2) + pos = strchr (pos_server, ':'); + if (pos) { - pos2[0] = '\0'; - server->port = atoi (pos2 + 1); + pos[0] = '\0'; + server->port = atoi (pos + 1); + } + server->name = strdup (pos_server); + server->address = strdup (pos_server); + if (pos_channel && pos_channel[0]) + { + 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); @@ -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 diff --git a/weechat/ChangeLog b/weechat/ChangeLog index f533c0ac7..ef2865106 100644 --- a/weechat/ChangeLog +++ b/weechat/ChangeLog @@ -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") diff --git a/weechat/src/common/weechat.c b/weechat/src/common/weechat.c index 976dd3edb..39bb39a82 100644 --- a/weechat/src/common/weechat.c +++ b/weechat/src/common/weechat.c @@ -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); diff --git a/weechat/src/common/weechat.h b/weechat/src/common/weechat.h index 8fcf09efe..51b0cf9e9 100644 --- a/weechat/src/common/weechat.h +++ b/weechat/src/common/weechat.h @@ -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" \ diff --git a/weechat/src/irc/irc-server.c b/weechat/src/irc/irc-server.c index 289d98ffb..7354adcd2 100644 --- a/weechat/src/irc/irc-server.c +++ b/weechat/src/irc/irc-server.c @@ -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) { - free (url); - return -1; + 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; } - pos_address[0] = '\0'; - pos_address++; - pos = url + 6; - if (!pos[0]) + if (!pos_server[0]) { free (url); return -1; } - pos2 = strchr (pos, ':'); - if (pos2) + pos_channel = strchr (pos_server, '/'); + if (pos_channel) { - pos2[0] = '\0'; - server->password = strdup (pos2 + 1); + pos_channel[0] = '\0'; + pos_channel++; } - server->nick1 = strdup (pos); - - pos2 = strchr (pos_address, ':'); - if (pos2) + pos = strchr (pos_server, ':'); + if (pos) { - pos2[0] = '\0'; - server->port = atoi (pos2 + 1); + pos[0] = '\0'; + server->port = atoi (pos + 1); + } + server->name = strdup (pos_server); + server->address = strdup (pos_server); + if (pos_channel && pos_channel[0]) + { + 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); diff --git a/weechat/weechat.1 b/weechat/weechat.1 index bd4510c21..fc859dd88 100644 --- a/weechat/weechat.1 +++ b/weechat/weechat.1 @@ -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 |