Compare commits
5 Commits
4d8cc7e846
...
01d751aa42
Author | SHA1 | Date |
---|---|---|
Pentium44 | 01d751aa42 | |
Pentium44 | 40f9056774 | |
Pentium44 | 939c2bd20a | |
Pentium44 | fcbe6f03db | |
Pentium44 | 4298eecb68 |
|
@ -4,7 +4,6 @@
|
|||
int irc_send(int socketfd, char *out) {
|
||||
//printf(">> %s", out);
|
||||
return send(socketfd, out, strlen(out), 0);
|
||||
free(&socketfd);
|
||||
}
|
||||
|
||||
int irc_connect(char *server, int port, int *socketfd) {
|
||||
|
|
20
src/main.c
20
src/main.c
|
@ -2,13 +2,13 @@
|
|||
#include "irc.h"
|
||||
#include "functions.h"
|
||||
#include "dictionary.h"
|
||||
#define BUF 36864
|
||||
#define LINEBUF 4096
|
||||
#define MAINBUFSIZ 36864
|
||||
#define LINEBUFSIZ 4096
|
||||
|
||||
char *process_string(char *in, int n) {
|
||||
int ii = -1, o, i, e;
|
||||
char *nothing = "0";
|
||||
char *buf = malloc(8128);
|
||||
static char buf[MAINBUFSIZ];
|
||||
|
||||
for(i = 0; i < n; i++) {
|
||||
|
||||
|
@ -35,11 +35,10 @@ char *process_string(char *in, int n) {
|
|||
char *cmd;
|
||||
char *chan;
|
||||
char *e;
|
||||
char *pass;
|
||||
char *topic;
|
||||
char *topicchan;
|
||||
char *msg;
|
||||
char *b = malloc(4096);
|
||||
static char b[LINEBUFSIZ];
|
||||
|
||||
name = buf+1;
|
||||
e = strchr(name,'!');
|
||||
|
@ -99,11 +98,10 @@ char *process_string(char *in, int n) {
|
|||
if(strncmp(msg, searchstr, strlen(searchstr))==0) {
|
||||
sprintf(b,"PRIVMSG %s :%s, %s\r\n",chan,
|
||||
name,dictionary[k].reply);
|
||||
free(searchstr);
|
||||
if(searchstr != NULL) free(searchstr);
|
||||
return b;
|
||||
}
|
||||
|
||||
free(searchstr);
|
||||
if(searchstr != NULL) free(searchstr);
|
||||
}
|
||||
|
||||
/*if(strncmp(msg, "@topic", 4)==0) {
|
||||
|
@ -329,13 +327,11 @@ char *process_string(char *in, int n) {
|
|||
|
||||
} // for loop
|
||||
|
||||
free(buf); // Free memory allocated with malloc
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int socketfd, n;
|
||||
char in[BUF+1], out[BUF+1], c[8128];
|
||||
char in[MAINBUFSIZ+1], out[MAINBUFSIZ+1], c[LINEBUFSIZ];
|
||||
char *pos, *action;
|
||||
|
||||
if(argc != 6) {
|
||||
|
@ -388,12 +384,10 @@ int main(int argc, char **argv) {
|
|||
char *str = process_string(in, n);
|
||||
if(strncmp(str, "0", 1)!=0) {
|
||||
irc_send(socketfd, str);
|
||||
free(str);
|
||||
fflush(stderr);
|
||||
}
|
||||
if(strncmp(str, "QUIT", 4)==0) {
|
||||
fflush(stderr);
|
||||
free(str);
|
||||
break;
|
||||
}
|
||||
} // if(n > 0)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
YOURUSER="Pentium44"
|
||||
BOTNICK="MultiServ"
|
||||
BOTPASS="changemeeeee"
|
||||
BOTPASS="changeme"
|
||||
ADDRESS="localhost"
|
||||
PORT="1337"
|
||||
|
||||
|
|
Loading…
Reference in New Issue