This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
style: Detabify indentation of the C code maintained by the core.
authorMichael G. Schwern <schwern@pobox.com>
Tue, 29 Dec 2020 02:04:52 +0000 (18:04 -0800)
committerKarl Williamson <khw@cpan.org>
Sun, 17 Jan 2021 16:18:15 +0000 (09:18 -0700)
This just detabifies to get rid of the mixed tab/space indentation.

Applying consistent indentation and dealing with other tabs are another issue.

Done with `expand -i`.

* vutil.* left alone, it's part of version.
* Left regen managed files alone for now.

128 files changed:
NetWare/CLIBstuf.c
NetWare/Main.c
NetWare/NWTInfo.c
NetWare/NWUtil.c
NetWare/Nwmain.c
NetWare/Nwpipe.c
NetWare/deb.h
NetWare/intdef.h
NetWare/interface.c
NetWare/interface.h
NetWare/iperlhost.h
NetWare/netware.h
NetWare/nw5.c
NetWare/nw5sck.c
NetWare/nw5thread.c
NetWare/nw5thread.h
NetWare/nwhashcls.h
NetWare/nwperlhost.h
NetWare/nwperlsys.c
NetWare/nwperlsys.h
NetWare/nwpipe.h
NetWare/nwplglob.c
NetWare/nwtinfo.h
NetWare/nwutil.h
NetWare/nwvmem.h
NetWare/win32ish.h
Porting/timecheck.c
Porting/timecheck2.c
amigaos4/amigaio.c
amigaos4/amigaio.h
amigaos4/amigaos.c
av.c
av.h
cv.h
cygwin/cygwin.c
deb.c
dist/IO/poll.c
djgpp/djgpp.c
doio.c
doop.c
dosish.h
dquote.c
dump.c
ext/DynaLoader/dlutils.c
ext/File-Glob/bsd_glob.c
ext/File-Glob/bsd_glob.h
ext/SDBM_File/dba.c
ext/SDBM_File/dbd.c
ext/SDBM_File/dbe.c
ext/SDBM_File/dbu.c
ext/SDBM_File/sdbm.c
ext/SDBM_File/sdbm.h
ext/SDBM_File/tune.h
ext/SDBM_File/util.c
ext/Win32CORE/Win32CORE.c
generate_uudmap.c
gv.c
gv.h
handy.h
hints/t001.c
hv.c
hv.h
inline.h
intrpvar.h
invlist_inline.h
iperlsys.h
locale.c
malloc.c
mathoms.c
mg.c
mg.h
mro_core.c
numeric.c
op.h
os2/dl_os2.c
os2/os2.c
os2/os2ish.h
os2/perlrexx.c
pad.c
pad.h
parser.h
patchlevel.h
perl_inc_macro.h
perlio.c
perlio.h
perliol.h
perlvars.h
perly.c
plan9/plan9.c
plan9/plan9ish.h
pp.h
pp_ctl.c
pp_hot.c
pp_pack.c
pp_sys.c
qnx/qnx.c
regcomp.c
regcomp.h
regen.pl
scope.c
scope.h
t/lib/h2ph.h
taint.c
thread.h
universal.c
unixish.h
utf8.c
utf8.h
utfebcdic.h
util.c
util.h
vms/munchconfig.c
vms/vms.c
vms/vmsish.h
win32/fcrypt.c
win32/include/dirent.h
win32/include/sys/socket.h
win32/perlglob.c
win32/perlhost.h
win32/perllib.c
win32/vdir.h
win32/vmem.h
win32/win32.c
win32/win32.h
win32/win32io.c
win32/win32iop.h
win32/win32sck.c
win32/win32thread.h

index 26a4a4b..f0e58b1 100644 (file)
 
 void ImportFromCLIB (unsigned int nlmHandle, void** psymbol, char* symbolName)
 {
-       *psymbol = ImportSymbol(nlmHandle, symbolName);
-       if (*psymbol == NULL)
-       {
-               ConsolePrintf("Symbol %s not found, unable to continue\n", symbolName);
-               exit(1);
-       }
+        *psymbol = ImportSymbol(nlmHandle, symbolName);
+        if (*psymbol == NULL)
+        {
+                ConsolePrintf("Symbol %s not found, unable to continue\n", symbolName);
+                exit(1);
+        }
 }
 
 
 void fnInitGpfGlobals(void)
 {
-       unsigned int nlmHandle = GetNLMHandle();
-
-       ImportFromCLIB(nlmHandle, &gpf___get_stdin, "__get_stdin");
-       ImportFromCLIB(nlmHandle, &gpf___get_stdout, "__get_stdout");
-       ImportFromCLIB(nlmHandle, &gpf___get_stderr, "__get_stderr");
-       ImportFromCLIB(nlmHandle, &gpf_clearerr, "clearerr");
-       ImportFromCLIB(nlmHandle, &gpf_fclose, "fclose");
-       ImportFromCLIB(nlmHandle, &gpf_feof, "feof");
-       ImportFromCLIB(nlmHandle, &gpf_ferror, "ferror");
-       ImportFromCLIB(nlmHandle, &gpf_fflush, "fflush");
-       ImportFromCLIB(nlmHandle, &gpf_fgetc, "fgetc");
-       ImportFromCLIB(nlmHandle, &gpf_fgetpos, "fgetpos");
-       ImportFromCLIB(nlmHandle, &gpf_fgets, "fgets");
-       ImportFromCLIB(nlmHandle, &gpf_fopen, "fopen");
-       ImportFromCLIB(nlmHandle, &gpf_fputc, "fputc");
-       ImportFromCLIB(nlmHandle, &gpf_fputs, "fputs");
-       ImportFromCLIB(nlmHandle, &gpf_fread, "fread");
-       ImportFromCLIB(nlmHandle, &gpf_freopen, "freopen");
-       ImportFromCLIB(nlmHandle, &gpf_fscanf, "fscanf");
-       ImportFromCLIB(nlmHandle, &gpf_fseek, "fseek");
-       ImportFromCLIB(nlmHandle, &gpf_fsetpos, "fsetpos");
-       ImportFromCLIB(nlmHandle, &gpf_ftell, "ftell");
-       ImportFromCLIB(nlmHandle, &gpf_fwrite, "fwrite");
-       ImportFromCLIB(nlmHandle, &gpf_getc, "getc");
-       ImportFromCLIB(nlmHandle, &gpf_getchar, "getchar");
-       ImportFromCLIB(nlmHandle, &gpf_gets, "gets");
-       ImportFromCLIB(nlmHandle, &gpf_perror, "perror");
-       ImportFromCLIB(nlmHandle, &gpf_putc, "putc");
-       ImportFromCLIB(nlmHandle, &gpf_putchar, "putchar");
-       ImportFromCLIB(nlmHandle, &gpf_puts, "puts");
-       ImportFromCLIB(nlmHandle, &gpf_rename, "rename");
-       ImportFromCLIB(nlmHandle, &gpf_rewind, "rewind");
-       ImportFromCLIB(nlmHandle, &gpf_scanf, "scanf");
-       ImportFromCLIB(nlmHandle, &gpf_setbuf, "setbuf");
-       ImportFromCLIB(nlmHandle, &gpf_setvbuf, "setvbuf");
-       ImportFromCLIB(nlmHandle, &gpf_sscanf, "sscanf");
-       ImportFromCLIB(nlmHandle, &gpf_tmpfile, "tmpfile");
-       ImportFromCLIB(nlmHandle, &gpf_tmpnam, "tmpnam");
-       ImportFromCLIB(nlmHandle, &gpf_ungetc, "ungetc");
-       ImportFromCLIB(nlmHandle, &gpf_vfscanf, "vfscanf");
-       ImportFromCLIB(nlmHandle, &gpf_vscanf, "vscanf");
-       ImportFromCLIB(nlmHandle, &gpf_vsscanf, "vsscanf");
-       ImportFromCLIB(nlmHandle, &gpf_fdopen, "fdopen");
-       ImportFromCLIB(nlmHandle, &gpf_fileno, "fileno");
-       ImportFromCLIB(nlmHandle, &gpf_cgets, "cgets");
-       ImportFromCLIB(nlmHandle, &gpf_cprintf, "cprintf");
-       ImportFromCLIB(nlmHandle, &gpf_cputs, "cputs");
-       ImportFromCLIB(nlmHandle, &gpf_cscanf, "cscanf");
-       ImportFromCLIB(nlmHandle, &gpf_fcloseall, "fcloseall");
-       ImportFromCLIB(nlmHandle, &gpf_fgetchar, "fgetchar");
-       ImportFromCLIB(nlmHandle, &gpf_flushall, "flushall");
-       ImportFromCLIB(nlmHandle, &gpf_fputchar, "fputchar");
-       ImportFromCLIB(nlmHandle, &gpf_getch, "getch");
-       ImportFromCLIB(nlmHandle, &gpf_getche, "getche");
-       ImportFromCLIB(nlmHandle, &gpf_putch, "putch");
-       ImportFromCLIB(nlmHandle, &gpf_ungetch, "ungetch");
-       ImportFromCLIB(nlmHandle, &gpf_vcprintf, "vcprintf");
-       ImportFromCLIB(nlmHandle, &gpf_vcscanf, "vcscanf");
-
-       ImportFromCLIB(nlmHandle, &gpf_memchr, "memchr");
-       ImportFromCLIB(nlmHandle, &gpf_memcmp, "memcmp");
-       ImportFromCLIB(nlmHandle, &gpf_memcpy, "memcpy");
-       ImportFromCLIB(nlmHandle, &gpf_memmove, "memmove");
-       ImportFromCLIB(nlmHandle, &gpf_memset, "memset");
-       ImportFromCLIB(nlmHandle, &gpf_memicmp, "memicmp");
-
-       ImportFromCLIB(nlmHandle, &gpf_strerror, "strerror");
-       ImportFromCLIB(nlmHandle, &gpf_strtok_r, "strtok_r");
-       
-       ImportFromCLIB(nlmHandle, &gpf_strcpy, "strcpy");
-       ImportFromCLIB(nlmHandle, &gpf_strcat, "strcat");
-       ImportFromCLIB(nlmHandle, &gpf_strchr, "strchr");
-       ImportFromCLIB(nlmHandle, &gpf_strstr, "strstr");
-       ImportFromCLIB(nlmHandle, &gpf_strcoll, "strcoll");
-       ImportFromCLIB(nlmHandle, &gpf_strcspn, "strcspn");
-       ImportFromCLIB(nlmHandle, &gpf_strpbrk, "strpbrk");
-       ImportFromCLIB(nlmHandle, &gpf_strrchr, "strrchr");
-       ImportFromCLIB(nlmHandle, &gpf_strrev, "strrev");
-       ImportFromCLIB(nlmHandle, &gpf_strspn, "strspn");
-       ImportFromCLIB(nlmHandle, &gpf_strupr, "strupr");
-       ImportFromCLIB(nlmHandle, &gpf_strxfrm, "strxfrm");
-       ImportFromCLIB(nlmHandle, &gpf_strcmp, "strcmp");
-       ImportFromCLIB(nlmHandle, &gpf_stricmp, "stricmp");
-       ImportFromCLIB(nlmHandle, &gpf_strtok, "strtok");
-       ImportFromCLIB(nlmHandle, &gpf_strlen, "strlen");
-       ImportFromCLIB(nlmHandle, &gpf_strncpy, "strncpy");
-       ImportFromCLIB(nlmHandle, &gpf_strncat, "strncat");
-       ImportFromCLIB(nlmHandle, &gpf_strncmp, "strncmp");
-       ImportFromCLIB(nlmHandle, &gpf_strcmpi, "strcmpi");
-       ImportFromCLIB(nlmHandle, &gpf_strnicmp, "strnicmp");
-       ImportFromCLIB(nlmHandle, &gpf_strdup, "strdup");
-       ImportFromCLIB(nlmHandle, &gpf_strlist, "strlist");
-       ImportFromCLIB(nlmHandle, &gpf_strlwr, "strlwr");
-       ImportFromCLIB(nlmHandle, &gpf_strnset, "strnset");
-       ImportFromCLIB(nlmHandle, &gpf_strset, "strset");
-       ImportFromCLIB(nlmHandle, &gpf_strtok_r, "strtok_r");
-       ImportFromCLIB(nlmHandle, &gpf_printf, "printf");
-       ImportFromCLIB(nlmHandle, &gpf_fprintf, "fprintf");
-       ImportFromCLIB(nlmHandle, &gpf_sprintf, "sprintf");
-       ImportFromCLIB(nlmHandle, &gpf_vprintf, "vprintf");
-       ImportFromCLIB(nlmHandle, &gpf_vfprintf, "vfprintf");
-       ImportFromCLIB(nlmHandle, &gpf_vsprintf, "vsprintf");
+        unsigned int nlmHandle = GetNLMHandle();
+
+        ImportFromCLIB(nlmHandle, &gpf___get_stdin, "__get_stdin");
+        ImportFromCLIB(nlmHandle, &gpf___get_stdout, "__get_stdout");
+        ImportFromCLIB(nlmHandle, &gpf___get_stderr, "__get_stderr");
+        ImportFromCLIB(nlmHandle, &gpf_clearerr, "clearerr");
+        ImportFromCLIB(nlmHandle, &gpf_fclose, "fclose");
+        ImportFromCLIB(nlmHandle, &gpf_feof, "feof");
+        ImportFromCLIB(nlmHandle, &gpf_ferror, "ferror");
+        ImportFromCLIB(nlmHandle, &gpf_fflush, "fflush");
+        ImportFromCLIB(nlmHandle, &gpf_fgetc, "fgetc");
+        ImportFromCLIB(nlmHandle, &gpf_fgetpos, "fgetpos");
+        ImportFromCLIB(nlmHandle, &gpf_fgets, "fgets");
+        ImportFromCLIB(nlmHandle, &gpf_fopen, "fopen");
+        ImportFromCLIB(nlmHandle, &gpf_fputc, "fputc");
+        ImportFromCLIB(nlmHandle, &gpf_fputs, "fputs");
+        ImportFromCLIB(nlmHandle, &gpf_fread, "fread");
+        ImportFromCLIB(nlmHandle, &gpf_freopen, "freopen");
+        ImportFromCLIB(nlmHandle, &gpf_fscanf, "fscanf");
+        ImportFromCLIB(nlmHandle, &gpf_fseek, "fseek");
+        ImportFromCLIB(nlmHandle, &gpf_fsetpos, "fsetpos");
+        ImportFromCLIB(nlmHandle, &gpf_ftell, "ftell");
+        ImportFromCLIB(nlmHandle, &gpf_fwrite, "fwrite");
+        ImportFromCLIB(nlmHandle, &gpf_getc, "getc");
+        ImportFromCLIB(nlmHandle, &gpf_getchar, "getchar");
+        ImportFromCLIB(nlmHandle, &gpf_gets, "gets");
+        ImportFromCLIB(nlmHandle, &gpf_perror, "perror");
+        ImportFromCLIB(nlmHandle, &gpf_putc, "putc");
+        ImportFromCLIB(nlmHandle, &gpf_putchar, "putchar");
+        ImportFromCLIB(nlmHandle, &gpf_puts, "puts");
+        ImportFromCLIB(nlmHandle, &gpf_rename, "rename");
+        ImportFromCLIB(nlmHandle, &gpf_rewind, "rewind");
+        ImportFromCLIB(nlmHandle, &gpf_scanf, "scanf");
+        ImportFromCLIB(nlmHandle, &gpf_setbuf, "setbuf");
+        ImportFromCLIB(nlmHandle, &gpf_setvbuf, "setvbuf");
+        ImportFromCLIB(nlmHandle, &gpf_sscanf, "sscanf");
+        ImportFromCLIB(nlmHandle, &gpf_tmpfile, "tmpfile");
+        ImportFromCLIB(nlmHandle, &gpf_tmpnam, "tmpnam");
+        ImportFromCLIB(nlmHandle, &gpf_ungetc, "ungetc");
+        ImportFromCLIB(nlmHandle, &gpf_vfscanf, "vfscanf");
+        ImportFromCLIB(nlmHandle, &gpf_vscanf, "vscanf");
+        ImportFromCLIB(nlmHandle, &gpf_vsscanf, "vsscanf");
+        ImportFromCLIB(nlmHandle, &gpf_fdopen, "fdopen");
+        ImportFromCLIB(nlmHandle, &gpf_fileno, "fileno");
+        ImportFromCLIB(nlmHandle, &gpf_cgets, "cgets");
+        ImportFromCLIB(nlmHandle, &gpf_cprintf, "cprintf");
+        ImportFromCLIB(nlmHandle, &gpf_cputs, "cputs");
+        ImportFromCLIB(nlmHandle, &gpf_cscanf, "cscanf");
+        ImportFromCLIB(nlmHandle, &gpf_fcloseall, "fcloseall");
+        ImportFromCLIB(nlmHandle, &gpf_fgetchar, "fgetchar");
+        ImportFromCLIB(nlmHandle, &gpf_flushall, "flushall");
+        ImportFromCLIB(nlmHandle, &gpf_fputchar, "fputchar");
+        ImportFromCLIB(nlmHandle, &gpf_getch, "getch");
+        ImportFromCLIB(nlmHandle, &gpf_getche, "getche");
+        ImportFromCLIB(nlmHandle, &gpf_putch, "putch");
+        ImportFromCLIB(nlmHandle, &gpf_ungetch, "ungetch");
+        ImportFromCLIB(nlmHandle, &gpf_vcprintf, "vcprintf");
+        ImportFromCLIB(nlmHandle, &gpf_vcscanf, "vcscanf");
+
+        ImportFromCLIB(nlmHandle, &gpf_memchr, "memchr");
+        ImportFromCLIB(nlmHandle, &gpf_memcmp, "memcmp");
+        ImportFromCLIB(nlmHandle, &gpf_memcpy, "memcpy");
+        ImportFromCLIB(nlmHandle, &gpf_memmove, "memmove");
+        ImportFromCLIB(nlmHandle, &gpf_memset, "memset");
+        ImportFromCLIB(nlmHandle, &gpf_memicmp, "memicmp");
+
+        ImportFromCLIB(nlmHandle, &gpf_strerror, "strerror");
+        ImportFromCLIB(nlmHandle, &gpf_strtok_r, "strtok_r");
+        
+        ImportFromCLIB(nlmHandle, &gpf_strcpy, "strcpy");
+        ImportFromCLIB(nlmHandle, &gpf_strcat, "strcat");
+        ImportFromCLIB(nlmHandle, &gpf_strchr, "strchr");
+        ImportFromCLIB(nlmHandle, &gpf_strstr, "strstr");
+        ImportFromCLIB(nlmHandle, &gpf_strcoll, "strcoll");
+        ImportFromCLIB(nlmHandle, &gpf_strcspn, "strcspn");
+        ImportFromCLIB(nlmHandle, &gpf_strpbrk, "strpbrk");
+        ImportFromCLIB(nlmHandle, &gpf_strrchr, "strrchr");
+        ImportFromCLIB(nlmHandle, &gpf_strrev, "strrev");
+        ImportFromCLIB(nlmHandle, &gpf_strspn, "strspn");
+        ImportFromCLIB(nlmHandle, &gpf_strupr, "strupr");
+        ImportFromCLIB(nlmHandle, &gpf_strxfrm, "strxfrm");
+        ImportFromCLIB(nlmHandle, &gpf_strcmp, "strcmp");
+        ImportFromCLIB(nlmHandle, &gpf_stricmp, "stricmp");
+        ImportFromCLIB(nlmHandle, &gpf_strtok, "strtok");
+        ImportFromCLIB(nlmHandle, &gpf_strlen, "strlen");
+        ImportFromCLIB(nlmHandle, &gpf_strncpy, "strncpy");
+        ImportFromCLIB(nlmHandle, &gpf_strncat, "strncat");
+        ImportFromCLIB(nlmHandle, &gpf_strncmp, "strncmp");
+        ImportFromCLIB(nlmHandle, &gpf_strcmpi, "strcmpi");
+        ImportFromCLIB(nlmHandle, &gpf_strnicmp, "strnicmp");
+        ImportFromCLIB(nlmHandle, &gpf_strdup, "strdup");
+        ImportFromCLIB(nlmHandle, &gpf_strlist, "strlist");
+        ImportFromCLIB(nlmHandle, &gpf_strlwr, "strlwr");
+        ImportFromCLIB(nlmHandle, &gpf_strnset, "strnset");
+        ImportFromCLIB(nlmHandle, &gpf_strset, "strset");
+        ImportFromCLIB(nlmHandle, &gpf_strtok_r, "strtok_r");
+        ImportFromCLIB(nlmHandle, &gpf_printf, "printf");
+        ImportFromCLIB(nlmHandle, &gpf_fprintf, "fprintf");
+        ImportFromCLIB(nlmHandle, &gpf_sprintf, "sprintf");
+        ImportFromCLIB(nlmHandle, &gpf_vprintf, "vprintf");
+        ImportFromCLIB(nlmHandle, &gpf_vfprintf, "vfprintf");
+        ImportFromCLIB(nlmHandle, &gpf_vsprintf, "vsprintf");
 
 }
 
index 5116cbc..4dea1dd 100644 (file)
@@ -32,8 +32,8 @@
 #include "clibstuf.h"
 
 #ifdef MPK_ON
