X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Flist_dir.c;h=a909067e64be4db1283e705227a15afcb58a4387;hb=HEAD;hp=c38a30639b6d84876d7c59075ff33d4df2b47eeb;hpb=1194fb66aa28d9929c3f2bef3cc6c1c3f40a60a4;p=debian%2Famanda diff --git a/server-src/list_dir.c b/server-src/list_dir.c index c38a306..a909067 100644 --- a/server-src/list_dir.c +++ b/server-src/list_dir.c @@ -1,6 +1,7 @@ /* * Amanda, The Advanced Maryland Automatic Network Disk Archiver * Copyright (c) 1991-1998 University of Maryland at College Park + * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved. * All Rights Reserved. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -23,7 +24,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 +37,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 +71,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); @@ -85,13 +90,15 @@ char *path; return 0; /* added */ } - if(strcmp(path,dir_last->path) == 0) + if (strcmp(path, "/") != 0 && + strcmp(path, dir_last->path) == 0) { return 0; /* found */ + } /* 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 +124,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 +141,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;