Code cleanups and debian changelogs
committer: Markus Bröker <mbroeker@largo.homelinux.org>
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-mcbot (0.94-2) unstable; urgency=low
+mcbot (0.94-3) unstable; urgency=low
* Initial Release
* the location of mcbot.cgi is stored in the db
@@ -9,5 +9,6 @@
* stream handling for freebsd
* Debian Policy: Assume everything is working and start the service via default
* irc_login connects now to the proper (non-freenode.net) server
+ * privmsgs will be send to the proper location...
- -- Markus Broeker <mbroeker@largo.homelinux.org> Sat, 9 Aug 2008 09:05:54 +0200
+ -- Markus Broeker <mbroeker@largo.homelinux.org> Sat, 9 Aug 2008 18:05:54 +0200
--- a/src/config.c
+++ b/src/config.c
@@ -14,14 +14,13 @@
char *CONFIG_OPTIONS[] = {
"NICK", "PASSWORD", "SERVER", "PORT",
"CHANNEL", "TOPIC",
- NULL
};
int config (UC * uc, char *fname)
{
FILE *f;
char buffer[513];
- static char **line;
+ char **line;
char *token;
char *value;
int i = 0;
--- a/src/irc.c
+++ b/src/irc.c
@@ -25,7 +25,6 @@
"NOTICE", "MODE", "JOIN", "PART",
"TOPIC", "PING", "ENOMEM", "ERROR",
"VERSION", "PRIVMSG", "QUIT", "NICK",
- NULL,
};
FILE *irc_connect (char *server, unsigned int port)
@@ -34,7 +33,7 @@
char *ip;
struct sockaddr_in ca;
int csocket;
- FILE *stream = NULL;
+ FILE *stream;
he = gethostbyname (server);
if (he == NULL) {
@@ -43,7 +42,7 @@
}
if ((ip = inet_ntoa (*((struct in_addr *)he->h_addr_list[0]))) == NULL) {
- perror ("GETHOSTBYNAME");
+ perror ("INET_NTOA");
return NULL;
} else
printf ("IP: %s\n", ip);
@@ -80,26 +79,31 @@
int irc_login (FILE * stream, char *server, char *nick, char *password)
{
- MSG message;
+ MSG message = { NULL, 0, 0, 0, 0, 0, 0 };
char msg[513];
char *user;
- struct passwd *pwd = NULL;
+ struct passwd *pwd;
- if ((user = getenv ("USER")) != NULL)
- if ((pwd = getpwnam (user)) == NULL)
- return IRC_GENERAL_ERROR;
+ if ((user = getenv ("USER")) == NULL)
+ return IRC_GENERAL_ERROR;
+
+ if ((pwd = getpwnam (user)) == NULL)
+ return IRC_GENERAL_ERROR;
if (password == NULL)
return IRC_LOGIN_ERROR;
if (stream == NULL)
return IRC_GENERAL_ERROR;
+ else
+ message.stream = stream;
fprintf (stream, "NICK %s\r\n", nick);
fprintf (stream, "USER %s 0 %s %s\r\n", user, server, pwd->pw_gecos);
fprintf (stream, "PRIVMSG NICKSERV :IDENTIFY %s\r\n", password);
for (;;) {
+ *msg = 0;
fgets (msg, 512, stream);
if ((user = irc_parsemessage (msg, &message)) != NULL)
printf ("%10s %s\n", user, message.line);
@@ -283,6 +287,7 @@
fprintf (message->stream, "PRIVMSG %s :%s\r\n", message->current_channel, message->line);
return command;
case 320:
+ case 328: /* INFORMATION */
case 332: /* TOPIC OF CHANNEL */
case 333: /* NAMES IN CHANNEL */
message->channel = strtok (message->line, " ");
@@ -311,8 +316,8 @@
return command;
break;
case 401: /* NO SUCH NICK/CHANNEL */
- case 403: /* That CHANNEL doesnt exist */
- case 441: /* They aren't on this channel */
+ case 403: /* THAT CHANNEL DOESN'T EXIST */
+ case 441: /* THEY AREN'T ON THIS CHANNEL */
return command;
case 474:
case 475:
--- a/src/main.c
+++ b/src/main.c
@@ -8,12 +8,6 @@
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
#include <signal.h>
#include <locale.h>
#include <libintl.h>
@@ -37,7 +31,7 @@
int main (int argc, char **argv)
{
UC uc;
- MSG message = { NULL, 0, 0, 0, 0, 0, 0 };
+ MSG message;
char buf[513];
char *msg;
char *command;
@@ -96,7 +90,6 @@
}
while (!feof (message.stream)) {
- message.line = NULL;
*buf = 0;
fgets (buf, 512, message.stream);
--- a/src/parse.c
+++ b/src/parse.c
@@ -36,7 +36,6 @@
"!debug: prints some debug infos\r\n",
"!vaccuum: reorganizes the database\r\n",
"!logout: Protected logout function\r\n",
- NULL,
};
const