-       #include <mpktypes.h>
-       #include <mpkapis.h>
+        #include <mpktypes.h>
+        #include <mpkapis.h>
 #endif //MPK_ON
 
 
 
 void main(void)
 {
-       fnInitGpfGlobals();             // For importing the CLIB calls in place of the Watcom calls
-       SynchronizeStart();             // Don't allow anything else to happen until all the symbols are imported
-       #ifdef MPK_ON
-               ExitThread(TSR_THREAD, 0);
-       #else
-               ExitThread(TSR_THREAD, 0);
-       #endif
+        fnInitGpfGlobals();            // For importing the CLIB calls in place of the Watcom calls
+        SynchronizeStart();            // Don't allow anything else to happen until all the symbols are imported
+        #ifdef MPK_ON
+                ExitThread(TSR_THREAD, 0);
+        #else
+                ExitThread(TSR_THREAD, 0);
+        #endif
 }
 
 
 void ImportFromCLIB (unsigned int nlmHandle, void** psymbol, char* symbolName)
 {
-       *psymbol = ImportSymbol(nlmHandle, symbolName);
-       if (*psymbol == NULL)
-       {
-               ConsolePrintf("Symbol %s not found, unable to continue\n", symbolName);
-               exit(1);
-       }
+        *psymbol = ImportSymbol(nlmHandle, symbolName);
+        if (*psymbol == NULL)
+        {
+                ConsolePrintf("Symbol %s not found, unable to continue\n", symbolName);
+                exit(1);
+        }
 }
 
 
 void fnInitGpfGlobals(void)
 {
-       unsigned int nlmHandle = GetNLMHandle();
-
-       ImportFromCLIB(nlmHandle, &gpf___get_stdin, "__get_stdin");
-       ImportFromCLIB(nlmHandle, &gpf___get_stdout, "__get_stdout");
-       ImportFromCLIB(nlmHandle, &gpf___get_stderr, "__get_stderr");
-       ImportFromCLIB(nlmHandle, &gpf_clearerr, "clearerr");
-       ImportFromCLIB(nlmHandle, &gpf_fclose, "fclose");
-       ImportFromCLIB(nlmHandle, &gpf_feof, "feof");
-       ImportFromCLIB(nlmHandle, &gpf_ferror, "ferror");
-       ImportFromCLIB(nlmHandle, &gpf_fflush, "fflush");
-       ImportFromCLIB(nlmHandle, &gpf_fgetc, "fgetc");
-       ImportFromCLIB(nlmHandle, &gpf_fgetpos, "fgetpos");
-       ImportFromCLIB(nlmHandle, &gpf_fgets, "fgets");
-       ImportFromCLIB(nlmHandle, &gpf_fopen, "fopen");
-       ImportFromCLIB(nlmHandle, &gpf_fputc, "fputc");
-       ImportFromCLIB(nlmHandle, &gpf_fputs, "fputs");
-       ImportFromCLIB(nlmHandle, &gpf_fread, "fread");
-       ImportFromCLIB(nlmHandle, &gpf_freopen, "freopen");
-       ImportFromCLIB(nlmHandle, &gpf_fscanf, "fscanf");
-       ImportFromCLIB(nlmHandle, &gpf_fseek, "fseek");
-       ImportFromCLIB(nlmHandle, &gpf_fsetpos, "fsetpos");
-       ImportFromCLIB(nlmHandle, &gpf_ftell, "ftell");
-       ImportFromCLIB(nlmHandle, &gpf_fwrite, "fwrite");
-       ImportFromCLIB(nlmHandle, &gpf_getc, "getc");
-       ImportFromCLIB(nlmHandle, &gpf_getchar, "getchar");
-       ImportFromCLIB(nlmHandle, &gpf_gets, "gets");
-       ImportFromCLIB(nlmHandle, &gpf_perror, "perror");
-       ImportFromCLIB(nlmHandle, &gpf_putc, "putc");
-       ImportFromCLIB(nlmHandle, &gpf_putchar, "putchar");
-       ImportFromCLIB(nlmHandle, &gpf_puts, "puts");
-       ImportFromCLIB(nlmHandle, &gpf_rename, "rename");
-       ImportFromCLIB(nlmHandle, &gpf_rewind, "rewind");
-       ImportFromCLIB(nlmHandle, &gpf_scanf, "scanf");
-       ImportFromCLIB(nlmHandle, &gpf_setbuf, "setbuf");
-       ImportFromCLIB(nlmHandle, &gpf_setvbuf, "setvbuf");
-       ImportFromCLIB(nlmHandle, &gpf_sscanf, "sscanf");
-       ImportFromCLIB(nlmHandle, &gpf_tmpfile, "tmpfile");
-       ImportFromCLIB(nlmHandle, &gpf_tmpnam, "tmpnam");
-       ImportFromCLIB(nlmHandle, &gpf_ungetc, "ungetc");
-       ImportFromCLIB(nlmHandle, &gpf_vfscanf, "vfscanf");
-       ImportFromCLIB(nlmHandle, &gpf_vscanf, "vscanf");
-       ImportFromCLIB(nlmHandle, &gpf_vsscanf, "vsscanf");
-       ImportFromCLIB(nlmHandle, &gpf_fdopen, "fdopen");
-       ImportFromCLIB(nlmHandle, &gpf_fileno, "fileno");
-       ImportFromCLIB(nlmHandle, &gpf_cgets, "cgets");
-       ImportFromCLIB(nlmHandle, &gpf_cprintf, "cprintf");
-       ImportFromCLIB(nlmHandle, &gpf_cputs, "cputs");
-       ImportFromCLIB(nlmHandle, &gpf_cscanf, "cscanf");
-       ImportFromCLIB(nlmHandle, &gpf_fcloseall, "fcloseall");
-       ImportFromCLIB(nlmHandle, &gpf_fgetchar, "fgetchar");
-       ImportFromCLIB(nlmHandle, &gpf_flushall, "flushall");
-       ImportFromCLIB(nlmHandle, &gpf_fputchar, "fputchar");
-       ImportFromCLIB(nlmHandle, &gpf_getch, "getch");
-       ImportFromCLIB(nlmHandle, &gpf_getche, "getche");
-       ImportFromCLIB(nlmHandle, &gpf_putch, "putch");
-       ImportFromCLIB(nlmHandle, &gpf_ungetch, "ungetch");
-       ImportFromCLIB(nlmHandle, &gpf_vcprintf, "vcprintf");
-       ImportFromCLIB(nlmHandle, &gpf_vcscanf, "vcscanf");
-
-       ImportFromCLIB(nlmHandle, &gpf_memchr, "memchr");
-       ImportFromCLIB(nlmHandle, &gpf_memcmp, "memcmp");
-       ImportFromCLIB(nlmHandle, &gpf_memcpy, "memcpy");
-       ImportFromCLIB(nlmHandle, &gpf_memmove, "memmove");
-       ImportFromCLIB(nlmHandle, &gpf_memset, "memset");
-       ImportFromCLIB(nlmHandle, &gpf_memicmp, "memicmp");
-
-       ImportFromCLIB(nlmHandle, &gpf_strerror, "strerror");
-       ImportFromCLIB(nlmHandle, &gpf_strtok_r, "strtok_r");
-       
-       ImportFromCLIB(nlmHandle, &gpf_strcpy, "strcpy");
-       ImportFromCLIB(nlmHandle, &gpf_strcat, "strcat");
-       ImportFromCLIB(nlmHandle, &gpf_strchr, "strchr");
-       ImportFromCLIB(nlmHandle, &gpf_strstr, "strstr");
-       ImportFromCLIB(nlmHandle, &gpf_strcoll, "strcoll");
-       ImportFromCLIB(nlmHandle, &gpf_strcspn, "strcspn");
-       ImportFromCLIB(nlmHandle, &gpf_strpbrk, "strpbrk");
-       ImportFromCLIB(nlmHandle, &gpf_strrchr, "strrchr");
-       ImportFromCLIB(nlmHandle, &gpf_strrev, "strrev");
-       ImportFromCLIB(nlmHandle, &gpf_strspn, "strspn");
-       ImportFromCLIB(nlmHandle, &gpf_strupr, "strupr");
-       ImportFromCLIB(nlmHandle, &gpf_strxfrm, "strxfrm");
-       ImportFromCLIB(nlmHandle, &gpf_strcmp, "strcmp");
-       ImportFromCLIB(nlmHandle, &gpf_stricmp, "stricmp");
-       ImportFromCLIB(nlmHandle, &gpf_strtok, "strtok");
-       ImportFromCLIB(nlmHandle, &gpf_strlen, "strlen");
-       ImportFromCLIB(nlmHandle, &gpf_strncpy, "strncpy");
-       ImportFromCLIB(nlmHandle, &gpf_strncat, "strncat");
-       ImportFromCLIB(nlmHandle, &gpf_strncmp, "strncmp");
-       ImportFromCLIB(nlmHandle, &gpf_strcmpi, "strcmpi");
-       ImportFromCLIB(nlmHandle, &gpf_strnicmp, "strnicmp");
-       ImportFromCLIB(nlmHandle, &gpf_strdup, "strdup");
-       ImportFromCLIB(nlmHandle, &gpf_strlist, "strlist");
-       ImportFromCLIB(nlmHandle, &gpf_strlwr, "strlwr");
-       ImportFromCLIB(nlmHandle, &gpf_strnset, "strnset");
-       ImportFromCLIB(nlmHandle, &gpf_strset, "strset");
-       ImportFromCLIB(nlmHandle, &gpf_strtok_r, "strtok_r");
-       ImportFromCLIB(nlmHandle, &gpf_printf, "printf");
-       ImportFromCLIB(nlmHandle, &gpf_fprintf, "fprintf");
-       ImportFromCLIB(nlmHandle, &gpf_sprintf, "sprintf");
-       ImportFromCLIB(nlmHandle, &gpf_vprintf, "vprintf");
-       ImportFromCLIB(nlmHandle, &gpf_vfprintf, "vfprintf");
-       ImportFromCLIB(nlmHandle, &gpf_vsprintf, "vsprintf");
+        unsigned int nlmHandle = GetNLMHandle();
+
+        ImportFromCLIB(nlmHandle, &gpf___get_stdin, "__get_stdin");
+        ImportFromCLIB(nlmHandle, &gpf___get_stdout, "__get_stdout");
+        ImportFromCLIB(nlmHandle, &gpf___get_stderr, "__get_stderr");
+        ImportFromCLIB(nlmHandle, &gpf_clearerr, "clearerr");
+        ImportFromCLIB(nlmHandle, &gpf_fclose, "fclose");
+        ImportFromCLIB(nlmHandle, &gpf_feof, "feof");
+        ImportFromCLIB(nlmHandle, &gpf_ferror, "ferror");
+        ImportFromCLIB(nlmHandle, &gpf_fflush, "fflush");
+        ImportFromCLIB(nlmHandle, &gpf_fgetc, "fgetc");
+        ImportFromCLIB(nlmHandle, &gpf_fgetpos, "fgetpos");
+        ImportFromCLIB(nlmHandle, &gpf_fgets, "fgets");
+        ImportFromCLIB(nlmHandle, &gpf_fopen, "fopen");
+        ImportFromCLIB(nlmHandle, &gpf_fputc, "fputc");
+        ImportFromCLIB(nlmHandle, &gpf_fputs, "fputs");
+        ImportFromCLIB(nlmHandle, &gpf_fread, "fread");
+        ImportFromCLIB(nlmHandle, &gpf_freopen, "freopen");
+        ImportFromCLIB(nlmHandle, &gpf_fscanf, "fscanf");
+        ImportFromCLIB(nlmHandle, &gpf_fseek, "fseek");
+        ImportFromCLIB(nlmHandle, &gpf_fsetpos, "fsetpos");
+        ImportFromCLIB(nlmHandle, &gpf_ftell, "ftell");
+        ImportFromCLIB(nlmHandle, &gpf_fwrite, "fwrite");
+        ImportFromCLIB(nlmHandle, &gpf_getc, "getc");
+        ImportFromCLIB(nlmHandle, &gpf_getchar, "getchar");
+        ImportFromCLIB(nlmHandle, &gpf_gets, "gets");
+        ImportFromCLIB(nlmHandle, &gpf_perror, "perror");
+        ImportFromCLIB(nlmHandle, &gpf_putc, "putc");
+        ImportFromCLIB(nlmHandle, &gpf_putchar, "putchar");
+        ImportFromCLIB(nlmHandle, &gpf_puts, "puts");
+        ImportFromCLIB(nlmHandle, &gpf_rename, "rename");
+        ImportFromCLIB(nlmHandle, &gpf_rewind, "rewind");
+        ImportFromCLIB(nlmHandle, &gpf_scanf, "scanf");
+        ImportFromCLIB(nlmHandle, &gpf_setbuf, "setbuf");
+        ImportFromCLIB(nlmHandle, &gpf_setvbuf, "setvbuf");
+        ImportFromCLIB(nlmHandle, &gpf_sscanf, "sscanf");
+        ImportFromCLIB(nlmHandle, &gpf_tmpfile, "tmpfile");
+        ImportFromCLIB(nlmHandle, &gpf_tmpnam, "tmpnam");
+        ImportFromCLIB(nlmHandle, &gpf_ungetc, "ungetc");
+        ImportFromCLIB(nlmHandle, &gpf_vfscanf, "vfscanf");
+        ImportFromCLIB(nlmHandle, &gpf_vscanf, "vscanf");
+        ImportFromCLIB(nlmHandle, &gpf_vsscanf, "vsscanf");
+        ImportFromCLIB(nlmHandle, &gpf_fdopen, "fdopen");
+        ImportFromCLIB(nlmHandle, &gpf_fileno, "fileno");
+        ImportFromCLIB(nlmHandle, &gpf_cgets, "cgets");
+        ImportFromCLIB(nlmHandle, &gpf_cprintf, "cprintf");
+        ImportFromCLIB(nlmHandle, &gpf_cputs, "cputs");
+        ImportFromCLIB(nlmHandle, &gpf_cscanf, "cscanf");
+        ImportFromCLIB(nlmHandle, &gpf_fcloseall, "fcloseall");
+        ImportFromCLIB(nlmHandle, &gpf_fgetchar, "fgetchar");
+        ImportFromCLIB(nlmHandle, &gpf_flushall, "flushall");
+        ImportFromCLIB(nlmHandle, &gpf_fputchar, "fputchar");
+        ImportFromCLIB(nlmHandle, &gpf_getch, "getch");
+        ImportFromCLIB(nlmHandle, &gpf_getche, "getche");
+        ImportFromCLIB(nlmHandle, &gpf_putch, "putch");
+        ImportFromCLIB(nlmHandle, &gpf_ungetch, "ungetch");
+        ImportFromCLIB(nlmHandle, &gpf_vcprintf, "vcprintf");
+        ImportFromCLIB(nlmHandle, &gpf_vcscanf, "vcscanf");
+
+        ImportFromCLIB(nlmHandle, &gpf_memchr, "memchr");
+        ImportFromCLIB(nlmHandle, &gpf_memcmp, "memcmp");
+        ImportFromCLIB(nlmHandle, &gpf_memcpy, "memcpy");
+        ImportFromCLIB(nlmHandle, &gpf_memmove, "memmove");
+        ImportFromCLIB(nlmHandle, &gpf_memset, "memset");
+        ImportFromCLIB(nlmHandle, &gpf_memicmp, "memicmp");
+
+        ImportFromCLIB(nlmHandle, &gpf_strerror, "strerror");
+        ImportFromCLIB(nlmHandle, &gpf_strtok_r, "strtok_r");
+        
+        ImportFromCLIB(nlmHandle, &gpf_strcpy, "strcpy");
+        ImportFromCLIB(nlmHandle, &gpf_strcat, "strcat");
+        ImportFromCLIB(nlmHandle, &gpf_strchr, "strchr");
+        ImportFromCLIB(nlmHandle, &gpf_strstr, "strstr");
+        ImportFromCLIB(nlmHandle, &gpf_strcoll, "strcoll");
+        ImportFromCLIB(nlmHandle, &gpf_strcspn, "strcspn");
+        ImportFromCLIB(nlmHandle, &gpf_strpbrk, "strpbrk");
+        ImportFromCLIB(nlmHandle, &gpf_strrchr, "strrchr");
+        ImportFromCLIB(nlmHandle, &gpf_strrev, "strrev");
+        ImportFromCLIB(nlmHandle, &gpf_strspn, "strspn");
+        ImportFromCLIB(nlmHandle, &gpf_strupr, "strupr");
+        ImportFromCLIB(nlmHandle, &gpf_strxfrm, "strxfrm");
+        ImportFromCLIB(nlmHandle, &gpf_strcmp, "strcmp");
+        ImportFromCLIB(nlmHandle, &gpf_stricmp, "stricmp");
+        ImportFromCLIB(nlmHandle, &gpf_strtok, "strtok");
+        ImportFromCLIB(nlmHandle, &gpf_strlen, "strlen");
+        ImportFromCLIB(nlmHandle, &gpf_strncpy, "strncpy");
+        ImportFromCLIB(nlmHandle, &gpf_strncat, "strncat");
+        ImportFromCLIB(nlmHandle, &gpf_strncmp, "strncmp");
+        ImportFromCLIB(nlmHandle, &gpf_strcmpi, "strcmpi");
+        ImportFromCLIB(nlmHandle, &gpf_strnicmp, "strnicmp");
+        ImportFromCLIB(nlmHandle, &gpf_strdup, "strdup");
+        ImportFromCLIB(nlmHandle, &gpf_strlist, "strlist");
+        ImportFromCLIB(nlmHandle, &gpf_strlwr, "strlwr");
+        ImportFromCLIB(nlmHandle, &gpf_strnset, "strnset");
+        ImportFromCLIB(nlmHandle, &gpf_strset, "strset");
+        ImportFromCLIB(nlmHandle, &gpf_strtok_r, "strtok_r");
+        ImportFromCLIB(nlmHandle, &gpf_printf, "printf");
+        ImportFromCLIB(nlmHandle, &gpf_fprintf, "fprintf");
+        ImportFromCLIB(nlmHandle, &gpf_sprintf, "sprintf");
+        ImportFromCLIB(nlmHandle, &gpf_vprintf, "vprintf");
+        ImportFromCLIB(nlmHandle, &gpf_vfprintf, "vfprintf");
+        ImportFromCLIB(nlmHandle, &gpf_vsprintf, "vsprintf");
 
 }
 
index b057d56..a1221e7 100644 (file)
 #include "nwtinfo.h"
 
 #ifdef MPK_ON
-       #include <mpktypes.h>   
-       #include <mpkapis.h>
+        #include <mpktypes.h>  
+        #include <mpkapis.h>
 #else
-       #include <nwsemaph.h>
+        #include <nwsemaph.h>
 #endif //MPK_ON
 
 // Number of entries in the hashtable
 // Semaphore to control access to global linked list
 //
 #ifdef MPK_ON
-       static SEMAPHORE g_tinfoSem = NULL;
-       static SEMAPHORE g_tCtxSem = NULL;
+        static SEMAPHORE g_tinfoSem = NULL;
+        static SEMAPHORE g_tCtxSem = NULL;
 #else
-       static LONG g_tinfoSem = 0L;
-       static LONG g_tCtxSem = 0L;
+        static LONG g_tinfoSem = 0L;
+        static LONG g_tCtxSem = 0L;
 #endif //MPK_ON
 
 // Hash table of thread information structures
@@ -70,37 +70,37 @@ ThreadContext* g_ThreadCtx;
 
 BOOL fnTerminateThreadInfo(void)
 {
-       int index = 0;
-
-       if (g_tinfoSem)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreWait(g_tinfoSem);
-               #else
-                       WaitOnLocalSemaphore(g_tinfoSem);
-               #endif  //MPK_ON
-               for (index = 0; index < NUM_ENTRIES; index++)
-               {
-                       if (g_ThreadInfo[index] != NULL)
-                       {
-                               #ifdef MPK_ON
-                                       kSemaphoreSignal(g_tinfoSem);
-                               #else
-                                       SignalLocalSemaphore(g_tinfoSem);
-                               #endif  //MPK_ON
-                               return FALSE;
-                       }
-               }
-               #ifdef MPK_ON
-                       kSemaphoreFree(g_tinfoSem);
-                       g_tinfoSem = NULL;
-               #else
-                       CloseLocalSemaphore(g_tinfoSem);
-                       g_tinfoSem = 0;
-               #endif  //MPK_ON
-       }
-
-       return TRUE;
+        int index = 0;
+
+        if (g_tinfoSem)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreWait(g_tinfoSem);
+                #else
+                        WaitOnLocalSemaphore(g_tinfoSem);
+                #endif //MPK_ON
+                for (index = 0; index < NUM_ENTRIES; index++)
+                {
+                        if (g_ThreadInfo[index] != NULL)
+                        {
+                                #ifdef MPK_ON
+                                        kSemaphoreSignal(g_tinfoSem);
+                                #else
+                                        SignalLocalSemaphore(g_tinfoSem);
+                                #endif //MPK_ON
+                                return FALSE;
+                        }
+                }
+                #ifdef MPK_ON
+                        kSemaphoreFree(g_tinfoSem);
+                        g_tinfoSem = NULL;
+                #else
+                        CloseLocalSemaphore(g_tinfoSem);
+                        g_tinfoSem = 0;
+                #endif //MPK_ON
+        }
+
+        return TRUE;
 }
 
 
@@ -109,7 +109,7 @@ BOOL fnTerminateThreadInfo(void)
  Function              :       fnInitializeThreadInfo
 
  Description   :       Initializes the global ThreadInfo hashtable and semaphore.
-                                       Call once per NLM instance
+                                        Call once per NLM instance
 
  Parameters    :       None.
 
@@ -119,22 +119,22 @@ BOOL fnTerminateThreadInfo(void)
 
 void fnInitializeThreadInfo(void)
 {
-       int index = 0;
+        int index = 0;
 
-       if (g_tinfoSem)
-               return;
+        if (g_tinfoSem)
+                return;
 
-       #ifdef MPK_ON
-               g_tinfoSem = kSemaphoreAlloc((BYTE *)"threadInfo", 1);
-       #else
-               g_tinfoSem = OpenLocalSemaphore(1);
-       #endif  //MPK_ON
-       
+        #ifdef MPK_ON
+                g_tinfoSem = kSemaphoreAlloc((BYTE *)"threadInfo", 1);
+        #else
+                g_tinfoSem = OpenLocalSemaphore(1);
+        #endif //MPK_ON
+        
 
-       for (index = 0; index < NUM_ENTRIES; index++)
-               g_ThreadInfo[index] = NULL;
+        for (index = 0; index < NUM_ENTRIES; index++)
+                g_ThreadInfo[index] = NULL;
 
-       return;
+        return;
 }
 
 
@@ -152,18 +152,18 @@ void fnInitializeThreadInfo(void)
 
 BOOL fnRegisterWithThreadTable(void)
 {
-       ThreadInfo* tinfo = NULL;
-
-       #ifdef MPK_ON
-               tinfo = fnAddThreadInfo(labs((int)kCurrentThread()));
-       #else
-               tinfo = fnAddThreadInfo(GetThreadID());
-       #endif  //MPK_ON
-       
-       if (!tinfo)
-               return FALSE;
-       else
-               return TRUE;
+        ThreadInfo* tinfo = NULL;
+
+        #ifdef MPK_ON
+                tinfo = fnAddThreadInfo(labs((int)kCurrentThread()));
+        #else
+                tinfo = fnAddThreadInfo(GetThreadID());
+        #endif //MPK_ON
+        
+        if (!tinfo)
+                return FALSE;
+        else
+                return TRUE;
 }
 
 
@@ -181,11 +181,11 @@ BOOL fnRegisterWithThreadTable(void)
 
 BOOL fnUnregisterWithThreadTable(void)
 {
-       #ifdef MPK_ON
-               return fnRemoveThreadInfo(labs((int)kCurrentThread()));
-       #else
-               return fnRemoveThreadInfo(GetThreadID());
-       #endif  //MPK_ON
+        #ifdef MPK_ON
+                return fnRemoveThreadInfo(labs((int)kCurrentThread()));
+        #else
+                return fnRemoveThreadInfo(GetThreadID());
+        #endif //MPK_ON
 }
 
 
@@ -203,50 +203,50 @@ BOOL fnUnregisterWithThreadTable(void)
 
 ThreadInfo* fnAddThreadInfo(int tid)
 {
-       ThreadInfo* tip = NULL;
-       int index = 0;
-
-       if (g_tinfoSem)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreWait(g_tinfoSem);
-               #else
-                       WaitOnLocalSemaphore(g_tinfoSem);
-               #endif  //MPK_ON
-       }
-
-       // Add a new one to the beginning of the hash entry
-       //
-       tip = (ThreadInfo *) malloc(sizeof(ThreadInfo));
-       if (tip == NULL)
-       {  
-               if (g_tinfoSem)
-               {
-                       #ifdef MPK_ON
-                               kSemaphoreSignal(g_tinfoSem);
-                       #else
-                               SignalLocalSemaphore(g_tinfoSem);
-                       #endif  //MPK_ON
-               }
-               return NULL;
-       }
-       index = INDEXOF(tid);     // just take the bottom five bits
-       tip->next            =  g_ThreadInfo[index];
-       tip->tid             =  tid;
-       tip->m_dontTouchHashLists = FALSE;
-       tip->m_allocList = NULL;
-
-       g_ThreadInfo [index] =  tip;
-       if (g_tinfoSem)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreSignal(g_tinfoSem);
-               #else
-                       SignalLocalSemaphore(g_tinfoSem);
-               #endif  //MPK_ON
-       }
-
-       return tip;
+        ThreadInfo* tip = NULL;
+        int index = 0;
+
+        if (g_tinfoSem)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreWait(g_tinfoSem);
+                #else
+                        WaitOnLocalSemaphore(g_tinfoSem);
+                #endif //MPK_ON
+        }
+
+        // Add a new one to the beginning of the hash entry
+        //
+        tip = (ThreadInfo *) malloc(sizeof(ThreadInfo));
+        if (tip == NULL)
+        {  
+                if (g_tinfoSem)
+                {
+                        #ifdef MPK_ON
+                                kSemaphoreSignal(g_tinfoSem);
+                        #else
+                                SignalLocalSemaphore(g_tinfoSem);
+                        #endif //MPK_ON
+                }
+                return NULL;
+        }
+        index = INDEXOF(tid);     // just take the bottom five bits
+        tip->next            =  g_ThreadInfo[index];
+        tip->tid             =  tid;
+        tip->m_dontTouchHashLists = FALSE;
+        tip->m_allocList = NULL;
+
+        g_ThreadInfo [index] =  tip;
+        if (g_tinfoSem)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreSignal(g_tinfoSem);
+                #else
+                        SignalLocalSemaphore(g_tinfoSem);
+                #endif //MPK_ON
+        }
+
+        return tip;
 }
 
 
@@ -255,7 +255,7 @@ ThreadInfo* fnAddThreadInfo(int tid)
  Function              :       fnRemoveThreadInfo
 
  Description   :       Frees the specified thread info structure and removes it from the
-                                       global linked list.
+                                        global linked list.
 
  Parameters    :       tid     (IN)    -       ID of the thread.
 
@@ -265,54 +265,54 @@ ThreadInfo* fnAddThreadInfo(int tid)
 
 BOOL fnRemoveThreadInfo(int tid)
 {
-       ThreadInfo* tip = NULL;
-       ThreadInfo* prevt = NULL;
-       int index = INDEXOF(tid);     // just take the bottom five bits
-
-       if (g_tinfoSem)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreWait(g_tinfoSem);
-               #else
-                       WaitOnLocalSemaphore(g_tinfoSem);
-               #endif  //MPK_ON
-       }
-
-       for (tip = g_ThreadInfo[index]; tip != NULL; tip = tip->next)
-       {
-               if (tip->tid == tid)
-               {
-                       if (prevt == NULL)
-                               g_ThreadInfo[index] = tip->next;
-                       else
-                               prevt->next = tip->next;
-
-                       free(tip);
-                       tip=NULL;
-                       if (g_tinfoSem)
-                       {
-                               #ifdef MPK_ON
-                                       kSemaphoreSignal(g_tinfoSem);
-                               #else
-                                       SignalLocalSemaphore(g_tinfoSem);
-                               #endif  //MPK_ON
-                       }
-
-                       return TRUE;
-               }
-               prevt = tip;
-       }
-
-       if (g_tinfoSem)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreSignal(g_tinfoSem);
-               #else
-                       SignalLocalSemaphore(g_tinfoSem);
-               #endif  //MPK_ON
-       }
-
-       return FALSE;       // entry not found
+        ThreadInfo* tip = NULL;
+        ThreadInfo* prevt = NULL;
+        int index = INDEXOF(tid);     // just take the bottom five bits
+
+        if (g_tinfoSem)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreWait(g_tinfoSem);
+                #else
+                        WaitOnLocalSemaphore(g_tinfoSem);
+                #endif //MPK_ON
+        }
+
+        for (tip = g_ThreadInfo[index]; tip != NULL; tip = tip->next)
+        {
+                if (tip->tid == tid)
+                {
+                        if (prevt == NULL)
+                                g_ThreadInfo[index] = tip->next;
+                        else
+                                prevt->next = tip->next;
+
+                        free(tip);
+                        tip=NULL;
+                        if (g_tinfoSem)
+                        {
+                                #ifdef MPK_ON
+                                        kSemaphoreSignal(g_tinfoSem);
+                                #else
+                                        SignalLocalSemaphore(g_tinfoSem);
+                                #endif //MPK_ON
+                        }
+
+                        return TRUE;
+                }
+                prevt = tip;
+        }
+
+        if (g_tinfoSem)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreSignal(g_tinfoSem);
+                #else
+                        SignalLocalSemaphore(g_tinfoSem);
+                #endif //MPK_ON
+        }
+
+        return FALSE;       // entry not found
 }
 
 
