diff options
author | Christian Pointner <equinox@helsinki.at> | 2013-12-27 12:36:13 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2013-12-27 12:36:13 (GMT) |
commit | bfca54665d2fa4e72997ab9816b35011d756694e (patch) | |
tree | 36317219a8477ff7ca197090ea5ce346acc1ee28 /src/file_list.c | |
parent | b46d601c70c6a2f39ca1cd1de83b0aa561ce5204 (diff) |
fixed some depreacated library calls
Diffstat (limited to 'src/file_list.c')
-rw-r--r-- | src/file_list.c | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/src/file_list.c b/src/file_list.c index 44a4949..deb6337 100644 --- a/src/file_list.c +++ b/src/file_list.c @@ -52,31 +52,28 @@ static void delete_file(void* element) int file_list_init(file_list_t* list) { - list->mutex_ = g_mutex_new(); - if(!list->mutex_) - return -2; - + g_mutex_init(&(list->mutex_)); return slist_init(&(list->list_), &delete_file); } void file_list_clear(file_list_t* list) { - g_mutex_lock(list->mutex_); + g_mutex_lock(&(list->mutex_)); slist_clear(&(list->list_)); - g_mutex_unlock(list->mutex_); + g_mutex_unlock(&(list->mutex_)); } file_t* file_list_add(file_list_t* list, struct tm* time, const char* type, const char* format, const char* dir, mode_t mode) { - if(!list || !(list->mutex_)) + if(!list || !(&(list->mutex_))) return NULL; - + file_t* tmp = malloc(sizeof(file_t)); if(!tmp) return NULL; log_printf(INFO, "%s time: %02d:%02d:%02d on %d.%d.%d%s", type, time->tm_hour, time->tm_min, time->tm_sec, time->tm_mday, time->tm_mon+1, time->tm_year+1900, time->tm_isdst > 0 ? " (DST)": ""); - + char name[256]; strftime(name, sizeof(name), format, time); int len = asprintf(&(tmp->path_), "%s/%s", dir, name); @@ -90,24 +87,24 @@ file_t* file_list_add(file_list_t* list, struct tm* time, const char* type, cons tmp->mode_ = mode; tmp->pp_child_ = NULL; - g_mutex_lock(list->mutex_); + g_mutex_lock(&(list->mutex_)); if(slist_add(&(list->list_), tmp) == NULL) { - g_mutex_unlock(list->mutex_); + g_mutex_unlock(&(list->mutex_)); free(tmp->path_); free(tmp); return NULL; } - g_mutex_unlock(list->mutex_); + g_mutex_unlock(&(list->mutex_)); return tmp; } int file_list_remove(file_list_t* list, int fd) { - if(!list || !(list->mutex_)) + if(!list || !(&(list->mutex_))) return -1; - - g_mutex_lock(list->mutex_); + + g_mutex_lock(&(list->mutex_)); slist_element_t* tmp = list->list_.first_; while(tmp) { if(((file_t*)tmp->data_)->fd_ == fd) { @@ -116,24 +113,24 @@ int file_list_remove(file_list_t* list, int fd) } tmp = tmp->next_; } - g_mutex_unlock(list->mutex_); - + g_mutex_unlock(&(list->mutex_)); + return 0; } int file_list_call_post_process(file_list_t* list, int fd, char* script) { - if(!list || !(list->mutex_)) + if(!list || !(&(list->mutex_))) return -1; - - g_mutex_lock(list->mutex_); + + 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_); close(((file_t*)tmp->data_)->fd_); ((file_t*)tmp->data_)->fd_ = FILE_POST_PROCESS; - + char* const argv[] = { script, ((file_t*)tmp->data_)->path_, NULL }; char* const evp[] = { NULL }; ((file_t*)tmp->data_)->pp_child_ = rh_exec(script, argv, evp); @@ -144,17 +141,17 @@ int file_list_call_post_process(file_list_t* list, int fd, char* script) } tmp = tmp->next_; } - g_mutex_unlock(list->mutex_); - + g_mutex_unlock(&(list->mutex_)); + return 0; } int file_list_waitpid(file_list_t* list) { - if(!list || !(list->mutex_)) + if(!list || !(&(list->mutex_))) return -1; - - g_mutex_lock(list->mutex_); + + g_mutex_lock(&(list->mutex_)); slist_element_t* tmp = list->list_.first_; while(tmp) { if(((file_t*)tmp->data_)->fd_ == FILE_POST_PROCESS) { @@ -167,8 +164,8 @@ int file_list_waitpid(file_list_t* list) else tmp = tmp->next_; } - g_mutex_unlock(list->mutex_); - + g_mutex_unlock(&(list->mutex_)); + return 0; } @@ -198,7 +195,7 @@ int open_file(file_t* file) free(orig_path); return -2; } - + if(file->path_ != orig_path) free(file->path_); file->path_ = tmp; |