X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Flist_dir.c;h=060f07f8e44dd2eccbf1033be75c101f4863f90c;hb=621a0076ec80b352e52ba6f05f1729e254bfa423;hp=c38a30639b6d84876d7c59075ff33d4df2b47eeb;hpb=1194fb66aa28d9929c3f2bef3cc6c1c3f40a60a4;p=debian%2Famanda diff --git a/server-src/list_dir.c b/server-src/list_dir.c index c38a306..060f07f 100644 --- a/server-src/list_dir.c +++ b/server-src/list_dir.c @@ -23,7 +23,7 @@ * Authors: the Amanda Development Team. Its members are listed in a * file named AUTHORS, in the root directory of this distribution. */ -/* $Id: list_dir.c,v 1.17 2002/03/24 19:25:51 jrjackson Exp $ +/* $Id: list_dir.c,v 1.19 2006/07/05 11:22:49 martinea Exp $ * * manage directory listings from index files */ @@ -36,13 +36,15 @@ DIR_ITEM *dir_list = NULL; /* first dir entry */ DIR_ITEM *dir_last = NULL; /* last dir entry */ DIR_ITEM *cur_list = NULL; /* current dir entry,for speeding up search */ -DIR_ITEM *get_dir_list() +DIR_ITEM * +get_dir_list(void) { return dir_list; } -void clear_dir_list P((void)) +void +clear_dir_list(void) { DIR_ITEM *this; @@ -68,15 +70,17 @@ void clear_dir_list P((void)) /* It's true because the output of the index file is sorted */ /* Maybe it could be more efficient if the index was sorted when */ /* it is generated */ -int add_dir_list_item(dump, path) -DUMP_ITEM *dump; -char *path; + +int +add_dir_list_item( + DUMP_ITEM * dump, + const char *path) { DIR_ITEM *cur; if (dir_list == NULL) { - dir_list = (DIR_ITEM *)alloc(sizeof(DIR_ITEM)); + dir_list = (DIR_ITEM *)alloc(SIZEOF(DIR_ITEM)); dir_list->next = NULL; dir_list->dump = dump; dir_list->path = stralloc(path); @@ -91,7 +95,7 @@ char *path; /* add at head of list */ if(strcmp(path,dir_list->path) < 0) { - cur_list = (DIR_ITEM *)alloc(sizeof(DIR_ITEM)); + cur_list = (DIR_ITEM *)alloc(SIZEOF(DIR_ITEM)); cur_list->next = dir_list; cur_list->dump = dump; cur_list->path = stralloc(path); @@ -117,14 +121,14 @@ char *path; cur_list=cur_list->next; } - if(strcmp(path,cur_list->next->path) == 0) + if (cur_list->next && strcmp(path, cur_list->next->path) == 0) { cur_list=cur_list->next; return 0; /* found */ } /* add at cur_list */ - cur = (DIR_ITEM *)alloc(sizeof(DIR_ITEM)); + cur = (DIR_ITEM *)alloc(SIZEOF(DIR_ITEM)); cur->next = cur_list->next; cur->dump = dump; cur->path = stralloc(path); @@ -134,7 +138,7 @@ char *path; } else /* add at end of list */ { - dir_last->next = (DIR_ITEM *)alloc(sizeof(DIR_ITEM)); + dir_last->next = (DIR_ITEM *)alloc(SIZEOF(DIR_ITEM)); dir_last=dir_last->next; dir_last->next = NULL; dir_last->dump = dump;