@@ -330,153 +330,153 @@ BOOL fnRemoveThreadInfo(int tid)
 
 ThreadInfo* fnGetThreadInfo(int tid)
 {
-       ThreadInfo*  tip;   
-       int index = INDEXOF(tid);     // just take the bottom five bits
-
-       if (g_tinfoSem) {
-               #ifdef MPK_ON
-                       kSemaphoreWait(g_tinfoSem);
-               #else
-                       WaitOnLocalSemaphore(g_tinfoSem);
-               #endif  //MPK_ON
-       }
-
-       // see if this is already in the table at the index'th offset
-       //
-       for (tip = g_ThreadInfo[index]; tip != NULL; tip = tip->next)
-       {
-               if (tip->tid == tid)
-               {
-                       if (g_tinfoSem)
-                       {
-                               #ifdef MPK_ON
-                                       kSemaphoreSignal(g_tinfoSem);
-                               #else
-                                       SignalLocalSemaphore(g_tinfoSem);
-                               #endif  //MPK_ON
-                       }
-                       return tip;
-               }
-       }
-
-       if (g_tinfoSem)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreSignal(g_tinfoSem);
-               #else
-                       SignalLocalSemaphore(g_tinfoSem);
-               #endif  //MPK_ON
-       }
-
-       return NULL;
+        ThreadInfo*  tip;   
+        int index = INDEXOF(tid);     // just take the bottom five bits
+
+        if (g_tinfoSem) {
+                #ifdef MPK_ON
+                        kSemaphoreWait(g_tinfoSem);
+                #else
+                        WaitOnLocalSemaphore(g_tinfoSem);
+                #endif //MPK_ON
+        }
+
+        // see if this is already in the table at the index'th offset
+        //
+        for (tip = g_ThreadInfo[index]; tip != NULL; tip = tip->next)
+        {
+                if (tip->tid == tid)
+                {
+                        if (g_tinfoSem)
+                        {
+                                #ifdef MPK_ON
+                                        kSemaphoreSignal(g_tinfoSem);
+                                #else
+                                        SignalLocalSemaphore(g_tinfoSem);
+                                #endif //MPK_ON
+                        }
+                        return tip;
+                }
+        }
+
+        if (g_tinfoSem)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreSignal(g_tinfoSem);
+                #else
+                        SignalLocalSemaphore(g_tinfoSem);
+                #endif //MPK_ON
+        }
+
+        return NULL;
 }
 
 BOOL fnInsertHashListAddrs(void *addrs, BOOL dontTouchHashList)
 {
-       ThreadInfo*  tip;   
-       int index,tid;
-
-       if (g_tinfoSem) 
-       {
-               #ifdef MPK_ON
-                       kSemaphoreWait(g_tinfoSem);
-               #else
-                       WaitOnLocalSemaphore(g_tinfoSem);
-               #endif  //MPK_ON
-       }
-
-       #ifdef MPK_ON
-               tid=index = abs(kCurrentThread());
-       #else
-               tid=index = GetThreadID();
-       #endif  //MPK_ON
-
-       index = INDEXOF(index);     // just take the bottom five bits   
-
-       // see if this is already in the table at the index'th offset
-       //
-       for (tip = g_ThreadInfo[index]; tip != NULL; tip = tip->next)
-       {
-               if (tip->tid == tid)
-               {
-                       if (g_tinfoSem)
-                       {
-                               #ifdef MPK_ON
-                                       kSemaphoreSignal(g_tinfoSem);
-                               #else
-                                       SignalLocalSemaphore(g_tinfoSem);
-                               #endif  //MPK_ON
-                       }
-                       tip->m_allocList = addrs;
-                       tip->m_dontTouchHashLists = dontTouchHashList;
-                       return TRUE;
-               }
-       }
-
-       if (g_tinfoSem)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreSignal(g_tinfoSem);
-               #else
-                       SignalLocalSemaphore(g_tinfoSem);
-               #endif  //MPK_ON
-       }
-
-       return FALSE;
+        ThreadInfo*  tip;   
+        int index,tid;
+
+        if (g_tinfoSem) 
+        {
+                #ifdef MPK_ON
+                        kSemaphoreWait(g_tinfoSem);
+                #else
+                        WaitOnLocalSemaphore(g_tinfoSem);
+                #endif //MPK_ON
+        }
+
+        #ifdef MPK_ON
+                tid=index = abs(kCurrentThread());
+        #else
+                tid=index = GetThreadID();
+        #endif //MPK_ON
+
+        index = INDEXOF(index);     // just take the bottom five bits   
+
+        // see if this is already in the table at the index'th offset
+        //
+        for (tip = g_ThreadInfo[index]; tip != NULL; tip = tip->next)
+        {
+                if (tip->tid == tid)
+                {
+                        if (g_tinfoSem)
+                        {
+                                #ifdef MPK_ON
+                                        kSemaphoreSignal(g_tinfoSem);
+                                #else
+                                        SignalLocalSemaphore(g_tinfoSem);
+                                #endif //MPK_ON
+                        }
+                        tip->m_allocList = addrs;
+                        tip->m_dontTouchHashLists = dontTouchHashList;
+                        return TRUE;
+                }
+        }
+
+        if (g_tinfoSem)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreSignal(g_tinfoSem);
+                #else
+                        SignalLocalSemaphore(g_tinfoSem);
+                #endif //MPK_ON
+        }
+
+        return FALSE;
 }
 
 BOOL fnGetHashListAddrs(void **addrs, BOOL *dontTouchHashList)
 {
-       ThreadInfo*  tip;   
-       int index,tid;   
-
-       if (g_tinfoSem) 
-       {
-               #ifdef MPK_ON
-                       kSemaphoreWait(g_tinfoSem);
-               #else
-                       WaitOnLocalSemaphore(g_tinfoSem);
-               #endif  //MPK_ON
-       }
-
-       #ifdef MPK_ON
-               tid=index = abs(kCurrentThread());
-       #else
-               tid=index = GetThreadID();
-       #endif  //MPK_ON
-
-       index = INDEXOF(index);     // just take the bottom five bits 
-
-       // see if this is already in the table at the index'th offset
-       //
-       for (tip = g_ThreadInfo[index]; tip != NULL; tip = tip->next)
-       {
-               if (tip->tid == tid)
-               {
-                       if (g_tinfoSem)
-                       {
-                               #ifdef MPK_ON
-                                       kSemaphoreSignal(g_tinfoSem);
-                               #else
-                                       SignalLocalSemaphore(g_tinfoSem);
-                               #endif  //MPK_ON
-                       }
-                       *addrs = tip->m_allocList;
-                       *dontTouchHashList = tip->m_dontTouchHashLists;
-                       return TRUE;
-               }
-       }
-
-       if (g_tinfoSem)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreSignal(g_tinfoSem);
-               #else
-                       SignalLocalSemaphore(g_tinfoSem);
-               #endif  //MPK_ON
-       }
-
-       return FALSE;
+        ThreadInfo*  tip;   
+        int index,tid;   
+
+        if (g_tinfoSem) 
+        {
+                #ifdef MPK_ON
+                        kSemaphoreWait(g_tinfoSem);
+                #else
+                        WaitOnLocalSemaphore(g_tinfoSem);
+                #endif //MPK_ON
+        }
+
+        #ifdef MPK_ON
+                tid=index = abs(kCurrentThread());
+        #else
+                tid=index = GetThreadID();
+        #endif //MPK_ON
+
+        index = INDEXOF(index);     // just take the bottom five bits 
+
+        // see if this is already in the table at the index'th offset
+        //
+        for (tip = g_ThreadInfo[index]; tip != NULL; tip = tip->next)
+        {
+                if (tip->tid == tid)
+                {
+                        if (g_tinfoSem)
+                        {
+                                #ifdef MPK_ON
+                                        kSemaphoreSignal(g_tinfoSem);
+                                #else
+                                        SignalLocalSemaphore(g_tinfoSem);
+                                #endif //MPK_ON
+                        }
+                        *addrs = tip->m_allocList;
+                        *dontTouchHashList = tip->m_dontTouchHashLists;
+                        return TRUE;
+                }
+        }
+
+        if (g_tinfoSem)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreSignal(g_tinfoSem);
+                #else
+                        SignalLocalSemaphore(g_tinfoSem);
+                #endif //MPK_ON
+        }
+
+        return FALSE;
 }
 
 
@@ -494,20 +494,20 @@ BOOL fnGetHashListAddrs(void **addrs, BOOL *dontTouchHashList)
 
 long fnInitializeThreadCtx(void)
 {
-       int index = 0;
-       //long tid;
+        int index = 0;
+        //long tid;
 
-       if (!g_tCtxSem) {
-               #ifdef MPK_ON
-                       g_tCtxSem = kSemaphoreAlloc((BYTE *)"threadCtx", 1);
-               #else
-                       g_tCtxSem = OpenLocalSemaphore(1);
-               #endif  //MPK_ON
+        if (!g_tCtxSem) {
+                #ifdef MPK_ON
+                        g_tCtxSem = kSemaphoreAlloc((BYTE *)"threadCtx", 1);
+                #else
+                        g_tCtxSem = OpenLocalSemaphore(1);
+                #endif //MPK_ON
 
-               g_ThreadCtx =NULL;
-       }
+                g_ThreadCtx =NULL;
+        }
 
-       return 0l;
+        return 0l;
 }
 
 
@@ -518,7 +518,7 @@ long fnInitializeThreadCtx(void)
  Description   :       Add a new thread context.
 
  Parameters    :       lTLSIndex       (IN)    -       Index
-                                             (IN)    -       void pointer.
+                                        t      (IN)    -       void pointer.
 
  Returns               :       Pointer to ThreadContext structure.
 
@@ -526,67 +526,67 @@ long fnInitializeThreadCtx(void)
 
 ThreadContext* fnAddThreadCtx(long lTLSIndex, void *t)
 {
-       ThreadContext* tip = NULL;
-       ThreadContext* temp = NULL;
-
-       if (g_tCtxSem)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreWait(g_tCtxSem);
-               #else
-                       WaitOnLocalSemaphore(g_tCtxSem);
-               #endif  //MPK_ON
-       }
-
-       // add a new one to the beginning of the list
-       //
-       tip = (ThreadContext *) malloc(sizeof(ThreadContext));
-       if (tip == NULL)
-       {  
-               if (g_tCtxSem)
-               {
-                       #ifdef MPK_ON
-                               kSemaphoreSignal(g_tCtxSem);
-                       #else
-                               SignalLocalSemaphore(g_tCtxSem);
-                       #endif  //MPK_ON
-               }
-               return NULL;
-       }
-
-       #ifdef MPK_ON
-               lTLSIndex = labs(kCurrentThread());
-       #else
-               lTLSIndex = GetThreadID();
-       #endif  //MPK_ON
-
-       tip->next            =  NULL;
-       tip->tid             =  lTLSIndex;
-       tip->tInfo                       =  t;
-
-       if(g_ThreadCtx==NULL) {
-               g_ThreadCtx = tip;
-       } else {
-               int count=0;
-               //Traverse to the end
-               temp = g_ThreadCtx;
-               while(temp->next != NULL)
-               {
-                       temp = temp->next;
-                       count++;
-               }
-               temp->next = tip;
-       }
-
-       if (g_tCtxSem)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreSignal(g_tCtxSem);
-               #else
-                       SignalLocalSemaphore(g_tCtxSem);
-               #endif  //MPK_ON
-       }
-       return tip;
+        ThreadContext* tip = NULL;
+        ThreadContext* temp = NULL;
+
+        if (g_tCtxSem)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreWait(g_tCtxSem);
+                #else
+                        WaitOnLocalSemaphore(g_tCtxSem);
+                #endif //MPK_ON
+        }
+
+        // add a new one to the beginning of the list
+        //
+        tip = (ThreadContext *) malloc(sizeof(ThreadContext));
+        if (tip == NULL)
+        {  
+                if (g_tCtxSem)
+                {
+                        #ifdef MPK_ON
+                                kSemaphoreSignal(g_tCtxSem);
+                        #else
+                                SignalLocalSemaphore(g_tCtxSem);
+                        #endif //MPK_ON
+                }
+                return NULL;
+        }
+
+        #ifdef MPK_ON
+                lTLSIndex = labs(kCurrentThread());
+        #else
+                lTLSIndex = GetThreadID();
+        #endif //MPK_ON
+
+        tip->next            =  NULL;
+        tip->tid             =  lTLSIndex;
+        tip->tInfo                      =  t;
+
+        if(g_ThreadCtx==NULL) {
+                g_ThreadCtx = tip;
+        } else {
+                int count=0;
+                //Traverse to the end
+                temp = g_ThreadCtx;
+                while(temp->next != NULL)
+                {
+                        temp = temp->next;
+                        count++;
+                }
+                temp->next = tip;
+        }
+
+        if (g_tCtxSem)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreSignal(g_tCtxSem);
+                #else
+                        SignalLocalSemaphore(g_tCtxSem);
+                #endif //MPK_ON
+        }
+        return tip;
 }
 
 
@@ -604,58 +604,58 @@ ThreadContext* fnAddThreadCtx(long lTLSIndex, void *t)
 
 BOOL fnRemoveThreadCtx(long lTLSIndex)
 {
-       ThreadContext* tip = NULL;
-       ThreadContext* prevt = NULL;
-
-       if (g_tCtxSem)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreWait(g_tCtxSem);
-               #else
-                       WaitOnLocalSemaphore(g_tCtxSem);
-               #endif  //MPK_ON
-       }
-
-       #ifdef MPK_ON
-               lTLSIndex = labs(kCurrentThread());
-       #else
-               lTLSIndex = GetThreadID();
-       #endif  //MPK_ON
-
-       tip = g_ThreadCtx;
-       while(tip) {
-               if (tip->tid == lTLSIndex) {
-                       if (prevt == NULL)
-                               g_ThreadCtx = tip->next;
-                       else
-                               prevt->next = tip->next;
-
-                       free(tip);
-                       tip=NULL;
-                       if (g_tCtxSem)
-                       {
-                               #ifdef MPK_ON
-                                       kSemaphoreSignal(g_tCtxSem);
-                               #else
-                                       SignalLocalSemaphore(g_tCtxSem);
-                               #endif  //MPK_ON
-                       }
-                       return TRUE;
-               }
-               prevt = tip;
-               tip = tip->next;
-       }
-
-       if (g_tCtxSem)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreSignal(g_tCtxSem);
-               #else
-                       SignalLocalSemaphore(g_tCtxSem);
-               #endif  //MPK_ON
-       }
-
-       return FALSE;       // entry not found
+        ThreadContext* tip = NULL;
+        ThreadContext* prevt = NULL;
+
+        if (g_tCtxSem)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreWait(g_tCtxSem);
+                #else
+                        WaitOnLocalSemaphore(g_tCtxSem);
+                #endif //MPK_ON
+        }
+
+        #ifdef MPK_ON
+                lTLSIndex = labs(kCurrentThread());
+        #else
+                lTLSIndex = GetThreadID();
+        #endif //MPK_ON
+
+        tip = g_ThreadCtx;
+        while(tip) {
+                if (tip->tid == lTLSIndex) {
+                        if (prevt == NULL)
+                                g_ThreadCtx = tip->next;
+                        else
+                                prevt->next = tip->next;
+
+                        free(tip);
+                        tip=NULL;
+                        if (g_tCtxSem)
+                        {
+                                #ifdef MPK_ON
+                                        kSemaphoreSignal(g_tCtxSem);
+                                #else
+                                        SignalLocalSemaphore(g_tCtxSem);
+                                #endif //MPK_ON
+                        }
+                        return TRUE;
+                }
+                prevt = tip;
+                tip = tip->next;
+        }
+
+        if (g_tCtxSem)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreSignal(g_tCtxSem);
+                #else
+                        SignalLocalSemaphore(g_tCtxSem);
+                #endif //MPK_ON
+        }
+
+        return FALSE;       // entry not found
 }
 
 
@@ -673,48 +673,48 @@ BOOL fnRemoveThreadCtx(long lTLSIndex)
 
 void* fnGetThreadCtx(long lTLSIndex)
 {
-       ThreadContext*  tip;   
-
-       if (g_tCtxSem) 
-       {
-               #ifdef MPK_ON
-                       kSemaphoreWait(g_tCtxSem);
-               #else
-                       WaitOnLocalSemaphore(g_tCtxSem);
-               #endif  //MPK_ON
-       }
-
-       #ifdef MPK_ON
-               lTLSIndex = labs(kCurrentThread());
-       #else
-               lTLSIndex = GetThreadID();
-       #endif  //MPK_ON
-
-       tip = g_ThreadCtx;
-       while(tip) {
-               if (tip->tid == lTLSIndex) {
-                       if (g_tCtxSem)
-                       {
-                               #ifdef MPK_ON
-                                       kSemaphoreSignal(g_tCtxSem);
-                               #else
-                                       SignalLocalSemaphore(g_tCtxSem);
-                               #endif  //MPK_ON
-                       }
-                       return (tip->tInfo);
-               }
-               tip=tip->next;
-       }
-
-       if (g_tCtxSem)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreSignal(g_tCtxSem);
-               #else
-                       SignalLocalSemaphore(g_tCtxSem);
-               #endif  //MPK_ON
-       }
-
-       return NULL;
+        ThreadContext*  tip;   
+
+        if (g_tCtxSem) 
+        {
+                #ifdef MPK_ON
+                        kSemaphoreWait(g_tCtxSem);
+                #else
+                        WaitOnLocalSemaphore(g_tCtxSem);
+                #endif //MPK_ON
+        }
+
+        #ifdef MPK_ON
+                lTLSIndex = labs(kCurrentThread());
+        #else
+                lTLSIndex = GetThreadID();
+        #endif //MPK_ON
+
+        tip = g_ThreadCtx;
+        while(tip) {
+                if (tip->tid == lTLSIndex) {
+                        if (g_tCtxSem)
+                        {
+                                #ifdef MPK_ON
+                                        kSemaphoreSignal(g_tCtxSem);
+                                #else
+                                        SignalLocalSemaphore(g_tCtxSem);
+                                #endif //MPK_ON
+                        }
+                        return (tip->tInfo);
+                }
+                tip=tip->next;
+        }
+
+        if (g_tCtxSem)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreSignal(g_tCtxSem);
+                #else
+                        SignalLocalSemaphore(g_tCtxSem);
+                #endif //MPK_ON
+        }
+
+        return NULL;
 }
 
index 6d60dfb..bb39971 100644 (file)
@@ -57,7 +57,7 @@ char *s2 = NULL;      // Used in fnSkipToken.
  Function              :       fnSkipWhite
 
  Description   :       This function skips the white space characters in the given string and
-                                       returns the resultant value.
+                                        returns the resultant value.
 
  Parameters    :       s       (IN)    -       Input string.
 
@@ -67,9 +67,9 @@ char *s2 = NULL;      // Used in fnSkipToken.
 
 char *fnSkipWhite(char *s)
 {
-       while (isspace(*s))
-               s++;
-       return s;
+        while (isspace(*s))
+                s++;
+        return s;
 }
 
 
@@ -79,10 +79,10 @@ char *fnSkipWhite(char *s)
  Function              :       fnNwGetEnvironmentStr
 
  Description   :       This function returns the NetWare environment string if available,
-                                       otherwise returns the supplied default value
+                                        otherwise returns the supplied default value
 
  Parameters    :       name                    (IN)    -       To hold the NetWare environment value.
-                                       defaultvalue    (IN)    -       Default value.
+                                        defaultvalue   (IN)    -       Default value.
 
 
  Returns               :       String.
@@ -91,10 +91,10 @@ char *fnSkipWhite(char *s)
 
 char *fnNwGetEnvironmentStr(char *name, char *defaultvalue)
 {
-       char* ret = getenv(name);
-       if (ret == NULL)
-               ret = defaultvalue;
-       return ret;
+        char* ret = getenv(name);
+        if (ret == NULL)
+                ret = defaultvalue;
+        return ret;
 }
 
 
@@ -104,11 +104,11 @@ char *fnNwGetEnvironmentStr(char *name, char *defaultvalue)
  Function              :       fnCommandLineParser
 
  Description   :       This function parses the command line into argc/argv style of
-                                       Number of params and array of params.
+                                        Number of params and array of params.
 
  Parameters    :       pclp            (IN)    -       CommandLine structure.
-                                       commandLine     (IN)    -       CommandLine String.
-                                       preserverQuotes (IN)    -       Indicates whether to preserve/copy the quotes or not.
+                                        commandLine    (IN)    -       CommandLine String.
+                                        preserverQuotes        (IN)    -       Indicates whether to preserve/copy the quotes or not.
 
  Returns               :       Nothing.
 
@@ -116,275 +116,275 @@ char *fnNwGetEnvironmentStr(char *name, char *defaultvalue)
 
 void fnCommandLineParser(PCOMMANDLINEPARSER pclp, char * commandLine, BOOL preserveQuotes)
 {
-       char *buffer = NULL;
+        char *buffer = NULL;
 
-       int index = 0;
-       int do_delete = 1;
-       int i=0, j=0, k=0;
+        int index = 0;
+        int do_delete = 1;
+        int i=0, j=0, k=0;
 
 
-       // +1 makes room for the terminating NULL
-       buffer = (char *) malloc((strlen(commandLine) + 1) * sizeof(char));
-       if (buffer == NULL)
-       {
-               pclp->m_isValid = FALSE;
-               return;
-       }
+        // +1 makes room for the terminating NULL
+        buffer = (char *) malloc((strlen(commandLine) + 1) * sizeof(char));
+        if (buffer == NULL)
+        {
+                pclp->m_isValid = FALSE;
+                return;
+        }
 
-       if (preserveQuotes)
-       {
-               // No I/O redirection nor quote processing if preserveQuotes
+        if (preserveQuotes)
+        {
+                // No I/O redirection nor quote processing if preserveQuotes
 
-               char *s = NULL;
-               char *sSkippedToken = NULL;
+                char *s = NULL;
+                char *sSkippedToken = NULL;
 
 
-               strcpy(buffer, commandLine);
-               s = buffer;
-               s = fnSkipWhite(s);             // Skip white spaces.
+                strcpy(buffer, commandLine);
+                s = buffer;
+                s = fnSkipWhite(s);            // Skip white spaces.
 
-               s2 = s; // Update the global pointer.
+                s2 = s;        // Update the global pointer.
 
 
-               pclp->sSkippedToken = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-               if(pclp->sSkippedToken == NULL)
-               {
-                       pclp->m_isValid = FALSE;
-                       return;
-               }
+                pclp->sSkippedToken = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+                if(pclp->sSkippedToken == NULL)
+                {
+                        pclp->m_isValid = FALSE;
+                        return;
+                }
 
-               while (*s && pclp->m_isValid)
-               {
+                while (*s && pclp->m_isValid)
+                {
 /****
 // Commented since only one time malloc and free is enough as is done outside this while loop.
 // It is not required to do them everytime the execution comes into this while loop.
 // Still retained here. Remove this  once things are proved to be working fine to a good confident level,
 
-                       if(pclp->sSkippedToken)
-                       {
-                               free(pclp->sSkippedToken);
-                               pclp->sSkippedToken = NULL;
-                       }
-
-                       if(pclp->sSkippedToken == NULL)
-                       {
-                               pclp->sSkippedToken = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-                               if(pclp->sSkippedToken == NULL)
-                               {
-                                       pclp->m_isValid = FALSE;
-                                       return;
-                               }
-                       }
+                        if(pclp->sSkippedToken)
+                        {
+                                free(pclp->sSkippedToken);
+                                pclp->sSkippedToken = NULL;
+                        }
+
+                        if(pclp->sSkippedToken == NULL)
+                        {
+                                pclp->sSkippedToken = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+                                if(pclp->sSkippedToken == NULL)
+                                {
+                                        pclp->m_isValid = FALSE;
+                                        return;
+                                }
+                        }
 ****/
 
-                       // Empty the string.
-                       strncpy(pclp->sSkippedToken, "", (MAX_DN_BYTES * sizeof(char)));
-
-                       // s is advanced by fnSkipToken
-                       pclp->sSkippedToken = fnSkipToken(s, pclp->sSkippedToken);      // Collect the next command-line argument.
-
-                       s2 = fnSkipWhite(s2);   // s2 is already updated by fnSkipToken.
-                       s = s2;         // Update the local pointer too.
-
-                       fnAppendArgument(pclp, pclp->sSkippedToken);    // Append the argument into an array.
-               }
-
-               if(pclp->sSkippedToken)
-               {
-                       free(pclp->sSkippedToken);
-                       pclp->sSkippedToken = NULL;
-               }
-       }
-       else
-       {
-               char *s = NULL;
-
-               strcpy(buffer, commandLine);
-               s = buffer;
-               s = fnSkipWhite(s);
-
-               s1 = s; // Update the global pointer.
-
-               while (*s && pclp->m_isValid)
-               {
-                       // s is advanced by fnScanToken
-                       // Check for I/O redirection here, *outside* of
-                       // fnScanToken(), so that quote-protected angle
-                       // brackets do NOT cause redirection.
-                       if (*s == '<')
-                       {
-                               s = fnSkipWhite(s+1); // get stdin redirection
-
-                               if(pclp->m_redirInName)
-                               {
-                                       free(pclp->m_redirInName);
-                                       pclp->m_redirInName = NULL;
-                               }
-
-                               if(pclp->m_redirInName == NULL)
-                               {
-                                       pclp->m_redirInName = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-                                       if(pclp->m_redirInName == NULL)
-                                       {
-                                               pclp->m_isValid = FALSE;
-                                               return;
-                                       }
-                               }
-
-                               // Collect the next command-line argument.
-                               pclp->m_redirInName = fnScanToken(s, pclp->m_redirInName);
-
-                               s1 = fnSkipWhite(s1);   // s1 is already updated by fnScanToken.
-                               s = s1;         // Update the local pointer too.
-                       }
-                       else if (*s == '>')
-                       {
-                               s = fnSkipWhite(s+1); //get stdout redirection
-
-                               if(pclp->m_redirOutName)
-                               {
-                                       free(pclp->m_redirOutName);
-                                       pclp->m_redirOutName = NULL;
-                               }
-
-                               if(pclp->m_redirOutName == NULL)
-                               {
-                                       pclp->m_redirOutName = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-                                       if(pclp->m_redirOutName == NULL)
-                                       {
-                                               pclp->m_isValid = FALSE;
-                                               return;
-                                       }
-                               }
-
-                               // Collect the next command-line argument.
-                               pclp->m_redirOutName = fnScanToken(s, pclp->m_redirOutName);
-
-                               s1 = fnSkipWhite(s1);   // s1 is already updated by fnScanToken.
-                               s = s1;         // Update the local pointer too.
-                       }
-                       else if (*s == '2' && s[1] == '>')
-                       {
-                               s = fnSkipWhite(s+2); // get stderr redirection
-
-                               if(pclp->m_redirErrName)
-                               {
-                                       free(pclp->m_redirErrName);
-                                       pclp->m_redirErrName = NULL;
-                               }
-
-                               if(pclp->m_redirErrName == NULL)
-                               {
-                                       pclp->m_redirErrName = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-                                       if(pclp->m_redirErrName == NULL)
-                                       {
-                                               pclp->m_isValid = FALSE;
-                                               return;
-                                       }
-                               }
-
-                               // Collect the next command-line argument.
-                               pclp->m_redirErrName = fnScanToken(s, pclp->m_redirErrName);
-
-                               s1 = fnSkipWhite(s1);   // s1 is already updated by fnScanToken.
-                               s = s1;         // Update the local pointer too.
-                       }
-                       else if (*s == '&' && s[1] == '>')
-                       {
-                               s = fnSkipWhite(s+2); // get stdout+stderr redirection
-
-                               if(pclp->m_redirBothName)
-                               {
-                                       free(pclp->m_redirBothName);
-                                       pclp->m_redirBothName = NULL;
-                               }
-
-                               if(pclp->m_redirBothName == NULL)
-                               {
-                                       pclp->m_redirBothName = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-                                       if(pclp->m_redirBothName == NULL)
-                                       {
-                                               pclp->m_isValid = FALSE;
-                                               return;
-                                       }
-                               }
-
-                               // Collect the next command-line argument.
-                               pclp->m_redirBothName = fnScanToken(s, pclp->m_redirBothName);
-
-                               s1 = fnSkipWhite(s1);   // s1 is already updated by fnScanToken.
-                               s = s1;         // Update the local pointer too.
-                       }
-                       else
-                       {
-                               if(pclp->nextarg)
-                               {
-                                       free(pclp->nextarg);
-                                       pclp->nextarg = NULL;
-                               }
-
-                               if(pclp->nextarg == NULL)
-                               {
-                                       pclp->nextarg = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-                                       if(pclp->nextarg == NULL)
-                                       {
-                                               pclp->m_isValid = FALSE;
-                                               return;
-                                       }
-                               }
-
-                               // Collect the next command-line argument.
-                               pclp->nextarg = fnScanToken(s, pclp->nextarg);
-
-                               s1 = fnSkipWhite(s1);   // s1 is already updated by fnScanToken.
-                               s = s1;         // Update the local pointer too.
-
-                               // Append the next command-line argument into an array.
-                               fnAppendArgument(pclp, pclp->nextarg);
-                       }
-               }
-       }
-
-
-       // The -{ option, the --noscreen option, the --autodestroy option, if present,
-       // are processed now and removed from the argument vector.
-       for(index=0; index < pclp->m_argc; )
-       {
-               // "-q" is replaced by "-{", because of clash with GetOpt - sgp - 7th Nov 2000
-               // Copied from NDK build - Jan 5th 2001
-               if (strncmp(pclp->m_argv[index], (char *)"-{", 2) == 0)
-               {
-                       // found a -q option; grab the semaphore number
-                       sscanf(pclp->m_argv[index], (char *)"-{%x", &pclp->m_qSemaphore);
-                       fnDeleteArgument(pclp, index);          // Delete the argument from the list.
-               }
-               else if (strcmp(pclp->m_argv[index], (char *)"--noscreen") == 0)
-               {
-                       // found a --noscreen option
-                       pclp->m_noScreen = 1;
-                       fnDeleteArgument(pclp, index);
-               }
-               else if (strcmp(pclp->m_argv[index], (char *)"--autodestroy") == 0)
-               {
-                       // found a --autodestroy option - create a screen but close automatically
-                       pclp->m_AutoDestroy = 1;
-                       fnDeleteArgument(pclp, index);
-               }
-               else
-                       index++;
-       }
-
-       // pclp->m_isValid is TRUE if there are more than 2 command line parameters  OR
-       // if there is only one command and if it is the comman PERL.
-       pclp->m_isValid = ((pclp->m_argc >= 2) || ((pclp->m_argc > 0) && (stricmp(pclp->m_argv[0], LOAD_COMMAND) != 0)));
-
-       if(buffer)
-       {
-               free(buffer);
-               buffer = NULL;
-       }
-
-       return;
+                        // Empty the string.
+                        strncpy(pclp->sSkippedToken, "", (MAX_DN_BYTES * sizeof(char)));
+
+                        // s is advanced by fnSkipToken
+                        pclp->sSkippedToken = fnSkipToken(s, pclp->sSkippedToken);     // Collect the next command-line argument.
+
+                        s2 = fnSkipWhite(s2);  // s2 is already updated by fnSkipToken.
+                        s = s2;                // Update the local pointer too.
+
+                        fnAppendArgument(pclp, pclp->sSkippedToken);   // Append the argument into an array.
+                }
+
+                if(pclp->sSkippedToken)
+                {
+                        free(pclp->sSkippedToken);
+                        pclp->sSkippedToken = NULL;
+                }
+        }
+        else
+        {
+                char *s = NULL;
+
+                strcpy(buffer, commandLine);
+                s = buffer;
+                s = fnSkipWhite(s);
+
+                s1 = s;        // Update the global pointer.
+
+                while (*s && pclp->m_isValid)
+                {
+                        // s is advanced by fnScanToken
+                        // Check for I/O redirection here, *outside* of
+                        // fnScanToken(), so that quote-protected angle
+                        // brackets do NOT cause redirection.
+                        if (*s == '<')
+                        {
+                                s = fnSkipWhite(s+1); // get stdin redirection
+
+                                if(pclp->m_redirInName)
+                                {
+                                        free(pclp->m_redirInName);
+                                        pclp->m_redirInName = NULL;
+                                }
+
+                                if(pclp->m_redirInName == NULL)
+                                {
+                                        pclp->m_redirInName = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+                                        if(pclp->m_redirInName == NULL)
+                                        {
+                                                pclp->m_isValid = FALSE;
+                                                return;
+                                        }
+                                }
+
+                                // Collect the next command-line argument.
+                                pclp->m_redirInName = fnScanToken(s, pclp->m_redirInName);
+
+                                s1 = fnSkipWhite(s1);  // s1 is already updated by fnScanToken.
+                                s = s1;                // Update the local pointer too.
+                        }
+                        else if (*s == '>')
+                        {
+                                s = fnSkipWhite(s+1); //get stdout redirection
+
+                                if(pclp->m_redirOutName)
+                                {
+                                        free(pclp->m_redirOutName);
+                                        pclp->m_redirOutName = NULL;
+                                }
+
+                                if(pclp->m_redirOutName == NULL)
+                                {
+                                        pclp->m_redirOutName = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+                                        if(pclp->m_redirOutName == NULL)
+                                        {
+                                                pclp->m_isValid = FALSE;
+                                                return;
+                                        }
+                                }
+
+                                // Collect the next command-line argument.
+                                pclp->m_redirOutName = fnScanToken(s, pclp->m_redirOutName);
+
+                                s1 = fnSkipWhite(s1);  // s1 is already updated by fnScanToken.
+                                s = s1;                // Update the local pointer too.
+                        }
+                        else if (*s == '2' && s[1] == '>')
+                        {
+                                s = fnSkipWhite(s+2); // get stderr redirection
+
+                                if(pclp->m_redirErrName)
+                                {
+                                        free(pclp->m_redirErrName);
+                                        pclp->m_redirErrName = NULL;
+                                }
+
+                                if(pclp->m_redirErrName == NULL)
+                                {
+                                        pclp->m_redirErrName = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+                                        if(pclp->m_redirErrName == NULL)
+                                        {
+                                                pclp->m_isValid = FALSE;
+                                                return;
+                                        }
+                                }
+
+                                // Collect the next command-line argument.
+                                pclp->m_redirErrName = fnScanToken(s, pclp->m_redirErrName);
+
+                                s1 = fnSkipWhite(s1);  // s1 is already updated by fnScanToken.
+                                s = s1;                // Update the local pointer too.
+                        }
+                        else if (*s == '&' && s[1] == '>')
+                        {
+                                s = fnSkipWhite(s+2); // get stdout+stderr redirection
+
+                                if(pclp->m_redirBothName)
+                                {
+                                        free(pclp->m_redirBothName);
+                                        pclp->m_redirBothName = NULL;
+                                }
+
+                                if(pclp->m_redirBothName == NULL)
+                                {
+                                        pclp->m_redirBothName = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+                                        if(pclp->m_redirBothName == NULL)
+                                        {
+                                                pclp->m_isValid = FALSE;
+                                                return;
+                                        }
+                                }
+
+                                // Collect the next command-line argument.
+                                pclp->m_redirBothName = fnScanToken(s, pclp->m_redirBothName);
+
+                                s1 = fnSkipWhite(s1);  // s1 is already updated by fnScanToken.
+                                s = s1;                // Update the local pointer too.
+                        }
+                        else
+                        {
+                                if(pclp->nextarg)
+                                {
+                                        free(pclp->nextarg);
+                                        pclp->nextarg = NULL;
+                                }
+
+                                if(pclp->nextarg == NULL)
+                                {
+                                        pclp->nextarg = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+                                        if(pclp->nextarg == NULL)
+                                        {
+                                                pclp->m_isValid = FALSE;
+                                                return;
+                                        }
+                                }
+
+                                // Collect the next command-line argument.
+                                pclp->nextarg = fnScanToken(s, pclp->nextarg);
+
+                                s1 = fnSkipWhite(s1);  // s1 is already updated by fnScanToken.
+                                s = s1;                // Update the local pointer too.
+
+                                // Append the next command-line argument into an array.
+                                fnAppendArgument(pclp, pclp->nextarg);
+                        }
+                }
+        }
+
+
+        // The -{ option, the --noscreen option, the --autodestroy option, if present,
+        // are processed now and removed from the argument vector.
+        for(index=0; index < pclp->m_argc; )
+        {
+                // "-q" is replaced by "-{", because of clash with GetOpt - sgp - 7th Nov 2000
+                // Copied from NDK build - Jan 5th 2001
+                if (strncmp(pclp->m_argv[index], (char *)"-{", 2) == 0)
+                {
+                        // found a -q option; grab the semaphore number
+                        sscanf(pclp->m_argv[index], (char *)"-{%x", &pclp->m_qSemaphore);
+                        fnDeleteArgument(pclp, index);         // Delete the argument from the list.
+                }
+                else if (strcmp(pclp->m_argv[index], (char *)"--noscreen") == 0)
+                {
+                        // found a --noscreen option
+                        pclp->m_noScreen = 1;
+                        fnDeleteArgument(pclp, index);
+                }
+                else if (strcmp(pclp->m_argv[index], (char *)"--autodestroy") == 0)
+                {
+                        // found a --autodestroy option - create a screen but close automatically
+                        pclp->m_AutoDestroy = 1;
+                        fnDeleteArgument(pclp, index);
+                }
+                else
+                        index++;
+        }
+
+        // pclp->m_isValid is TRUE if there are more than 2 command line parameters  OR
+        // if there is only one command and if it is the comman PERL.
+        pclp->m_isValid = ((pclp->m_argc >= 2) || ((pclp->m_argc > 0) && (stricmp(pclp->m_argv[0], LOAD_COMMAND) != 0)));
+
+        if(buffer)
+        {
+                free(buffer);
+                buffer = NULL;
+        }
+
+        return;
 }
 
 
