--- a/src/irc.c
+++ b/src/irc.c
@@ -19,20 +19,11 @@
#include <compat.h>
#include <irc.h>
+#include "common.h"
-#define NOTICE 0
-#define MODE 1
-#define JOIN 2
-#define PART 3
-#define TOPIC 4
-#define PING 5
-#define ENOMEM 6
-#define ERROR 7
-#define VERSION 8
-#define PRIVMSG 9
-#define QUIT 10
-#define NICK 11
-#define KICK 12
+enum {
+ NOTICE, MODE, JOIN, PART, TOPIC, PING, ENOMEM, ERROR, VERSION, PRIVMSG, QUIT, NICK, KICK
+};
#define VERSION_STRING "MCBOT on GNU/LINUX"
@@ -96,7 +87,7 @@
int irc_login (FILE * stream, char *server, char *nick, char *password)
{
MSG message = { NULL, 0, 0, 0, 0, 0, 0 };
- char msg[513];
+ char msg[DEFAULT_BUF_SIZE];
char *user;
struct passwd *pwd;
@@ -118,8 +109,7 @@
fprintf (stream, "PRIVMSG NICKSERV :IDENTIFY %s\r\n", password);
for (;;) {
- *msg = '\0';
- fgets (msg, 512, stream);
+ fgets (msg, sizeof (msg), stream);
if ((user = irc_parsemessage (msg, &message)) != NULL)
printf ("%10s %s\n", user, message.line);
@@ -267,7 +257,7 @@
*ptr = '\0';
message->channel = strtok (message->line, " ");
- strncpy (message->current_channel, message->channel, 40);
+ strncpy (message->current_channel, message->channel, sizeof (message->current_channel));
message->line = strtok (NULL, "\r\n");
message->line++;
printf ("%10s %s %s :%s\n", "READ", message->command, message->channel, message->line);