summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2009-08-14 17:07:26 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2009-08-14 17:07:26 +0200
commitb8c88bbf4e928a0ac4af89dfe72f0661beb35827 (patch)
tree6fcc7b01ad0b7bec02b6b257f561ffd88889f4d9 /main.c
parent11ff809614169d26efaf9c0d0a30185cf971730c (diff)
Parse text and join lines.
Add users from text lines. Fixed hash table code.
Diffstat (limited to 'main.c')
-rw-r--r--main.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/main.c b/main.c
index a3b3c7e..79b1eec 100644
--- a/main.c
+++ b/main.c
@@ -1,8 +1,10 @@
#include <stdio.h>
+#include <string.h>
#include "config.h"
#include "regexset.h"
#include "channel.h"
+#include "user.h"
int main(int argc, char **argv) {
/* Regex sets must be initialized before config. */
@@ -15,6 +17,7 @@ int main(int argc, char **argv) {
channel_free();
return 1;
}
+ user_init();
/* Parsing stuff goes here. */
for(int chan_i = 0; chan_i < channel_get_count(); chan_i++) {
@@ -33,13 +36,29 @@ int main(int argc, char **argv) {
char line[0x2ff];
while(fgets(line, 0x2ff, f)) {
- // TODO: Magic.
+ int rc;
+ int ovector[30];
+
+ rc = pcre_exec(rs->text, NULL, line, strlen(line), 0, 0, ovector, 30);
+ if(rc > 0) {
+ char nick[0x20], text[0x200];
+ pcre_copy_named_substring(rs->text, line, ovector, rc, "nick", nick, 0x20);
+ pcre_copy_named_substring(rs->text, line, ovector, rc, "text", text, 0x200);
+ struct user_t *user = user_get(nick);
+ continue;
+ }
+
+ rc = pcre_exec(rs->join, NULL, line, strlen(line), 0, 0, ovector, 30);
+ if(rc > 0) {
+ continue;
+ }
}
file = file->next;
}
}
+ user_free();
cfg_free();
channel_free();
rs_free();