@@ -396,7 +396,7 @@ void fnCommandLineParser(PCOMMANDLINEPARSER pclp, char * commandLine, BOOL prese
  Description   :       This function appends the arguments into a list.
 
  Parameters    :       pclp    (IN)    -       CommandLine structure.
-                                       new_arg (IN)    -       The new argument to be appended.
+                                        new_arg        (IN)    -       The new argument to be appended.
 
  Returns               :       Nothing.
 
@@ -404,98 +404,98 @@ void fnCommandLineParser(PCOMMANDLINEPARSER pclp, char * commandLine, BOOL prese
 
 void fnAppendArgument(PCOMMANDLINEPARSER pclp, char *new_arg)
 {
-       char **new_argv = pclp->new_argv;
-
-       int new_argv_len = pclp->m_argv_len*2;
-       int i = 0, j = 0;
-
-
-       // Lengthen the argument vector if there's not room for another.
-       // Testing for 'm_argc+2' rather than 'm_argc+1' in the test guarantees 
-       // that there'll always be a NULL terminator at the end of argv.
-       if ((pclp->m_argc + 2) > pclp->m_argv_len)
-       {
-               new_argv = (char **) malloc(new_argv_len * sizeof(char*));      // get a longer arg-vector
-               if (new_argv == NULL)
-               {
-                       pclp->m_isValid = FALSE;
-                       return;
-               }
-               for(i=0; i<new_argv_len; i++)
-               {
-                       new_argv[i] = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-                       if (new_argv[i] == NULL)
-                       {
-                               for(j=0; j<i; j++)
-                               {
-                                       if(new_argv[j])
-                                       {
-                                               free(new_argv[j]);
-                                               new_argv[j] = NULL;
-                                       }
-                               }
-                               if(new_argv)
-                               {
-                                       free(new_argv);
-                                       new_argv = NULL;
-                               }
-
-                               pclp->m_isValid = FALSE;
-                               return;
-                       }
-               }
-
-               for (i=0; i<pclp->m_argc; i++)
-                       strcpy(new_argv[i], pclp->m_argv[i]);  // copy old arg strings
-
-               for(i=0; i<(pclp->m_argv_len); i++)
-               {
-                       if(pclp->m_argv[i])
-                       {
-                               free(pclp->m_argv[i]);
-                               pclp->m_argv[i] = NULL;
-                       }
-               }
-               if (pclp->m_argv != NULL)
-               {
-                       free(pclp->m_argv);
-                       pclp->m_argv = NULL;
-               }
-
-
-               pclp->m_argv = new_argv;
-               pclp->m_argv_len = new_argv_len;
-
-       }
-
-       // Once m_argv is guaranteed long enough, appending the argument is a direct job.
-       strcpy(pclp->m_argv[pclp->m_argc], new_arg);    // Appended the new argument.
-       pclp->m_argc++;         // Increment the number of parameters appended.
-
-       // The char array is emptied for all elements upto the end so that there are no
-       // junk characters. If this is not done, then the issue is like this:
-       // - Simple perl command like "perl" on the system console works fine for the first time.
-       // - When "perl" is executed the second time, a new blank screen should come up
-       //   which allows for editing also. This was not consistently working well.
-       //   More so when the command was like, "perl   ", that is the name "perl" followed
-       //   by a few blank spaces, it used to give error in opening file:
-       //   "unable to open the file" since the filename would have some junk characters.
-       // 
-       // These issues are fixed through the code below.
-       for(i=pclp->m_argc; i<pclp->m_argv_len; i++)
-               strncpy(pclp->m_argv[i], "", (MAX_DN_BYTES * sizeof(char)));    // MAX_DN_BYTES is the size of pclp->m_argv[].
-
-
-       // Fix for empty command line double quote abend - perl <.pl> ""
-       if ((new_arg==NULL) || ((strlen(new_arg))<=0))
-       {
-               pclp->m_argc--;         // Decrement the number of parameters appended.
-               pclp->m_isValid = FALSE;
-               return;
-       }
-
-
-       return;
+        char **new_argv = pclp->new_argv;
+
+        int new_argv_len = pclp->m_argv_len*2;
+        int i = 0, j = 0;
+
+
+        // Lengthen the argument vector if there's not room for another.
+        // Testing for 'm_argc+2' rather than 'm_argc+1' in the test guarantees 
+        // that there'll always be a NULL terminator at the end of argv.
+        if ((pclp->m_argc + 2) > pclp->m_argv_len)
+        {
+                new_argv = (char **) malloc(new_argv_len * sizeof(char*));     // get a longer arg-vector
+                if (new_argv == NULL)
+                {
+                        pclp->m_isValid = FALSE;
+                        return;
+                }
+                for(i=0; i<new_argv_len; i++)
+                {
+                        new_argv[i] = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+                        if (new_argv[i] == NULL)
+                        {
+                                for(j=0; j<i; j++)
+                                {
+                                        if(new_argv[j])
+                                        {
+                                                free(new_argv[j]);
+                                                new_argv[j] = NULL;
+                                        }
+                                }
+                                if(new_argv)
+                                {
+                                        free(new_argv);
+                                        new_argv = NULL;
+                                }
+
+                                pclp->m_isValid = FALSE;
+                                return;
+                        }
+                }
+
+                for (i=0; i<pclp->m_argc; i++)
+                        strcpy(new_argv[i], pclp->m_argv[i]);  // copy old arg strings
+
+                for(i=0; i<(pclp->m_argv_len); i++)
+                {
+                        if(pclp->m_argv[i])
+                        {
+                                free(pclp->m_argv[i]);
+                                pclp->m_argv[i] = NULL;
+                        }
+                }
+                if (pclp->m_argv != NULL)
+                {
+                        free(pclp->m_argv);
+                        pclp->m_argv = NULL;
+                }
+
+
+                pclp->m_argv = new_argv;
+                pclp->m_argv_len = new_argv_len;
+
+        }
+
+        // Once m_argv is guaranteed long enough, appending the argument is a direct job.
+        strcpy(pclp->m_argv[pclp->m_argc], new_arg);   // Appended the new argument.
+        pclp->m_argc++;                // Increment the number of parameters appended.
+
+        // The char array is emptied for all elements upto the end so that there are no
+        // junk characters. If this is not done, then the issue is like this:
+        // - Simple perl command like "perl" on the system console works fine for the first time.
+        // - When "perl" is executed the second time, a new blank screen should come up
+        //   which allows for editing also. This was not consistently working well.
+        //   More so when the command was like, "perl   ", that is the name "perl" followed
+        //   by a few blank spaces, it used to give error in opening file:
+        //   "unable to open the file" since the filename would have some junk characters.
+        // 
+        // These issues are fixed through the code below.
+        for(i=pclp->m_argc; i<pclp->m_argv_len; i++)
+                strncpy(pclp->m_argv[i], "", (MAX_DN_BYTES * sizeof(char)));   // MAX_DN_BYTES is the size of pclp->m_argv[].
+
+
+        // Fix for empty command line double quote abend - perl <.pl> ""
+        if ((new_arg==NULL) || ((strlen(new_arg))<=0))
+        {
+                pclp->m_argc--;                // Decrement the number of parameters appended.
+                pclp->m_isValid = FALSE;
+                return;
+        }
+
+
+        return;
 }
 
 
@@ -505,11 +505,11 @@ void fnAppendArgument(PCOMMANDLINEPARSER pclp, char *new_arg)
  Function              :       fnSkipToken
 
  Description   :       This function collects the next command-line argument, breaking on
-                                       unquoted white space. The quote symbols are copied into the output.
-                                       White space has already been skipped.
+                                        unquoted white space. The quote symbols are copied into the output.
+                                        White space has already been skipped.
 
  Parameters    :       s       (IN)    -       Input string in which the token is skipped.
-                                             (IN)    -       The resultant return string.
+                                        r      (IN)    -       The resultant return string.
 
  Returns               :       String.
 
@@ -517,44 +517,44 @@ void fnAppendArgument(PCOMMANDLINEPARSER pclp, char *new_arg)
 
 char *fnSkipToken(char *s, char *r)
 {
-       char *t=NULL;
-       char quote = '\0'; // NULL, single quote, or double quote
-       char ch = '\0';
-
-       for (t=s; t[0]; t++)
-       {
-               ch = t[0];
-               if (!quote)
-               {
-                       if (isspace(ch))                                // if unquoted whitespace...
-                       {
-                               break;                                          // ...end of token found
-                       }
-                       else if (ch=='"' || ch=='\'')   // if opening quote...
-                       {
-                               quote = ch;                                     // ...enter quote mode
-                       }
-               }
-               else
-               {
-                       if (ch=='\\' && t[1]==quote)    // if escaped quote...
-                       {
-                               t++;                                            // ...skip backslash
-                       }
-                       else if (ch==quote)                             // if close quote...
-                       {
-                               quote = 0;                                      // ...leave quote mode
-                       } 
-               }
-       }
-
-       r = fnStashString(s, r, t-s);  // get heap-allocated token string
-       t = fnSkipWhite(t);                // skip any trailing white space
-       s = t;                           // return updated source pointer
-
-       s2 = t;                           // return updated global source pointer
-
-       return r;                        // return heap-allocated token string
+        char *t=NULL;
+        char quote = '\0'; // NULL, single quote, or double quote
+        char ch = '\0';
+
+        for (t=s; t[0]; t++)
+        {
+                ch = t[0];
+                if (!quote)
+                {
+                        if (isspace(ch))                               // if unquoted whitespace...
+                        {
+                                break;                                         // ...end of token found
+                        }
+                        else if (ch=='"' || ch=='\'')  // if opening quote...
+                        {
+                                quote = ch;                                    // ...enter quote mode
+                        }
+                }
+                else
+                {
+                        if (ch=='\\' && t[1]==quote)   // if escaped quote...
+                        {
+                                t++;                                           // ...skip backslash
+                        }
+                        else if (ch==quote)                            // if close quote...
+                        {
+                                quote = 0;                                     // ...leave quote mode
+                        
+                }
+        }
+
+        r = fnStashString(s, r, t-s);  // get heap-allocated token string
+        t = fnSkipWhite(t);                // skip any trailing white space
+        s = t;                           // return updated source pointer
+
+        s2 = t;                           // return updated global source pointer
+
+        return r;                        // return heap-allocated token string
 }
 
 
@@ -564,12 +564,12 @@ char *fnSkipToken(char *s, char *r)
  Function              :       fnScanToken
 
  Description   :       This function collects the next command-line argument, breaking on
-                                       unquoted white space or I/O redirection symbols. Quote symbols are not
-                                       copied into the output.
-                                       When called, any leading white space has already been skipped.
+                                        unquoted white space or I/O redirection symbols. Quote symbols are not
+                                        copied into the output.
+                                        When called, any leading white space has already been skipped.
 
  Parameters    :       x       (IN)    -       Input string in which the token is scanned.
-                                             (IN)    -       The resultant return string.
+                                        r      (IN)    -       The resultant return string.
 
  Returns               :       String.
 
@@ -577,61 +577,61 @@ char *fnSkipToken(char *s, char *r)
 
 char *fnScanToken(char *x, char *r)
 {
-       char *s = x; // input string position
-       char *t = x; // output string position
-       char quote = '\0'; // either NULL, or single quote, or double quote
-       char ch = '\0';
-       char c = '\0';
-
-       while (*s)
-       {
-               ch = *s; // invariant: ch != 0
-               
-               // look to see if we've reached the end of the token
-               if (!quote)             // but don't look for token break if we're inside quotes
-               {
-                       if (isspace(ch))
-                               break;          // break on whitespace
-                       if (ch=='>')
-                               break;              // break on ">"  (redirect stdout)
-                       if (ch=='<')
-                               break;              // break on "<"  (redirect stdin)
-                       if (ch=='&' && x[1]=='>')
-                               break; // break on "&>" (redirect both stdout & stderr)
-               }
-               
-               // process the next source character
-               if (ch=='\\' && (c=s[1]) && (c=='\\'||c=='>'||c=='<'||c==quote))
-               {
-                       //-----------------if an escaped '\\', '>', '<', or quote...
-                       s++;            // ...skip over the backslash...
-                       *t++ = *s++;    // ...and copy the escaped character
-               }
-               else if (ch==quote)             // (won't match unless inside quotes because invariant ch!=0)
-               {
-                       //-----------------if close quote...
-                       s++;            // ...skip over the quote...
-                       quote=0;        // ...and leave quote mode
-               }
-               else if (!quote && (ch=='"' || ch=='\''))
-               {
-                       //-----------------if opening quote...
-                       quote = *s++;   // ...enter quote mode (remembering quote char, and skipping the quote)
-               }
-               else
-                             //----------if normal character...
-                       *t++ = *s++;    // ...copy the character
-               }
-       }
-
-       // clean up return values
-       r = fnStashString(x, r, t-x);  // get heap-allocated token string
-       s = fnSkipWhite(s);                // skip any trailing white space
-       x = s;                           // return updated source pointer
-
-       s1 = s;                           // return updated global source pointer
-
-       return r;
+        char *s = x; // input string position
+        char *t = x; // output string position
+        char quote = '\0'; // either NULL, or single quote, or double quote
+        char ch = '\0';
+        char c = '\0';
+
+        while (*s)
+        {
+                ch = *s; // invariant: ch != 0
+                
+                // look to see if we've reached the end of the token
+                if (!quote)            // but don't look for token break if we're inside quotes
+                {
+                        if (isspace(ch))
+                                break;          // break on whitespace
+                        if (ch=='>')
+                                break;              // break on ">"  (redirect stdout)
+                        if (ch=='<')
+                                break;              // break on "<"  (redirect stdin)
+                        if (ch=='&' && x[1]=='>')
+                                break; // break on "&>" (redirect both stdout & stderr)
+                }
+                
+                // process the next source character
+                if (ch=='\\' && (c=s[1]) && (c=='\\'||c=='>'||c=='<'||c==quote))
+                {
+                        //-----------------if an escaped '\\', '>', '<', or quote...
+                        s++;            // ...skip over the backslash...
+                        *t++ = *s++;    // ...and copy the escaped character
+                }
+                else if (ch==quote)            // (won't match unless inside quotes because invariant ch!=0)
+                {
+                        //-----------------if close quote...
+                        s++;            // ...skip over the quote...
+                        quote=0;        // ...and leave quote mode
+                }
+                else if (!quote && (ch=='"' || ch=='\''))
+                {
+                        //-----------------if opening quote...
+                        quote = *s++;   // ...enter quote mode (remembering quote char, and skipping the quote)
+                }
+                else
+                {              //----------if normal character...
+                        *t++ = *s++;    // ...copy the character
+                }
+        }
+
+        // clean up return values
+        r = fnStashString(x, r, t-x);  // get heap-allocated token string
+        s = fnSkipWhite(s);                // skip any trailing white space
+        x = s;                           // return updated source pointer
+
+        s1 = s;                           // return updated global source pointer
+
+        return r;
 }
 
 
@@ -643,8 +643,8 @@ char *fnScanToken(char *x, char *r)
  Description   :       This function return the heap-allocated token string.
 
  Parameters    :       s       (IN)    -       Input string from which the token is extracted.
-                                       buffer  (IN)    -       Return string.
-                                       length  (IN)    -       Length of the token to be extracted.
+                                        buffer (IN)    -       Return string.
+                                        length (IN)    -       Length of the token to be extracted.
 
  Returns               :       String.
 
@@ -652,19 +652,19 @@ char *fnScanToken(char *x, char *r)
 
 char *fnStashString(char *s, char *buffer, int length)
 {
-       if (length <= 0)
-       {
-               // Copy "" instead of NULL since "" indicates that there is memory allocated having no/null value.
-               // NULL indicates that there is no memory allocated to it!
-               strcpy(buffer, "");
-       }
-       else
-       {
-               strncpy(buffer, s, length);
-               buffer[length] = '\0';
-       }
-
-       return buffer;
+        if (length <= 0)
+        {
+                // Copy "" instead of NULL since "" indicates that there is memory allocated having no/null value.
+                // NULL indicates that there is no memory allocated to it!
+                strcpy(buffer, "");
+        }
+        else
+        {
+                strncpy(buffer, s, length);
+                buffer[length] = '\0';
+        }
+
+        return buffer;
 }
 
 
@@ -676,7 +676,7 @@ char *fnStashString(char *s, char *buffer, int length)
  Description   :       This function deletes an argument (that was originally appended) from the list.
 
  Parameters    :       pclp    (IN)    -       CommandLine structure.
-                                       index   (IN)    -       Index of the argument to be deleted.
+                                        index  (IN)    -       Index of the argument to be deleted.
 
  Returns               :       Nothing.
 
@@ -684,33 +684,33 @@ char *fnStashString(char *s, char *buffer, int length)
 
 void fnDeleteArgument(PCOMMANDLINEPARSER pclp, int index)
 {
-       int i = index;
+        int i = index;
 
 
-       // If index is greater than the no. of arguments, just return.
-       if (index >= pclp->m_argc)
-               return;
+        // If index is greater than the no. of arguments, just return.
+        if (index >= pclp->m_argc)
+                return;
 
-       // Move all the arguments after the index one up.
-       while(i < (pclp->m_argv_len-1))
-       {
-               strcpy(pclp->m_argv[i], pclp->m_argv[i+1]);
-               i++;
-       }
+        // Move all the arguments after the index one up.
+        while(i < (pclp->m_argv_len-1))
+        {
+                strcpy(pclp->m_argv[i], pclp->m_argv[i+1]);
+                i++;
+        }
 
 
-       // Delete the last one and free memory.
-       if ( pclp->m_argv[i] )
-       {
-               free(pclp->m_argv[i]);
-               pclp->m_argv[i] = NULL;
-       }
+        // Delete the last one and free memory.
+        if ( pclp->m_argv[i] )
+        {
+                free(pclp->m_argv[i]);
+                pclp->m_argv[i] = NULL;
+        }
 
 
-       pclp->m_argc--;         // Decrement the number of arguments.
-       pclp->m_argv_len--;
+        pclp->m_argc--;                // Decrement the number of arguments.
+        pclp->m_argv_len--;
 
-       return;
+        return;
 }
 
 
@@ -729,82 +729,82 @@ void fnDeleteArgument(PCOMMANDLINEPARSER pclp, int index)
 
 char* fnMy_MkTemp(char* templatestr)
 {
-       char* pXs=NULL;
-       char numbuf[50]={'\0'};
-       int count=0;
-       char* pPid=NULL;
+        char* pXs=NULL;
+        char numbuf[50]={'\0'};
+        int count=0;
+        char* pPid=NULL;
 
-       char termchar = '\0';
-       char letter = 'a';
-       char letter1 = 'a';
+        char termchar = '\0';
+        char letter = 'a';
+        char letter1 = 'a';
 
 
-       if (templatestr && (pXs = strstr(templatestr, (char *)"XXXXXX")))
-       {
-               // generate temp name
-               termchar = pXs[6];
-               ltoa(GetThreadID(), numbuf, 16);
+        if (templatestr && (pXs = strstr(templatestr, (char *)"XXXXXX")))
+        {
+                // generate temp name
+                termchar = pXs[6];
+                ltoa(GetThreadID(), numbuf, 16);
 //             numbuf[sizeof(numbuf)-1] = '\0';
-               numbuf[strlen(numbuf)-1] = '\0';
-               // beware! thread IDs are 8 hex digits on NW 4.11 and only the
-               // lower digits seem to change, whereas on NW 5 they are in the
-               // range of < 1000 hex or 3 hex digits in length. So the following
-               // logic ensures we use the least significant portion of the number.
-               if (strlen(numbuf) > 5)
-                       pPid = &numbuf[strlen(numbuf)-5];
-               else
-                       pPid = numbuf;
+                numbuf[strlen(numbuf)-1] = '\0';
+                // beware! thread IDs are 8 hex digits on NW 4.11 and only the
+                // lower digits seem to change, whereas on NW 5 they are in the
+                // range of < 1000 hex or 3 hex digits in length. So the following
+                // logic ensures we use the least significant portion of the number.
+                if (strlen(numbuf) > 5)
+                        pPid = &numbuf[strlen(numbuf)-5];
+                else
+                        pPid = numbuf;
 
 /**
-               Backtick operation uses temp files that are stored under NWDEFPERLTEMP
-               directory. They are temporarily used and then cleaned up after usage.
-               In cases where multiple backtick operations are used that call some
-               complex scripts, new temp files will be created before the old ones are
-               deleted. So, we need to have a provision to create many temp files.
-               Hence the below logic. It is found that provision for 26 files may
-               not be enough in some cases.
-
-               This below logic allows 26 files (like, pla00015.tmp through plz00015.tmp)
-               plus 6x26=676 (like, plaa0015.tmp through plzz0015.tmp)
+                Backtick operation uses temp files that are stored under NWDEFPERLTEMP
+                directory. They are temporarily used and then cleaned up after usage.
+                In cases where multiple backtick operations are used that call some
+                complex scripts, new temp files will be created before the old ones are
+                deleted. So, we need to have a provision to create many temp files.
+                Hence the below logic. It is found that provision for 26 files may
+                not be enough in some cases.
+
+                This below logic allows 26 files (like, pla00015.tmp through plz00015.tmp)
+                plus 6x26=676 (like, plaa0015.tmp through plzz0015.tmp)
 **/
 
-               letter = 'a';
-               do
-               {
-                       sprintf(pXs, (char *)"%c%05.5s", letter, pPid);
-                       pXs[6] = termchar;
-                       if (access(templatestr, 0) != 0)        // File does not exist
-                       {
-                               return templatestr;
-                       }
-                       letter++;
-               } while (letter <= 'z');
-
-               letter1 = 'a';
-               do
-               {
-                       letter = 'a';
-                       do
-                       {
-                               sprintf(pXs, (char *)"%c%c%04.5s", letter1, letter, pPid);
-                               pXs[6] = termchar;
-                               if (access(templatestr, 0) != 0)        // File does not exist
-                               {
-                                       return templatestr;
-                               }
-                               letter++;
-                       } while (letter <= 'z');
-                       letter1++;
-               } while (letter1 <= 'z');
-
-               errno = ENOENT;
-               return NULL;
-       }
-       else
-       {
-               errno = EINVAL;
-               return NULL;
-       }
+                letter = 'a';
+                do
+                {
+                        sprintf(pXs, (char *)"%c%05.5s", letter, pPid);
+                        pXs[6] = termchar;
+                        if (access(templatestr, 0) != 0)       // File does not exist
+                        {
+                                return templatestr;
+                        }
+                        letter++;
+                } while (letter <= 'z');
+
+                letter1 = 'a';
+                do
+                {
+                        letter = 'a';
+                        do
+                        {
+                                sprintf(pXs, (char *)"%c%c%04.5s", letter1, letter, pPid);
+                                pXs[6] = termchar;
+                                if (access(templatestr, 0) != 0)       // File does not exist
+                                {
+                                        return templatestr;
+                                }
+                                letter++;
+                        } while (letter <= 'z');
+                        letter1++;
+                } while (letter1 <= 'z');
+
+                errno = ENOENT;
+                return NULL;
+        }
+        else
+        {
+                errno = EINVAL;
+                return NULL;
+        }
 }
 
 
@@ -814,10 +814,10 @@ char* fnMy_MkTemp(char* templatestr)
  Function              :       fnSystemCommand
 
  Description   :       This function constructs a system command from the given
-                                       null-terminated argv array and runs the command on the system console.
+                                        null-terminated argv array and runs the command on the system console.
 
  Parameters    :       argv    (IN)    -       Array of input commands.
-                                       argc    (IN)    -       Number of input parameters.
+                                        argc   (IN)    -       Number of input parameters.
 
  Returns               :       Nothing.
 
@@ -825,34 +825,34 @@ char* fnMy_MkTemp(char* templatestr)
 
 void fnSystemCommand (char** argv, int argc)
 {
-       // calculate the size of a temp buffer needed
-       int k = 0;
-       int totalSize = 0;
-       int bytes = 0;
-       char* tempCmd = NULL;
-       char* tptr = NULL;
+        // calculate the size of a temp buffer needed
+        int k = 0;
+        int totalSize = 0;
+        int bytes = 0;
+        char* tempCmd = NULL;
+        char* tptr = NULL;
 
 
-       for(k=0; k<argc; k++)
-               totalSize += strlen(argv[k]) + 1;
+        for(k=0; k<argc; k++)
+                totalSize += strlen(argv[k]) + 1;
 
-       tempCmd = (char *) malloc((totalSize+1) * sizeof(char));
-       if (!tempCmd)
-               return;
-       tptr = tempCmd;
+        tempCmd = (char *) malloc((totalSize+1) * sizeof(char));
+        if (!tempCmd)
+                return;
+        tptr = tempCmd;
 
-       for(k=0; k<argc; k++)
-               tptr += sprintf(tptr, (char *)"%s ", argv[k]);
-       *tptr = 0;
+        for(k=0; k<argc; k++)
+                tptr += sprintf(tptr, (char *)"%s ", argv[k]);
+        *tptr = 0;
 
-       if (stricmp(argv[0], PERL_COMMAND_NAME) == 0)
-               fnInternalPerlLaunchHandler(tempCmd);   // Launch perl.
-       else
-               system(tempCmd);
+        if (stricmp(argv[0], PERL_COMMAND_NAME) == 0)
+                fnInternalPerlLaunchHandler(tempCmd);  // Launch perl.
+        else
+                system(tempCmd);
 
 
-       free(tempCmd);
-       tempCmd = NULL;
-       return;
+        free(tempCmd);
+        tempCmd = NULL;
+        return;
 }
 
index 0b9728a..c45513e 100644 (file)
@@ -35,8 +35,8 @@
 #include "clibstuf.h"
 
 #ifdef MPK_ON
-       #include <mpktypes.h>
-       #include <mpkapis.h>
+        #include <mpktypes.h>
+        #include <mpkapis.h>
 #endif //MPK_ON
 
 
@@ -44,9 +44,9 @@
 // so it should be okay for this to be global.
 //
 #ifdef MPK_ON
-       THREAD  gThreadHandle;
+        THREAD gThreadHandle;
 #else
-       int gThreadGroupID = -1;
+        int gThreadGroupID = -1;
 #endif //MPK_ON
 
 
@@ -77,8 +77,8 @@ char sPerlScreenName[MAX_DN_BYTES * sizeof(char)] = {'\0'};
 //
 typedef struct tagScriptData
 {
-       char *m_commandLine;
-       BOOL m_fromConsole;
+        char *m_commandLine;
+        BOOL m_fromConsole;
 }ScriptData;
 
 
@@ -131,10 +131,10 @@ void nw_freeenviron();
  Function              :       main
 
  Description   :       Called when the NLM is first loaded. Registers the command-line handler
-                                                               and then terminates-stay-resident.
+                                                                and then terminates-stay-resident.
 
  Parameters            :       argc    (IN)    -       No of  Input  strings.
-                                                               argv    (IN)    -       Array of  Input  strings.
+                                                                argv   (IN)    -       Array of  Input  strings.
 
  Returns               :       Nothing.
 
@@ -142,117 +142,117 @@ void nw_freeenviron();
 
 void main(int argc, char *argv[]) 
 {
-       char sysCmdLine[MAX_COMMAND_SIZE] = {'\0'};
-       char cmdLineCopy[sizeof(PERL_COMMAND_NAME)+sizeof(sysCmdLine)+2] = {'\0'};
+        char sysCmdLine[MAX_COMMAND_SIZE] = {'\0'};
+        char cmdLineCopy[sizeof(PERL_COMMAND_NAME)+sizeof(sysCmdLine)+2] = {'\0'};
 
-       ScriptData* psdata = NULL;
+        ScriptData* psdata = NULL;
 
 
-       // Keep this thread alive, since we use the thread group id of this thread to allocate memory on.
-       // When we unload the NLM, clib will tear the thread down.
-       //
-       #ifdef MPK_ON
-               gThreadHandle = kCurrentThread();
-       #else
-               gThreadGroupID = GetThreadGroupID ();
-       #endif  //MPK_ON
+        // Keep this thread alive, since we use the thread group id of this thread to allocate memory on.
+        // When we unload the NLM, clib will tear the thread down.
+        //
+        #ifdef MPK_ON
+                gThreadHandle = kCurrentThread();
+        #else
+                gThreadGroupID = GetThreadGroupID ();
+        #endif //MPK_ON
 
-       signal (SIGTERM, fnSigTermHandler);
-       fnInitGpfGlobals();             // For importing the CLIB calls in place of the Watcom calls
-       fnInitializeThreadInfo();
+        signal (SIGTERM, fnSigTermHandler);
+        fnInitGpfGlobals();            // For importing the CLIB calls in place of the Watcom calls
+        fnInitializeThreadInfo();
 
 
 //     Ensure that we have a "temp" directory
-       fnSetupNamespace();
-       if (access(NWDEFPERLTEMP, 0) != 0)
-               mkdir(NWDEFPERLTEMP);
-
-       // Create the file NUL if not present. This is done only once per NLM load.
-       // This is required for -e.
-       // Earlier versions were creating temporary files (in perl.c file) for -e.
-       // Now, the technique of creating temporary files are removed since they were
-       // fragile or insecure or slow. It now uses the memory by setting
-       // the BIT_BUCKET to "nul" on Win32, which is equivalent to /dev/nul of Unix.
-       // Since there is no equivalent of /dev/nul on NetWare, the work-around is that
-       // we create a file called "nul" and the BIT_BUCKET is set to "nul".
-       // This makes sure that -e works on NetWare too without the creation of temporary files
-       // in -e code in perl.c
-       {
-               char sNUL[MAX_DN_BYTES] = {'\0'};
-
-               strcpy(sNUL, NWDEFPERLROOT);
-               strcat(sNUL, "\\nwnul");
-               if (access((const char *)sNUL, 0) != 0)
-               {
-                       // The file, "nul" is not found and so create the file.
-                       FILE *fp = NULL;
-
-                       fp = fopen((const char *)sNUL, (const char *)"w");
-                       fclose(fp);
-               }
-       }
-
-       fnRegisterCommandLineHandler();         // Register the command line handler
-       SynchronizeStart();             // Restart the NLM startup process when using synchronization mode.
-
-       fnGetPerlScreenName(sPerlScreenName);   // Get the screen name. Done only once per NLM load.
-
-
-       // If the command line has two strings, then the first has to be "Perl" and the second is assumed
-       // to be a script to be run. If only one string (i.e., Perl) is input, then there is nothing to do!
-       //
-       if ((argc > 1) && getcmd(sysCmdLine))
-       {
-               strcpy(cmdLineCopy, PERL_COMMAND_NAME);
-               strcat(cmdLineCopy, (char *)" ");       // Space between the Perl Command and the input script name.
-               strcat(cmdLineCopy, sysCmdLine);        // The command line parameters built into 
-
-               // Create a safe copy of the command line and pass it to the
-               // new thread for parsing. The new thread will be responsible
-               // to delete it when it is finished with it.
-               //
-               psdata = (ScriptData *) malloc(sizeof(ScriptData));
-               if (psdata)
-               {
-                       psdata->m_commandLine = NULL;
-                       psdata->m_commandLine = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-                       if(psdata->m_commandLine)
-                       {
-                               strcpy(psdata->m_commandLine, cmdLineCopy);
-                               psdata->m_fromConsole = TRUE;
-
-                               #ifdef MPK_ON
+        fnSetupNamespace();
+        if (access(NWDEFPERLTEMP, 0) != 0)
+                mkdir(NWDEFPERLTEMP);
+
+        // Create the file NUL if not present. This is done only once per NLM load.
+        // This is required for -e.
+        // Earlier versions were creating temporary files (in perl.c file) for -e.
+        // Now, the technique of creating temporary files are removed since they were
+        // fragile or insecure or slow. It now uses the memory by setting
+        // the BIT_BUCKET to "nul" on Win32, which is equivalent to /dev/nul of Unix.
+        // Since there is no equivalent of /dev/nul on NetWare, the work-around is that
+        // we create a file called "nul" and the BIT_BUCKET is set to "nul".
+        // This makes sure that -e works on NetWare too without the creation of temporary files
+        // in -e code in perl.c
+        {
+                char sNUL[MAX_DN_BYTES] = {'\0'};
+
+                strcpy(sNUL, NWDEFPERLROOT);
+                strcat(sNUL, "\\nwnul");
+                if (access((const char *)sNUL, 0) != 0)
+                {
+                        // The file, "nul" is not found and so create the file.
+                        FILE *fp = NULL;
+
+                        fp = fopen((const char *)sNUL, (const char *)"w");
+                        fclose(fp);
+                }
+        }
+
+        fnRegisterCommandLineHandler();                // Register the command line handler
+        SynchronizeStart();            // Restart the NLM startup process when using synchronization mode.
+
+        fnGetPerlScreenName(sPerlScreenName);  // Get the screen name. Done only once per NLM load.
+
+
+        // If the command line has two strings, then the first has to be "Perl" and the second is assumed
+        // to be a script to be run. If only one string (i.e., Perl) is input, then there is nothing to do!
+        //
+        if ((argc > 1) && getcmd(sysCmdLine))
+        {
+                strcpy(cmdLineCopy, PERL_COMMAND_NAME);
+                strcat(cmdLineCopy, (char *)" ");      // Space between the Perl Command and the input script name.
+                strcat(cmdLineCopy, sysCmdLine);       // The command line parameters built into 
+
+                // Create a safe copy of the command line and pass it to the
+                // new thread for parsing. The new thread will be responsible
+                // to delete it when it is finished with it.
+                //
+                psdata = (ScriptData *) malloc(sizeof(ScriptData));
+                if (psdata)
+                {
+                        psdata->m_commandLine = NULL;
+                        psdata->m_commandLine = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+                        if(psdata->m_commandLine)
+                        {
+                                strcpy(psdata->m_commandLine, cmdLineCopy);
+                                psdata->m_fromConsole = TRUE;
+
+                                #ifdef MPK_ON
 //                                     kStartThread((char *)"ConsoleHandlerThread", fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void *)psdata);
-                                       // Establish a new thread within a new thread group.
-                                       BeginThreadGroup(fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void*)psdata);
-                               #else
-                                       // Start a new thread in its own thread group
-                                       BeginThreadGroup(fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void*)psdata);
-                               #endif  //MPK_ON
-                       }
-                       else
-                       {
-                               free(psdata);
-                               psdata = NULL;
-                               return;
-                       }
-               }
-               else
-                       return;
-       }
-
-
-       // Keep this thread alive, since we use the thread group id of this thread to allocate memory on.
-       // When we unload the NLM, clib will tear the thread down.
-       //
-       #ifdef MPK_ON
-               kSuspendThread(gThreadHandle);
-       #else
-               SuspendThread(GetThreadID());
-       #endif  //MPK_ON
-
-
-       return;
+                                        // Establish a new thread within a new thread group.
+                                        BeginThreadGroup(fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void*)psdata);
+                                #else
+                                        // Start a new thread in its own thread group
+                                        BeginThreadGroup(fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void*)psdata);
+                                #endif //MPK_ON
+                        }
+                        else
+                        {
+                                free(psdata);
+                                psdata = NULL;
+                                return;
+                        }
+                }
+                else
+                        return;
+        }
+
+
+        // Keep this thread alive, since we use the thread group id of this thread to allocate memory on.
+        // When we unload the NLM, clib will tear the thread down.
+        //
+        #ifdef MPK_ON
+                kSuspendThread(gThreadHandle);
+        #else
+                SuspendThread(GetThreadID());
+        #endif //MPK_ON
+
+
+        return;
 }
 
 
