mirror of
https://github.com/hexchat/hexchat.git
synced 2024-11-06 19:22:39 +01:00
Add key support to urls like mirc
This commit is contained in:
parent
c76dedd9b9
commit
d1c36f170b
@ -3066,7 +3066,7 @@ cmd_splay (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parse_irc_url (char *url, char *server_name[], char *port[], char *channel[], int *use_ssl)
|
parse_irc_url (char *url, char *server_name[], char *port[], char *channel[], char *key[], int *use_ssl)
|
||||||
{
|
{
|
||||||
char *co;
|
char *co;
|
||||||
#ifdef USE_OPENSSL
|
#ifdef USE_OPENSSL
|
||||||
@ -3104,6 +3104,15 @@ urlserv:
|
|||||||
*channel = co;
|
*channel = co;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/* check for key - mirc style */
|
||||||
|
co = strchr (co + 1, '?');
|
||||||
|
if (co)
|
||||||
|
{
|
||||||
|
*co = 0;
|
||||||
|
co++;
|
||||||
|
*key = co;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -3117,6 +3126,7 @@ cmd_server (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
|||||||
char *port = NULL;
|
char *port = NULL;
|
||||||
char *pass = NULL;
|
char *pass = NULL;
|
||||||
char *channel = NULL;
|
char *channel = NULL;
|
||||||
|
char *key = NULL;
|
||||||
int use_ssl = FALSE;
|
int use_ssl = FALSE;
|
||||||
int is_url = TRUE;
|
int is_url = TRUE;
|
||||||
server *serv = sess->server;
|
server *serv = sess->server;
|
||||||
@ -3130,7 +3140,7 @@ cmd_server (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!parse_irc_url (word[2 + offset], &server_name, &port, &channel, &use_ssl))
|
if (!parse_irc_url (word[2 + offset], &server_name, &port, &channel, &key, &use_ssl))
|
||||||
{
|
{
|
||||||
is_url = FALSE;
|
is_url = FALSE;
|
||||||
server_name = word[2 + offset];
|
server_name = word[2 + offset];
|
||||||
@ -3356,14 +3366,17 @@ find_server_from_net (void *net)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
url_join_only (server *serv, char *tbuf, char *channel)
|
url_join_only (server *serv, char *tbuf, char *channel, char *key)
|
||||||
{
|
{
|
||||||
/* already connected, JOIN only. FIXME: support keys? */
|
/* already connected, JOIN only. */
|
||||||
if (channel == NULL)
|
if (channel == NULL)
|
||||||
return;
|
return;
|
||||||
tbuf[0] = '#';
|
tbuf[0] = '#';
|
||||||
/* tbuf is 4kb */
|
/* tbuf is 4kb */
|
||||||
safe_strcpy ((tbuf + 1), channel, 256);
|
safe_strcpy ((tbuf + 1), channel, 256);
|
||||||
|
if (key)
|
||||||
|
serv->p_join (serv, tbuf, key);
|
||||||
|
else
|
||||||
serv->p_join (serv, tbuf, "");
|
serv->p_join (serv, tbuf, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3375,12 +3388,13 @@ cmd_url (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
|||||||
char *server_name = NULL;
|
char *server_name = NULL;
|
||||||
char *port = NULL;
|
char *port = NULL;
|
||||||
char *channel = NULL;
|
char *channel = NULL;
|
||||||
|
char *key = NULL;
|
||||||
char *url = g_strdup (word[2]);
|
char *url = g_strdup (word[2]);
|
||||||
int use_ssl = FALSE;
|
int use_ssl = FALSE;
|
||||||
void *net;
|
void *net;
|
||||||
server *serv;
|
server *serv;
|
||||||
|
|
||||||
if (parse_irc_url (url, &server_name, &port, &channel, &use_ssl))
|
if (parse_irc_url (url, &server_name, &port, &channel, &key, &use_ssl))
|
||||||
{
|
{
|
||||||
/* maybe we're already connected to this net */
|
/* maybe we're already connected to this net */
|
||||||
|
|
||||||
@ -3396,7 +3410,7 @@ cmd_url (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
|||||||
serv = find_server_from_net (net);
|
serv = find_server_from_net (net);
|
||||||
if (serv)
|
if (serv)
|
||||||
{
|
{
|
||||||
url_join_only (serv, tbuf, channel);
|
url_join_only (serv, tbuf, channel, key);
|
||||||
g_free (url);
|
g_free (url);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -3407,7 +3421,7 @@ cmd_url (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
|||||||
serv = find_server_from_hostname (server_name);
|
serv = find_server_from_hostname (server_name);
|
||||||
if (serv)
|
if (serv)
|
||||||
{
|
{
|
||||||
url_join_only (serv, tbuf, channel);
|
url_join_only (serv, tbuf, channel, key);
|
||||||
g_free (url);
|
g_free (url);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user