Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
//%% (c) Copyright 1993, 1994 Novell, Inc.
//%% $XConsortium: common.C /main/3 1995/10/20 16:25:17 rswiston $
/*
*
* common.cc
*
* Some utility routines common to all inspect-and-repair tools (but
* not part of any class.)
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*/
#include "dbck.h"
static int
do_a_directory(_Tt_string path, int (*fn)(_Tt_string))
{
_Tt_string suffix("TT_DB/");
if (path.right(1)!="/") {
path = path.cat("/");
}
if (path.right(suffix.len())!=suffix) {
path = path.cat(suffix);
}
return (*fn)(path);
}
int
do_directories(const _Tt_string_list_ptr &dirs, int (*fn)(_Tt_string))
{
int failcount = 0;
_Tt_string_list_cursor c(dirs);
if (dirs->is_empty()) {
failcount = !do_a_directory(".",fn);
} else {
while(c.next()) {
failcount += !do_a_directory(*c,fn);
}
}
return failcount;
}