@@ -271,55 +271,55 @@ void main(int argc, char *argv[])
 
 void fnSigTermHandler(int sig)
 {
-       int k = 0;
-
-
-       #ifdef MPK_ON
-               kResumeThread(gThreadHandle);
-       #endif  //MPK_ON
-
-       // Unregister the command line handler.
-       //
-       if (gCmdProcInit)
-       {
-               UnRegisterConsoleCommand (&gCmdParser);
-               gCmdProcInit = FALSE;
-       }
-
-       // Free the global environ buffer
-       nw_freeenviron();
-
-       // Kill running scripts.
-       //
-       if (!fnTerminateThreadInfo())
-       {
-               ConsolePrintf("Terminating Perl scripts...\n");
-               gKillAll = TRUE;
-
-               // fnTerminateThreadInfo will be run for 5 threads. If more threads/scripts are run,
-               // then the NLM will unload without terminating the thread info and leaks more memory.
-               // If this number is increased to reduce memory leaks, then it will unnecessarily take more time
-               // to unload when there are a smaller no of threads. Since this is a rare case, the no is kept as 5.
-               //
-               while (!fnTerminateThreadInfo() && k < 5)
-               {
-                       nw_sleep(1);
-                       k++;
-               }
-       }
-
-       // Delete the file, "nul" if present since the NLM is unloaded.
-       {
-               char sNUL[MAX_DN_BYTES] = {'\0'};
-
-               strcpy(sNUL, NWDEFPERLROOT);
-               strcat(sNUL, "\\nwnul");
-               if (access((const char *)sNUL, 0) == 0)
-               {
-                       // The file, "nul" is found and so delete it.
-                       unlink((const char *)sNUL);
-               }
-       }
+        int k = 0;
+
+
+        #ifdef MPK_ON
+                kResumeThread(gThreadHandle);
+        #endif //MPK_ON
+
+        // Unregister the command line handler.
+        //
+        if (gCmdProcInit)
+        {
+                UnRegisterConsoleCommand (&gCmdParser);
+                gCmdProcInit = FALSE;
+        }
+
+        // Free the global environ buffer
+        nw_freeenviron();
+
+        // Kill running scripts.
+        //
+        if (!fnTerminateThreadInfo())
+        {
+                ConsolePrintf("Terminating Perl scripts...\n");
+                gKillAll = TRUE;
+
+                // fnTerminateThreadInfo will be run for 5 threads. If more threads/scripts are run,
+                // then the NLM will unload without terminating the thread info and leaks more memory.
+                // If this number is increased to reduce memory leaks, then it will unnecessarily take more time
+                // to unload when there are a smaller no of threads. Since this is a rare case, the no is kept as 5.
+                //
+                while (!fnTerminateThreadInfo() && k < 5)
+                {
+                        nw_sleep(1);
+                        k++;
+                }
+        }
+
+        // Delete the file, "nul" if present since the NLM is unloaded.
+        {
+                char sNUL[MAX_DN_BYTES] = {'\0'};
+
+                strcpy(sNUL, NWDEFPERLROOT);
+                strcat(sNUL, "\\nwnul");
+                if (access((const char *)sNUL, 0) == 0)
+                {
+                        // The file, "nul" is found and so delete it.
+                        unlink((const char *)sNUL);
+                }
+        }
 }
 
 
@@ -329,12 +329,12 @@ void fnSigTermHandler(int sig)
  Function              :       fnCommandLineHandler
 
  Description   :       Gets called by OS when someone enters an unknown command at the system console,
-                                       after this routine is registered by RegisterConsoleCommand.
-                                       For the valid command we just spawn     a thread with enough stack space
-                                       to actually run the script.
+                                        after this routine is registered by RegisterConsoleCommand.
+                                        For the valid command we just spawn    a thread with enough stack space
+                                        to actually run the script.
 
  Parameters            :       screenID        (IN)    -       id for the screen.
-                                                               cmdLine         (IN)    -       Command line string.
+                                                                cmdLine                (IN)    -       Command line string.
 
  Returns               :       Long.
 
@@ -342,78 +342,78 @@ void fnSigTermHandler(int sig)
 
 LONG  fnCommandLineHandler (LONG screenID, BYTE * cmdLine)
 {
-       ScriptData* psdata=NULL;
-       int OsThrdGrpID = -1;
-       LONG retCode = CS_CMD_FOUND;
-       char* cptr = NULL;
-
-
-       #ifdef MPK_ON
-               // Initialisation for MPK_ON
-       #else
-               OsThrdGrpID = -1;
-       #endif  //MPK_ON
-
-
-       #ifdef MPK_ON
-               // For MPK_ON
-       #else
-               if (gThreadGroupID != -1)
-                       OsThrdGrpID = SetThreadGroupID (gThreadGroupID);
-       #endif  //MPK_ON
-
-
-       cptr = fnSkipWhite(cmdLine);    // Skip white spaces.
-       if ((strnicmp(cptr, PERL_COMMAND_NAME, strlen(PERL_COMMAND_NAME)) == 0) &&
-                ((cptr[strlen(PERL_COMMAND_NAME)] == ' ') ||
-                (cptr[strlen(PERL_COMMAND_NAME)] == '\t') ||
-                (cptr[strlen(PERL_COMMAND_NAME)] == '\0')))
-       {
-               // Create a safe copy of the command line and pass it to the new thread for parsing.
-               // The new thread will be responsible to delete it when it is finished with it.
-               //
-               psdata = (ScriptData *) malloc(sizeof(ScriptData));
-               if (psdata)
-               {
-                       psdata->m_commandLine = NULL;
-                       psdata->m_commandLine = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-                       if(psdata->m_commandLine)
-                       {
-                               strcpy(psdata->m_commandLine, (char *)cmdLine);
-                               psdata->m_fromConsole = TRUE;
-
-                               #ifdef MPK_ON
+        ScriptData* psdata=NULL;
+        int OsThrdGrpID = -1;
+        LONG retCode = CS_CMD_FOUND;
+        char* cptr = NULL;
+
+
+        #ifdef MPK_ON
+                // Initialisation for MPK_ON
+        #else
+                OsThrdGrpID = -1;
+        #endif //MPK_ON
+
+
+        #ifdef MPK_ON
+                // For MPK_ON
+        #else
+                if (gThreadGroupID != -1)
+                        OsThrdGrpID = SetThreadGroupID (gThreadGroupID);
+        #endif //MPK_ON
+
+
+        cptr = fnSkipWhite(cmdLine);   // Skip white spaces.
+        if ((strnicmp(cptr, PERL_COMMAND_NAME, strlen(PERL_COMMAND_NAME)) == 0) &&
+                 ((cptr[strlen(PERL_COMMAND_NAME)] == ' ') ||
+                 (cptr[strlen(PERL_COMMAND_NAME)] == '\t') ||
+                 (cptr[strlen(PERL_COMMAND_NAME)] == '\0')))
+        {
+                // Create a safe copy of the command line and pass it to the new thread for parsing.
+                // The new thread will be responsible to delete it when it is finished with it.
+                //
+                psdata = (ScriptData *) malloc(sizeof(ScriptData));
+                if (psdata)
+                {
+                        psdata->m_commandLine = NULL;
+                        psdata->m_commandLine = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+                        if(psdata->m_commandLine)
+                        {
+                                strcpy(psdata->m_commandLine, (char *)cmdLine);
+                                psdata->m_fromConsole = TRUE;
+
+                                #ifdef MPK_ON
 //                                     kStartThread((char *)"ConsoleHandlerThread", fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void *)psdata);
-                                       // Establish a new thread within a new thread group.
-                                       BeginThreadGroup(fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void*)psdata);
-                               #else
-                                       // Start a new thread in its own thread group
-                                       BeginThreadGroup(fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void*)psdata);
-                               #endif  //MPK_ON
-                       }
-                       else
-                       {
-                               free(psdata);
-                               psdata = NULL;
-                               retCode = CS_CMD_NOT_FOUND;
-                       }
-               }
-               else
-                       retCode = CS_CMD_NOT_FOUND;
-       }
-       else
-               retCode = CS_CMD_NOT_FOUND;
-
-
-       #ifdef MPK_ON
-               // For MPK_ON
-       #else
-               if (OsThrdGrpID != -1)
-                       SetThreadGroupID (OsThrdGrpID);
-       #endif  //MPK_ON
-
-
-       return retCode;
+                                        // Establish a new thread within a new thread group.
+                                        BeginThreadGroup(fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void*)psdata);
+                                #else
+                                        // Start a new thread in its own thread group
+                                        BeginThreadGroup(fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void*)psdata);
+                                #endif //MPK_ON
+                        }
+                        else
+                        {
+                                free(psdata);
+                                psdata = NULL;
+                                retCode = CS_CMD_NOT_FOUND;
+                        }
+                }
+                else
+                        retCode = CS_CMD_NOT_FOUND;
+        }
+        else
+                retCode = CS_CMD_NOT_FOUND;
+
+
+        #ifdef MPK_ON
+                // For MPK_ON
+        #else
+                if (OsThrdGrpID != -1)
+                        SetThreadGroupID (OsThrdGrpID);
+        #endif //MPK_ON
+
+
+        return retCode;
 }
 
 
@@ -432,16 +432,16 @@ LONG  fnCommandLineHandler (LONG screenID, BYTE * cmdLine)
 
 void fnRegisterCommandLineHandler(void)
 {
-       // Allocates resource tag for Console Command
-       if ((gCmdParser.RTag =
-               AllocateResourceTag (GetNLMHandle(), (char *)"Console Command", ConsoleCommandSignature)) != 0)
-       {
-               gCmdParser.parseRoutine = fnCommandLineHandler;         // Set the Console Command parsing routine.
-               RegisterConsoleCommand (&gCmdParser);           // Registers the Console Command parsing function
-               gCmdProcInit = TRUE;
-       }
-
-       return;
+        // Allocates resource tag for Console Command
+        if ((gCmdParser.RTag =
+                AllocateResourceTag (GetNLMHandle(), (char *)"Console Command", ConsoleCommandSignature)) != 0)
+        {
+                gCmdParser.parseRoutine = fnCommandLineHandler;                // Set the Console Command parsing routine.
+                RegisterConsoleCommand (&gCmdParser);          // Registers the Console Command parsing function
+                gCmdProcInit = TRUE;
+        }
+
+        return;
 }
 
 
