[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Condor-devel] fun new option: LOCAL_CONFIG_DIR
- Date: Thu, 9 Mar 2006 22:48:34 -0600
- From: Erik Paulson <epaulson@xxxxxxxxxxx>
- Subject: Re: [Condor-devel] fun new option: LOCAL_CONFIG_DIR
On Thu, Mar 09, 2006 at 07:00:43PM -0600, Erik Paulson wrote:
>
> It's currently a single directory, though I might change that
> to be a list of directories.
>
I added this, see the new patch
-Erik
Index: condor_config.C
===================================================================
RCS file: /p/condor/repository/CONDOR_SRC/src/condor_c++_util/condor_config.C,v
retrieving revision 1.56.8.19.6.10.4.18
diff -r1.56.8.19.6.10.4.18 condor_config.C
92a93
> void process_directory( char*, char*);
394a396,399
> char *dirlist = param("LOCAL_CONFIG_DIR");
> if(dirlist) {
> process_directory(dirlist, host);
> }
396a402,411
> char* newdirlist = param("LOCAL_CONFIG_DIR");
> if(newdirlist && dirlist) {
> if(strcmp(dirlist, newdirlist) ) {
> process_directory(newdirlist, host);
> }
> }
>
> if(dirlist) { free(dirlist); dirlist = NULL; }
> if(newdirlist) { free(newdirlist); newdirlist = NULL; }
>
605a621,680
> int compareFiles(const void *a, const void *b) {
> return strcmp(*(char **)a, *(char **)b);
> }
>
> // examine each file in a directory and treat it as a config file
> void
> process_directory( char* dirlist, char* host )
> {
> StringList locals;
> Directory *files;
> char *file, *dirpath;
> char **paths;
> char *tmp;
> int local_required;
>
> local_required = true;
> tmp = param( "REQUIRE_LOCAL_CONFIG_FILE" );
> if( tmp ) {
> if( tmp[0] == 'f' || tmp[0] == 'F' ) {
> local_required = false;
> }
> free( tmp );
> }
>
> if(!dirlist) { return; }
> locals.initializeFromString( dirlist );
> locals.rewind();
> while( (dirpath = locals.next()) ) {
>
> paths = (char **)calloc(65536, sizeof(char *));
> files = new Directory(dirpath);
> int i = 0;
> if(files == NULL) {
> fprintf(stderr, "Cannot open %s\n", dirpath);
> } else {
> while( (file = (char *)files->Next()) && i < 65536) {
> // don't consider directories
> // maybe we should squash symlinks here...
> if(! files->IsDirectory() ) {
> paths[i] = strdup((char *)files->GetFullPath());
> i++;
> }
> }
> delete files;
> }
> qsort(paths, i, sizeof(char *), compareFiles);
> char **pathCopy = paths;
> while(*pathCopy) {
> process_file( *pathCopy, "config file", host, local_required );
> if (local_config_files.Length() > 0) {
> local_config_files += " ";
> }
> local_config_files += *pathCopy;
> //fprintf(stderr, "We could be creating %s\n", *pathCopy);
> free(*pathCopy);
> pathCopy++;
> }
> free(paths);
> }
> }