changeset: 91:ef1dbf796238
user: Nico Golde <nion_AT_suckless.org>
date: Mon Jan 31 21:45:52 2011 +0100
files: ii.c
description:
restructuring to stay under 500 lines ;) fix regression from 1.5 on handling unknown commands
diff -r a7debdf569e4 -r ef1dbf796238 ii.c
--- a/ii.c Mon Jan 24 17:52:38 2011 +0100
+++ b/ii.c Mon Jan 31 21:45:52 2011 +0100
@@ -1,7 +1,6 @@
/* (C)opyright MMV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
* (C)opyright MMV-MMXI Nico Golde <nico at ngolde dot de>
* See LICENSE file for license details. */
-
#include <errno.h>
#include <netdb.h>
#include <sys/types.h>
@@ -22,7 +21,8 @@
#ifndef PIPE_BUF /* FreeBSD don't know PIPE_BUF */
#define PIPE_BUF 4096
#endif
-
+#define PING_TIMEOUT 300
+#define SERVER_PORT 6667
enum { TOK_NICKSRV = 0, TOK_USER, TOK_CMD, TOK_CHAN, TOK_ARG, TOK_TEXT, TOK_LAST };
typedef struct Channel Channel;
@@ -32,8 +32,6 @@
Channel *next;
};
-#define PING_TIMEOUT 300
-#define SERVER_PORT 6667
static int irc;
static time_t last_response;
static Channel *channels = NULL;
@@ -51,6 +49,7 @@
" [-n <nick>] [-k <password>] [-f <fullname>]\n");
exit(EXIT_SUCCESS);
}
+
static char *striplower(char *s) {
char *p = NULL;
for(p = s; p && *p; p++) {
@@ -65,7 +64,6 @@
char tmp[256];
char *p = NULL;
size_t len;
-
snprintf(tmp, sizeof(tmp),"%s",dir);
len = strlen(tmp);
if(tmp[len - 1] == '/')
@@ -150,7 +148,6 @@
nick, nick, host, fullname ? fullname : nick);
else snprintf(message, PIPE_BUF, "NICK %s\r\nUSER %s localhost %s :%s\r\n",
nick, nick, host, fullname ? fullname : nick);
-
write(irc, message, strlen(message)); /* login */
}
@@ -288,7 +285,10 @@
default:
snprintf(message, PIPE_BUF, "%s\r\n", &buf[1]);
break;
- }
+ }
+ else
+ snprintf(message, PIPE_BUF, "%s\r\n", &buf[1]);
+
if (message[0] != '\0')
write(irc, message, strlen(message));
}
Received on Mon Jan 31 2011 - 21:45:19 CET
This archive was generated by hypermail 2.2.0 : Mon Jan 31 2011 - 21:48:04 CET