summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2003-09-28 22:05:06 +0000
committerSebastien Helleu <flashcode@flashtux.org>2003-09-28 22:05:06 +0000
commit13c7cb9dd42a741c250e071bea27cf5117548a02 (patch)
tree0e0b54435c3499c573b46d1b7a883aab7f6bb6a5 /src/irc
parenta5ae266ee4df887edbe2ed3608c7f8479c167745 (diff)
downloadweechat-13c7cb9dd42a741c250e071bea27cf5117548a02.zip
Added /connect and /disconnect commands
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/irc-server.c38
-rw-r--r--src/irc/irc.h1
2 files changed, 35 insertions, 4 deletions
diff --git a/src/irc/irc-server.c b/src/irc/irc-server.c
index dce3d337e..daa059ca3 100644
--- a/src/irc/irc-server.c
+++ b/src/irc/irc-server.c
@@ -208,15 +208,15 @@ server_new (char *name, int autoconnect, char *address, int port,
{
t_irc_server *new_server;
- if (!name || !address || (port < 0) || !nick1 || !nick2 || !nick3
- || !username || !realname)
+ if (!name || !address || (port < 0))
return NULL;
#if DEBUG >= 1
log_printf ("creating new server (name:%s, address:%s, port:%d, pwd:%s, "
"nick1:%s, nick2:%s, nick3:%s, username:%s, realname:%s)\n",
- name, address, port, password, nick1, nick2, nick3,
- username, realname);
+ name, address, port, (password) ? password : "",
+ (nick1) ? nick1 : "", (nick2) ? nick2 : "", (nick3) ? nick3 : "",
+ (username) ? username : "", (realname) ? realname : "");
#endif
if ((new_server = server_alloc ()))
@@ -576,12 +576,24 @@ server_connect (t_irc_server *server)
void
server_disconnect (t_irc_server *server)
{
+ t_irc_channel *ptr_channel;
+
if (server->is_connected)
{
+ /* write disconnection message on each channel/private window */
+ for (ptr_channel = server->channels; ptr_channel;
+ ptr_channel = ptr_channel->next_channel)
+ {
+ irc_display_prefix (ptr_channel->window, PREFIX_INFO);
+ gui_printf (ptr_channel->window, "Disconnected from server!\n");
+ }
+
+ /* close communication with server */
close (server->server_read);
close (server->server_write);
close (server->sock4);
server->is_connected = 0;
+ server->sock4 = -1;
}
}
@@ -599,6 +611,24 @@ server_disconnect_all ()
}
/*
+ * server_search: return pointer on a server with a name
+ */
+
+t_irc_server *
+server_search (char *servername)
+{
+ t_irc_server *ptr_server;
+
+ for (ptr_server = irc_servers; ptr_server;
+ ptr_server = ptr_server->next_server)
+ {
+ if (strcmp (ptr_server->name, servername) == 0)
+ return ptr_server;
+ }
+ return NULL;
+}
+
+/*
* server_get_number_connected: returns number of connected server
*/
diff --git a/src/irc/irc.h b/src/irc/irc.h
index b74c8e28f..389a9f70f 100644
--- a/src/irc/irc.h
+++ b/src/irc/irc.h
@@ -152,6 +152,7 @@ extern void server_recv (t_irc_server *);
extern int server_connect ();
extern void server_disconnect (t_irc_server *);
extern void server_disconnect_all ();
+extern t_irc_server *server_search (char *);
extern int server_get_number_connected ();
extern int server_name_already_exists (char *);