diff --git a/Makefile b/Makefile index 8fd5111..5ef1406 100644 --- a/Makefile +++ b/Makefile @@ -45,9 +45,9 @@ obj += src/notify/event.o obj += src/notify/tree.o obj += src/notify/queue.o -obj += src/indexer.o obj += src/arch.o +.PHONY : all clean cleaner all : $(PROGRAM) $(PROGRAM) : $(obj) diff --git a/src/indexer.c b/src/indexer.c deleted file mode 100644 index eddf2ed..0000000 --- a/src/indexer.c +++ /dev/null @@ -1,146 +0,0 @@ -/* indexer.c - * - * (C) Copyright 2010 Henrik Hautakoski - * (C) Copyright 2010 Fredric Nilsson - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - */ -#include -#include -#include "common/debug.h" -#include "common/path.h" -#include "output/output.h" -#include "notify/notify.h" -#include "notify/tree.h" -#include "indexer.h" - -static char *stack[256]; -static unsigned char st_size = 0; -static struct tree *current = NULL; - -/* REF:1 */ -static void index_entry(struct entry *ent) { - - static char buf[1024]; -#if __DEBUG__ - printf("DEBUG: index_entry adding to db: %s %s %d\n", ent->base, ent->name, ent->dir); -#endif - - - // Event change, just for test. - notify_event ev; - - ev.path = ent->base; - ev.filename = ent->name; - ev.type = NOTIFY_CREATE; - int status = output_process(&ev); - if (0 != status) - fprintf(stderr,"%s",output_error(status)); - - if (ent->dir) { - memcpy(buf, ent->base, strlen(ent->base)); - memcpy(buf + strlen(ent->base), ent->name, strlen(ent->name)+1); - notify_add_watch(buf); - } - -#ifdef __DEBUG__ - printf("Index: %s%s\n", ent->base, ent->name); -#endif -} - -static void add(const char *path) { - - char *newstr; - - if (st_size >= 255) - return; - - newstr = malloc(sizeof(char) * (strlen(path)+1)); - - if (newstr == NULL) - return; - - memcpy(newstr, path, strlen(path)+1); - - stack[st_size] = newstr; - - st_size++; -} - -/* we only shift the stack when getting the - * next tree, so this will do for now. */ -static int rm() { - - int i; - - current = NULL; - - while(current == NULL) { - - if (st_size == 0) - return 0; - - current = tree_new(stack[0]); - - free(stack[0]); - - st_size--; - - for(i=0; i < st_size; i++) - stack[i] = stack[i+1]; - } - - return 1; -} - -void indexer_register(const char *base, const char *name) { - - char *fullpath = path_normalize(base, name, 1); - - if (!indexer_pending()) { -#if __DEBUG__ - printf("sched: adding current index: %s\n", fullpath); -#endif - current = tree_new(fullpath); - free(fullpath); - return; - } - -#if __DEBUG__ - printf("sched: scheduling index: %s\n", fullpath); -#endif - - add(fullpath); -} - -void indexer_run(unsigned int num) { - - struct entry *ent; - - int i; - - for(i=0; i < num; i++) { - - ent = tree_next_ent(current); - - if (ent == NULL) { - - if (rm()) - continue; - - return; - } - - index_entry(ent); -#if __DEBUG__ - printf("DEBUG: indexer_run(): "); -#endif - } -} - -inline int indexer_pending() { - return current != NULL || st_size; -} diff --git a/src/indexer.h b/src/indexer.h deleted file mode 100644 index 07476f3..0000000 --- a/src/indexer.h +++ /dev/null @@ -1,12 +0,0 @@ - -#ifndef _INDEXER_H - -#define _INDEXER_H - -void indexer_register(const char *base, const char *name); - -void indexer_run(); - -inline int indexer_pending(); - -#endif /* _INDEXER_H */ diff --git a/test/Makefile b/test/Makefile index 60cd8a7..b008e46 100644 --- a/test/Makefile +++ b/test/Makefile @@ -3,7 +3,7 @@ CC=gcc CFLAGS=-g -D__DEBUG__ LDFLAGS=-L/usr/lib64/mysql -lmysqlclient -all : raw_inotify strbuf path rbtree inotify tree indexer mysql stdout queue +all : raw_inotify strbuf path rbtree inotify tree mysql stdout queue raw_inotify : $(CC) -linotifytools t_raw_inotify.c -o test_raw_inotify @@ -52,22 +52,6 @@ tree : ../src/common/die.c \ ../src/common/strbuf.c \ t_tree.c -o test_tree - -indexer : - $(CC) $(CFLAGS) $(LDFLAGS) \ - ../src/common/rbtree.c \ - ../src/common/path.c \ - ../src/common/xalloc.c \ - ../src/common/die.c \ - ../src/common/strbuf.c \ - ../src/notify/tree.c \ - ../src/notify/inotify.c \ - ../src/notify/event.c \ - ../src/ini/iniparser.c \ - ../src/ini/dictionary.c \ - ../src/output/stdout.c \ - ../src/indexer.c \ - t_indexer.c -o test_indexer mysql : $(CC) -D DB_DEBUG $(CFLAGS) $(LDFLAGS) \ diff --git a/test/t_indexer.c b/test/t_indexer.c deleted file mode 100644 index ec21770..0000000 --- a/test/t_indexer.c +++ /dev/null @@ -1,29 +0,0 @@ - -#include -#include -#include "../src/indexer.h" - -int main() { - - indexer_register("/home/pnx/", "tmptree"); - indexer_register("/home/pnx/", "tmptree"); - indexer_register("/home/pnx/", "tmptree"); - - while(indexer_pending()) { - indexer_run(5); - sleep(1); - } - - printf("---\n"); - - indexer_register("/home/pnx/", "tmptree"); - - while(indexer_pending()) { - indexer_run(5); - sleep(1); - } - - printf("done\n"); - - return 0; -}