aboutsummaryrefslogtreecommitdiff
path: root/irc.c
diff options
context:
space:
mode:
Diffstat (limited to 'irc.c')
-rw-r--r--irc.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/irc.c b/irc.c
index 065cee0..b30af48 100644
--- a/irc.c
+++ b/irc.c
@@ -6,6 +6,16 @@
int g_ircsock = -1;
+char *g_chanlist[] = {
+ "a",
+ "b",
+ "g",
+ "cg",
+ "secret-channel",
+};
+const int g_nchannels = sizeof(g_chanlist)/sizeof(g_chanlist[0]);
+
+
int
irc_connect()
{
@@ -53,13 +63,13 @@ irc_handshake()
#define E(x) do { if (x==-1) { perror("irc_sendall"); return -1; } } while(0)
char msg1[] = "NICK "NICK"\r\nUSER "USERNAME" 0 * :"REALNAME"\r\n";
E(irc_sendall(msg1, sizeof msg1-1));
- for (int i = 0; CHANNELS[i] != NULL; i++) {
- if (strlen(CHANNELS[i]) > 16) {
- fprintf(stderr,"channel name too long (%s)\n",CHANNELS[i]);
+ for (int i = 0; i<g_nchannels; i++) {
+ if (strlen(g_chanlist[i]) > 16) {
+ fprintf(stderr,"channel name too long (%s)\n",g_chanlist[i]);
return -1;
}
E(irc_sendall("JOIN #",6));
- E(irc_sendall(CHANNELS[i],strlen(CHANNELS[i])));
+ E(irc_sendall(g_chanlist[i],strlen(g_chanlist[i])));
E(irc_sendall("\r\n",2));
}
#undef E