@@ -460,44 +460,44 @@ void fnRegisterCommandLineHandler(void)
 
 void fnSetupNamespace(void)
 {
-       SetCurrentNameSpace(NWOS2_NAME_SPACE);
+        SetCurrentNameSpace(NWOS2_NAME_SPACE);
 
 
-       //LATER: call SetTargetNameSpace(NWOS2_NAME_SPACE)? Currently, if
-       // I make this call, then CPerlExe::Rename fails in certain cases,
-       // and it isn't clear why. Looks like a CLIB bug...
+        //LATER: call SetTargetNameSpace(NWOS2_NAME_SPACE)? Currently, if
+        // I make this call, then CPerlExe::Rename fails in certain cases,
+        // and it isn't clear why. Looks like a CLIB bug...
 //     SetTargetNameSpace(NWOS2_NAME_SPACE); 
 
-       //Uncommented that above call, retaining the comment so that it will be easy 
-       //to revert back if there is any problem - sgp - 10th May 2000
-
-       //Commented again, since Perl debugger had some problems because of
-       //the above call - sgp - 20th June 2000
-
-       {
-               // if running on Moab, call UseAccurateCaseForPaths. This API
-               // does bad things on 4.11 so we call only for Moab.
-               PFGETFILESERVERMAJORVERSIONNUMBER pf_getfileservermajorversionnumber = NULL;
-               pf_getfileservermajorversionnumber = (PFGETFILESERVERMAJORVERSIONNUMBER) 
-               ImportSymbol(GetNLMHandle(), (char *)"GetFileServerMajorVersionNumber");
-               if (pf_getfileservermajorversionnumber && ((*pf_getfileservermajorversionnumber)() > 4))
-               {
-                       PFUSEACCURATECASEFORPATHS pf_useaccuratecaseforpaths = NULL;
-                       pf_useaccuratecaseforpaths = (PFUSEACCURATECASEFORPATHS) 
-                       ImportSymbol(GetNLMHandle(), (char *)"UseAccurateCaseForPaths");
-                       if (pf_useaccuratecaseforpaths)
-                               (*pf_useaccuratecaseforpaths)(TRUE);
-                       {
-                               PFUNAUGMENTASTERISK pf_unaugmentasterisk = NULL;
-                               pf_unaugmentasterisk = (PFUNAUGMENTASTERISK)
-                               ImportSymbol(GetNLMHandle(), (char *)"UnAugmentAsterisk");
-                               if (pf_unaugmentasterisk)
-                                       (*pf_unaugmentasterisk)(TRUE);
-                       }
-               }
-       }
-
-       return;
+        //Uncommented that above call, retaining the comment so that it will be easy 
+        //to revert back if there is any problem - sgp - 10th May 2000
+
+        //Commented again, since Perl debugger had some problems because of
+        //the above call - sgp - 20th June 2000
+
+        {
+                // if running on Moab, call UseAccurateCaseForPaths. This API
+                // does bad things on 4.11 so we call only for Moab.
+                PFGETFILESERVERMAJORVERSIONNUMBER pf_getfileservermajorversionnumber = NULL;
+                pf_getfileservermajorversionnumber = (PFGETFILESERVERMAJORVERSIONNUMBER) 
+                ImportSymbol(GetNLMHandle(), (char *)"GetFileServerMajorVersionNumber");
+                if (pf_getfileservermajorversionnumber && ((*pf_getfileservermajorversionnumber)() > 4))
+                {
+                        PFUSEACCURATECASEFORPATHS pf_useaccuratecaseforpaths = NULL;
+                        pf_useaccuratecaseforpaths = (PFUSEACCURATECASEFORPATHS) 
+                        ImportSymbol(GetNLMHandle(), (char *)"UseAccurateCaseForPaths");
+                        if (pf_useaccuratecaseforpaths)
+                                (*pf_useaccuratecaseforpaths)(TRUE);
+                        {
+                                PFUNAUGMENTASTERISK pf_unaugmentasterisk = NULL;
+                                pf_unaugmentasterisk = (PFUNAUGMENTASTERISK)
+                                ImportSymbol(GetNLMHandle(), (char *)"UnAugmentAsterisk");
+                                if (pf_unaugmentasterisk)
+                                        (*pf_unaugmentasterisk)(TRUE);
+                        }
+                }
+        }
+
+        return;
 }
 
 
@@ -516,94 +516,94 @@ void fnSetupNamespace(void)
 
 void fnLaunchPerl(void* context)
 {
-       char* defaultDir = NULL;
-       char curdir[_MAX_PATH] = {'\0'};
-       ScriptData* psdata = (ScriptData *) context;
-
-       unsigned int moduleHandle = 0;
-       int currentThreadGroupID = -1;
-
-       #ifdef MPK_ON
-               kExitNetWare();
-       #endif  //MPK_ON
-
-       errno = 0;
-
-       if (psdata->m_fromConsole)
-       {
-               // get the default working directory name
-               //
-               defaultDir = fnNwGetEnvironmentStr("PERL_ROOT", NWDEFPERLROOT);
-       }
-       else
-               defaultDir = getcwd(curdir, sizeof(curdir)-1);
-
-       // set long name space
-       //
-       fnSetupNamespace();
-
-       // make the working directory the current directory if from console
-       //
-       if (psdata->m_fromConsole)
-               chdir(defaultDir);
-
-       // run the script
-       //
-       fnRunScript(psdata);
-
-       // May have to check this, I am blindly calling UCSTerminate, irrespective of
-       // whether it is initialized or not
-       // Copied from the previous Perl - sgp - 31st Oct 2000
-       moduleHandle = FindNLMHandle("UCSCORE.NLM");
-       if (moduleHandle)
-       {
-               PFUCSTERMINATE ucsterminate = (PFUCSTERMINATE)ImportSymbol(moduleHandle, "therealUCSTerminate");
-               if (ucsterminate!=NULL)
-                       (*ucsterminate)();
-       }
-
-       if (psdata->m_fromConsole)
-       {
-               // change thread groups for the call to free the memory
-               // allocated before the new thread group was started
-               #ifdef MPK_ON
-                       // For MPK_ON
-               #else
-                       if (gThreadGroupID != -1)
-                               currentThreadGroupID = SetThreadGroupID (gThreadGroupID);
-               #endif  //MPK_ON
-       }
-
-       // Free memory
-       if (psdata)
-       {
-               if(psdata->m_commandLine)
-               {
-                       free(psdata->m_commandLine);
-                       psdata->m_commandLine = NULL;
-               }
-
-               free(psdata);
-               psdata = NULL;
-               context = NULL;
-       }
-
-       #ifdef MPK_ON
-               // For MPK_ON
-       #else
-               if (currentThreadGroupID != -1)
-                       SetThreadGroupID (currentThreadGroupID);
-       #endif  //MPK_ON
-
-       #ifdef MPK_ON
+        char* defaultDir = NULL;
+        char curdir[_MAX_PATH] = {'\0'};
+        ScriptData* psdata = (ScriptData *) context;
+
+        unsigned int moduleHandle = 0;
+        int currentThreadGroupID = -1;
+
+        #ifdef MPK_ON
+                kExitNetWare();
+        #endif //MPK_ON
+
+        errno = 0;
+
+        if (psdata->m_fromConsole)
+        {
+                // get the default working directory name
+                //
+                defaultDir = fnNwGetEnvironmentStr("PERL_ROOT", NWDEFPERLROOT);
+        }
+        else
+                defaultDir = getcwd(curdir, sizeof(curdir)-1);
+
+        // set long name space
+        //
+        fnSetupNamespace();
+
+        // make the working directory the current directory if from console
+        //
+        if (psdata->m_fromConsole)
+                chdir(defaultDir);
+
+        // run the script
+        //
+        fnRunScript(psdata);
+
+        // May have to check this, I am blindly calling UCSTerminate, irrespective of
+        // whether it is initialized or not
+        // Copied from the previous Perl - sgp - 31st Oct 2000
+        moduleHandle = FindNLMHandle("UCSCORE.NLM");
+        if (moduleHandle)
+        {
+                PFUCSTERMINATE ucsterminate = (PFUCSTERMINATE)ImportSymbol(moduleHandle, "therealUCSTerminate");
+                if (ucsterminate!=NULL)
+                        (*ucsterminate)();
+        }
+
+        if (psdata->m_fromConsole)
+        {
+                // change thread groups for the call to free the memory
+                // allocated before the new thread group was started
+                #ifdef MPK_ON
+                        // For MPK_ON
+                #else
+                        if (gThreadGroupID != -1)
+                                currentThreadGroupID = SetThreadGroupID (gThreadGroupID);
+                #endif //MPK_ON
+        }
+
+        // Free memory
+        if (psdata)
+        {
+                if(psdata->m_commandLine)
+                {
+                        free(psdata->m_commandLine);
+                        psdata->m_commandLine = NULL;
+                }
+
+                free(psdata);
+                psdata = NULL;
+                context = NULL;
+        }
+
+        #ifdef MPK_ON
+                // For MPK_ON
+        #else
+                if (currentThreadGroupID != -1)
+                        SetThreadGroupID (currentThreadGroupID);
+        #endif //MPK_ON
+
+        #ifdef MPK_ON
 //             kExitThread(NULL);
-       #else
-               // just let the thread terminate by falling off the end of the
-               // function started by BeginThreadGroup
+        #else
+                // just let the thread terminate by falling off the end of the
+                // function started by BeginThreadGroup
 //             ExitThread(EXIT_THREAD, 0);
-       #endif
+        #endif
 
-       return;
+        return;
 }
 
 
@@ -622,459 +622,459 @@ void fnLaunchPerl(void* context)
 
 void fnRunScript(ScriptData* psdata)
 {
-       char **av=NULL;
-       char **en=NULL;
-       int exitstatus = 1;
-       int i=0, j=0;
-       int *dummy = 0;
-
-       PCOMMANDLINEPARSER pclp = NULL;
-
-       // Set up the environment block. This will only work on
-       // on Moab; on 4.11 the environment block will be empty.
-       char** env = NULL;
-
-       BOOL use_system_console = TRUE;
-       BOOL newscreen = FALSE;
-       int newscreenhandle = 0;
-
-       // redirect stdin or stdout and run the script
-       FILE* redirOut = NULL;
-       FILE* redirIn = NULL;
-       FILE* redirErr = NULL;
-       FILE* stderr_fp = NULL;
-
-       int stdin_fd=-1, stdin_fd_dup=-1;
-       int stdout_fd=-1, stdout_fd_dup=-1;
-       int stderr_fd=-1, stderr_fd_dup=-1;
-
-
-       // Main callback instance
-       //
-       if (fnRegisterWithThreadTable() == FALSE)
-               return;
-
-       // parse the command line into argc/argv style:
-       // number of params and char array of params
-       //
-       pclp = (PCOMMANDLINEPARSER) malloc(sizeof(COMMANDLINEPARSER));
-       if (!pclp)
-       {
-               fnUnregisterWithThreadTable();
-               return;
-       }
-
-       // Initialise the variables
-       pclp->m_isValid = TRUE;
-       pclp->m_redirInName = NULL;
-       pclp->m_redirOutName = NULL;
-       pclp->m_redirErrName = NULL;
-       pclp->m_redirBothName = NULL;
-       pclp->nextarg = NULL;
-       pclp->sSkippedToken = NULL;
-       pclp->m_argv = NULL;
-       pclp->new_argv = NULL;
-
-       #ifdef MPK_ON
-               pclp->m_qSemaphore = NULL;
-       #else
-               pclp->m_qSemaphore = 0L;
-       #endif  //MPK_ON
-
-       pclp->m_noScreen = 0;
-       pclp->m_AutoDestroy = 0;
-       pclp->m_argc = 0;
-       pclp->m_argv_len = 1;
-
-       // Allocate memory
-       pclp->m_argv = (char **) malloc(pclp->m_argv_len * sizeof(char *));
-       if (pclp->m_argv == NULL)
-       {
-               free(pclp);
-               pclp = NULL;
-
-               fnUnregisterWithThreadTable();
-               return;
-       }
-
-       pclp->m_argv[0] = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-       if (pclp->m_argv[0] == NULL)
-       {
-               free(pclp->m_argv);
-               pclp->m_argv=NULL;
-
-               free(pclp);
-               pclp = NULL;
-
-               fnUnregisterWithThreadTable();
-               return;
-       }
-
-       // Parse the command line
-       fnCommandLineParser(pclp, (char *)psdata->m_commandLine, FALSE);
-       if (!pclp->m_isValid)
-       {
-               if(pclp->m_argv)
-               {
-                       for(i=0; i<pclp->m_argv_len; i++)
-                       {
-                               if(pclp->m_argv[i] != NULL)
-                               {
-                                       free(pclp->m_argv[i]);
-                                       pclp->m_argv[i] = NULL;
-                               }
-                       }
-
-                       free(pclp->m_argv);
-                       pclp->m_argv = NULL;
-               }
-
-               if(pclp->nextarg)
-               {
-                       free(pclp->nextarg);
-                       pclp->nextarg = NULL;
-               }
-               if(pclp->sSkippedToken != NULL)
-               {
-                       free(pclp->sSkippedToken);
-                       pclp->sSkippedToken = NULL;
-               }
-
-               if(pclp->m_redirInName)
-               {
-                       free(pclp->m_redirInName);
-                       pclp->m_redirInName = NULL;
-               }
-               if(pclp->m_redirOutName)
-               {
-                       free(pclp->m_redirOutName);
-                       pclp->m_redirOutName = NULL;
-               }
-               if(pclp->m_redirErrName)
-               {
-                       free(pclp->m_redirErrName);
-                       pclp->m_redirErrName = NULL;
-               }
-               if(pclp->m_redirBothName)
-               {
-                       free(pclp->m_redirBothName);
-                       pclp->m_redirBothName = NULL;
-               }
-
-               // Signal a semaphore, if indicated by "-{" option, to indicate that
-               // the script has terminated and files are closed
-               //
-               if (pclp->m_qSemaphore != 0)
-               {
-                       #ifdef MPK_ON
-                               kSemaphoreSignal(pclp->m_qSemaphore);
-                       #else
-                               SignalLocalSemaphore(pclp->m_qSemaphore);
-                       #endif  //MPK_ON
-               }
-
-               free(pclp);
-               pclp = NULL;
-
-               fnUnregisterWithThreadTable();
-               return;
-       }
-
-       // Simulating a shell on NetWare can be difficult. If you don't
-       // create a new screen for the script to run in, you can output to
-       // the console but you can't get any input from the console. Therefore,
-       // every invocation of perl potentially needs its own screen unless
-       // you are running either "perl -h" or "perl -v" or you are redirecting
-       // stdin from a file.
-       //
-       // So we need to create a new screen and set that screen as the current
-       // screen when running any script launched from the console that is not
-       // "perl -h" or "perl -v" and is not redirecting stdin from a file.
-       //
-       // But it would be a little weird if we didn't create a new screen only
-       // in the case when redirecting stdin from a file; in only that case,
-       // stdout would be the console instead of a new screen.
-       //
-       // There is also the issue of standard err. In short, we might as well
-       // create a new screen no matter what is going on with redirection, just
-       // for the sake of consistency.
-       //
-       // In summary, we should a create a new screen and make that screen the
-       // current screen unless one of the following is true:
-       //  * The command is "perl -h"
-       //  * The command is "perl -v"
-       //  * The script was launched by another perl script. In this case,
-       //        the screen belonging to the parent perl script should probably be
-       //    the same screen for this process. And it will be if use BeginThread
-       //    instead of BeginThreadGroup when launching Perl from within a Perl
-       //    script.
-       //
-       // In those cases where we create a new screen we should probably also display
-       // that screen.
-       //
-
-       use_system_console = pclp->m_noScreen  ||
-                               ((pclp->m_argc == 2) && (strcmp(pclp->m_argv[1], (char *)"-h") == 0))  ||
-                               ((pclp->m_argc == 2) && (strcmp(pclp->m_argv[1], (char *)"-v") == 0));
-
-       newscreen = (!use_system_console) && psdata->m_fromConsole;
-
-       if (newscreen)
-       {
-               newscreenhandle = CreateScreen(sPerlScreenName, 0);
-               if (newscreenhandle)
-                       DisplayScreen(newscreenhandle);
-       }
-       else if (use_system_console)
-         CreateScreen((char *)"System Console", 0);
-
-       if (pclp->m_redirInName)
-       {
-               if ((stdin_fd = fileno(stdin)) != -1)
-               {
-                       stdin_fd_dup = dup(stdin_fd);
-                       if (stdin_fd_dup != -1)
-                       {
-                               redirIn = fdopen (stdin_fd_dup, (char const *)"r");
-                               if (redirIn)
-                                       stdin = freopen (pclp->m_redirInName, (char const *)"r", redirIn);
-                               if (!stdin)
-                               {
-                                       redirIn = NULL;
-                                       // undo the redirect, if possible
-                                       stdin = fdopen(stdin_fd, (char const *)"r");
-                               }
-                       }
-               }
-       }
-
-       /**
-       The below code stores the handle for the existing stdout to be used later and the existing stdout is closed.
-       stdout is then initialised to the new File pointer where the operations are done onto that.
-       Later (look below for the code), the saved stdout is restored back.
-       **/
-       if (pclp->m_redirOutName)
-       {
-               if ((stdout_fd = fileno(stdout)) != -1)         // Handle of the existing stdout.
-               {
-                       stdout_fd_dup = dup(stdout_fd);
-                       if (stdout_fd_dup != -1)
-                       {
-                               // Close the existing stdout.
-                               fflush(stdout);         // Write any unwritten data to the file.
-
-                               // New stdout
-                               redirOut = fdopen (stdout_fd_dup, (char const *)"w");
-                               if (redirOut)
-                                       stdout = freopen (pclp->m_redirOutName, (char const *)"w", redirOut);
-                               if (!stdout)
-                               {
-                                       redirOut = NULL;
-                                       // Undo the redirection.
-                                       stdout = fdopen(stdout_fd, (char const *)"w");
-                               }
-                               setbuf(stdout, NULL);   // Unbuffered file pointer.
-                       }
-               }
-       }
-
-       if (pclp->m_redirErrName)
-       {
-               if ((stderr_fd = fileno(stderr)) != -1)
-               {
-                       stderr_fd_dup = dup(stderr_fd);
-                       if (stderr_fd_dup != -1)
-                       {
-                               fflush(stderr);
-
-                               redirErr = fdopen (stderr_fd_dup, (char const *)"w");
-                               if (redirErr)
-                                       stderr = freopen (pclp->m_redirErrName, (char const *)"w", redirErr);
-                               if (!stderr)
-                               {
-                                       redirErr = NULL;
-                                       // undo the redirect, if possible
-                                       stderr = fdopen(stderr_fd, (char const *)"w");
-                               }
-                               setbuf(stderr, NULL);   // Unbuffered file pointer.
-                       }
-               }
-       }
-
-       if (pclp->m_redirBothName)
-       {
-               if ((stdout_fd = fileno(stdout)) != -1)
-               {
-                       stdout_fd_dup = dup(stdout_fd);
-                       if (stdout_fd_dup != -1)
-                       {
-                               fflush(stdout);
-
-                               redirOut = fdopen (stdout_fd_dup, (char const *)"w");
-                               if (redirOut)
-                                       stdout = freopen (pclp->m_redirBothName, (char const *)"w", redirOut);
-                               if (!stdout)
-                               {
-                                       redirOut = NULL;
-                                       // undo the redirect, if possible
-                                       stdout = fdopen(stdout_fd, (char const *)"w");
-                               }
-                               setbuf(stdout, NULL);   // Unbuffered file pointer.
-                       }
-               }
-               if ((stderr_fd = fileno(stderr)) != -1)
-               {
-               stderr_fp = stderr;
-                       stderr = stdout;
-               }
-       }
-
-       env = NULL;
-       fnSetUpEnvBlock(&env);  // Set up the ENV block
-
-       // Run the Perl script
-       exitstatus = RunPerl(pclp->m_argc, pclp->m_argv, env);
-
-       // clean up any redirection
-       //
-       if (pclp->m_redirInName && redirIn)
-       {
-               fclose(stdin);
-               stdin = fdopen(stdin_fd, (char const *)"r");            // Put back the old handle for stdin.
-       }
-
-       if (pclp->m_redirOutName && redirOut)
-       {
-               // Close the new stdout.
-               fflush(stdout);
-               fclose(stdout);
-
-               // Put back the old handle for stdout.
-               stdout = fdopen(stdout_fd, (char const *)"w");
-               setbuf(stdout, NULL);   // Unbuffered file pointer.
-       }
-
-       if (pclp->m_redirErrName && redirErr)
-       {
-               fflush(stderr);
-               fclose(stderr);
-
-               stderr = fdopen(stderr_fd, (char const *)"w");          // Put back the old handle for stderr.
-               setbuf(stderr, NULL);   // Unbuffered file pointer.
-       }
-
-       if (pclp->m_redirBothName && redirOut)
-       {
-               stderr = stderr_fp;
-
-               fflush(stdout);
-               fclose(stdout);
-
-               stdout = fdopen(stdout_fd, (char const *)"w");          // Put back the old handle for stdout.
-               setbuf(stdout, NULL);   // Unbuffered file pointer.
-       }
-
-
-       if (newscreen && newscreenhandle)
-       {
-               //added for --autodestroy switch
-               if(!pclp->m_AutoDestroy)
-               {
-                       if ((redirOut == NULL) && (redirIn == NULL) && (!gKillAll))
-                       {
-                               printf((char *)"\n\nPress any key to exit\n");
-                               getch();
-                       }
-               }
-               DestroyScreen(newscreenhandle);
-       }
+        char **av=NULL;
+        char **en=NULL;
+        int exitstatus = 1;
+        int i=0, j=0;
+        int *dummy = 0;
+
+        PCOMMANDLINEPARSER pclp = NULL;
+
+        // Set up the environment block. This will only work on
+        // on Moab; on 4.11 the environment block will be empty.
+        char** env = NULL;
+
+        BOOL use_system_console = TRUE;
+        BOOL newscreen = FALSE;
+        int newscreenhandle = 0;
+
+        // redirect stdin or stdout and run the script
+        FILE* redirOut = NULL;
+        FILE* redirIn = NULL;
+        FILE* redirErr = NULL;
+        FILE* stderr_fp = NULL;
+
+        int stdin_fd=-1, stdin_fd_dup=-1;
+        int stdout_fd=-1, stdout_fd_dup=-1;
+        int stderr_fd=-1, stderr_fd_dup=-1;
+
+
+        // Main callback instance
+        //
+        if (fnRegisterWithThreadTable() == FALSE)
+                return;
+
+        // parse the command line into argc/argv style:
+        // number of params and char array of params
+        //
+        pclp = (PCOMMANDLINEPARSER) malloc(sizeof(COMMANDLINEPARSER));
+        if (!pclp)
+        {
+                fnUnregisterWithThreadTable();
+                return;
+        }
+
+        // Initialise the variables
+        pclp->m_isValid = TRUE;
+        pclp->m_redirInName = NULL;
+        pclp->m_redirOutName = NULL;
+        pclp->m_redirErrName = NULL;
+        pclp->m_redirBothName = NULL;
+        pclp->nextarg = NULL;
+        pclp->sSkippedToken = NULL;
+        pclp->m_argv = NULL;
+        pclp->new_argv = NULL;
+
+        #ifdef MPK_ON
+                pclp->m_qSemaphore = NULL;
+        #else
+                pclp->m_qSemaphore = 0L;
+        #endif //MPK_ON
+
+        pclp->m_noScreen = 0;
+        pclp->m_AutoDestroy = 0;
+        pclp->m_argc = 0;
+        pclp->m_argv_len = 1;
+
+        // Allocate memory
+        pclp->m_argv = (char **) malloc(pclp->m_argv_len * sizeof(char *));
+        if (pclp->m_argv == NULL)
+        {
+                free(pclp);
+                pclp = NULL;
+
+                fnUnregisterWithThreadTable();
+                return;
+        }
+
+        pclp->m_argv[0] = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+        if (pclp->m_argv[0] == NULL)
+        {
+                free(pclp->m_argv);
+                pclp->m_argv=NULL;
+
+                free(pclp);
+                pclp = NULL;
+
+                fnUnregisterWithThreadTable();
+                return;
+        }
+
+        // Parse the command line
+        fnCommandLineParser(pclp, (char *)psdata->m_commandLine, FALSE);
+        if (!pclp->m_isValid)
+        {
+                if(pclp->m_argv)
+                {
+                        for(i=0; i<pclp->m_argv_len; i++)
+                        {
+                                if(pclp->m_argv[i] != NULL)
+                                {
+                                        free(pclp->m_argv[i]);
+                                        pclp->m_argv[i] = NULL;
+                                }
+                        }
+
+                        free(pclp->m_argv);
+                        pclp->m_argv = NULL;
+                }
+
+                if(pclp->nextarg)
+                {
+                        free(pclp->nextarg);
+                        pclp->nextarg = NULL;
+                }
+                if(pclp->sSkippedToken != NULL)
+                {
+                        free(pclp->sSkippedToken);
+                        pclp->sSkippedToken = NULL;
+                }
+
+                if(pclp->m_redirInName)
+                {
+                        free(pclp->m_redirInName);
+                        pclp->m_redirInName = NULL;
+                }
+                if(pclp->m_redirOutName)
+                {
+                        free(pclp->m_redirOutName);
+                        pclp->m_redirOutName = NULL;
+                }
+                if(pclp->m_redirErrName)
+                {
+                        free(pclp->m_redirErrName);
+                        pclp->m_redirErrName = NULL;
+                }
+                if(pclp->m_redirBothName)
+                {
+                        free(pclp->m_redirBothName);
+                        pclp->m_redirBothName = NULL;
+                }
+
+                // Signal a semaphore, if indicated by "-{" option, to indicate that
+                // the script has terminated and files are closed
+                //
+                if (pclp->m_qSemaphore != 0)
+                {
+                        #ifdef MPK_ON
+                                kSemaphoreSignal(pclp->m_qSemaphore);
+                        #else
+                                SignalLocalSemaphore(pclp->m_qSemaphore);
+                        #endif //MPK_ON
+                }
+
+                free(pclp);
+                pclp = NULL;
+
+                fnUnregisterWithThreadTable();
+                return;
+        }
+
+        // Simulating a shell on NetWare can be difficult. If you don't
+        // create a new screen for the script to run in, you can output to
+        // the console but you can't get any input from the console. Therefore,
+        // every invocation of perl potentially needs its own screen unless
+        // you are running either "perl -h" or "perl -v" or you are redirecting
+        // stdin from a file.
+        //
+        // So we need to create a new screen and set that screen as the current
+        // screen when running any script launched from the console that is not
+        // "perl -h" or "perl -v" and is not redirecting stdin from a file.
+        //
+        // But it would be a little weird if we didn't create a new screen only
+        // in the case when redirecting stdin from a file; in only that case,
+        // stdout would be the console instead of a new screen.
+        //
+        // There is also the issue of standard err. In short, we might as well
+        // create a new screen no matter what is going on with redirection, just
+        // for the sake of consistency.
+        //
+        // In summary, we should a create a new screen and make that screen the
+        // current screen unless one of the following is true:
+        //  * The command is "perl -h"
+        //  * The command is "perl -v"
+        //  * The script was launched by another perl script. In this case,
+        //       the screen belonging to the parent perl script should probably be
+        //    the same screen for this process. And it will be if use BeginThread
+        //    instead of BeginThreadGroup when launching Perl from within a Perl
+        //    script.
+        //
+        // In those cases where we create a new screen we should probably also display
+        // that screen.
+        //
+
+        use_system_console = pclp->m_noScreen  ||
+                                ((pclp->m_argc == 2) && (strcmp(pclp->m_argv[1], (char *)"-h") == 0))  ||
+                                ((pclp->m_argc == 2) && (strcmp(pclp->m_argv[1], (char *)"-v") == 0));
+
+        newscreen = (!use_system_console) && psdata->m_fromConsole;
+
+        if (newscreen)
+        {
+                newscreenhandle = CreateScreen(sPerlScreenName, 0);
+                if (newscreenhandle)
+                        DisplayScreen(newscreenhandle);
+        }
+        else if (use_system_console)
+          CreateScreen((char *)"System Console", 0);
+
+        if (pclp->m_redirInName)
+        {
+                if ((stdin_fd = fileno(stdin)) != -1)
+                {
+                        stdin_fd_dup = dup(stdin_fd);
+                        if (stdin_fd_dup != -1)
+                        {
+                                redirIn = fdopen (stdin_fd_dup, (char const *)"r");
+                                if (redirIn)
+                                        stdin = freopen (pclp->m_redirInName, (char const *)"r", redirIn);
+                                if (!stdin)
+                                {
+                                        redirIn = NULL;
+                                        // undo the redirect, if possible
+                                        stdin = fdopen(stdin_fd, (char const *)"r");
+                                }
+                        }
+                }
+        }
+
+        /**
+        The below code stores the handle for the existing stdout to be used later and the existing stdout is closed.
+        stdout is then initialised to the new File pointer where the operations are done onto that.
+        Later (look below for the code), the saved stdout is restored back.
+        **/
+        if (pclp->m_redirOutName)
+        {
+                if ((stdout_fd = fileno(stdout)) != -1)                // Handle of the existing stdout.
+                {
+                        stdout_fd_dup = dup(stdout_fd);
+                        if (stdout_fd_dup != -1)
+                        {
+                                // Close the existing stdout.
+                                fflush(stdout);                // Write any unwritten data to the file.
+
+                                // New stdout
+                                redirOut = fdopen (stdout_fd_dup, (char const *)"w");
+                                if (redirOut)
+                                        stdout = freopen (pclp->m_redirOutName, (char const *)"w", redirOut);
+                                if (!stdout)
+                                {
+                                        redirOut = NULL;
+                                        // Undo the redirection.
+                                        stdout = fdopen(stdout_fd, (char const *)"w");
+                                }
+                                setbuf(stdout, NULL);  // Unbuffered file pointer.
+                        }
+                }
+        }
+
+        if (pclp->m_redirErrName)
+        {
+                if ((stderr_fd = fileno(stderr)) != -1)
+                {
+                        stderr_fd_dup = dup(stderr_fd);
+                        if (stderr_fd_dup != -1)
+                        {
+                                fflush(stderr);
+
+                                redirErr = fdopen (stderr_fd_dup, (char const *)"w");
+                                if (redirErr)
+                                        stderr = freopen (pclp->m_redirErrName, (char const *)"w", redirErr);
+                                if (!stderr)
+                                {
+                                        redirErr = NULL;
+                                        // undo the redirect, if possible
+                                        stderr = fdopen(stderr_fd, (char const *)"w");
+                                }
+                                setbuf(stderr, NULL);  // Unbuffered file pointer.
+                        }
+                }
+        }
+
+        if (pclp->m_redirBothName)
+        {
+                if ((stdout_fd = fileno(stdout)) != -1)
+                {
+                        stdout_fd_dup = dup(stdout_fd);
+                        if (stdout_fd_dup != -1)
+                        {
+                                fflush(stdout);
+
+                                redirOut = fdopen (stdout_fd_dup, (char const *)"w");
+                                if (redirOut)
+                                        stdout = freopen (pclp->m_redirBothName, (char const *)"w", redirOut);
+                                if (!stdout)
+                                {
+                                        redirOut = NULL;
+                                        // undo the redirect, if possible
+                                        stdout = fdopen(stdout_fd, (char const *)"w");
+                                }
+                                setbuf(stdout, NULL);  // Unbuffered file pointer.
+                        }
+                }
+                if ((stderr_fd = fileno(stderr)) != -1)
+                {
+                stderr_fp = stderr;
+                        stderr = stdout;
+                }
+        }
+
+        env = NULL;
+        fnSetUpEnvBlock(&env); // Set up the ENV block
+
+        // Run the Perl script
+        exitstatus = RunPerl(pclp->m_argc, pclp->m_argv, env);
+
+        // clean up any redirection
+        //
+        if (pclp->m_redirInName && redirIn)
+        {
+                fclose(stdin);
+                stdin = fdopen(stdin_fd, (char const *)"r");           // Put back the old handle for stdin.
+        }
+
+        if (pclp->m_redirOutName && redirOut)
+        {
+                // Close the new stdout.
+                fflush(stdout);
+                fclose(stdout);
+
+                // Put back the old handle for stdout.
+                stdout = fdopen(stdout_fd, (char const *)"w");
+                setbuf(stdout, NULL);  // Unbuffered file pointer.
+        }
+
+        if (pclp->m_redirErrName && redirErr)
+        {
+                fflush(stderr);
+                fclose(stderr);
+
+                stderr = fdopen(stderr_fd, (char const *)"w");         // Put back the old handle for stderr.
+                setbuf(stderr, NULL);  // Unbuffered file pointer.
+        }
+
+        if (pclp->m_redirBothName && redirOut)
+        {
+                stderr = stderr_fp;
+
+                fflush(stdout);
+                fclose(stdout);
+
+                stdout = fdopen(stdout_fd, (char const *)"w");         // Put back the old handle for stdout.
+                setbuf(stdout, NULL);  // Unbuffered file pointer.
+        }
+
+
+        if (newscreen && newscreenhandle)
+        {
+                //added for --autodestroy switch
+                if(!pclp->m_AutoDestroy)
+                {
+                        if ((redirOut == NULL) && (redirIn == NULL) && (!gKillAll))
+                        {
+                                printf((char *)"\n\nPress any key to exit\n");
+                                getch();
+                        }
+                }
+                DestroyScreen(newscreenhandle);
+        }
 
 /**
-       // Commented since a few abends were happening in fnFpSetMode
-       // Set the mode for stdin and stdout
-       fnFpSetMode(stdin, O_TEXT, dummy);
-       fnFpSetMode(stdout, O_TEXT, dummy);
+        // Commented since a few abends were happening in fnFpSetMode
+        // Set the mode for stdin and stdout
+        fnFpSetMode(stdin, O_TEXT, dummy);
+        fnFpSetMode(stdout, O_TEXT, dummy);
 **/
-       setmode(stdin, O_TEXT);
-       setmode(stdout, O_TEXT);
-
-       // Cleanup
-       if(pclp->m_argv)
-       {
-               for(i=0; i<pclp->m_argv_len; i++)
-               {
-                       if(pclp->m_argv[i] != NULL)
-                       {
-                               free(pclp->m_argv[i]);
-                               pclp->m_argv[i] = NULL;
-                       }
-               }
-
-               free(pclp->m_argv);
-               pclp->m_argv = NULL;
-       }
-
-       if(pclp->nextarg)
-       {
-               free(pclp->nextarg);
-               pclp->nextarg = NULL;
-       }
-       if(pclp->sSkippedToken != NULL)
-       {
-               free(pclp->sSkippedToken);
-               pclp->sSkippedToken = NULL;
-       }
-
-       if(pclp->m_redirInName)
-       {
-               free(pclp->m_redirInName);
-               pclp->m_redirInName = NULL;
-       }
-       if(pclp->m_redirOutName)
-       {
-               free(pclp->m_redirOutName);
-               pclp->m_redirOutName = NULL;
-       }
-       if(pclp->m_redirErrName)
-       {
-               free(pclp->m_redirErrName);
-               pclp->m_redirErrName = NULL;
-       }
-       if(pclp->m_redirBothName)
-       {
-               free(pclp->m_redirBothName);
-               pclp->m_redirBothName = NULL;
-       }
-
-       // Signal a semaphore, if indicated by -{ option, to indicate that
-       // the script has terminated and files are closed
-       //
-       if (pclp->m_qSemaphore != 0)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreSignal(pclp->m_qSemaphore);
-               #else
-                       SignalLocalSemaphore(pclp->m_qSemaphore);
-               #endif  //MPK_ON
-       }
-
-       if(pclp)
-       {
-               free(pclp);
-               pclp = NULL;
-       }
-
-       if(env)
-       {
-               fnDestroyEnvBlock(env);
-               env = NULL;
-       }
-
-       fnUnregisterWithThreadTable();
-       // Remove the thread context set during Perl_set_context
-       Remove_Thread_Ctx();
-
-       return;
+        setmode(stdin, O_TEXT);
+        setmode(stdout, O_TEXT);
+
+        // Cleanup
+        if(pclp->m_argv)
+        {
+                for(i=0; i<pclp->m_argv_len; i++)
+                {
+                        if(pclp->m_argv[i] != NULL)
+                        {
+                                free(pclp->m_argv[i]);
+                                pclp->m_argv[i] = NULL;
+                        }
+                }
+
+                free(pclp->m_argv);
+                pclp->m_argv = NULL;
+        }
+
+        if(pclp->nextarg)
+        {
+                free(pclp->nextarg);
+                pclp->nextarg = NULL;
+        }
+        if(pclp->sSkippedToken != NULL)
+        {
+                free(pclp->sSkippedToken);
+                pclp->sSkippedToken = NULL;
+        }
+
+        if(pclp->m_redirInName)
+        {
+                free(pclp->m_redirInName);
+                pclp->m_redirInName = NULL;
+        }
+        if(pclp->m_redirOutName)
+        {
+                free(pclp->m_redirOutName);
+                pclp->m_redirOutName = NULL;
+        }
+        if(pclp->m_redirErrName)
+        {
+                free(pclp->m_redirErrName);
+                pclp->m_redirErrName = NULL;
+        }
+        if(pclp->m_redirBothName)
+        {
+                free(pclp->m_redirBothName);
+                pclp->m_redirBothName = NULL;
+        }
+
+        // Signal a semaphore, if indicated by -{ option, to indicate that
+        // the script has terminated and files are closed
+        //
+        if (pclp->m_qSemaphore != 0)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreSignal(pclp->m_qSemaphore);
+                #else
+                        SignalLocalSemaphore(pclp->m_qSemaphore);
+                #endif //MPK_ON
+        }
+
+        if(pclp)
+        {
+                free(pclp);
+                pclp = NULL;
+        }
+
+        if(env)
+        {
+                fnDestroyEnvBlock(env);
+                env = NULL;
+        }
+
+        fnUnregisterWithThreadTable();
+        // Remove the thread context set during Perl_set_context
+        Remove_Thread_Ctx();
+
+        return;
 }
 
 
