diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-06-16 19:46:38 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-06-16 19:46:38 +0000 |
commit | 2986a63f7e513cf37f46db9f211b77071260031f (patch) | |
tree | 9a6e62602396938ea5a612420f53ebf267e8d941 /NetWare/nwplglob.c | |
parent | 87b11a197a59fac210fc9265bde0ef1ffe36de89 (diff) | |
download | perl-2986a63f7e513cf37f46db9f211b77071260031f.tar.gz |
NetWare port from Guruprasad S <SGURUPRASAD@novell.com>.
p4raw-id: //depot/perl@10643
Diffstat (limited to 'NetWare/nwplglob.c')
-rw-r--r-- | NetWare/nwplglob.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/NetWare/nwplglob.c b/NetWare/nwplglob.c new file mode 100644 index 0000000000..c7a210458c --- /dev/null +++ b/NetWare/nwplglob.c @@ -0,0 +1,90 @@ + +/* + * Copyright © 2001 Novell, Inc. All Rights Reserved. + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the README file. + * + */ + +/* + * FILENAME : nwplglob.c + * DESCRIPTION : Perl globbing support for NetWare. Other platforms have usually lauched + * a separate executable for this in order to take advantage of their + * shell's capability for generating a list of files from a given + * wildcard file spec. On NetWare, we don't have that luxury. + * So we just hack the support into pipe open support (which we also had to hack). + * Author : HYAK + * Date : January 2001. + * + */ + + + +#include <nwtypes.h> +#include "stdio.h" +#include <dirent.h> + +#include "win32ish.h" +#include "nwplglob.h" + + + +/*============================================================================================ + + Function : fnDoPerlGlob + + Description : Perl globbing support: Takes an array of wildcard descriptors + and produces from it a list of files that the wildcards expand into. + The list of files is written to the temporary file named by fileName. + + Parameters : argv (IN) - Input argument vector. + fileName (IN) - Input file name for storing globed file names. + + Returns : Nothing. + +==============================================================================================*/ + +void fnDoPerlGlob(char** argv, char* fileName) +{ + FILE * redirOut = NULL; + + if (*argv) + argv++; + if (*argv == NULL) + return; + + redirOut = fopen((const char *)fileName, (const char *)"w"); + if (!redirOut) + return; + + do + { + DIR* dir = NULL; + DIR* fil = NULL; + char* pattern = NULL; + + pattern = *argv++; + + dir = opendir((const char *)pattern); + if (!dir) + continue; + + /* find the last separator in pattern, NetWare has three: /\: */ + while (fil = readdir(dir)) + { + // The below displays the files separated by tab character. + // Also, it displays only the file names and not directories. + // If any other format is desired, it needs to be done here. + fprintf(redirOut, "%s\t", fil->d_name); + } + + closedir(dir); + + } while (*argv); + + fclose(redirOut); + + return; +} + |