From c8bc6703879da5a96dbc1319a07fa307cf1892f1 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 20 Apr 2011 14:31:37 +0000 Subject: added option for post processing diff --git a/src/file_list.c b/src/file_list.c index c427381..c2027a0 100644 --- a/src/file_list.c +++ b/src/file_list.c @@ -120,6 +120,25 @@ int file_list_remove(file_list_t* list, int fd) return 0; } +int file_list_call_post_process(file_list_t* list, int fd) +{ + if(!list || !(list->mutex_)) + return -1; + + g_mutex_lock(list->mutex_); + slist_element_t* tmp = list->list_.first_; + while(tmp) { + if(((file_t*)tmp->data_)->fd_ == fd) { + log_printf(INFO, "calling post processing for '%s'", ((file_t*)tmp->data_)->path_); + break; + } + tmp = tmp->next_; + } + g_mutex_unlock(list->mutex_); + + return 0; +} + int open_file(file_t* file) { if(!file || file->fd_ > 0) // file already open! diff --git a/src/file_list.h b/src/file_list.h index 322df62..4415f12 100644 --- a/src/file_list.h +++ b/src/file_list.h @@ -51,6 +51,7 @@ typedef struct file_list_struct file_list_t; int file_list_init(file_list_t* list); void file_list_clear(file_list_t* list); file_t* file_list_add(file_list_t* list, struct tm* time, const char* type, const char* format, const char* dir, mode_t mode); +int file_list_call_post_process(file_list_t* list, int fd); int file_list_remove(file_list_t* list, int fd); int open_file(file_t* file); diff --git a/src/options.c b/src/options.c index 0ad0844..90ea6f3 100644 --- a/src/options.c +++ b/src/options.c @@ -202,6 +202,7 @@ int options_parse(options_t* opt, int argc, char* argv[]) PARSE_INT_PARAM("-m","--mode", opt->mode_, 8) PARSE_INT_PARAM("-i","--interval", opt->interval_, 10) PARSE_INT_PARAM("-o","--offset", opt->offset_, 10) + PARSE_STRING_PARAM("-x","--post-process", opt->post_process_) else return i; } @@ -248,6 +249,7 @@ void options_default(options_t* opt) opt->mode_ = 0644; opt->interval_ = 50; opt->offset_ = 0; + opt->post_process_ = NULL; } void options_clear(options_t* opt) @@ -272,6 +274,8 @@ void options_clear(options_t* opt) free(opt->output_dir_); if(opt->name_format_) free(opt->name_format_); + if(opt->post_process_) + free(opt->post_process_); } void options_print_usage() @@ -294,6 +298,7 @@ void options_print_usage() printf(" [-m|--mode] ocatl represantion of the file permission mode\n"); printf(" [-i|--interval] interval for time checks in ms\n"); printf(" [-o|--offset] time offset for recordings in ms\n"); + printf(" [-x|--post-process]