@@ -1093,74 +1093,74 @@ void fnRunScript(ScriptData* psdata)
 
 void fnSetUpEnvBlock(char*** penv)
 {
-       char** env = NULL;
-
-       int sequence = 0;
-       char var[kMaxVariableNameLen+1] = {'\0'};
-       char val[kMaxValueLen+1] = {'\0'};
-       char both[kMaxVariableNameLen + kMaxValueLen + 5] = {'\0'};
-       size_t len  = kMaxValueLen;
-       int totalcnt = 0;
-
-       while(scanenv( &sequence, var, &len, val ))
-       {
-               totalcnt++;
-               len  = kMaxValueLen;
-       }
-       // add one for null termination
-       totalcnt++;
-
-       env = (char **) malloc (totalcnt * sizeof(char *));
-       if (env)
-       {
-               int cnt = 0;
-               int i = 0;
-
-               sequence = 0;
-               len  = kMaxValueLen;
-
-               while( (cnt < (totalcnt-1)) && scanenv( &sequence, var, &len, val ) )
-               {
-                       val[len] = '\0';
-                       strcpy( both, var );
-                       strcat( both, (char *)"=" );
-                       strcat( both, val );
-
-                       env[cnt] = (char *) malloc((sizeof(both)+1) * sizeof(char));
-                       if (env[cnt])
-                       {
-                               strcpy(env[cnt], both);
-                               cnt++;
-                       }
-                       else
-                       {
-                               for(i=0; i<cnt; i++)
-                               {
-                                       if(env[i])
-                                       {
-                                               free(env[i]);
-                                               env[i] = NULL;
-                                       }
-                               }
-
-                               free(env);
-                               env = NULL;
-
-                               return;
-                       }
-
-                       len  = kMaxValueLen;
-               }
-
-               for(i=cnt; i<=(totalcnt-1); i++)
-                       env[i] = NULL;
-       }
-       else
-               return;
-
-       *penv = env;
-
-       return;
+        char** env = NULL;
+
+        int sequence = 0;
+        char var[kMaxVariableNameLen+1] = {'\0'};
+        char val[kMaxValueLen+1] = {'\0'};
+        char both[kMaxVariableNameLen + kMaxValueLen + 5] = {'\0'};
+        size_t len  = kMaxValueLen;
+        int totalcnt = 0;
+
+        while(scanenv( &sequence, var, &len, val ))
+        {
+                totalcnt++;
+                len  = kMaxValueLen;
+        }
+        // add one for null termination
+        totalcnt++;
+
+        env = (char **) malloc (totalcnt * sizeof(char *));
+        if (env)
+        {
+                int cnt = 0;
+                int i = 0;
+
+                sequence = 0;
+                len  = kMaxValueLen;
+
+                while( (cnt < (totalcnt-1)) && scanenv( &sequence, var, &len, val ) )
+                {
+                        val[len] = '\0';
+                        strcpy( both, var );
+                        strcat( both, (char *)"=" );
+                        strcat( both, val );
+
+                        env[cnt] = (char *) malloc((sizeof(both)+1) * sizeof(char));
+                        if (env[cnt])
+                        {
+                                strcpy(env[cnt], both);
+                                cnt++;
+                        }
+                        else
+                        {
+                                for(i=0; i<cnt; i++)
+                                {
+                                        if(env[i])
+                                        {
+                                                free(env[i]);
+                                                env[i] = NULL;
+                                        }
+                                }
+
+                                free(env);
+                                env = NULL;
+
+                                return;
+                        }
+
+                        len  = kMaxValueLen;
+                }
+
+                for(i=cnt; i<=(totalcnt-1); i++)
+                        env[i] = NULL;
+        }
+        else
+                return;
+
+        *penv = env;
+
+        return;
 }
 
 
@@ -1179,21 +1179,21 @@ void fnSetUpEnvBlock(char*** penv)
 
 void fnDestroyEnvBlock(char** env)
 {
-       // It is assumed that this block is entered only if env is TRUE. So, the calling function
-       // must check for this condition before calling fnDestroyEnvBlock.
-       // If no check is made by the calling function, then the server abends.
-       int k = 0;
-       while (env[k] != NULL)
-       {
-               free(env[k]);
-               env[k] = NULL;
-               k++;
-       }
-
-       free(env);
-       env = NULL;
-
-       return;
+        // It is assumed that this block is entered only if env is TRUE. So, the calling function
+        // must check for this condition before calling fnDestroyEnvBlock.
+        // If no check is made by the calling function, then the server abends.
+        int k = 0;
+        while (env[k] != NULL)
+        {
+                free(env[k]);
+                env[k] = NULL;
+                k++;
+        }
+
+        free(env);
+        env = NULL;
+
+        return;
 }
 
 
@@ -1205,8 +1205,8 @@ void fnDestroyEnvBlock(char** env)
  Description   :       Sets the mode for a file.
 
  Parameters            :       fp      (IN)    -       FILE pointer for the input file.
-                                       mode    (IN)    -       Mode to be set
-                                             (OUT)   -       Error.
+                                        mode   (IN)    -       Mode to be set
+                                        e      (OUT)   -       Error.
 
  Returns               :       Integer which is the set value.
 
@@ -1214,44 +1214,44 @@ void fnDestroyEnvBlock(char** env)
 
 int fnFpSetMode(FILE* fp, int mode, int *err)
 {
-       int ret = -1;
-
-       PFFSETMODE pf_fsetmode;
-
-       if (mode == O_BINARY || mode == O_TEXT)
-       {
-               if (fp)
-               {
-                       errno = 0;
-                       // the setmode call is not implemented (correctly) on NetWare,
-                       // but the CLIB guys were kind enough to provide another
-                       // call, fsetmode, which does a similar thing. It only works
-                       // on Moab
-                       pf_fsetmode = (PFFSETMODE) ImportSymbol(GetNLMHandle(), (char *)"fsetmode");
-                       if (pf_fsetmode)
-                               ret = (*pf_fsetmode) (fp, ((mode == O_BINARY) ? "b" : "t"));
-                       else
-                       {
-                               // we are on 4.11 instead of Moab, so we just return an error
-                               errno = ESERVER;
-                               err = &errno;
-                       }
-                       if (errno)
-                               err = &errno;
-               }
-               else
-               {
-                       errno = EBADF;
-                       err = &errno;
-               }
-       }
-       else
-       {
-               errno = EINVAL;
-               err = &errno;
-       }
-
-       return ret;
+        int ret = -1;
+
+        PFFSETMODE pf_fsetmode;
+
+        if (mode == O_BINARY || mode == O_TEXT)
+        {
+                if (fp)
+                {
+                        errno = 0;
+                        // the setmode call is not implemented (correctly) on NetWare,
+                        // but the CLIB guys were kind enough to provide another
+                        // call, fsetmode, which does a similar thing. It only works
+                        // on Moab
+                        pf_fsetmode = (PFFSETMODE) ImportSymbol(GetNLMHandle(), (char *)"fsetmode");
+                        if (pf_fsetmode)
+                                ret = (*pf_fsetmode) (fp, ((mode == O_BINARY) ? "b" : "t"));
+                        else
+                        {
+                                // we are on 4.11 instead of Moab, so we just return an error
+                                errno = ESERVER;
+                                err = &errno;
+                        }
+                        if (errno)
+                                err = &errno;
+                }
+                else
+                {
+                        errno = EBADF;
+                        err = &errno;
+                }
+        }
+        else
+        {
+                errno = EINVAL;
+                err = &errno;
+        }
+
+        return ret;
 }
 
 
@@ -1270,42 +1270,42 @@ int fnFpSetMode(FILE* fp, int mode, int *err)
 
 void fnInternalPerlLaunchHandler(char* cmdLine)
 {
-       int currentThreadGroup = -1;
-
-       ScriptData* psdata=NULL;
-
-       // Create a safe copy of the command line and pass it to the
-       // new thread for parsing. The new thread will be responsible
-       // to delete it when it is finished with it.
-       psdata = (ScriptData *) malloc(sizeof(ScriptData));
-       if (psdata)
-       {
-               psdata->m_commandLine = NULL;
-               psdata->m_commandLine = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-
-               if(psdata->m_commandLine)
-               {
-                       strcpy(psdata->m_commandLine, cmdLine);
-                       psdata->m_fromConsole = FALSE;
-
-                       #ifdef MPK_ON
-                               BeginThread(fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void*)psdata);
-                       #else
-                               // Start a new thread in its own thread group
-                               BeginThread(fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void*)psdata);
-                       #endif  //MPK_ON
-               }
-               else
-               {
-                       free(psdata);
-                       psdata = NULL;
-                       return;
-               }
-       }
-       else
-               return;
-
-       return;
+        int currentThreadGroup = -1;
+
+        ScriptData* psdata=NULL;
+
+        // Create a safe copy of the command line and pass it to the
+        // new thread for parsing. The new thread will be responsible
+        // to delete it when it is finished with it.
+        psdata = (ScriptData *) malloc(sizeof(ScriptData));
+        if (psdata)
+        {
+                psdata->m_commandLine = NULL;
+                psdata->m_commandLine = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+
+                if(psdata->m_commandLine)
+                {
+                        strcpy(psdata->m_commandLine, cmdLine);
+                        psdata->m_fromConsole = FALSE;
+
+                        #ifdef MPK_ON
+                                BeginThread(fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void*)psdata);
+                        #else
+                                // Start a new thread in its own thread group
+                                BeginThread(fnLaunchPerl, NULL, PERL_COMMAND_STACK_SIZE, (void*)psdata);
+                        #endif //MPK_ON
+                }
+                else
+                {
+                        free(psdata);
+                        psdata = NULL;
+                        return;
+                }
+        }
+        else
+                return;
+
+        return;
 }
 
 
@@ -1315,7 +1315,7 @@ void fnInternalPerlLaunchHandler(char* cmdLine)
  Function              :       fnGetPerlScreenName
 
  Description   :       This function creates the Perl screen name.
-                                       Gets called from main only once when the Perl NLM loads.
+                                        Gets called from main only once when the Perl NLM loads.
 
  Parameters            :       sPerlScreenName (OUT)   -       Resultant Perl screen name.
 
@@ -1325,30 +1325,30 @@ void fnInternalPerlLaunchHandler(char* cmdLine)
 
 void fnGetPerlScreenName(char *sPerlScreenName)
 {
-       // HYAK:
-       // The logic for using 32 in the below array sizes is like this:
-       // The NetWare CLIB SDK documentation says that for base 2 conversion,
-       // this number must be minimum 8. Also, in the example of the documentation,
-       // 20 is used as the size and testing is done for bases from 2 upto 16.
-       // So, to simply chose a number above 20 and also keeping in mind not to reserve
-       // unnecessary big array sizes, I have chosen 32 !
-       // Less than that may also suffice.
-       char sPerlRevision[32 * sizeof(char)] = {'\0'};
-       char sPerlVersion[32 * sizeof(char)] = {'\0'};
-       char sPerlSubVersion[32 * sizeof(char)] = {'\0'};
-
-       // The defines for PERL_REVISION, PERL_VERSION, PERL_SUBVERSION are available in
-       // patchlevel.h  under root and gets included when  perl.h  is included.
-       // The number 10 below indicates base 10.
-       itoa(PERL_REVISION, sPerlRevision, 10);
-       itoa(PERL_VERSION, sPerlVersion, 10);
-       itoa(PERL_SUBVERSION, sPerlSubVersion, 10);
-
-       // Concatenate substrings to get a string like Perl5.6.1 which is used as the screen name.
-       sprintf(sPerlScreenName, "%s%s.%s.%s", PERL_COMMAND_NAME,
-                                                                       sPerlRevision, sPerlVersion, sPerlSubVersion);
-
-       return;
+        // HYAK:
+        // The logic for using 32 in the below array sizes is like this:
+        // The NetWare CLIB SDK documentation says that for base 2 conversion,
+        // this number must be minimum 8. Also, in the example of the documentation,
+        // 20 is used as the size and testing is done for bases from 2 upto 16.
+        // So, to simply chose a number above 20 and also keeping in mind not to reserve
+        // unnecessary big array sizes, I have chosen 32 !
+        // Less than that may also suffice.
+        char sPerlRevision[32 * sizeof(char)] = {'\0'};
+        char sPerlVersion[32 * sizeof(char)] = {'\0'};
+        char sPerlSubVersion[32 * sizeof(char)] = {'\0'};
+
+        // The defines for PERL_REVISION, PERL_VERSION, PERL_SUBVERSION are available in
+        // patchlevel.h  under root and gets included when  perl.h  is included.
+        // The number 10 below indicates base 10.
+        itoa(PERL_REVISION, sPerlRevision, 10);
+        itoa(PERL_VERSION, sPerlVersion, 10);
+        itoa(PERL_SUBVERSION, sPerlSubVersion, 10);
+
+        // Concatenate substrings to get a string like Perl5.6.1 which is used as the screen name.
+        sprintf(sPerlScreenName, "%s%s.%s.%s", PERL_COMMAND_NAME,
+                                                                        sPerlRevision, sPerlVersion, sPerlSubVersion);
+
+        return;
 }
 
 
@@ -1376,13 +1376,13 @@ char** genviron = NULL;
 char ***
 nw_getenviron()
 {
-       if (genviron)
-               return (&genviron);     // This might leak memory upto 11736 bytes on some versions of NetWare.
+        if (genviron)
+                return (&genviron);    // This might leak memory upto 11736 bytes on some versions of NetWare.
 //             return genviron;        // Abending on some versions of NetWare.
-       else
-               fnSetUpEnvBlock(&genviron);
+        else
+                fnSetUpEnvBlock(&genviron);
 
-       return (&genviron);
+        return (&genviron);
 }
 
 
@@ -1402,10 +1402,10 @@ nw_getenviron()
 void
 nw_freeenviron()
 {
-       if (genviron)
-       {
-               fnDestroyEnvBlock(genviron);
-               genviron=NULL;
-       }
+        if (genviron)
+        {
+                fnDestroyEnvBlock(genviron);
+                genviron=NULL;
+        }
 }
 
