summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--channel.c8
-rw-r--r--channel.h2
-rw-r--r--config.c1
-rw-r--r--main.c22
4 files changed, 32 insertions, 1 deletions
diff --git a/channel.c b/channel.c
index cdd1748..065e606 100644
--- a/channel.c
+++ b/channel.c
@@ -42,6 +42,14 @@ struct channel_file_t *channel_file_add(struct channel_t *channel, const char *p
return file;
}
+int channel_get_count() {
+ return channel_count;
+}
+
+struct channel_t *channel_get(int index) {
+ return (index < channel_count ? &channels[index] : NULL);
+}
+
void channel_free() {
for(int i = 0; i < channel_count; i++) {
free(channels[i].name);
diff --git a/channel.h b/channel.h
index 5ad75ea..73f2dde 100644
--- a/channel.h
+++ b/channel.h
@@ -17,6 +17,8 @@ struct channel_t {
void channel_init();
struct channel_t *channel_add(const char *name);
struct channel_file_t *channel_file_add(struct channel_t *channel, const char *path, int rs_index);
+int channel_get_count();
+struct channel_t *channel_get(int index);
void channel_free();
#endif
diff --git a/config.c b/config.c
index de9b8aa..d50c90b 100644
--- a/config.c
+++ b/config.c
@@ -59,7 +59,6 @@ int cfg_init() {
sprintf(sname, "channel #%d", i+1);
name = sname;
}
- printf("Channel %s\n", name);
struct channel_t *channel;
if(!(channel = channel_add(name))) {
return 0;
diff --git a/main.c b/main.c
index 9f822ed..a3b3c7e 100644
--- a/main.c
+++ b/main.c
@@ -17,6 +17,28 @@ int main(int argc, char **argv) {
}
/* Parsing stuff goes here. */
+ for(int chan_i = 0; chan_i < channel_get_count(); chan_i++) {
+ struct channel_t *channel = channel_get(chan_i);
+ printf("Channel %s\n", channel->name);
+ struct channel_file_t *file = channel->files;
+ while(file) {
+ struct regexset_t *rs = file->rs;
+ FILE *f = fopen(file->path, "r");
+ if(!f) {
+ fprintf(stderr, "\tFailed to open %s\n", file->path);
+ file = file->next;
+ continue;
+ } else
+ printf("\tParsing %s\n", file->path);
+
+ char line[0x2ff];
+ while(fgets(line, 0x2ff, f)) {
+ // TODO: Magic.
+ }
+
+ file = file->next;
+ }
+ }
cfg_free();
channel_free();