index ce9c198..154ee09 100644 (file)
 
 BOOL fnPipeFileMakeArgv(PTEMPPIPEFILE ptpf)
 {
-       int i=0, j=0;
-       int dindex = 0;
-       int sindex = 0;
-
-       ptpf->m_argv_len = 0;
-
-
-       // Below 2 is added for the following reason:
-       //   - The first one is for an additional value that will be added through ptpf->m_redirect.
-       //   - The second one is for a NULL termination of the array.
-       //     This is required for spawnvp API that takes a NULL-terminated array as its 3rd parameter.
-       //     If the array is NOT NULL-terminated, then the server abends at the spawnvp call !!
-       ptpf->m_argv = (char **) malloc((ptpf->m_pipeCommand->m_argc + 2) * sizeof(char*));
-       if (ptpf->m_argv == NULL)
-               return FALSE;
-
-       // For memory allocation it is just +1 since the last one is only for NULL-termination
-       // and no memory is required to be allocated.
-       for(i=0; i<(ptpf->m_pipeCommand->m_argc + 1); i++)
-       {
-               ptpf->m_argv[i] = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-               if (ptpf->m_argv[i] == NULL)
-               {
-                       for(j=0; j<i; j++)
-                       {
-                               if(ptpf->m_argv[j])
-                               {
-                                       free(ptpf->m_argv[j]);
-                                       ptpf->m_argv[j] = NULL;
-                               }
-                       }
-                       free(ptpf->m_argv);
-                       ptpf->m_argv = NULL;
-
-                       return FALSE;
-               }
-       }
-
-       // Copy over parsed items, removing "load" keyword if necessary.
-       sindex = ((stricmp(ptpf->m_pipeCommand->m_argv[0], LOAD_COMMAND) == 0) ? 1 : 0);
-       while (sindex < ptpf->m_pipeCommand->m_argc)
-       {
-               strcpy(ptpf->m_argv[dindex], ptpf->m_pipeCommand->m_argv[sindex]);
-               dindex++;
-               sindex++;
-       }
-
-       if (stricmp(ptpf->m_argv[0], PERL_COMMAND_NAME) == 0)   // If Perl is the first command.
-       {
-               ptpf->m_launchPerl = TRUE;
-
-               #ifdef MPK_ON
-                       ptpf->m_perlSynchSemaphore = kSemaphoreAlloc((BYTE *)"pipeSemaphore", 0);
-               #else
-                       ptpf->m_perlSynchSemaphore = OpenLocalSemaphore(0);
-               #endif  //MPK_ON
-       }
-       else if (stricmp(ptpf->m_argv[0], (char *)"perlglob") == 0)
-               ptpf->m_doPerlGlob = TRUE;
-
-
-       // Create last argument, which will redirect to or from the temp file
-       if (!ptpf->m_doPerlGlob || ptpf->m_mode)
-       {
-               if (!ptpf->m_mode)      // If read mode?
-               {
-                       if (ptpf->m_launchPerl)
-                               strcpy(ptpf->m_redirect, (char *)">");
-                       else
-                               strcpy(ptpf->m_redirect, (char *)"(CLIB_OPT)/>");
-               }
-               else
-               {
-                       if (ptpf->m_launchPerl)
-                               strcpy(ptpf->m_redirect, (char *)"<");
-                       else
-                               strcpy(ptpf->m_redirect, (char *)"(CLIB_OPT)/<");
-               }
-               strcat(ptpf->m_redirect, ptpf->m_fileName);
-
-               if (ptpf->m_launchPerl)
-               {
-                       char tbuf[15] = {'\0'};
-                       sprintf(tbuf, (char *)" -{%x", ptpf->m_perlSynchSemaphore);
-                       strcat(ptpf->m_redirect, tbuf);
-               }
-
-               strcpy(ptpf->m_argv[dindex], (char*) ptpf->m_redirect);
-               dindex++;
-       }
-
-       if (dindex < (ptpf->m_pipeCommand->m_argc + 1))
-       {
-               if(ptpf->m_argv[dindex])
-               {
-                       free(ptpf->m_argv[dindex]);
-                       ptpf->m_argv[dindex] = NULL;    // NULL termination - required for  spawnvp  call.
-               }
-       }
-
-       ptpf->m_argv_len = dindex;              // Length of the argv array  OR  number of argv string values.
-       ptpf->m_argv[ptpf->m_argv_len] = NULL;  // NULL termination - required for  spawnvp  call.
-
-
-       return TRUE;
+        int i=0, j=0;
+        int dindex = 0;
+        int sindex = 0;
+
+        ptpf->m_argv_len = 0;
+
+
+        // Below 2 is added for the following reason:
+        //   - The first one is for an additional value that will be added through ptpf->m_redirect.
+        //   - The second one is for a NULL termination of the array.
+        //     This is required for spawnvp API that takes a NULL-terminated array as its 3rd parameter.
+        //     If the array is NOT NULL-terminated, then the server abends at the spawnvp call !!
+        ptpf->m_argv = (char **) malloc((ptpf->m_pipeCommand->m_argc + 2) * sizeof(char*));
+        if (ptpf->m_argv == NULL)
+                return FALSE;
+
+        // For memory allocation it is just +1 since the last one is only for NULL-termination
+        // and no memory is required to be allocated.
+        for(i=0; i<(ptpf->m_pipeCommand->m_argc + 1); i++)
+        {
+                ptpf->m_argv[i] = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+                if (ptpf->m_argv[i] == NULL)
+                {
+                        for(j=0; j<i; j++)
+                        {
+                                if(ptpf->m_argv[j])
+                                {
+                                        free(ptpf->m_argv[j]);
+                                        ptpf->m_argv[j] = NULL;
+                                }
+                        }
+                        free(ptpf->m_argv);
+                        ptpf->m_argv = NULL;
+
+                        return FALSE;
+                }
+        }
+
+        // Copy over parsed items, removing "load" keyword if necessary.
+        sindex = ((stricmp(ptpf->m_pipeCommand->m_argv[0], LOAD_COMMAND) == 0) ? 1 : 0);
+        while (sindex < ptpf->m_pipeCommand->m_argc)
+        {
+                strcpy(ptpf->m_argv[dindex], ptpf->m_pipeCommand->m_argv[sindex]);
+                dindex++;
+                sindex++;
+        }
+
+        if (stricmp(ptpf->m_argv[0], PERL_COMMAND_NAME) == 0)  // If Perl is the first command.
+        {
+                ptpf->m_launchPerl = TRUE;
+
+                #ifdef MPK_ON
+                        ptpf->m_perlSynchSemaphore = kSemaphoreAlloc((BYTE *)"pipeSemaphore", 0);
+                #else
+                        ptpf->m_perlSynchSemaphore = OpenLocalSemaphore(0);
+                #endif //MPK_ON
+        }
+        else if (stricmp(ptpf->m_argv[0], (char *)"perlglob") == 0)
+                ptpf->m_doPerlGlob = TRUE;
+
+
+        // Create last argument, which will redirect to or from the temp file
+        if (!ptpf->m_doPerlGlob || ptpf->m_mode)
+        {
+                if (!ptpf->m_mode)     // If read mode?
+                {
+                        if (ptpf->m_launchPerl)
+                                strcpy(ptpf->m_redirect, (char *)">");
+                        else
+                                strcpy(ptpf->m_redirect, (char *)"(CLIB_OPT)/>");
+                }
+                else
+                {
+                        if (ptpf->m_launchPerl)
+                                strcpy(ptpf->m_redirect, (char *)"<");
+                        else
+                                strcpy(ptpf->m_redirect, (char *)"(CLIB_OPT)/<");
+                }
+                strcat(ptpf->m_redirect, ptpf->m_fileName);
+
+                if (ptpf->m_launchPerl)
+                {
+                        char tbuf[15] = {'\0'};
+                        sprintf(tbuf, (char *)" -{%x", ptpf->m_perlSynchSemaphore);
+                        strcat(ptpf->m_redirect, tbuf);
+                }
+
+                strcpy(ptpf->m_argv[dindex], (char*) ptpf->m_redirect);
+                dindex++;
+        }
+
+        if (dindex < (ptpf->m_pipeCommand->m_argc + 1))
+        {
+                if(ptpf->m_argv[dindex])
+                {
+                        free(ptpf->m_argv[dindex]);
+                        ptpf->m_argv[dindex] = NULL;   // NULL termination - required for  spawnvp  call.
+                }
+        }
+
+        ptpf->m_argv_len = dindex;             // Length of the argv array  OR  number of argv string values.
+        ptpf->m_argv[ptpf->m_argv_len] = NULL; // NULL termination - required for  spawnvp  call.
+
+
+        return TRUE;
 }
 
 
@@ -167,8 +167,8 @@ BOOL fnPipeFileMakeArgv(PTEMPPIPEFILE ptpf)
  Description   :       This function opens the pipe file.
 
  Parameters    :       ptpf    (IN)    -       Input structure.
-                                       command (IN)    -       Input command string.
-                                       mode    (IN)    -       Mode of opening.
+                                        command        (IN)    -       Input command string.
+                                        mode   (IN)    -       Mode of opening.
 
  Returns               :       File pointer.
 
@@ -176,281 +176,281 @@ BOOL fnPipeFileMakeArgv(PTEMPPIPEFILE ptpf)
 
 FILE* fnPipeFileOpen(PTEMPPIPEFILE ptpf, char* command, char* mode)
 {
-       int i=0, j=0;
+        int i=0, j=0;
 
-       char tempName[_MAX_PATH] = {'\0'};
+        char tempName[_MAX_PATH] = {'\0'};
 
 
-       ptpf->m_fileName = (char *) malloc(_MAX_PATH * sizeof(char));
-       if(ptpf->m_fileName == NULL)
-               return NULL;
+        ptpf->m_fileName = (char *) malloc(_MAX_PATH * sizeof(char));
+        if(ptpf->m_fileName == NULL)
+                return NULL;
 
-       // The char array is emptied so that there is no junk characters.
-       strncpy(ptpf->m_fileName, "", (_MAX_PATH * sizeof(char)));
-       
+        // The char array is emptied so that there is no junk characters.
+        strncpy(ptpf->m_fileName, "", (_MAX_PATH * sizeof(char)));
+        
 
-       // Save off stuff
-       //
-       if(strchr(mode,'r') != 0)
-               ptpf->m_mode = FALSE;   // Read mode
-       else if(strchr(mode,'w') != 0)
-               ptpf->m_mode = TRUE;    // Write mode
-       else
-       {
-               if(ptpf->m_fileName != NULL)
-               {
+        // Save off stuff
+        //
+        if(strchr(mode,'r') != 0)
+                ptpf->m_mode = FALSE;  // Read mode
+        else if(strchr(mode,'w') != 0)
+                ptpf->m_mode = TRUE;   // Write mode
+        else
+        {
+                if(ptpf->m_fileName != NULL)
+                {
 //                     if (strlen(ptpf->m_fileName))
-                       if (ptpf->m_fileName)
-                               unlink(ptpf->m_fileName);
+                        if (ptpf->m_fileName)
+                                unlink(ptpf->m_fileName);
 
-                       free(ptpf->m_fileName);
-                       ptpf->m_fileName = NULL;
-               }
+                        free(ptpf->m_fileName);
+                        ptpf->m_fileName = NULL;
+                }
 
-               return NULL;
-       }
+                return NULL;
+        }
 
 
-       ptpf->m_pipeCommand = (PCOMMANDLINEPARSER) malloc(sizeof(COMMANDLINEPARSER));
-       if (!ptpf->m_pipeCommand)
-       {
+        ptpf->m_pipeCommand = (PCOMMANDLINEPARSER) malloc(sizeof(COMMANDLINEPARSER));
+        if (!ptpf->m_pipeCommand)
+        {
 //             if (strlen(ptpf->m_fileName))
-               if (ptpf->m_fileName)
-                       unlink(ptpf->m_fileName);
+                if (ptpf->m_fileName)
+                        unlink(ptpf->m_fileName);
 
-               free(ptpf->m_fileName);
-               ptpf->m_fileName = NULL;
+                free(ptpf->m_fileName);
+                ptpf->m_fileName = NULL;
 
-               return NULL;
-       }
+                return NULL;
+        }
 
-       // Initialise the variables
-       ptpf->m_pipeCommand->m_isValid = TRUE;
+        // Initialise the variables
+        ptpf->m_pipeCommand->m_isValid = TRUE;
 
 /****
 // Commented since these are not being used.  Still retained here.
 // To be removed once things are proved to be working fine to a good confident level,
 
-       ptpf->m_pipeCommand->m_redirInName = NULL;
-       ptpf->m_pipeCommand->m_redirOutName = NULL;
-       ptpf->m_pipeCommand->m_redirErrName = NULL;
-       ptpf->m_pipeCommand->m_redirBothName = NULL;
-       ptpf->m_pipeCommand->nextarg = NULL;
+        ptpf->m_pipeCommand->m_redirInName = NULL;
+        ptpf->m_pipeCommand->m_redirOutName = NULL;
+        ptpf->m_pipeCommand->m_redirErrName = NULL;
+        ptpf->m_pipeCommand->m_redirBothName = NULL;
+        ptpf->m_pipeCommand->nextarg = NULL;
 ****/
 
-       ptpf->m_pipeCommand->sSkippedToken = NULL;
-       ptpf->m_pipeCommand->m_argv = NULL;
-       ptpf->m_pipeCommand->new_argv = NULL;
+        ptpf->m_pipeCommand->sSkippedToken = NULL;
+        ptpf->m_pipeCommand->m_argv = NULL;
+        ptpf->m_pipeCommand->new_argv = NULL;
 
-       #ifdef MPK_ON
-               ptpf->m_pipeCommand->m_qSemaphore = NULL;
-       #else
-               ptpf->m_pipeCommand->m_qSemaphore = 0L;
-       #endif  //MPK_ON
+        #ifdef MPK_ON
+                ptpf->m_pipeCommand->m_qSemaphore = NULL;
+        #else
+                ptpf->m_pipeCommand->m_qSemaphore = 0L;
+        #endif //MPK_ON
 
-       ptpf->m_pipeCommand->m_noScreen = 0;
-       ptpf->m_pipeCommand->m_AutoDestroy = 0;
-       ptpf->m_pipeCommand->m_argc = 0;
-       ptpf->m_pipeCommand->m_argv_len = 1;
+        ptpf->m_pipeCommand->m_noScreen = 0;
+        ptpf->m_pipeCommand->m_AutoDestroy = 0;
+        ptpf->m_pipeCommand->m_argc = 0;
+        ptpf->m_pipeCommand->m_argv_len = 1;
 
 
-       ptpf->m_pipeCommand->m_argv = (char **) malloc(ptpf->m_pipeCommand->m_argv_len * sizeof(char *));
-       if (ptpf->m_pipeCommand->m_argv == NULL)
-       {
-               free(ptpf->m_pipeCommand);
-               ptpf->m_pipeCommand = NULL;
+        ptpf->m_pipeCommand->m_argv = (char **) malloc(ptpf->m_pipeCommand->m_argv_len * sizeof(char *));
+        if (ptpf->m_pipeCommand->m_argv == NULL)
+        {
+                free(ptpf->m_pipeCommand);
+                ptpf->m_pipeCommand = NULL;
 
 //             if (strlen(ptpf->m_fileName))
-               if (ptpf->m_fileName)
-                       unlink(ptpf->m_fileName);
-
-               free(ptpf->m_fileName);
-               ptpf->m_fileName = NULL;
-
-               return NULL;
-       }
-       ptpf->m_pipeCommand->m_argv[0] = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-       if (ptpf->m_pipeCommand->m_argv[0] == NULL)
-       {
-               for(j=0; j<i; j++)
-               {
-                       if(ptpf->m_pipeCommand->m_argv[j])
-                       {
-                               free(ptpf->m_pipeCommand->m_argv[j]);
-                               ptpf->m_pipeCommand->m_argv[j]=NULL;
-                       }
-               }
-               free(ptpf->m_pipeCommand->m_argv);
-               ptpf->m_pipeCommand->m_argv=NULL;
-
-               free(ptpf->m_pipeCommand);
-               ptpf->m_pipeCommand = NULL;
+                if (ptpf->m_fileName)
+                        unlink(ptpf->m_fileName);
+
+                free(ptpf->m_fileName);
+                ptpf->m_fileName = NULL;
+
+                return NULL;
+        }
+        ptpf->m_pipeCommand->m_argv[0] = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+        if (ptpf->m_pipeCommand->m_argv[0] == NULL)
+        {
+                for(j=0; j<i; j++)
+                {
+                        if(ptpf->m_pipeCommand->m_argv[j])
+                        {
+                                free(ptpf->m_pipeCommand->m_argv[j]);
+                                ptpf->m_pipeCommand->m_argv[j]=NULL;
+                        }
+                }
+                free(ptpf->m_pipeCommand->m_argv);
+                ptpf->m_pipeCommand->m_argv=NULL;
+
+                free(ptpf->m_pipeCommand);
+                ptpf->m_pipeCommand = NULL;
 
 //             if (strlen(ptpf->m_fileName))
-               if (ptpf->m_fileName)
-                       unlink(ptpf->m_fileName);
+                if (ptpf->m_fileName)
+                        unlink(ptpf->m_fileName);
 
-               free(ptpf->m_fileName);
-               ptpf->m_fileName = NULL;
+                free(ptpf->m_fileName);
+                ptpf->m_fileName = NULL;
 
-               return NULL;
-       }
+                return NULL;
+        }
 
 
-       ptpf->m_redirect = (char *) malloc(MAX_DN_BYTES * sizeof(char));
-       if (ptpf->m_redirect == NULL)
-       {
-               for(i=0; i<ptpf->m_pipeCommand->m_argv_len; i++)
-               {
-                       if(ptpf->m_pipeCommand->m_argv[i] != NULL)
-                       {
-                               free(ptpf->m_pipeCommand->m_argv[i]);
-                               ptpf->m_pipeCommand->m_argv[i] = NULL;
-                       }
-               }
+        ptpf->m_redirect = (char *) malloc(MAX_DN_BYTES * sizeof(char));
+        if (ptpf->m_redirect == NULL)
+        {
+                for(i=0; i<ptpf->m_pipeCommand->m_argv_len; i++)
+                {
+                        if(ptpf->m_pipeCommand->m_argv[i] != NULL)
+                        {
+                                free(ptpf->m_pipeCommand->m_argv[i]);
+                                ptpf->m_pipeCommand->m_argv[i] = NULL;
+                        }
+                }
 
-               free(ptpf->m_pipeCommand->m_argv);
-               ptpf->m_pipeCommand->m_argv = NULL;
+                free(ptpf->m_pipeCommand->m_argv);
+                ptpf->m_pipeCommand->m_argv = NULL;
 
-               free(ptpf->m_pipeCommand);
-               ptpf->m_pipeCommand = NULL;
+                free(ptpf->m_pipeCommand);
+                ptpf->m_pipeCommand = NULL;
 
 
 //             if (strlen(ptpf->m_fileName))
-               if (ptpf->m_fileName)
-                       unlink(ptpf->m_fileName);
-
-               free(ptpf->m_fileName);
-               ptpf->m_fileName = NULL;
-
-               return NULL;
-       }
-
-       // The char array is emptied.
-       // If it is not done so, then it could contain some junk values and the string length in that case
-       // will not be zero.  This causes erroneous results in  fnPipeFileMakeArgv()  function
-       // where  strlen(ptpf->m_redirect)  is used as a check for incrementing the parameter count and
-       // it will wrongly get incremented in such cases.
-       strncpy(ptpf->m_redirect, "", (MAX_DN_BYTES * sizeof(char)));
-
-       // Parse the parameters.
-       fnCommandLineParser(ptpf->m_pipeCommand, (char *)command, TRUE);
-       if (!ptpf->m_pipeCommand->m_isValid)
-       {
-               fnTempPipeFileReleaseMemory(ptpf);
-               return NULL;
-       }
-
-
-       // Create a temporary file name
-       //
-       strncpy ( tempName, fnNwGetEnvironmentStr((char *)"TEMP", NWDEFPERLTEMP), (_MAX_PATH - 20) );
-       tempName[_MAX_PATH-20] = '\0';
-       strcat(tempName, (char *)"\\plXXXXXX.tmp");
-       if (!fnMy_MkTemp(tempName))
-       {
-               fnTempPipeFileReleaseMemory(ptpf);
-               return NULL;
-       }
-
-       // create a temporary place-holder file
-       fclose(fopen(tempName, (char *)"w"));
-       strcpy(ptpf->m_fileName, tempName);
-
-
-       // Make the argument array
-       if(!fnPipeFileMakeArgv(ptpf))
-       {
-               fnTempPipeFileReleaseMemory(ptpf);
-
-               // Release additional memory
-               if(ptpf->m_argv != NULL)
-               {
-                       for(i=0; i<ptpf->m_argv_len; i++)
-                       {
-                               if(ptpf->m_argv[i] != NULL)
-                               {
-                                       free(ptpf->m_argv[i]);
-                                       ptpf->m_argv[i] = NULL;
-                               }
-                       }
-
-                       free(ptpf->m_argv);
-                       ptpf->m_argv = NULL;
-               }
-
-               return NULL;
-       }
-
-
-       // Open the temp file in the appropriate way...
-       //
-       if (!ptpf->m_mode)      // If Read mode?
-       {
-               // we wish to spawn a command, intercept its output,
-               // and then get that output
-               //
-               if (!ptpf->m_argv[0])
-               {
-                       fnTempPipeFileReleaseMemory(ptpf);
-
-                       // Release additional memory
-                       if(ptpf->m_argv != NULL)
-                       {
-                               for(i=0; i<ptpf->m_argv_len; i++)
-                               {
-                                       if(ptpf->m_argv[i] != NULL)
-                                       {
-                                               free(ptpf->m_argv[i]);
-                                               ptpf->m_argv[i] = NULL;
-                                       }
-                               }
-
-                               free(ptpf->m_argv);
-                               ptpf->m_argv = NULL;
-                       }
-
-                       return NULL;
-               }
-
-               if (ptpf->m_launchPerl)
-                       fnPipeFileDoPerlLaunch(ptpf);
-               else
-                       if (ptpf->m_doPerlGlob)
-                               fnDoPerlGlob(ptpf->m_argv, ptpf->m_fileName);   // hack to do perl globbing
-               else
-                       spawnvp(P_WAIT, ptpf->m_argv[0], ptpf->m_argv);
-
-               ptpf->m_file = fopen (ptpf->m_fileName, (char *)"r");   // Get the Pipe file handle
-       }
-       else if (ptpf->m_mode)  // If Write mode?
-       {
-               // we wish to open the file for writing now and
-               // do the command later
-               //
-               ptpf->m_file = fopen(ptpf->m_fileName, (char *)"w");
-       }
-
-       fnTempPipeFileReleaseMemory(ptpf);
-
-       // Release additional memory
-       if(ptpf->m_argv != NULL)
-       {
-               for(i=0; i<(ptpf->m_argv_len); i++)
-               {
-                       if(ptpf->m_argv[i] != NULL)
-                       {
-                               free(ptpf->m_argv[i]);
-                               ptpf->m_argv[i] = NULL;
-                       }
-               }
-
-               free(ptpf->m_argv);
-               ptpf->m_argv = NULL;
-       }
-
-               
-       return ptpf->m_file;    // Return the Pipe file handle.
+                if (ptpf->m_fileName)
+                        unlink(ptpf->m_fileName);
+
+                free(ptpf->m_fileName);
+                ptpf->m_fileName = NULL;
+
+                return NULL;
+        }
+
+        // The char array is emptied.
+        // If it is not done so, then it could contain some junk values and the string length in that case
+        // will not be zero.  This causes erroneous results in  fnPipeFileMakeArgv()  function
+        // where  strlen(ptpf->m_redirect)  is used as a check for incrementing the parameter count and
+        // it will wrongly get incremented in such cases.
+        strncpy(ptpf->m_redirect, "", (MAX_DN_BYTES * sizeof(char)));
+
+        // Parse the parameters.
+        fnCommandLineParser(ptpf->m_pipeCommand, (char *)command, TRUE);
+        if (!ptpf->m_pipeCommand->m_isValid)
+        {
+                fnTempPipeFileReleaseMemory(ptpf);
+                return NULL;
+        }
+
+
+        // Create a temporary file name
+        //
+        strncpy ( tempName, fnNwGetEnvironmentStr((char *)"TEMP", NWDEFPERLTEMP), (_MAX_PATH - 20) );
+        tempName[_MAX_PATH-20] = '\0';
+        strcat(tempName, (char *)"\\plXXXXXX.tmp");
+        if (!fnMy_MkTemp(tempName))
+        {
+                fnTempPipeFileReleaseMemory(ptpf);
+                return NULL;
+        }
+
+        // create a temporary place-holder file
+        fclose(fopen(tempName, (char *)"w"));
+        strcpy(ptpf->m_fileName, tempName);
+
+
+        // Make the argument array
+        if(!fnPipeFileMakeArgv(ptpf))
+        {
+                fnTempPipeFileReleaseMemory(ptpf);
+
+                // Release additional memory
+                if(ptpf->m_argv != NULL)
+                {
+                        for(i=0; i<ptpf->m_argv_len; i++)
+                        {
+                                if(ptpf->m_argv[i] != NULL)
+                                {
+                                        free(ptpf->m_argv[i]);
+                                        ptpf->m_argv[i] = NULL;
+                                }
+                        }
+
+                        free(ptpf->m_argv);
+                        ptpf->m_argv = NULL;
+                }
+
+                return NULL;
+        }
+
+
+        // Open the temp file in the appropriate way...
+        //
+        if (!ptpf->m_mode)     // If Read mode?
+        {
+                // we wish to spawn a command, intercept its output,
+                // and then get that output
+                //
+                if (!ptpf->m_argv[0])
+                {
+                        fnTempPipeFileReleaseMemory(ptpf);
+
+                        // Release additional memory
+                        if(ptpf->m_argv != NULL)
+                        {
+                                for(i=0; i<ptpf->m_argv_len; i++)
+                                {
+                                        if(ptpf->m_argv[i] != NULL)
+                                        {
+                                                free(ptpf->m_argv[i]);
+                                                ptpf->m_argv[i] = NULL;
+                                        }
+                                }
+
+                                free(ptpf->m_argv);
+                                ptpf->m_argv = NULL;
+                        }
+
+                        return NULL;
+                }
+
+                if (ptpf->m_launchPerl)
+                        fnPipeFileDoPerlLaunch(ptpf);
+                else
+                        if (ptpf->m_doPerlGlob)
+                                fnDoPerlGlob(ptpf->m_argv, ptpf->m_fileName);  // hack to do perl globbing
+                else
+                        spawnvp(P_WAIT, ptpf->m_argv[0], ptpf->m_argv);
+
+                ptpf->m_file = fopen (ptpf->m_fileName, (char *)"r");  // Get the Pipe file handle
+        }
+        else if (ptpf->m_mode) // If Write mode?
+        {
+                // we wish to open the file for writing now and
+                // do the command later
+                //
+                ptpf->m_file = fopen(ptpf->m_fileName, (char *)"w");
+        }
+
+        fnTempPipeFileReleaseMemory(ptpf);
+
+        // Release additional memory
+        if(ptpf->m_argv != NULL)
+        {
+                for(i=0; i<(ptpf->m_argv_len); i++)
+                {
+                        if(ptpf->m_argv[i] != NULL)
+                        {
+                                free(ptpf->m_argv[i]);
+                                ptpf->m_argv[i] = NULL;
+                        }
+                }
+
+                free(ptpf->m_argv);
+                ptpf->m_argv = NULL;
+        }
+
+                
+        return ptpf->m_file;   // Return the Pipe file handle.
 }
 
 
@@ -468,71 +468,71 @@ FILE* fnPipeFileOpen(PTEMPPIPEFILE ptpf, char* command, char* mode)
 
 void fnPipeFileClose(PTEMPPIPEFILE ptpf)
 {
-       int i = 0;
-
-       if (ptpf->m_mode)       // If Write mode?
-       {
-               // we wish to spawn a command using our temp file for
-               // its input
-               //
-               if(ptpf->m_file != NULL)
-               {
-                       fclose (ptpf->m_file);
-                       ptpf->m_file = NULL;
-               }
-
-               if (ptpf->m_launchPerl)
-                       fnPipeFileDoPerlLaunch(ptpf);
-               else if (ptpf->m_argv)
-                       spawnvp(P_WAIT, ptpf->m_argv[0], ptpf->m_argv);
-       }
-
-
-       // Close the temporary Pipe File, if opened
-       if (ptpf->m_file)
-       {
-               fclose(ptpf->m_file);
-               ptpf->m_file = NULL;
-       }
-       // Delete the temporary Pipe Filename if still valid and free the memory associated with the file name.
-       if(ptpf->m_fileName != NULL)
-       {
+        int i = 0;
+
+        if (ptpf->m_mode)      // If Write mode?
+        {
+                // we wish to spawn a command using our temp file for
+                // its input
+                //
+                if(ptpf->m_file != NULL)
+                {
+                        fclose (ptpf->m_file);
+                        ptpf->m_file = NULL;
+                }
+
+                if (ptpf->m_launchPerl)
+                        fnPipeFileDoPerlLaunch(ptpf);
+                else if (ptpf->m_argv)
+                        spawnvp(P_WAIT, ptpf->m_argv[0], ptpf->m_argv);
+        }
+
+
+        // Close the temporary Pipe File, if opened
+        if (ptpf->m_file)
+        {
+                fclose(ptpf->m_file);
+                ptpf->m_file = NULL;
+        }
+        // Delete the temporary Pipe Filename if still valid and free the memory associated with the file name.
+        if(ptpf->m_fileName != NULL)
+        {
 //             if (strlen(ptpf->m_fileName))
-               if (ptpf->m_fileName)
-                       unlink(ptpf->m_fileName);
+                if (ptpf->m_fileName)
+                        unlink(ptpf->m_fileName);
 
-               free(ptpf->m_fileName);
-               ptpf->m_fileName = NULL;
-       }
+                free(ptpf->m_fileName);
+                ptpf->m_fileName = NULL;
+        }
 
 /**
-       if(ptpf->m_argv != NULL)
-       {
-               for(i=0; i<(ptpf->m_argv_len); i++)
-               {
-                       if(ptpf->m_argv[i] != NULL)
-                       {
-                               free(ptpf->m_argv[i]);
-                               ptpf->m_argv[i] = NULL;
-                       }
-               }
-
-               free(ptpf->m_argv);
-               ptpf->m_argv = NULL;
-       }
+        if(ptpf->m_argv != NULL)
+        {
+                for(i=0; i<(ptpf->m_argv_len); i++)
+                {
+                        if(ptpf->m_argv[i] != NULL)
+                        {
+                                free(ptpf->m_argv[i]);
+                                ptpf->m_argv[i] = NULL;
+                        }
+                }
+
+                free(ptpf->m_argv);
+                ptpf->m_argv = NULL;
+        }
 **/
 
-       if (ptpf->m_perlSynchSemaphore)
-       {
-               #ifdef MPK_ON
-                       kSemaphoreFree(ptpf->m_perlSynchSemaphore);
-               #else
-                       CloseLocalSemaphore(ptpf->m_perlSynchSemaphore);
-               #endif  //MPK_ON
-       }
+        if (ptpf->m_perlSynchSemaphore)
+        {
+                #ifdef MPK_ON
+                        kSemaphoreFree(ptpf->m_perlSynchSemaphore);
+                #else
+                        CloseLocalSemaphore(ptpf->m_perlSyn