summaryrefslogtreecommitdiff
path: root/NetWare
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2020-12-28 18:04:52 -0800
committerKarl Williamson <khw@cpan.org>2021-01-17 09:18:15 -0700
commit1604cfb0273418ed479719f39def5ee559bffda2 (patch)
tree166a5ab935a029ab86cf6295d6f3cb77da22e559 /NetWare
parent557ff1b2a4ecd18fe9229e7e0eb8fa123adc5670 (diff)
downloadperl-1604cfb0273418ed479719f39def5ee559bffda2.tar.gz
style: Detabify indentation of the C code maintained by the core.
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.
Diffstat (limited to 'NetWare')
-rw-r--r--NetWare/CLIBstuf.c216
-rw-r--r--NetWare/Main.c234
-rw-r--r--NetWare/NWTInfo.c936
-rw-r--r--NetWare/NWUtil.c1168
-rw-r--r--NetWare/Nwmain.c2016
-rw-r--r--NetWare/Nwpipe.c1006
-rw-r--r--NetWare/deb.h28
-rw-r--r--NetWare/intdef.h28
-rw-r--r--NetWare/interface.c122
-rw-r--r--NetWare/interface.h20
-rw-r--r--NetWare/iperlhost.h16
-rw-r--r--NetWare/netware.h12
-rw-r--r--NetWare/nw5.c894
-rw-r--r--NetWare/nw5sck.c58
-rw-r--r--NetWare/nw5thread.c10
-rw-r--r--NetWare/nw5thread.h88
-rw-r--r--NetWare/nwhashcls.h32
-rw-r--r--NetWare/nwperlhost.h262
-rw-r--r--NetWare/nwperlsys.c194
-rw-r--r--NetWare/nwperlsys.h326
-rw-r--r--NetWare/nwpipe.h28
-rw-r--r--NetWare/nwplglob.c60
-rw-r--r--NetWare/nwtinfo.h34
-rw-r--r--NetWare/nwutil.h50
-rw-r--r--NetWare/nwvmem.h292
-rw-r--r--NetWare/win32ish.h8
26 files changed, 4069 insertions, 4069 deletions
diff --git a/NetWare/CLIBstuf.c b/NetWare/CLIBstuf.c
index 26a4a4b502..f0e58b14b9 100644
--- a/NetWare/CLIBstuf.c
+++ b/NetWare/CLIBstuf.c
@@ -33,119 +33,119 @@
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");
}
diff --git a/NetWare/Main.c b/NetWare/Main.c
index 5116cbcfe1..4dea1dd2be 100644
--- a/NetWare/Main.c
+++ b/NetWare/Main.c
@@ -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
@@ -52,131 +52,131 @@
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");
}
diff --git a/NetWare/NWTInfo.c b/NetWare/NWTInfo.c
index b057d56b2a..a1221e703c 100644
--- a/NetWare/NWTInfo.c
+++ b/NetWare/NWTInfo.c
@@ -23,10 +23,10 @@
#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
@@ -42,11 +42,11 @@
// 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
- t (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;
}
diff --git a/NetWare/NWUtil.c b/NetWare/NWUtil.c
index 6d60dfbabd..bb39971f56 100644
--- a/NetWare/NWUtil.c
+++ b/NetWare/NWUtil.c
@@ -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.
- r (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.
- r (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;
}
diff --git a/NetWare/Nwmain.c b/NetWare/Nwmain.c
index 0b9728a8ac..c45513e736 100644
--- a/NetWare/Nwmain.c
+++ b/NetWare/Nwmain.c
@@ -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
- e (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;
+ }
}
diff --git a/NetWare/Nwpipe.c b/NetWare/Nwpipe.c
index ce9c19800d..154ee09696 100644
--- a/NetWare/Nwpipe.c
+++ b/NetWare/Nwpipe.c
@@ -52,111 +52,111 @@
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_perlSynchSemaphore);
+ #endif //MPK_ON
+ }
- return;
+ return;
}
@@ -550,30 +550,30 @@ void fnPipeFileClose(PTEMPPIPEFILE ptpf)
void fnPipeFileDoPerlLaunch(PTEMPPIPEFILE ptpf)
{
- char curdir[_MAX_PATH] = {'\0'};
- char* pcwd = NULL;
-
- int i=0;
-
-
- // save off the current working directory to restore later
- // this is just a hack! these problems of synchronization and
- // restoring calling context need a much better solution!
- pcwd = (char *)getcwd(curdir, sizeof(curdir)-1);
- fnSystemCommand(ptpf->m_argv, ptpf->m_argv_len);
- if (ptpf->m_perlSynchSemaphore)
- {
- #ifdef MPK_ON
- kSemaphoreWait(ptpf->m_perlSynchSemaphore);
- #else
- WaitOnLocalSemaphore(ptpf->m_perlSynchSemaphore);
- #endif //MPK_ON
- }
-
- if (pcwd)
- chdir(pcwd);
-
- return;
+ char curdir[_MAX_PATH] = {'\0'};
+ char* pcwd = NULL;
+
+ int i=0;
+
+
+ // save off the current working directory to restore later
+ // this is just a hack! these problems of synchronization and
+ // restoring calling context need a much better solution!
+ pcwd = (char *)getcwd(curdir, sizeof(curdir)-1);
+ fnSystemCommand(ptpf->m_argv, ptpf->m_argv_len);
+ if (ptpf->m_perlSynchSemaphore)
+ {
+ #ifdef MPK_ON
+ kSemaphoreWait(ptpf->m_perlSynchSemaphore);
+ #else
+ WaitOnLocalSemaphore(ptpf->m_perlSynchSemaphore);
+ #endif //MPK_ON
+ }
+
+ if (pcwd)
+ chdir(pcwd);
+
+ return;
}
@@ -591,27 +591,27 @@ void fnPipeFileDoPerlLaunch(PTEMPPIPEFILE ptpf)
void fnTempPipeFile(PTEMPPIPEFILE ptpf)
{
- ptpf->m_fileName = NULL;
+ ptpf->m_fileName = NULL;
- ptpf->m_mode = FALSE; // Default mode = Read mode.
- ptpf->m_file = NULL;
- ptpf->m_pipeCommand = NULL;
- ptpf->m_argv = NULL;
+ ptpf->m_mode = FALSE; // Default mode = Read mode.
+ ptpf->m_file = NULL;
+ ptpf->m_pipeCommand = NULL;
+ ptpf->m_argv = NULL;
- ptpf->m_redirect = NULL;
+ ptpf->m_redirect = NULL;
- ptpf->m_launchPerl = FALSE;
- ptpf->m_doPerlGlob = FALSE;
+ ptpf->m_launchPerl = FALSE;
+ ptpf->m_doPerlGlob = FALSE;
- #ifdef MPK_ON
- ptpf->m_perlSynchSemaphore = NULL;
- #else
- ptpf->m_perlSynchSemaphore = 0L;
- #endif
+ #ifdef MPK_ON
+ ptpf->m_perlSynchSemaphore = NULL;
+ #else
+ ptpf->m_perlSynchSemaphore = 0L;
+ #endif
- ptpf->m_argv_len = 0;
+ ptpf->m_argv_len = 0;
- return;
+ return;
}
@@ -629,76 +629,76 @@ void fnTempPipeFile(PTEMPPIPEFILE ptpf)
void fnTempPipeFileReleaseMemory(PTEMPPIPEFILE ptpf)
{
- int i=0;
-
-
- if (ptpf->m_pipeCommand)
- {
- if(ptpf->m_pipeCommand->m_argv != 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;
- }
-
- if(ptpf->m_pipeCommand->sSkippedToken != NULL)
- {
- free(ptpf->m_pipeCommand->sSkippedToken);
- ptpf->m_pipeCommand->sSkippedToken = NULL;
- }
+ int i=0;
+
+
+ if (ptpf->m_pipeCommand)
+ {
+ if(ptpf->m_pipeCommand->m_argv != 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;
+ }
+
+ if(ptpf->m_pipeCommand->sSkippedToken != NULL)
+ {
+ free(ptpf->m_pipeCommand->sSkippedToken);
+ ptpf->m_pipeCommand->sSkippedToken = NULL;
+ }
/****
// 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,
- if(ptpf->m_pipeCommand->nextarg)
- {
- free(ptpf->m_pipeCommand->nextarg);
- ptpf->m_pipeCommand->nextarg = NULL;
- }
-
- if(ptpf->m_pipeCommand->m_redirInName)
- {
- free(ptpf->m_pipeCommand->m_redirInName);
- ptpf->m_pipeCommand->m_redirInName = NULL;
- }
- if(ptpf->m_pipeCommand->m_redirOutName)
- {
- free(ptpf->m_pipeCommand->m_redirOutName);
- ptpf->m_pipeCommand->m_redirOutName = NULL;
- }
- if(ptpf->m_pipeCommand->m_redirErrName)
- {
- free(ptpf->m_pipeCommand->m_redirErrName);
- ptpf->m_pipeCommand->m_redirErrName = NULL;
- }
- if(ptpf->m_pipeCommand->m_redirBothName)
- {
- free(ptpf->m_pipeCommand->m_redirBothName);
- ptpf->m_pipeCommand->m_redirBothName = NULL;
- }
+ if(ptpf->m_pipeCommand->nextarg)
+ {
+ free(ptpf->m_pipeCommand->nextarg);
+ ptpf->m_pipeCommand->nextarg = NULL;
+ }
+
+ if(ptpf->m_pipeCommand->m_redirInName)
+ {
+ free(ptpf->m_pipeCommand->m_redirInName);
+ ptpf->m_pipeCommand->m_redirInName = NULL;
+ }
+ if(ptpf->m_pipeCommand->m_redirOutName)
+ {
+ free(ptpf->m_pipeCommand->m_redirOutName);
+ ptpf->m_pipeCommand->m_redirOutName = NULL;
+ }
+ if(ptpf->m_pipeCommand->m_redirErrName)
+ {
+ free(ptpf->m_pipeCommand->m_redirErrName);
+ ptpf->m_pipeCommand->m_redirErrName = NULL;
+ }
+ if(ptpf->m_pipeCommand->m_redirBothName)
+ {
+ free(ptpf->m_pipeCommand->m_redirBothName);
+ ptpf->m_pipeCommand->m_redirBothName = NULL;
+ }
****/
- if(ptpf->m_pipeCommand != NULL)
- {
- free(ptpf->m_pipeCommand);
- ptpf->m_pipeCommand = NULL;
- }
- }
+ if(ptpf->m_pipeCommand != NULL)
+ {
+ free(ptpf->m_pipeCommand);
+ ptpf->m_pipeCommand = NULL;
+ }
+ }
- if(ptpf->m_redirect != NULL)
- {
- free(ptpf->m_redirect);
- ptpf->m_redirect = NULL;
- }
+ if(ptpf->m_redirect != NULL)
+ {
+ free(ptpf->m_redirect);
+ ptpf->m_redirect = NULL;
+ }
- return;
+ return;
}
diff --git a/NetWare/deb.h b/NetWare/deb.h
index e79a8f41a7..a0000bc041 100644
--- a/NetWare/deb.h
+++ b/NetWare/deb.h
@@ -25,21 +25,21 @@
#if defined(DEBUGON) && !defined(USE_D2)
- //debug build and d1 flag is used, so enable IDB
- #define DBGMESG ConsolePrintf
- #define IDB(x) \
- ConsolePrintf(x); \
- _asm {int 3}
+ //debug build and d1 flag is used, so enable IDB
+ #define DBGMESG ConsolePrintf
+ #define IDB(x) \
+ ConsolePrintf(x); \
+ _asm {int 3}
#else
- #if defined(USE_D2)
- //debug build and d2 flag is used, so disable IDB
- #define DBGMESG ConsolePrintf
- #define IDB ConsolePrintf
- #else
- //release build, so disable DBGMESG and IDB
- #define DBGMESG
- #define IDB
- #endif //if defined(USE_D2)
+ #if defined(USE_D2)
+ //debug build and d2 flag is used, so disable IDB
+ #define DBGMESG ConsolePrintf
+ #define IDB ConsolePrintf
+ #else
+ //release build, so disable DBGMESG and IDB
+ #define DBGMESG
+ #define IDB
+ #endif //if defined(USE_D2)
#endif //if defined(DEBUGON) && !defined(USE_D2)
diff --git a/NetWare/intdef.h b/NetWare/intdef.h
index 4c566c4e45..b0bcf010b5 100644
--- a/NetWare/intdef.h
+++ b/NetWare/intdef.h
@@ -47,8 +47,8 @@
//#define strcpy(x,y) NWLstrbcpy(x,y,NWstrlen(y)+1)
#define strcpy(x,y) \
- NWstrncpy(x,y,NWstrlen(y)); \
- x[NWstrlen(y)] ='\0';
+ NWstrncpy(x,y,NWstrlen(y)); \
+ x[NWstrlen(y)] ='\0';
#define strncpy(x,y,z) NWLstrbcpy(x,y,(z + 1))
#define strcat(x,y) NWLstrbcpy((x + NWstrlen(x)), y, (NWstrlen(y) +1))
#define strncmp(s1,s2,l) NWgstrncmp(s1,s2,l)
@@ -58,28 +58,28 @@
#define wsprintf NWsprintf
#define strncat(x,y,l) \
- NWsprintf("oops!!! Not yet defined for NWI18N, define in intdef.h, still using strncat\n"); \
- strncat(x,y,l);
+ NWsprintf("oops!!! Not yet defined for NWI18N, define in intdef.h, still using strncat\n"); \
+ strncat(x,y,l);
#define strdup(s1) \
- NWsprintf("oops!!! Not yet defined for NWI18N, define in intdef.h, still using strdup\n"); \
- strdup(s1);
+ NWsprintf("oops!!! Not yet defined for NWI18N, define in intdef.h, still using strdup\n"); \
+ strdup(s1);
#define strlist \
- NWsprintf("oops!!! Not yet defined for NWI18N, define in intdef.h, still using strlist\n"); \
- strlist;
+ NWsprintf("oops!!! Not yet defined for NWI18N, define in intdef.h, still using strlist\n"); \
+ strlist;
#define strlwr(s1) \
- NWsprintf("oops!!! Not yet defined for NWI18N, define in intdef.h, still using strlwr\n"); \
- strlwr(s1);
+ NWsprintf("oops!!! Not yet defined for NWI18N, define in intdef.h, still using strlwr\n"); \
+ strlwr(s1);
#define strnset(s1,l1,l2) \
- NWsprintf("oops!!! Not yet defined for NWI18N, define in intdef.h, still using strnset\n"); \
- strnset(s1,l1,l2);
+ NWsprintf("oops!!! Not yet defined for NWI18N, define in intdef.h, still using strnset\n"); \
+ strnset(s1,l1,l2);
#define strset(s1,l1) \
- NWsprintf("oops!!! Not yet defined for NWI18N, define in intdef.h, still using strset\n"); \
- strset(s1,l1);
+ NWsprintf("oops!!! Not yet defined for NWI18N, define in intdef.h, still using strset\n"); \
+ strset(s1,l1);
#endif // __INTDEF__
diff --git a/NetWare/interface.c b/NetWare/interface.c
index be3eddf149..cd2c6deb08 100644
--- a/NetWare/interface.c
+++ b/NetWare/interface.c
@@ -41,58 +41,58 @@ ClsPerlHost::~ClsPerlHost()
ClsPerlHost::VersionNumber()
{
- return 0;
+ return 0;
}
bool
ClsPerlHost::RegisterWithThreadTable()
{
- return(fnRegisterWithThreadTable());
+ return(fnRegisterWithThreadTable());
}
bool
ClsPerlHost::UnregisterWithThreadTable()
{
- return(fnUnregisterWithThreadTable());
+ return(fnUnregisterWithThreadTable());
}
int
ClsPerlHost::PerlCreate(PerlInterpreter *my_perl)
{
/* if (!(my_perl = perl_alloc())) // Allocate memory for Perl.
- return (1);*/
+ return (1);*/
perl_construct(my_perl);
- return 1;
+ return 1;
}
int
ClsPerlHost::PerlParse(PerlInterpreter *my_perl, int argc, char** argv, char** env)
{
- return(perl_parse(my_perl, xs_init, argc, argv, env)); // Parse the command line.
+ return(perl_parse(my_perl, xs_init, argc, argv, env)); // Parse the command line.
}
int
ClsPerlHost::PerlRun(PerlInterpreter *my_perl)
{
- return(perl_run(my_perl)); // Run Perl.
+ return(perl_run(my_perl)); // Run Perl.
}
int
ClsPerlHost::PerlDestroy(PerlInterpreter *my_perl)
{
- return(perl_destruct(my_perl)); // Destructor for Perl.
+ return(perl_destruct(my_perl)); // Destructor for Perl.
}
void
ClsPerlHost::PerlFree(PerlInterpreter *my_perl)
{
- perl_free(my_perl); // Free the memory allocated for Perl.
+ perl_free(my_perl); // Free the memory allocated for Perl.
- // Remove the thread context set during Perl_set_context
- // This is added here since for web script there is no other place this gets executed
- // and it cannot be included into cgi2perl.xs unless this symbol is exported.
- Remove_Thread_Ctx();
+ // Remove the thread context set during Perl_set_context
+ // This is added here since for web script there is no other place this gets executed
+ // and it cannot be included into cgi2perl.xs unless this symbol is exported.
+ Remove_Thread_Ctx();
}
/*============================================================================================
@@ -109,58 +109,58 @@ ClsPerlHost::PerlFree(PerlInterpreter *my_perl)
static void xs_init(pTHX)
{
- char *file = __FILE__;
+ char *file = __FILE__;
- dXSUB_SYS;
- newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
+ dXSUB_SYS;
+ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
}
EXTERN_C
int RunPerl(int argc, char **argv, char **env)
{
- int exitstatus = 0;
- ClsPerlHost nlm;
-
- PerlInterpreter *my_perl = NULL; // defined in Perl.h
- PerlInterpreter *new_perl = NULL; // defined in Perl.h
-
- PERL_SYS_INIT(&argc, &argv);
-
- if (!(my_perl = perl_alloc())) // Allocate memory for Perl.
- return (1);
-
- if(nlm.PerlCreate(my_perl))
- {
- PL_perl_destruct_level = 0;
-
- if(!nlm.PerlParse(my_perl, argc, argv, env))
- {
- #if defined(TOP_CLONE) && defined(USE_ITHREADS) // XXXXXX testing
- new_perl = perl_clone(my_perl, 1);
-
- (void) perl_run(new_perl); // Run Perl.
- PERL_SET_THX(my_perl);
- #else
- (void) nlm.PerlRun(my_perl);
- #endif
- }
- exitstatus = nlm.PerlDestroy(my_perl);
- }
- if(my_perl)
- nlm.PerlFree(my_perl);
-
- #ifdef USE_ITHREADS
- if (new_perl)
- {
- PERL_SET_THX(new_perl);
- exitstatus = nlm.PerlDestroy(new_perl);
- nlm.PerlFree(my_perl);
- }
- #endif
-
- PERL_SYS_TERM();
- return exitstatus;
+ int exitstatus = 0;
+ ClsPerlHost nlm;
+
+ PerlInterpreter *my_perl = NULL; // defined in Perl.h
+ PerlInterpreter *new_perl = NULL; // defined in Perl.h
+
+ PERL_SYS_INIT(&argc, &argv);
+
+ if (!(my_perl = perl_alloc())) // Allocate memory for Perl.
+ return (1);
+
+ if(nlm.PerlCreate(my_perl))
+ {
+ PL_perl_destruct_level = 0;
+
+ if(!nlm.PerlParse(my_perl, argc, argv, env))
+ {
+ #if defined(TOP_CLONE) && defined(USE_ITHREADS) // XXXXXX testing
+ new_perl = perl_clone(my_perl, 1);
+
+ (void) perl_run(new_perl); // Run Perl.
+ PERL_SET_THX(my_perl);
+ #else
+ (void) nlm.PerlRun(my_perl);
+ #endif
+ }
+ exitstatus = nlm.PerlDestroy(my_perl);
+ }
+ if(my_perl)
+ nlm.PerlFree(my_perl);
+
+ #ifdef USE_ITHREADS
+ if (new_perl)
+ {
+ PERL_SET_THX(new_perl);
+ exitstatus = nlm.PerlDestroy(new_perl);
+ nlm.PerlFree(my_perl);
+ }
+ #endif
+
+ PERL_SYS_TERM();
+ return exitstatus;
}
@@ -173,7 +173,7 @@ int RunPerl(int argc, char **argv, char **env)
//
IPerlHost* AllocStdPerl()
{
- return (IPerlHost*) new ClsPerlHost();
+ return (IPerlHost*) new ClsPerlHost();
}
@@ -185,7 +185,7 @@ IPerlHost* AllocStdPerl()
//
void FreeStdPerl(IPerlHost* pPerlHost)
{
- if (pPerlHost)
- delete (ClsPerlHost*) pPerlHost;
+ if (pPerlHost)
+ delete (ClsPerlHost*) pPerlHost;
}
diff --git a/NetWare/interface.h b/NetWare/interface.h
index 2c9d46d75d..3718cfea62 100644
--- a/NetWare/interface.h
+++ b/NetWare/interface.h
@@ -27,19 +27,19 @@
class ClsPerlHost : public IPerlHost
{
public:
- ClsPerlHost(void);
- virtual ~ClsPerlHost(void);
+ ClsPerlHost(void);
+ virtual ~ClsPerlHost(void);
- int VersionNumber();
+ int VersionNumber();
- int PerlCreate(PerlInterpreter *my_perl);
- int PerlParse(PerlInterpreter *my_perl, int argc, char** argv, char** env);
- int PerlRun(PerlInterpreter *my_perl);
- int PerlDestroy(PerlInterpreter *my_perl);
- void PerlFree(PerlInterpreter *my_perl);
+ int PerlCreate(PerlInterpreter *my_perl);
+ int PerlParse(PerlInterpreter *my_perl, int argc, char** argv, char** env);
+ int PerlRun(PerlInterpreter *my_perl);
+ int PerlDestroy(PerlInterpreter *my_perl);
+ void PerlFree(PerlInterpreter *my_perl);
- //bool RegisterWithThreadTable(void);
- //bool UnregisterWithThreadTable(void);
+ //bool RegisterWithThreadTable(void);
+ //bool UnregisterWithThreadTable(void);
};
diff --git a/NetWare/iperlhost.h b/NetWare/iperlhost.h
index fe3dab7a34..946ee0a2c3 100644
--- a/NetWare/iperlhost.h
+++ b/NetWare/iperlhost.h
@@ -28,16 +28,16 @@
class IPerlHost
{
public:
- virtual int VersionNumber() = 0;
+ virtual int VersionNumber() = 0;
- virtual int PerlCreate(PerlInterpreter *my_perl) = 0;
- virtual int PerlParse(PerlInterpreter *my_perl,int argc, char** argv, char** env) = 0;
- virtual int PerlRun(PerlInterpreter *my_perl) = 0;
- virtual int PerlDestroy(PerlInterpreter *my_perl) = 0;
- virtual void PerlFree(PerlInterpreter *my_perl) = 0;
+ virtual int PerlCreate(PerlInterpreter *my_perl) = 0;
+ virtual int PerlParse(PerlInterpreter *my_perl,int argc, char** argv, char** env) = 0;
+ virtual int PerlRun(PerlInterpreter *my_perl) = 0;
+ virtual int PerlDestroy(PerlInterpreter *my_perl) = 0;
+ virtual void PerlFree(PerlInterpreter *my_perl) = 0;
- //virtual bool RegisterWithThreadTable(void)=0;
- //virtual bool UnregisterWithThreadTable(void)=0;
+ //virtual bool RegisterWithThreadTable(void)=0;
+ //virtual bool UnregisterWithThreadTable(void)=0;
};
extern "C" IPerlHost* AllocStdPerl();
diff --git a/NetWare/netware.h b/NetWare/netware.h
index c106476e28..af9e59936a 100644
--- a/NetWare/netware.h
+++ b/NetWare/netware.h
@@ -33,10 +33,10 @@
//structure that will be used by times routine.
struct tms {
- long tms_utime;
- long tms_stime;
- long tms_cutime;
- long tms_cstime;
+ long tms_utime;
+ long tms_stime;
+ long tms_cutime;
+ long tms_cstime;
};
#define PERL_GET_CONTEXT_DEFINED
@@ -87,9 +87,9 @@ EXTERN_C void Perl_nw5_init(int *argcp, char ***argvp);
// Below is called in Run.c file when a perl script executes/runs.
#ifdef MPK_ON
- #define PERL_ASYNC_CHECK() kYieldThread();
+ #define PERL_ASYNC_CHECK() kYieldThread();
#else
- #define PERL_ASYNC_CHECK() ThreadSwitch();
+ #define PERL_ASYNC_CHECK() ThreadSwitch();
#endif
diff --git a/NetWare/nw5.c b/NetWare/nw5.c
index 46642a4d59..7db8ac0901 100644
--- a/NetWare/nw5.c
+++ b/NetWare/nw5.c
@@ -65,8 +65,8 @@ does not abend the server.
void
nw_abort(void)
{
- abort(); // Terminate the NLM application abnormally.
- return;
+ abort(); // Terminate the NLM application abnormally.
+ return;
}
int
@@ -84,8 +84,8 @@ nw_chmod(const char *path, int mode)
void
nw_clearerr(FILE *pf)
{
- if(pf)
- clearerr(pf);
+ if(pf)
+ clearerr(pf);
}
int
@@ -96,156 +96,156 @@ nw_close(int fd)
nw_closedir(DIR *dirp)
{
- return (closedir(dirp));
+ return (closedir(dirp));
}
void
nw_setbuf(FILE *pf, char *buf)
{
- if(pf)
- setbuf(pf, buf);
+ if(pf)
+ setbuf(pf, buf);
}
int
nw_setmode(FILE *fp, int mode)
{
/**
- // Commented since a few abends were happening in fnFpSetMode
- int *dummy = 0;
- return(fnFpSetMode(fp, mode, dummy));
+ // Commented since a few abends were happening in fnFpSetMode
+ int *dummy = 0;
+ return(fnFpSetMode(fp, mode, dummy));
**/
- int handle = -1;
- errno = 0;
+ int handle = -1;
+ errno = 0;
- handle = fileno(fp);
- if (errno)
- {
- errno = 0;
- return -1;
- }
- return setmode(handle, mode);
+ handle = fileno(fp);
+ if (errno)
+ {
+ errno = 0;
+ return -1;
+ }
+ return setmode(handle, mode);
}
int
nw_setvbuf(FILE *pf, char *buf, int type, size_t size)
{
- if(pf)
- return setvbuf(pf, buf, type, size);
- else
- return -1;
+ if(pf)
+ return setvbuf(pf, buf, type, size);
+ else
+ return -1;
}
unsigned int
nw_sleep(unsigned int t)
{
- delay(t*1000); // Put the thread to sleep for 't' seconds. Initially 't' is passed in milliseconds.
+ delay(t*1000); // Put the thread to sleep for 't' seconds. Initially 't' is passed in milliseconds.
return 0;
}
int
nw_spawnvp(int mode, char *cmdname, char **argv)
{
- // There is no pass-around environment on NetWare so we throw that
- // argument away for now.
-
- // The function "spawnvp" does not work in all situations. Loading
- // edit.nlm seems to work, for example, but the name of the file
- // to edit does not appear to get passed correctly. Another problem
- // is that on Netware, P_WAIT does not really work reliably. It only
- // works with NLMs built to use CLIB (according to Nile Thayne).
- // NLMs such as EDIT that are written directly to the system have no
- // way of running synchronously from another process. The whole
- // architecture on NetWare seems pretty busted, so we just support it
- // as best we can.
- //
- // The spawnvp function only launches NLMs, it will not execute a command;
- // the NetWare "system" function is used for that purpose. Unfortunately, "system"
- // always returns success whether the command is successful or not or even
- // if the command was not found! To avoid ambiguity--you can have both an
- // NLM named "perl" and a system command named "perl"--we need to
- // force perl scripts to carry the word "load" when loading an NLM. This
- // might be clearer anyway.
-
- int ret = 0;
- int argc = 0;
-
-
- if (stricmp(cmdname, LOAD_COMMAND) == 0)
- {
- if (argv[1] != NULL)
- ret = spawnvp(mode, argv[1], &argv[1]);
- }
- else
- {
- int i=0;
- while (argv[i] != '\0')
- i++;
- argc = i;
-
- fnSystemCommand(argv, argc);
- }
-
- return ret;
+ // There is no pass-around environment on NetWare so we throw that
+ // argument away for now.
+
+ // The function "spawnvp" does not work in all situations. Loading
+ // edit.nlm seems to work, for example, but the name of the file
+ // to edit does not appear to get passed correctly. Another problem
+ // is that on Netware, P_WAIT does not really work reliably. It only
+ // works with NLMs built to use CLIB (according to Nile Thayne).
+ // NLMs such as EDIT that are written directly to the system have no
+ // way of running synchronously from another process. The whole
+ // architecture on NetWare seems pretty busted, so we just support it
+ // as best we can.
+ //
+ // The spawnvp function only launches NLMs, it will not execute a command;
+ // the NetWare "system" function is used for that purpose. Unfortunately, "system"
+ // always returns success whether the command is successful or not or even
+ // if the command was not found! To avoid ambiguity--you can have both an
+ // NLM named "perl" and a system command named "perl"--we need to
+ // force perl scripts to carry the word "load" when loading an NLM. This
+ // might be clearer anyway.
+
+ int ret = 0;
+ int argc = 0;
+
+
+ if (stricmp(cmdname, LOAD_COMMAND) == 0)
+ {
+ if (argv[1] != NULL)
+ ret = spawnvp(mode, argv[1], &argv[1]);
+ }
+ else
+ {
+ int i=0;
+ while (argv[i] != '\0')
+ i++;
+ argc = i;
+
+ fnSystemCommand(argv, argc);
+ }
+
+ return ret;
}
int
nw_execv(char *cmdname, char **argv)
{
- return spawnvp(P_WAIT, cmdname, (char **)argv);
+ return spawnvp(P_WAIT, cmdname, (char **)argv);
}
int
nw_execvp(char *cmdname, char **argv)
{
- return nw_spawnvp(P_WAIT, cmdname, (char **)argv);
+ return nw_spawnvp(P_WAIT, cmdname, (char **)argv);
}
int
nw_stat(const char *path, struct stat *sbuf)
{
- return (stat(path, sbuf));
+ return (stat(path, sbuf));
}
FILE *
nw_stderr(void)
{
- return (stderr);
+ return (stderr);
}
FILE *
nw_stdin(void)
{
- return (stdin);
+ return (stdin);
}
FILE *
nw_stdout()
{
- return (stdout);
+ return (stdout);
}
long
nw_telldir(DIR *dirp)
{
- dTHX;
- Perl_croak(aTHX_ "The telldir() function is not implemented on NetWare\n");
- return 0l;
+ dTHX;
+ Perl_croak(aTHX_ "The telldir() function is not implemented on NetWare\n");
+ return 0l;
}
int
nw_times(struct tms *timebuf)
{
- clock_t now = clock();
+ clock_t now = clock();
- timebuf->tms_utime = now;
- timebuf->tms_stime = 0;
- timebuf->tms_cutime = 0;
- timebuf->tms_cstime = 0;
+ timebuf->tms_utime = now;
+ timebuf->tms_stime = 0;
+ timebuf->tms_cutime = 0;
+ timebuf->tms_cstime = 0;
- return 0;
+ return 0;
}
FILE*
@@ -257,37 +257,37 @@ nw_tmpfile(void)
int
nw_uname(struct utsname *name)
{
- return(uname(name));
+ return(uname(name));
}
int
nw_ungetc(int c, FILE *pf)
{
- if(pf)
- return ungetc(c, pf);
- else
- return -1;
+ if(pf)
+ return ungetc(c, pf);
+ else
+ return -1;
}
int
nw_unlink(const char *filename)
{
- return(unlink(filename));
+ return(unlink(filename));
}
int
nw_utime(const char *filename, struct utimbuf *times)
{
- return(utime(filename, times));
+ return(utime(filename, times));
}
int
nw_vfprintf(FILE *fp, const char *format, va_list args)
{
- if(fp)
- return (vfprintf(fp, format, args));
- else
- return -1;
+ if(fp)
+ return (vfprintf(fp, format, args));
+ else
+ return -1;
}
int
@@ -311,7 +311,7 @@ nw_write(int fd, const void *buf, unsigned int cnt)
char *
nw_crypt(const char *txt, const char *salt)
{
- dTHX;
+ dTHX;
#ifdef HAVE_DES_FCRYPT
dTHR;
@@ -331,221 +331,221 @@ nw_dup(int fd)
int
nw_dup2(int fd1,int fd2)
{
- return dup2(fd1,fd2);
+ return dup2(fd1,fd2);
}
void*
nw_dynaload(const char* filename)
{
- return NULL;
+ return NULL;
}
int
nw_fclose(FILE *pf)
{
- if(pf)
- return (fclose(pf));
- else
- return -1;
+ if(pf)
+ return (fclose(pf));
+ else
+ return -1;
}
FILE *
nw_fdopen(int handle, const char *mode)
{
- return(fdopen(handle, mode));
+ return(fdopen(handle, mode));
}
int
nw_feof(FILE *fp)
{
- if(fp)
- return (feof(fp));
- else
- return -1;
+ if(fp)
+ return (feof(fp));
+ else
+ return -1;
}
int
nw_ferror(FILE *fp)
{
- if(fp)
- return (ferror(fp));
- else
- return -1;
+ if(fp)
+ return (ferror(fp));
+ else
+ return -1;
}
int
nw_fflush(FILE *pf)
{
- if(pf)
- return fflush(pf);
- else
- return -1;
+ if(pf)
+ return fflush(pf);
+ else
+ return -1;
}
int
nw_fgetpos(FILE *pf, fpos_t *p)
{
- if(pf)
- return fgetpos(pf, p);
- else
- return -1;
+ if(pf)
+ return fgetpos(pf, p);
+ else
+ return -1;
}
char*
nw_fgets(char *s, int n, FILE *pf)
{
- if(pf)
- return(fgets(s, n, pf));
- else
- return NULL;
+ if(pf)
+ return(fgets(s, n, pf));
+ else
+ return NULL;
}
int
nw_fileno(FILE *pf)
{
- if(pf)
- return fileno(pf);
- else
- return -1;
+ if(pf)
+ return fileno(pf);
+ else
+ return -1;
}
int
nw_flock(int fd, int oper)
{
- dTHX;
- Perl_croak(aTHX_ "The flock() function is not implemented on NetWare\n");
- return 0;
+ dTHX;
+ Perl_croak(aTHX_ "The flock() function is not implemented on NetWare\n");
+ return 0;
}
FILE *
nw_fopen(const char *filename, const char *mode)
{
- return (fopen(filename, mode));
+ return (fopen(filename, mode));
}
int
nw_fputc(int c, FILE *pf)
{
- if(pf)
- return fputc(c,pf);
- else
- return -1;
+ if(pf)
+ return fputc(c,pf);
+ else
+ return -1;
}
int
nw_fputs(const char *s, FILE *pf)
{
- if(pf)
- return fputs(s, pf);
- else
- return -1;
+ if(pf)
+ return fputs(s, pf);
+ else
+ return -1;
}
size_t
nw_fread(void *buf, size_t size, size_t count, FILE *fp)
{
- if(fp)
- return fread(buf, size, count, fp);
- else
- return -1;
+ if(fp)
+ return fread(buf, size, count, fp);
+ else
+ return -1;
}
FILE *
nw_freopen(const char *path, const char *mode, FILE *stream)
{
- if(stream)
- return freopen(path, mode, stream);
- else
- return NULL;
+ if(stream)
+ return freopen(path, mode, stream);
+ else
+ return NULL;
}
int
nw_fseek(FILE *pf, long offset, int origin)
{
- if(pf)
- return (fseek(pf, offset, origin));
- else
- return -1;
+ if(pf)
+ return (fseek(pf, offset, origin));
+ else
+ return -1;
}
int
nw_fsetpos(FILE *pf, const fpos_t *p)
{
- if(pf)
- return fsetpos(pf, p);
- else
- return -1;
+ if(pf)
+ return fsetpos(pf, p);
+ else
+ return -1;
}
long
nw_ftell(FILE *pf)
{
- if(pf)
- return ftell(pf);
- else
- return -1;
+ if(pf)
+ return ftell(pf);
+ else
+ return -1;
}
size_t
nw_fwrite(const void *buf, size_t size, size_t count, FILE *fp)
{
- if(fp)
- return fwrite(buf, size, count, fp);
- else
- return -1;
+ if(fp)
+ return fwrite(buf, size, count, fp);
+ else
+ return -1;
}
long
nw_get_osfhandle(int fd)
{
- return 0l;
+ return 0l;
}
int
nw_getc(FILE *pf)
{
- if(pf)
- return getc(pf);
- else
- return -1;
+ if(pf)
+ return getc(pf);
+ else
+ return -1;
}
int
nw_putc(int c, FILE *pf)
{
- if(pf)
- return putc(c,pf);
- else
- return -1;
+ if(pf)
+ return putc(c,pf);
+ else
+ return -1;
}
int
nw_fgetc(FILE *pf)
{
- if(pf)
- return fgetc(pf);
- else
- return -1;
+ if(pf)
+ return fgetc(pf);
+ else
+ return -1;
}
int
nw_getpid(void)
{
- return GetThreadGroupID();
+ return GetThreadGroupID();
}
int
nw_kill(int pid, int sig)
{
- return 0;
+ return 0;
}
int
nw_link(const char *oldname, const char *newname)
{
- return 0;
+ return 0;
}
long
@@ -569,165 +569,165 @@ nw_rmdir(const char *dir)
DIR *
nw_opendir(const char *filename)
{
- char *buff = NULL;
- int len = 0;
- DIR *ret = NULL;
-
- len = strlen(filename);
- buff = malloc(len + 5);
- if (buff) {
- strcpy(buff, filename);
- if (buff[len-1]=='/' || buff[len-1]=='\\') {
- buff[--len] = 0;
- }
- strcpy(buff+len, "/*.*");
- ret = opendir(buff);
- free (buff);
- buff = NULL;
- return ret;
- } else {
- return NULL;
- }
+ char *buff = NULL;
+ int len = 0;
+ DIR *ret = NULL;
+
+ len = strlen(filename);
+ buff = malloc(len + 5);
+ if (buff) {
+ strcpy(buff, filename);
+ if (buff[len-1]=='/' || buff[len-1]=='\\') {
+ buff[--len] = 0;
+ }
+ strcpy(buff+len, "/*.*");
+ ret = opendir(buff);
+ free (buff);
+ buff = NULL;
+ return ret;
+ } else {
+ return NULL;
+ }
}
int
nw_open(const char *path, int flag, ...)
{
- va_list ap;
- int pmode = -1;
+ va_list ap;
+ int pmode = -1;
- va_start(ap, flag);
+ va_start(ap, flag);
pmode = va_arg(ap, int);
va_end(ap);
- if (stricmp(path, "/dev/null")==0)
- path = "NWNUL";
+ if (stricmp(path, "/dev/null")==0)
+ path = "NWNUL";
- return open(path, flag, pmode);
+ return open(path, flag, pmode);
}
int
nw_open_osfhandle(long handle, int flags)
{
- return 0;
+ return 0;
}
unsigned long
nw_os_id(void)
{
- return 0l;
+ return 0l;
}
int nw_Pipe(int* a, int* e)
{
- int ret = 0;
+ int ret = 0;
- errno = 0;
- ret = pipe(a);
- if(errno)
- e = &errno;
+ errno = 0;
+ ret = pipe(a);
+ if(errno)
+ e = &errno;
- return ret;
+ return ret;
}
FILE* nw_Popen(char* command, char* mode, int* e)
{
- int i = -1;
-
- FILE* ret = NULL;
- PTEMPPIPEFILE ptpf = NULL;
-
- // this callback is supposed to call _popen, which spawns an
- // asynchronous command and opens a pipe to it. The returned
- // file handle can be read or written to; if read, it represents
- // stdout of the called process and will return EOF when the
- // called process finishes. If written to, it represents stdin
- // of the called process. Naturally _popen is not available on
- // NetWare so we must do some fancy stuff to simulate it. We will
- // redirect to and from temp files; this has the side effect
- // of having to run the process synchronously rather than
- // asynchronously. This means that you will only be able to do
- // this with CLIB NLMs built to run on the calling thread.
-
- errno = 0;
-
- ptpf1[iPopenCount] = (PTEMPPIPEFILE) malloc(sizeof(TEMPPIPEFILE));
- if (!ptpf1[iPopenCount])
- return NULL;
-
- ptpf = ptpf1[iPopenCount];
- iPopenCount ++;
- if(iPopenCount > MAX_PIPE_RECURSION)
- iPopenCount = MAX_PIPE_RECURSION; // Limit to the max no of pipes to be open recursively.
-
- fnTempPipeFile(ptpf);
- ret = fnPipeFileOpen((PTEMPPIPEFILE) ptpf, (char *) command, (char *) mode);
- if (ret)
- File1[iPopenCount-1] = ret; // Store the obtained Pipe file handle.
- else
- { // Pipe file not obtained. So free the allocated memory.
- if(ptpf1[iPopenCount-1])
- {
- free(ptpf1[iPopenCount-1]);
- ptpf1[iPopenCount-1] = NULL;
- ptpf = NULL;
- iPopenCount --;
- }
- }
-
- if (errno)
- e = &errno;
-
- return ret;
+ int i = -1;
+
+ FILE* ret = NULL;
+ PTEMPPIPEFILE ptpf = NULL;
+
+ // this callback is supposed to call _popen, which spawns an
+ // asynchronous command and opens a pipe to it. The returned
+ // file handle can be read or written to; if read, it represents
+ // stdout of the called process and will return EOF when the
+ // called process finishes. If written to, it represents stdin
+ // of the called process. Naturally _popen is not available on
+ // NetWare so we must do some fancy stuff to simulate it. We will
+ // redirect to and from temp files; this has the side effect
+ // of having to run the process synchronously rather than
+ // asynchronously. This means that you will only be able to do
+ // this with CLIB NLMs built to run on the calling thread.
+
+ errno = 0;
+
+ ptpf1[iPopenCount] = (PTEMPPIPEFILE) malloc(sizeof(TEMPPIPEFILE));
+ if (!ptpf1[iPopenCount])
+ return NULL;
+
+ ptpf = ptpf1[iPopenCount];
+ iPopenCount ++;
+ if(iPopenCount > MAX_PIPE_RECURSION)
+ iPopenCount = MAX_PIPE_RECURSION; // Limit to the max no of pipes to be open recursively.
+
+ fnTempPipeFile(ptpf);
+ ret = fnPipeFileOpen((PTEMPPIPEFILE) ptpf, (char *) command, (char *) mode);
+ if (ret)
+ File1[iPopenCount-1] = ret; // Store the obtained Pipe file handle.
+ else
+ { // Pipe file not obtained. So free the allocated memory.
+ if(ptpf1[iPopenCount-1])
+ {
+ free(ptpf1[iPopenCount-1]);
+ ptpf1[iPopenCount-1] = NULL;
+ ptpf = NULL;
+ iPopenCount --;
+ }
+ }
+
+ if (errno)
+ e = &errno;
+
+ return ret;
}
int nw_Pclose(FILE* file, int* e)
{
- int i=0, j=0;
+ int i=0, j=0;
- errno = 0;
+ errno = 0;
- if(file)
- {
- if(iPopenCount > 0)
- {
- for (i=0; i<iPopenCount; i++)
- {
- if(File1[i] == file)
- {
- // Delete the memory allocated corresponding to the file handle passed-in and
- // also close the file corresponding to the file handle passed-in!
- if(ptpf1[i])
- {
- fnPipeFileClose(ptpf1[i]);
+ if(file)
+ {
+ if(iPopenCount > 0)
+ {
+ for (i=0; i<iPopenCount; i++)
+ {
+ if(File1[i] == file)
+ {
+ // Delete the memory allocated corresponding to the file handle passed-in and
+ // also close the file corresponding to the file handle passed-in!
+ if(ptpf1[i])
+ {
+ fnPipeFileClose(ptpf1[i]);
- free(ptpf1[i]);
- ptpf1[i] = NULL;
- }
+ free(ptpf1[i]);
+ ptpf1[i] = NULL;
+ }
- fclose(File1[i]);
- File1[i] = NULL;
+ fclose(File1[i]);
+ File1[i] = NULL;
- break;
- }
- }
+ break;
+ }
+ }
- // Rearrange the file pointer array
- for(j=i; j<(iPopenCount-1); j++)
- {
- File1[j] = File1[j+1];
- ptpf1[j] = ptpf1[j+1];
- }
- iPopenCount--;
- }
- }
- else
- return -1;
+ // Rearrange the file pointer array
+ for(j=i; j<(iPopenCount-1); j++)
+ {
+ File1[j] = File1[j+1];
+ ptpf1[j] = ptpf1[j+1];
+ }
+ iPopenCount--;
+ }
+ }
+ else
+ return -1;
- if (errno)
- e = &errno;
+ if (errno)
+ e = &errno;
- return 0;
+ return 0;
}
@@ -740,8 +740,8 @@ nw_vprintf(const char *format, va_list args)
int
nw_printf(const char *format, ...)
{
-
- va_list marker;
+
+ va_list marker;
va_start(marker, format); /* Initialize variable arguments. */
return (vprintf(format, marker));
@@ -750,45 +750,45 @@ nw_printf(const char *format, ...)
int
nw_read(int fd, void *buf, unsigned int cnt)
{
- return read(fd, buf, cnt);
+ return read(fd, buf, cnt);
}
struct direct *
nw_readdir(DIR *dirp)
{
- DIR* ret=NULL;
+ DIR* ret=NULL;
- ret = readdir(dirp);
- if(ret)
- return((struct direct *)ret);
- return NULL;
+ ret = readdir(dirp);
+ if(ret)
+ return((struct direct *)ret);
+ return NULL;
}
int
nw_rename(const char *oname, const char *newname)
{
- return(rename(oname,newname));
+ return(rename(oname,newname));
}
void
nw_rewinddir(DIR *dirp)
{
- dTHX;
- Perl_croak(aTHX_ "The rewinddir() function is not implemented on NetWare\n");
+ dTHX;
+ Perl_croak(aTHX_ "The rewinddir() function is not implemented on NetWare\n");
}
void
nw_rewind(FILE *pf)
{
- if(pf)
- rewind(pf);
+ if(pf)
+ rewind(pf);
}
void
nw_seekdir(DIR *dirp, long loc)
{
- dTHX;
- Perl_croak(aTHX_ "The seekdir() function is not implemented on NetWare\n");
+ dTHX;
+ Perl_croak(aTHX_ "The seekdir() function is not implemented on NetWare\n");
}
int *
@@ -800,31 +800,31 @@ nw_errno(void)
char ***
nw_environ(void)
{
- return ((char ***)nw_getenviron());
+ return ((char ***)nw_getenviron());
}
char *
nw_strerror(int e)
{
- return (strerror(e));
+ return (strerror(e));
}
int
nw_isatty(int fd)
{
- return(isatty(fd));
+ return(isatty(fd));
}
char *
nw_mktemp(char *Template)
{
- return (fnMy_MkTemp(Template));
+ return (fnMy_MkTemp(Template));
}
int
nw_chsize(int handle, long size)
{
- return(chsize(handle,size));
+ return(chsize(handle,size));
}
#ifdef HAVE_INTERP_INTERN
@@ -863,7 +863,7 @@ Perl_nw5_init(int *argcp, char ***argvp)
PerlInterpreter *
perl_clone_host(PerlInterpreter* proto_perl, UV flags)
{
- // Perl Clone is not implemented on NetWare.
+ // Perl Clone is not implemented on NetWare.
return NULL;
}
#endif
@@ -873,33 +873,33 @@ perl_clone_host(PerlInterpreter* proto_perl, UV flags)
int
execv(char *cmdname, char **argv)
{
- // This feature needs to be implemented.
- // _asm is commented out since it goes into the internal debugger.
+ // This feature needs to be implemented.
+ // _asm is commented out since it goes into the internal debugger.
// _asm {int 3};
- return(0);
+ return(0);
}
int
execvp(char *cmdname, char **argv)
{
- // This feature needs to be implemented.
- // _asm is commented out since it goes into the internal debugger.
+ // This feature needs to be implemented.
+ // _asm is commented out since it goes into the internal debugger.
// _asm {int 3};
- return(0);
+ return(0);
}
int
do_aspawn(void *vreally, void **vmark, void **vsp)
{
- // This feature needs to be implemented.
- // _asm is commented out since it goes into the internal debugger.
+ // This feature needs to be implemented.
+ // _asm is commented out since it goes into the internal debugger.
// _asm {int 3};
//// return(0);
- // This below code is required for system() call.
- // Otherwise system() does not work on NetWare.
- // Ananth, 3 Sept 2001
+ // This below code is required for system() call.
+ // Otherwise system() does not work on NetWare.
+ // Ananth, 3 Sept 2001
dTHX;
SV *really = (SV*)vreally;
@@ -913,47 +913,47 @@ do_aspawn(void *vreally, void **vmark, void **vsp)
if (sp <= mark)
- return -1;
+ return -1;
- nw_perlshell_items = 0; // No Shell
+ nw_perlshell_items = 0; // No Shell
// Newx(argv, (sp - mark) + nw_perlshell_items + 3, char*); // In the old code of 5.6.1
Newx(argv, (sp - mark) + nw_perlshell_items + 2, char*);
if (SvNIOKp(*(mark+1)) && !SvPOKp(*(mark+1))) {
- ++mark;
- flag = SvIVx(*mark);
+ ++mark;
+ flag = SvIVx(*mark);
}
while (++mark <= sp) {
- if (*mark && (str = (char *)SvPV_nolen(*mark)))
- {
- argv[index] = str;
- index++;
- }
- else
- {
- argv[index] = "";
+ if (*mark && (str = (char *)SvPV_nolen(*mark)))
+ {
+ argv[index] = str;
+ index++;
+ }
+ else
+ {
+ argv[index] = "";
// argv[index] = '\0';
- index++;
+ index++;
}
- }
+ }
argv[index] = '\0';
- index++;
+ index++;
status = nw_spawnvp(flag,
- (char*)(really ? SvPV_nolen(really) : argv[0]),
- (char**)argv);
+ (char*)(really ? SvPV_nolen(really) : argv[0]),
+ (char**)argv);
if (flag != P_NOWAIT) {
- if (status < 0) {
+ if (status < 0) {
// dTHR; // Only in old code of 5.6.1
- if (ckWARN(WARN_EXEC))
- Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't spawn \"%s\": %s", argv[0], strerror(errno));
- status = 255 * 256;
- }
- else
- status *= 256;
- PL_statusvalue = status;
+ if (ckWARN(WARN_EXEC))
+ Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't spawn \"%s\": %s", argv[0], strerror(errno));
+ status = 255 * 256;
+ }
+ else
+ status *= 256;
+ PL_statusvalue = status;
}
Safefree(argv);
@@ -963,12 +963,12 @@ do_aspawn(void *vreally, void **vmark, void **vsp)
int
do_spawn2(char *cmd, int exectype)
{
- // This feature needs to be implemented.
- // _asm is commented out since it goes into the internal debugger.
+ // This feature needs to be implemented.
+ // _asm is commented out since it goes into the internal debugger.
// _asm {int 3};
//// return(0);
- // Below added to make system() work for NetWare
+ // Below added to make system() work for NetWare
dTHX;
char **a;
@@ -981,80 +981,80 @@ do_spawn2(char *cmd, int exectype)
/* Save an extra exec if possible. See if there are shell
* metacharacters in it */
if (!has_shell_metachars(cmd)) {
- Newx(argv, strlen(cmd) / 2 + 2, char*);
- Newx(cmd2, strlen(cmd) + 1, char);
- strcpy(cmd2, cmd);
- a = argv;
- for (s = cmd2; *s;) {
- while (*s && isSPACE(*s))
- s++;
- if (*s)
- *(a++) = s;
- while (*s && !isSPACE(*s))
- s++;
- if (*s)
- *s++ = '\0';
- }
- *a = NULL;
- if (argv[0]) {
- switch (exectype) {
- case EXECF_SPAWN:
- status = nw_spawnvp(P_WAIT, argv[0], (char **)argv);
- break;
-
- case EXECF_SPAWN_NOWAIT:
- status = nw_spawnvp(P_NOWAIT, argv[0], (char **)argv);
- break;
-
- case EXECF_EXEC:
- status = nw_execvp(argv[0], (char **)argv);
- break;
- }
- if (status != -1 || errno == 0)
- needToTry = FALSE;
- }
- Safefree(argv);
- Safefree(cmd2);
+ Newx(argv, strlen(cmd) / 2 + 2, char*);
+ Newx(cmd2, strlen(cmd) + 1, char);
+ strcpy(cmd2, cmd);
+ a = argv;
+ for (s = cmd2; *s;) {
+ while (*s && isSPACE(*s))
+ s++;
+ if (*s)
+ *(a++) = s;
+ while (*s && !isSPACE(*s))
+ s++;
+ if (*s)
+ *s++ = '\0';
+ }
+ *a = NULL;
+ if (argv[0]) {
+ switch (exectype) {
+ case EXECF_SPAWN:
+ status = nw_spawnvp(P_WAIT, argv[0], (char **)argv);
+ break;
+
+ case EXECF_SPAWN_NOWAIT:
+ status = nw_spawnvp(P_NOWAIT, argv[0], (char **)argv);
+ break;
+
+ case EXECF_EXEC:
+ status = nw_execvp(argv[0], (char **)argv);
+ break;
+ }
+ if (status != -1 || errno == 0)
+ needToTry = FALSE;
+ }
+ Safefree(argv);
+ Safefree(cmd2);
}
if (needToTry) {
- char **argv = NULL;
- int i = -1;
-
- Newx(argv, nw_perlshell_items + 2, char*);
- while (++i < nw_perlshell_items)
- argv[i] = nw_perlshell_vec[i];
- argv[i++] = cmd;
- argv[i] = NULL;
- switch (exectype) {
- case EXECF_SPAWN:
- status = nw_spawnvp(P_WAIT, argv[0], (char **)argv);
- break;
-
- case EXECF_SPAWN_NOWAIT:
- status = nw_spawnvp(P_NOWAIT, argv[0], (char **)argv);
- break;
-
- case EXECF_EXEC:
- status = nw_execvp(argv[0], (char **)argv);
- break;
- }
- cmd = argv[0];
- Safefree(argv);
+ char **argv = NULL;
+ int i = -1;
+
+ Newx(argv, nw_perlshell_items + 2, char*);
+ while (++i < nw_perlshell_items)
+ argv[i] = nw_perlshell_vec[i];
+ argv[i++] = cmd;
+ argv[i] = NULL;
+ switch (exectype) {
+ case EXECF_SPAWN:
+ status = nw_spawnvp(P_WAIT, argv[0], (char **)argv);
+ break;
+
+ case EXECF_SPAWN_NOWAIT:
+ status = nw_spawnvp(P_NOWAIT, argv[0], (char **)argv);
+ break;
+
+ case EXECF_EXEC:
+ status = nw_execvp(argv[0], (char **)argv);
+ break;
+ }
+ cmd = argv[0];
+ Safefree(argv);
}
if (exectype != EXECF_SPAWN_NOWAIT) {
- if (status < 0) {
- dTHR;
- if (ckWARN(WARN_EXEC))
- Perl_warner(aTHX_ WARN_EXEC, "Can't %s \"%s\": %s",
- (exectype == EXECF_EXEC ? "exec" : "spawn"),
- cmd, strerror(errno));
- status = 255 * 256;
- }
- else
- status *= 256;
- PL_statusvalue = status;
+ if (status < 0) {
+ dTHR;
+ if (ckWARN(WARN_EXEC))
+ Perl_warner(aTHX_ WARN_EXEC, "Can't %s \"%s\": %s",
+ (exectype == EXECF_EXEC ? "exec" : "spawn"),
+ cmd, strerror(errno));
+ status = 255 * 256;
+ }
+ else
+ status *= 256;
+ PL_statusvalue = status;
}
return (status);
}
@@ -1078,31 +1078,31 @@ has_shell_metachars(char *ptr)
* Shell variable interpolation (%VAR%) can also happen inside strings.
*/
while (*ptr) {
- switch(*ptr) {
- case '%':
- return TRUE;
- case '\'':
- case '\"':
- if (inquote) {
- if (quote == *ptr) {
- inquote = 0;
- quote = '\0';
- }
- }
- else {
- quote = *ptr;
- inquote++;
- }
- break;
- case '>':
- case '<':
- case '|':
- if (!inquote)
- return TRUE;
- default:
- break;
- }
- ++ptr;
+ switch(*ptr) {
+ case '%':
+ return TRUE;
+ case '\'':
+ case '\"':
+ if (inquote) {
+ if (quote == *ptr) {
+ inquote = 0;
+ quote = '\0';
+ }
+ }
+ else {
+ quote = *ptr;
+ inquote++;
+ }
+ break;
+ case '>':
+ case '<':
+ case '|':
+ if (!inquote)
+ return TRUE;
+ default:
+ break;
+ }
+ ++ptr;
}
return FALSE;
}
@@ -1110,7 +1110,7 @@ has_shell_metachars(char *ptr)
int
fork(void)
{
- return 0;
+ return 0;
}
@@ -1118,5 +1118,5 @@ fork(void)
int
Perl_Ireentrant_buffer_ptr(aTHX)
{
- return 0;
+ return 0;
}
diff --git a/NetWare/nw5sck.c b/NetWare/nw5sck.c
index 35dee92bf1..217313e223 100644
--- a/NetWare/nw5sck.c
+++ b/NetWare/nw5sck.c
@@ -57,50 +57,50 @@ nw_ntohs(u_short netshort)
SOCKET
nw_accept(SOCKET s, struct sockaddr *addr, int *addrlen)
{
- return ((SOCKET)(accept(s, addr, addrlen)));
+ return ((SOCKET)(accept(s, addr, addrlen)));
}
int
nw_bind(SOCKET s, const struct sockaddr *addr, int addrlen)
{
- return ((int)bind(s, (struct sockaddr *)addr, addrlen));
+ return ((int)bind(s, (struct sockaddr *)addr, addrlen));
}
int
nw_connect(SOCKET s, const struct sockaddr *addr, int addrlen)
{
- return((int)connect(s, (struct sockaddr *)addr, addrlen));
+ return((int)connect(s, (struct sockaddr *)addr, addrlen));
}
void
nw_endhostent()
{
- endhostent();
+ endhostent();
}
void
nw_endnetent()
{
- endnetent();
+ endnetent();
}
void
nw_endprotoent()
{
- endprotoent();
+ endprotoent();
}
void
nw_endservent()
{
- endservent();
+ endservent();
}
struct hostent *
nw_gethostent()
{
- return(gethostent());
+ return(gethostent());
}
struct netent *
@@ -118,7 +118,7 @@ nw_getprotoent(void)
struct hostent *
nw_gethostbyname(const char *name)
{
- return(gethostbyname((char*)name));
+ return(gethostbyname((char*)name));
}
int
@@ -130,13 +130,13 @@ nw_gethostname(char *name, int len)
struct hostent *
nw_gethostbyaddr(const char *addr, int len, int type)
{
- return(gethostbyaddr((char*)addr, len, type));
+ return(gethostbyaddr((char*)addr, len, type));
}
struct netent *
nw_getnetbyaddr(long net, int type)
{
- return(getnetbyaddr(net,type));
+ return(getnetbyaddr(net,type));
}
struct netent *
@@ -148,19 +148,19 @@ nw_getnetbyname(char *name)
int
nw_getpeername(SOCKET s, struct sockaddr *addr, int *addrlen)
{
- return((int)getpeername(s, addr, addrlen));
+ return((int)getpeername(s, addr, addrlen));
}
struct protoent *
nw_getprotobyname(const char *name)
{
- return ((struct protoent *)getprotobyname((char*)name));
+ return ((struct protoent *)getprotobyname((char*)name));
}
struct protoent *
nw_getprotobynumber(int num)
{
- return ((struct protoent *)getprotobynumber(num));
+ return ((struct protoent *)getprotobynumber(num));
}
struct servent *
@@ -186,7 +186,7 @@ void
nw_sethostent(int stayopen)
{
#ifdef HAS_SETHOSTENT
- sethostent(stayopen);
+ sethostent(stayopen);
#endif
}
@@ -194,7 +194,7 @@ void
nw_setnetent(int stayopen)
{
#ifdef HAS_SETNETENT
- setnetent(stayopen);
+ setnetent(stayopen);
#endif
}
@@ -202,7 +202,7 @@ void
nw_setprotoent(int stayopen)
{
#ifdef HAS_SETPROTENT
- setprotoent(stayopen);
+ setprotoent(stayopen);
#endif
}
@@ -210,26 +210,26 @@ void
nw_setservent(int stayopen)
{
#ifdef HAS_SETSERVENT
- setservent(stayopen);
+ setservent(stayopen);
#endif
}
int
nw_setsockopt(SOCKET s, int level, int optname, const char* optval, int optlen)
{
- return setsockopt(s, level, optname, (char*)optval, optlen);
+ return setsockopt(s, level, optname, (char*)optval, optlen);
}
int
nw_getsockname(SOCKET s, struct sockaddr *addr, int *addrlen)
{
- return getsockname(s, addr, addrlen);
+ return getsockname(s, addr, addrlen);
}
int
nw_getsockopt(SOCKET s, int level, int optname, char *optval, int *optlen)
{
- return ((int)getsockopt(s, level, optname, optval, optlen));
+ return ((int)getsockopt(s, level, optname, optval, optlen));
}
unsigned long
@@ -253,9 +253,9 @@ nw_socket(int af, int type, int protocol)
s = socket(af, type, protocol);
#else
if((s = socket(af, type, protocol)) == INVALID_SOCKET)
- //errno = WSAGetLastError();
+ //errno = WSAGetLastError();
else
- s = s;
+ s = s;
#endif /* USE_SOCKETS_AS_HANDLES */
return s;
@@ -270,18 +270,18 @@ nw_listen(SOCKET s, int backlog)
int
nw_send(SOCKET s, const char *buf, int len, int flags)
{
- return(send(s,(char*)buf,len,flags));
+ return(send(s,(char*)buf,len,flags));
}
int
nw_recv(SOCKET s, char *buf, int len, int flags)
{
- return (recv(s, buf, len, flags));
+ return (recv(s, buf, len, flags));
}
int
nw_sendto(SOCKET s, const char *buf, int len, int flags,
- const struct sockaddr *to, int tolen)
+ const struct sockaddr *to, int tolen)
{
return(sendto(s, (char*)buf, len, flags, (struct sockaddr *)to, tolen));
}
@@ -293,16 +293,16 @@ nw_recvfrom(SOCKET s, char *buf, int len, int flags, struct sockaddr *from, int
int frombufsize = *fromlen;
r = recvfrom(s, buf, len, flags, from, fromlen);
- //Not sure if the is required - chksgp
+ //Not sure if the is required - chksgp
if (r && frombufsize == *fromlen)
- (void)nw_getpeername(s, from, fromlen);
+ (void)nw_getpeername(s, from, fromlen);
return r;
}
int
nw_select(int nfds, fd_set* rd, fd_set* wr, fd_set* ex, const struct timeval* timeout)
{
- return(select(nfds, rd, wr, ex, (struct timeval*)timeout));
+ return(select(nfds, rd, wr, ex, (struct timeval*)timeout));
}
int
diff --git a/NetWare/nw5thread.c b/NetWare/nw5thread.c
index abedb5c2da..3b9d8304de 100644
--- a/NetWare/nw5thread.c
+++ b/NetWare/nw5thread.c
@@ -36,7 +36,7 @@ Perl_set_context(void *t)
# ifdef USE_DECLSPEC_THREAD
Perl_current_context = t;
# else
- fnAddThreadCtx(PL_thr_key, t);
+ fnAddThreadCtx(PL_thr_key, t);
# endif
#endif
}
@@ -49,7 +49,7 @@ Perl_get_context(void)
# ifdef USE_DECLSPEC_THREAD
return Perl_current_context;
# else
- return(fnGetThreadCtx(PL_thr_key));
+ return(fnGetThreadCtx(PL_thr_key));
# endif
#else
return NULL;
@@ -63,12 +63,12 @@ Remove_Thread_Ctx(void)
{
#if defined(USE_ITHREADS)
# ifdef USE_DECLSPEC_THREAD
- return TRUE;
+ return TRUE;
# else
- return(fnRemoveThreadCtx(PL_thr_key));
+ return(fnRemoveThreadCtx(PL_thr_key));
# endif
# else
- return TRUE;
+ return TRUE;
#endif
}
diff --git a/NetWare/nw5thread.h b/NetWare/nw5thread.h
index e7d86757ee..40cbdc3aac 100644
--- a/NetWare/nw5thread.h
+++ b/NetWare/nw5thread.h
@@ -37,10 +37,10 @@ typedef struct nw_cond { long waiters; unsigned int sem; } perl_cond;
extern "C"
{
#endif
- #include <mpktypes.h>
- #include <mpkapis.h>
- #define kSUCCESS (0)
- #define ERROR_INVALID_MUTEX (0x1010)
+ #include <mpktypes.h>
+ #include <mpkapis.h>
+ #define kSUCCESS (0)
+ #define ERROR_INVALID_MUTEX (0x1010)
#ifdef __cplusplus
}
@@ -55,34 +55,34 @@ extern "C"
typedef MUTEX perl_mutex;
# define MUTEX_INIT(m) \
STMT_START { \
- /*if ((*(m) = kMutexAlloc("NetWarePerlMutex")) == NULL) */\
- /*Perl_croak_nocontext("panic: MUTEX_ALLOC"); */\
- /*ConsolePrintf("Mutex Init %d\n",*(m)); */\
+ /*if ((*(m) = kMutexAlloc("NetWarePerlMutex")) == NULL) */\
+ /*Perl_croak_nocontext("panic: MUTEX_ALLOC"); */\
+ /*ConsolePrintf("Mutex Init %d\n",*(m)); */\
} STMT_END
# define MUTEX_LOCK(m) \
STMT_START { \
- /*ConsolePrintf("Mutex lock %d\n",*(m)); */\
- /*if (kMutexLock(*(m)) == ERROR_INVALID_MUTEX) */\
- /*Perl_croak_nocontext("panic: MUTEX_LOCK"); */\
+ /*ConsolePrintf("Mutex lock %d\n",*(m)); */\
+ /*if (kMutexLock(*(m)) == ERROR_INVALID_MUTEX) */\
+ /*Perl_croak_nocontext("panic: MUTEX_LOCK"); */\
} STMT_END
# define MUTEX_UNLOCK(m) \
STMT_START { \
- /*ConsolePrintf("Mutex unlock %d\n",*(m)); */\
- /*if (kMutexUnlock(*(m)) != kSUCCESS) \
- Perl_croak_nocontext("panic: MUTEX_UNLOCK"); */\
+ /*ConsolePrintf("Mutex unlock %d\n",*(m)); */\
+ /*if (kMutexUnlock(*(m)) != kSUCCESS) \
+ Perl_croak_nocontext("panic: MUTEX_UNLOCK"); */\
} STMT_END
# define MUTEX_DESTROY(m) \
STMT_START { \
- /*ConsolePrintf("Mutex Destroy %d\n",*(m)); */\
- /*if (kMutexWaitCount(*(m)) == 0 ) */\
- /*{ */\
- /*PERL_SET_INTERP(NULL); *//*newly added CHKSGP???*/ \
- /*if (kMutexFree(*(m)) != kSUCCESS) */ \
- /*Perl_croak_nocontext("panic: MUTEX_FREE"); */\
- /*} */\
+ /*ConsolePrintf("Mutex Destroy %d\n",*(m)); */\
+ /*if (kMutexWaitCount(*(m)) == 0 ) */\
+ /*{ */\
+ /*PERL_SET_INTERP(NULL); *//*newly added CHKSGP???*/ \
+ /*if (kMutexFree(*(m)) != kSUCCESS) */ \
+ /*Perl_croak_nocontext("panic: MUTEX_FREE"); */\
+ /*} */\
} STMT_END
#else
@@ -100,56 +100,56 @@ typedef unsigned long perl_mutex;
//For now let us just see when this happens -sgp.
#define COND_INIT(c) \
STMT_START { \
- /*ConsolePrintf("In COND_INIT\n"); */\
+ /*ConsolePrintf("In COND_INIT\n"); */\
} STMT_END
/* (c)->waiters = 0; \
- (c)->sem = OpenLocalSemaphore (0); \
- if ((c)->sem == NULL) \
- Perl_croak_nocontext("panic: COND_INIT (%ld)",errno); \*/
+ (c)->sem = OpenLocalSemaphore (0); \
+ if ((c)->sem == NULL) \
+ Perl_croak_nocontext("panic: COND_INIT (%ld)",errno); \*/
#define COND_SIGNAL(c) \
STMT_START { \
- /*ConsolePrintf("In COND_SIGNAL\n"); */\
+ /*ConsolePrintf("In COND_SIGNAL\n"); */\
} STMT_END
/*if ((c)->waiters > 0 && \
- SignalLocalSemaphore((c)->sem) != 0) \
- Perl_croak_nocontext("panic: COND_SIGNAL (%ld)",errno); \*/
+ SignalLocalSemaphore((c)->sem) != 0) \
+ Perl_croak_nocontext("panic: COND_SIGNAL (%ld)",errno); \*/
#define COND_BROADCAST(c) \
STMT_START { \
- /*ConsolePrintf("In COND_BROADCAST\n"); */\
+ /*ConsolePrintf("In COND_BROADCAST\n"); */\
} STMT_END
- /*if ((c)->waiters > 0 ) { \
- int count; \
- for(count=0; count<(c)->waiters; count++) { \
- if(SignalLocalSemaphore((c)->sem) != 0) \
- Perl_croak_nocontext("panic: COND_BROADCAST (%ld)",GetLastError());\
- } \
- } \*/
+ /*if ((c)->waiters > 0 ) { \
+ int count; \
+ for(count=0; count<(c)->waiters; count++) { \
+ if(SignalLocalSemaphore((c)->sem) != 0) \
+ Perl_croak_nocontext("panic: COND_BROADCAST (%ld)",GetLastError());\
+ } \
+ } \*/
#define COND_WAIT(c, m) \
STMT_START { \
- /*ConsolePrintf("In COND_WAIT\n"); */\
+ /*ConsolePrintf("In COND_WAIT\n"); */\
} STMT_END
#define COND_DESTROY(c) \
STMT_START { \
- /*ConsolePrintf("In COND_DESTROY\n"); */\
+ /*ConsolePrintf("In COND_DESTROY\n"); */\
} STMT_END
/* (c)->waiters = 0; \
- if (CloseLocalSemaphore((c)->sem) != 0) \
- Perl_croak_nocontext("panic: COND_DESTROY (%ld)",errno); \*/
+ if (CloseLocalSemaphore((c)->sem) != 0) \
+ Perl_croak_nocontext("panic: COND_DESTROY (%ld)",errno); \*/
#if 0
#define DETACH(t) \
STMT_START { \
- if (CloseHandle((t)->self) == 0) { \
- MUTEX_UNLOCK(&(t)->mutex); \
- Perl_croak_nocontext("panic: DETACH"); \
- } \
+ if (CloseHandle((t)->self) == 0) { \
+ MUTEX_UNLOCK(&(t)->mutex); \
+ Perl_croak_nocontext("panic: DETACH"); \
+ } \
} STMT_END
#endif //#if 0
@@ -172,7 +172,7 @@ extern __declspec(thread) void *PL_current_context;
//See the comment at the end of file nw5thread.c as to why PL_thr_key is not assigned - sgp
#define ALLOC_THREAD_KEY \
STMT_START { \
- fnInitializeThreadCtx(); \
+ fnInitializeThreadCtx(); \
} STMT_END
diff --git a/NetWare/nwhashcls.h b/NetWare/nwhashcls.h
index 55ff200220..ba18053ee2 100644
--- a/NetWare/nwhashcls.h
+++ b/NetWare/nwhashcls.h
@@ -22,8 +22,8 @@
struct HASHNODE
{
- void *data;
- struct HASHNODE *next;
+ void *data;
+ struct HASHNODE *next;
};
typedef void (*HASHFORALLFUN)(void *, void *);
@@ -31,22 +31,22 @@ typedef void (*HASHFORALLFUN)(void *, void *);
class NWPerlHashList
{
private:
- HASHNODE* MemListHash[BUCKET_SIZE];
+ HASHNODE* MemListHash[BUCKET_SIZE];
void removeAll() const;
public:
- ~NWPerlHashList();
- NWPerlHashList();
- int insert(void *lData);
- int remove(void *lData);
+ ~NWPerlHashList();
+ NWPerlHashList();
+ int insert(void *lData);
+ int remove(void *lData);
void forAll( void (*)(void *, void*), void * ) const;
};
struct KEYHASHNODE
{
- void *key;
- void *data;
- KEYHASHNODE *next;
+ void *key;
+ void *data;
+ KEYHASHNODE *next;
};
/**
@@ -55,16 +55,16 @@ typedef void (*KEYHASHFORALLFUN)(void *, void *);
class NWPerlKeyHashList
{
private:
- KEYHASHNODE* MemListHash[BUCKET_SIZE];
+ KEYHASHNODE* MemListHash[BUCKET_SIZE];
void removeAll() const;
public:
- ~NWPerlKeyHashList();
- NWPerlKeyHashList();
- int insert(void *key, void *lData);
- int remove(void *key);
+ ~NWPerlKeyHashList();
+ NWPerlKeyHashList();
+ int insert(void *key, void *lData);
+ int remove(void *key);
void forAll( void (*)(void *, void*), void * ) const;
- int find(void *key, void **pData);
+ int find(void *key, void **pData);
};
**/
diff --git a/NetWare/nwperlhost.h b/NetWare/nwperlhost.h
index c69e554489..e011bd351f 100644
--- a/NetWare/nwperlhost.h
+++ b/NetWare/nwperlhost.h
@@ -52,10 +52,10 @@ class CPerlHost
public:
CPerlHost(void);
CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
- struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
- struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
- struct IPerlDir** ppDir, struct IPerlSock** ppSock,
- struct IPerlProc** ppProc);
+ struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
+ struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
+ struct IPerlDir** ppDir, struct IPerlSock** ppSock,
+ struct IPerlProc** ppProc);
CPerlHost(const CPerlHost& host);
virtual ~CPerlHost(void);
@@ -73,21 +73,21 @@ public:
inline void* Malloc(size_t size) { return m_pVMem->Malloc(size); };
inline void* Realloc(void* ptr, size_t size) { return m_pVMem->Realloc(ptr, size); };
inline void Free(void* ptr) { m_pVMem->Free(ptr); };
- inline void* Calloc(size_t num, size_t size){ return m_pVMem->Calloc(num, size); };
+ inline void* Calloc(size_t num, size_t size){ return m_pVMem->Calloc(num, size); };
/* IPerlMemShared */
inline void* MallocShared(size_t size)
{
- return m_pVMemShared->Malloc(size);
+ return m_pVMemShared->Malloc(size);
};
inline void* ReallocShared(void* ptr, size_t size) { return m_pVMemShared->Realloc(ptr, size); };
inline void FreeShared(void* ptr) { m_pVMemShared->Free(ptr); };
inline void* CallocShared(size_t num, size_t size)
{
- size_t count = num*size;
- void* lpVoid = MallocShared(count);
+ size_t count = num*size;
+ void* lpVoid = MallocShared(count);
- return lpVoid;
+ return lpVoid;
};
/* IPerlMemParse */
@@ -96,10 +96,10 @@ public:
inline void FreeParse(void* ptr) { m_pVMemParse->Free(ptr); };
inline void* CallocParse(size_t num, size_t size)
{
- size_t count = num*size;
- void* lpVoid = MallocParse(count);
+ size_t count = num*size;
+ void* lpVoid = MallocParse(count);
- return lpVoid;
+ return lpVoid;
};
/* IPerlEnv */
@@ -107,11 +107,11 @@ public:
int Putenv(const char *envstring);
inline char *Getenv(const char *varname, unsigned long *len)
{
- *len = 0;
- char *e = Getenv(varname);
- if (e)
- *len = strlen(e);
- return e;
+ *len = 0;
+ char *e = Getenv(varname);
+ if (e)
+ *len = strlen(e);
+ return e;
}
@@ -341,33 +341,33 @@ PerlEnvUname(struct IPerlEnv* piPerl, struct utsname *name)
void
PerlEnvClearenv(struct IPerlEnv* piPerl)
{
- // If removed, compilation fails while compiling CGI2Perl.
+ // If removed, compilation fails while compiling CGI2Perl.
}
void*
PerlEnvGetChildenv(struct IPerlEnv* piPerl)
{
- // If removed, compilation fails while compiling CGI2Perl.
- return NULL;
+ // If removed, compilation fails while compiling CGI2Perl.
+ return NULL;
}
void
PerlEnvFreeChildenv(struct IPerlEnv* piPerl, void* childEnv)
{
- // If removed, compilation fails while compiling CGI2Perl.
+ // If removed, compilation fails while compiling CGI2Perl.
}
char*
PerlEnvGetChilddir(struct IPerlEnv* piPerl)
{
- // If removed, compilation fails while compiling CGI2Perl.
- return NULL;
+ // If removed, compilation fails while compiling CGI2Perl.
+ return NULL;
}
void
PerlEnvFreeChilddir(struct IPerlEnv* piPerl, char* childDir)
{
- // If removed, compilation fails while compiling CGI2Perl.
+ // If removed, compilation fails while compiling CGI2Perl.
}
struct IPerlEnv perlEnv =
@@ -636,7 +636,7 @@ PerlStdIOSetpos(struct IPerlStdIO* piPerl, PerlIO* pf, const Fpos_t *p)
void
PerlStdIOInit(struct IPerlStdIO* piPerl)
{
- // If removed, compilation error occurs.
+ // If removed, compilation error occurs.
}
void
@@ -668,17 +668,17 @@ PerlStdIOFdupopen(struct IPerlStdIO* piPerl, PerlIO* pf)
/* open the file in the same mode */
if(((FILE*)pf)->_flag & _IOREAD) {
- mode[0] = 'r';
- mode[1] = 0;
+ mode[0] = 'r';
+ mode[1] = 0;
}
else if(((FILE*)pf)->_flag & _IOWRT) {
- mode[0] = 'a';
- mode[1] = 0;
+ mode[0] = 'a';
+ mode[1] = 0;
}
else if(((FILE*)pf)->_flag & _IORW) {
- mode[0] = 'r';
- mode[1] = '+';
- mode[2] = 0;
+ mode[0] = 'r';
+ mode[1] = '+';
+ mode[2] = 0;
}
/* it appears that the binmode is attached to the
@@ -689,7 +689,7 @@ PerlStdIOFdupopen(struct IPerlStdIO* piPerl, PerlIO* pf)
/* move the file pointer to the same position */
if (!fgetpos((FILE*)pf, &pos)) {
- fsetpos((FILE*)pfdup, &pos);
+ fsetpos((FILE*)pfdup, &pos);
}
return pfdup;
}
@@ -757,14 +757,14 @@ PerlLIOChmod(struct IPerlLIO* piPerl, const char *filename, int pmode)
int
PerlLIOChown(struct IPerlLIO* piPerl, const char *filename, uid_t owner, gid_t group)
{
- // If removed, compilation error occurs.
- return 0;
+ // If removed, compilation error occurs.
+ return 0;
}
int
PerlLIOChsize(struct IPerlLIO* piPerl, int handle, long size)
{
- return (nw_chsize(handle,size));
+ return (nw_chsize(handle,size));
}
int
@@ -788,7 +788,7 @@ PerlLIODup2(struct IPerlLIO* piPerl, int handle1, int handle2)
int
PerlLIOFlock(struct IPerlLIO* piPerl, int fd, int oper)
{
- //On NetWare simulate flock by locking a range on the file
+ //On NetWare simulate flock by locking a range on the file
return nw_flock(fd, oper);
}
@@ -801,8 +801,8 @@ PerlLIOFileStat(struct IPerlLIO* piPerl, int handle, struct stat *buffer)
int
PerlLIOIOCtl(struct IPerlLIO* piPerl, int i, unsigned int u, char *data)
{
- // If removed, compilation error occurs.
- return 0;
+ // If removed, compilation error occurs.
+ return 0;
}
int
@@ -832,7 +832,7 @@ PerlLIOLstat(struct IPerlLIO* piPerl, const char *path, struct stat *buffer)
char*
PerlLIOMktemp(struct IPerlLIO* piPerl, char *Template)
{
- return(nw_mktemp(Template));
+ return(nw_mktemp(Template));
}
int
@@ -939,37 +939,37 @@ struct IPerlLIO perlLIO =
int
PerlDirMakedir(struct IPerlDir* piPerl, const char *dirname, int mode)
{
- return mkdir(dirname);
+ return mkdir(dirname);
}
int
PerlDirChdir(struct IPerlDir* piPerl, const char *dirname)
{
- return nw_chdir(dirname);
+ return nw_chdir(dirname);
}
int
PerlDirRmdir(struct IPerlDir* piPerl, const char *dirname)
{
- return nw_rmdir(dirname);
+ return nw_rmdir(dirname);
}
int
PerlDirClose(struct IPerlDir* piPerl, DIR *dirp)
{
- return nw_closedir(dirp);
+ return nw_closedir(dirp);
}
DIR*
PerlDirOpen(struct IPerlDir* piPerl, const char *filename)
{
- return nw_opendir(filename);
+ return nw_opendir(filename);
}
struct direct *
PerlDirRead(struct IPerlDir* piPerl, DIR *dirp)
{
- return nw_readdir(dirp);
+ return nw_readdir(dirp);
}
void
@@ -1008,42 +1008,42 @@ struct IPerlDir perlDir =
u_long
PerlSockHtonl(struct IPerlSock* piPerl, u_long hostlong)
{
- return(nw_htonl(hostlong));
+ return(nw_htonl(hostlong));
}
u_short
PerlSockHtons(struct IPerlSock* piPerl, u_short hostshort)
{
- return(nw_htons(hostshort));
+ return(nw_htons(hostshort));
}
u_long
PerlSockNtohl(struct IPerlSock* piPerl, u_long netlong)
{
- return nw_ntohl(netlong);
+ return nw_ntohl(netlong);
}
u_short
PerlSockNtohs(struct IPerlSock* piPerl, u_short netshort)
{
- return nw_ntohs(netshort);
+ return nw_ntohs(netshort);
}
SOCKET PerlSockAccept(struct IPerlSock* piPerl, SOCKET s, struct sockaddr* addr, int* addrlen)
{
- return nw_accept(s, addr, addrlen);
+ return nw_accept(s, addr, addrlen);
}
int
PerlSockBind(struct IPerlSock* piPerl, SOCKET s, const struct sockaddr* name, int namelen)
{
- return nw_bind(s, name, namelen);
+ return nw_bind(s, name, namelen);
}
int
PerlSockConnect(struct IPerlSock* piPerl, SOCKET s, const struct sockaddr* name, int namelen)
{
- return nw_connect(s, name, namelen);
+ return nw_connect(s, name, namelen);
}
void
@@ -1073,7 +1073,7 @@ PerlSockEndservent(struct IPerlSock* piPerl)
struct hostent*
PerlSockGethostbyaddr(struct IPerlSock* piPerl, const char* addr, int len, int type)
{
- return(nw_gethostbyaddr(addr,len,type));
+ return(nw_gethostbyaddr(addr,len,type));
}
struct hostent*
@@ -1085,13 +1085,13 @@ PerlSockGethostbyname(struct IPerlSock* piPerl, const char* name)
struct hostent*
PerlSockGethostent(struct IPerlSock* piPerl)
{
- return(nw_gethostent());
+ return(nw_gethostent());
}
int
PerlSockGethostname(struct IPerlSock* piPerl, char* name, int namelen)
{
- return nw_gethostname(name,namelen);
+ return nw_gethostname(name,namelen);
}
struct netent *
@@ -1144,31 +1144,31 @@ PerlSockGetservbyname(struct IPerlSock* piPerl, const char* name, const char* pr
struct servent*
PerlSockGetservbyport(struct IPerlSock* piPerl, int port, const char* proto)
{
- return nw_getservbyport(port, proto);
+ return nw_getservbyport(port, proto);
}
struct servent*
PerlSockGetservent(struct IPerlSock* piPerl)
{
- return nw_getservent();
+ return nw_getservent();
}
int
PerlSockGetsockname(struct IPerlSock* piPerl, SOCKET s, struct sockaddr* name, int* namelen)
{
- return nw_getsockname(s, name, namelen);
+ return nw_getsockname(s, name, namelen);
}
int
PerlSockGetsockopt(struct IPerlSock* piPerl, SOCKET s, int level, int optname, char* optval, int* optlen)
{
- return nw_getsockopt(s, level, optname, optval, optlen);
+ return nw_getsockopt(s, level, optname, optval, optlen);
}
unsigned long
PerlSockInetAddr(struct IPerlSock* piPerl, const char* cp)
{
- return(nw_inet_addr(cp));
+ return(nw_inet_addr(cp));
}
char*
@@ -1180,79 +1180,79 @@ PerlSockInetNtoa(struct IPerlSock* piPerl, struct in_addr in)
int
PerlSockListen(struct IPerlSock* piPerl, SOCKET s, int backlog)
{
- return (nw_listen(s, backlog));
+ return (nw_listen(s, backlog));
}
int
PerlSockRecv(struct IPerlSock* piPerl, SOCKET s, char* buffer, int len, int flags)
{
- return (nw_recv(s, buffer, len, flags));
+ return (nw_recv(s, buffer, len, flags));
}
int
PerlSockRecvfrom(struct IPerlSock* piPerl, SOCKET s, char* buffer, int len, int flags, struct sockaddr* from, int* fromlen)
{
- return nw_recvfrom(s, buffer, len, flags, from, fromlen);
+ return nw_recvfrom(s, buffer, len, flags, from, fromlen);
}
int
PerlSockSelect(struct IPerlSock* piPerl, int nfds, char* readfds, char* writefds, char* exceptfds, const struct timeval* timeout)
{
- return nw_select(nfds, (fd_set*) readfds, (fd_set*) writefds, (fd_set*) exceptfds, timeout);
+ return nw_select(nfds, (fd_set*) readfds, (fd_set*) writefds, (fd_set*) exceptfds, timeout);
}
int
PerlSockSend(struct IPerlSock* piPerl, SOCKET s, const char* buffer, int len, int flags)
{
- return (nw_send(s, buffer, len, flags));
+ return (nw_send(s, buffer, len, flags));
}
int
PerlSockSendto(struct IPerlSock* piPerl, SOCKET s, const char* buffer, int len, int flags, const struct sockaddr* to, int tolen)
{
- return(nw_sendto(s, buffer, len, flags, to, tolen));
+ return(nw_sendto(s, buffer, len, flags, to, tolen));
}
void
PerlSockSethostent(struct IPerlSock* piPerl, int stayopen)
{
- nw_sethostent(stayopen);
+ nw_sethostent(stayopen);
}
void
PerlSockSetnetent(struct IPerlSock* piPerl, int stayopen)
{
- nw_setnetent(stayopen);
+ nw_setnetent(stayopen);
}
void
PerlSockSetprotoent(struct IPerlSock* piPerl, int stayopen)
{
- nw_setprotoent(stayopen);
+ nw_setprotoent(stayopen);
}
void
PerlSockSetservent(struct IPerlSock* piPerl, int stayopen)
{
- nw_setservent(stayopen);
+ nw_setservent(stayopen);
}
int
PerlSockSetsockopt(struct IPerlSock* piPerl, SOCKET s, int level, int optname, const char* optval, int optlen)
{
- return nw_setsockopt(s, level, optname, optval, optlen);
+ return nw_setsockopt(s, level, optname, optval, optlen);
}
int
PerlSockShutdown(struct IPerlSock* piPerl, SOCKET s, int how)
{
- return nw_shutdown(s, how);
+ return nw_shutdown(s, how);
}
SOCKET
PerlSockSocket(struct IPerlSock* piPerl, int af, int type, int protocol)
{
- return nw_socket(af, type, protocol);
+ return nw_socket(af, type, protocol);
}
int
@@ -1266,9 +1266,9 @@ PerlSockSocketpair(struct IPerlSock* piPerl, int domain, int type, int protocol,
int
PerlSockIoctlsocket(struct IPerlSock* piPerl, SOCKET s, long cmd, u_long *argp)
{
- dTHX; // (J) dTHXo
+ dTHX; // (J) dTHXo
Perl_croak(aTHX_ "ioctlsocket not implemented!\n");
- return 0;
+ return 0;
}
struct IPerlSock perlSock =
@@ -1301,8 +1301,8 @@ struct IPerlSock perlSock =
PerlSockGetsockname,
PerlSockGetsockopt,
PerlSockInetAddr,
- PerlSockInetNtoa,
- PerlSockListen,
+ PerlSockInetNtoa,
+ PerlSockListen,
PerlSockRecv,
PerlSockRecvfrom,
PerlSockSelect,
@@ -1314,9 +1314,9 @@ struct IPerlSock perlSock =
PerlSockSetservent,
PerlSockSetsockopt,
PerlSockShutdown,
- PerlSockSocket,
+ PerlSockSocket,
PerlSockSocketpair,
- //Following commented by sgp bcos of comiplation error too many initializers (E279)
+ //Following commented by sgp bcos of comiplation error too many initializers (E279)
// PerlSockClosesocket,
};
@@ -1342,25 +1342,25 @@ void
PerlProcExit(struct IPerlProc* piPerl, int status)
{
// exit(status);
- dTHX;
- //dJMPENV;
- JMPENV_JUMP(2);
+ dTHX;
+ //dJMPENV;
+ JMPENV_JUMP(2);
}
void
PerlProc_Exit(struct IPerlProc* piPerl, int status)
{
// _exit(status);
- dTHX;
- //dJMPENV;
- JMPENV_JUMP(2);
+ dTHX;
+ //dJMPENV;
+ JMPENV_JUMP(2);
}
int
PerlProcExecl(struct IPerlProc* piPerl, const char *cmdname, const char *arg0, const char *arg1, const char *arg2, const char *arg3)
{
- // If removed, compilation error occurs.
- return 0;
+ // If removed, compilation error occurs.
+ return 0;
}
int
@@ -1378,36 +1378,36 @@ PerlProcExecvp(struct IPerlProc* piPerl, const char *cmdname, const char *const
uid_t
PerlProcGetuid(struct IPerlProc* piPerl)
{
- // If removed, compilation error occurs.
- return 0;
+ // If removed, compilation error occurs.
+ return 0;
}
uid_t
PerlProcGeteuid(struct IPerlProc* piPerl)
{
- // If removed, compilation error occurs.
- return 0;
+ // If removed, compilation error occurs.
+ return 0;
}
gid_t
PerlProcGetgid(struct IPerlProc* piPerl)
{
- // If removed, compilation error occurs.
- return 0;
+ // If removed, compilation error occurs.
+ return 0;
}
gid_t
PerlProcGetegid(struct IPerlProc* piPerl)
{
- // If removed, compilation error occurs.
- return 0;
+ // If removed, compilation error occurs.
+ return 0;
}
char *
PerlProcGetlogin(struct IPerlProc* piPerl)
{
- // If removed, compilation error occurs.
- return NULL;
+ // If removed, compilation error occurs.
+ return NULL;
}
int
@@ -1436,7 +1436,7 @@ PerlProcPopen(struct IPerlProc* piPerl, const char *command, const char *mode)
dTHX; // (J) dTHXo
PERL_FLUSHALL_FOR_CHILD;
- return (PerlIO*)nw_Popen((char *)command, (char *)mode, (int *)errno);
+ return (PerlIO*)nw_Popen((char *)command, (char *)mode, (int *)errno);
}
int
@@ -1454,15 +1454,15 @@ PerlProcPipe(struct IPerlProc* piPerl, int *phandles)
int
PerlProcSetuid(struct IPerlProc* piPerl, uid_t u)
{
- // If removed, compilation error occurs.
- return 0;
+ // If removed, compilation error occurs.
+ return 0;
}
int
PerlProcSetgid(struct IPerlProc* piPerl, gid_t g)
{
- // If removed, compilation error occurs.
- return 0;
+ // If removed, compilation error occurs.
+ return 0;
}
int
@@ -1492,15 +1492,15 @@ PerlProcWaitpid(struct IPerlProc* piPerl, int pid, int *status, int flags)
Sighandler_t
PerlProcSignal(struct IPerlProc* piPerl, int sig, Sighandler_t subcode)
{
- // If removed, compilation error occurs.
+ // If removed, compilation error occurs.
return 0;
}
int
PerlProcFork(struct IPerlProc* piPerl)
{
- // If removed, compilation error occurs.
- return 0;
+ // If removed, compilation error occurs.
+ return 0;
}
int
@@ -1582,8 +1582,8 @@ CPerlHost::CPerlHost(void)
m_pVMemShared = new VMem();
m_pVMemParse = new VMem();
- memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem));
- memcpy(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
+ memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem));
+ memcpy(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
memcpy(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse));
memcpy(&m_hostperlEnv, &perlEnv, sizeof(perlEnv));
memcpy(&m_hostperlStdIO, &perlStdIO, sizeof(perlStdIO));
@@ -1605,26 +1605,26 @@ CPerlHost::CPerlHost(void)
#define SETUPEXCHANGE(xptr, iptr, table) \
STMT_START { \
- if (xptr) { \
- iptr = *xptr; \
- *xptr = &table; \
- } \
- else { \
- iptr = &table; \
- } \
+ if (xptr) { \
+ iptr = *xptr; \
+ *xptr = &table; \
+ } \
+ else { \
+ iptr = &table; \
+ } \
} STMT_END
CPerlHost::CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
- struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
- struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
- struct IPerlDir** ppDir, struct IPerlSock** ppSock,
- struct IPerlProc** ppProc)
+ struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
+ struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
+ struct IPerlDir** ppDir, struct IPerlSock** ppSock,
+ struct IPerlProc** ppProc)
{
m_pVMem = new VMem();
m_pVMemShared = new VMem();
m_pVMemParse = new VMem();
- memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem));
+ memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem));
memcpy(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
memcpy(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse));
memcpy(&m_hostperlEnv, &perlEnv, sizeof(perlEnv));
@@ -1648,7 +1648,7 @@ CPerlHost::CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
CPerlHost::CPerlHost(const CPerlHost& host)
{
- memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem));
+ memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem));
memcpy(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
memcpy(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse));
memcpy(&m_hostperlEnv, &perlEnv, sizeof(perlEnv));
@@ -1672,26 +1672,26 @@ CPerlHost::CPerlHost(const CPerlHost& host)
CPerlHost::~CPerlHost(void)
{
- if ( m_pVMemParse ) delete m_pVMemParse;
- if ( m_pVMemShared ) delete m_pVMemShared;
- if ( m_pVMem ) delete m_pVMem;
+ if ( m_pVMemParse ) delete m_pVMemParse;
+ if ( m_pVMemShared ) delete m_pVMemShared;
+ if ( m_pVMem ) delete m_pVMem;
}
char*
CPerlHost::Getenv(const char *varname)
{
- // getenv is always present. In old CLIB, it is implemented
- // to always return NULL. With java loaded on NW411, it will
- // return values set by envset. Is correctly implemented by
- // CLIB on MOAB.
- //
- return getenv(varname);
+ // getenv is always present. In old CLIB, it is implemented
+ // to always return NULL. With java loaded on NW411, it will
+ // return values set by envset. Is correctly implemented by
+ // CLIB on MOAB.
+ //
+ return getenv(varname);
}
int
CPerlHost::Putenv(const char *envstring)
{
- return(putenv(envstring));
+ return(putenv(envstring));
}
diff --git a/NetWare/nwperlsys.c b/NetWare/nwperlsys.c
index 32c15cb438..adc9abc75e 100644
--- a/NetWare/nwperlsys.c
+++ b/NetWare/nwperlsys.c
@@ -34,10 +34,10 @@
Function : fnFreeMemEntry
Description : Called for each outstanding memory allocation at the end of a script run.
- Frees the outstanding allocations
+ Frees the outstanding allocations
Parameters : ptr (IN).
- context (IN)
+ context (IN)
Returns : Nothing.
@@ -45,10 +45,10 @@
void fnFreeMemEntry(void* ptr, void* context)
{
- if(ptr)
- {
- PerlMemFree(NULL, ptr);
- }
+ if(ptr)
+ {
+ PerlMemFree(NULL, ptr);
+ }
}
/*============================================================================================
@@ -84,21 +84,21 @@ perl_alloc(void)
{
PerlInterpreter* my_perl = NULL;
- WCValHashTable<void*>* m_allocList;
- m_allocList = new WCValHashTable<void*> (fnAllocListHash, 256);
- fnInsertHashListAddrs(m_allocList, FALSE);
- my_perl = perl_alloc_using(&perlMem,
- &perlMem,
- NULL,
- &perlEnv,
- &perlStdIO,
- &perlLIO,
- &perlDir,
- &perlSock,
- &perlProc);
- if (my_perl) {
- //nw5_internal_host = m_allocList;
- }
+ WCValHashTable<void*>* m_allocList;
+ m_allocList = new WCValHashTable<void*> (fnAllocListHash, 256);
+ fnInsertHashListAddrs(m_allocList, FALSE);
+ my_perl = perl_alloc_using(&perlMem,
+ &perlMem,
+ NULL,
+ &perlEnv,
+ &perlStdIO,
+ &perlLIO,
+ &perlDir,
+ &perlSock,
+ &perlProc);
+ if (my_perl) {
+ //nw5_internal_host = m_allocList;
+ }
return my_perl;
}
@@ -115,72 +115,72 @@ perl_alloc(void)
==============================================================================================*/
EXTERN_C PerlInterpreter*
perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
- struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
- struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
- struct IPerlDir** ppDir, struct IPerlSock** ppSock,
- struct IPerlProc** ppProc)
+ struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
+ struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
+ struct IPerlDir** ppDir, struct IPerlSock** ppSock,
+ struct IPerlProc** ppProc)
{
PerlInterpreter *my_perl = NULL;
- struct IPerlMem* lpMem;
- struct IPerlEnv* lpEnv;
- struct IPerlStdIO* lpStdio;
- struct IPerlLIO* lpLIO;
- struct IPerlDir* lpDir;
- struct IPerlSock* lpSock;
- struct IPerlProc* lpProc;
-
- WCValHashTable<void*>* m_allocList;
- m_allocList = new WCValHashTable<void*> (fnAllocListHash, 256);
- fnInsertHashListAddrs(m_allocList, FALSE);
-
- if (!ppMem)
- lpMem=&perlMem;
- else
- lpMem=*ppMem;
-
- if (!ppEnv)
- lpEnv=&perlEnv;
- else
- lpEnv=*ppEnv;
-
- if (!ppStdIO)
- lpStdio=&perlStdIO;
- else
- lpStdio=*ppStdIO;
-
- if (!ppLIO)
- lpLIO=&perlLIO;
- else
- lpLIO=*ppLIO;
-
- if (!ppDir)
- lpDir=&perlDir;
- else
- lpDir=*ppDir;
-
- if (!ppSock)
- lpSock=&perlSock;
- else
- lpSock=*ppSock;
-
- if (!ppProc)
- lpProc=&perlProc;
- else
- lpProc=*ppProc;
- my_perl = perl_alloc_using(lpMem,
- lpMem,
- NULL,
- lpEnv,
- lpStdio,
- lpLIO,
- lpDir,
- lpSock,
- lpProc);
-
- if (my_perl) {
- //nw5_internal_host = pHost;
- }
+ struct IPerlMem* lpMem;
+ struct IPerlEnv* lpEnv;
+ struct IPerlStdIO* lpStdio;
+ struct IPerlLIO* lpLIO;
+ struct IPerlDir* lpDir;
+ struct IPerlSock* lpSock;
+ struct IPerlProc* lpProc;
+
+ WCValHashTable<void*>* m_allocList;
+ m_allocList = new WCValHashTable<void*> (fnAllocListHash, 256);
+ fnInsertHashListAddrs(m_allocList, FALSE);
+
+ if (!ppMem)
+ lpMem=&perlMem;
+ else
+ lpMem=*ppMem;
+
+ if (!ppEnv)
+ lpEnv=&perlEnv;
+ else
+ lpEnv=*ppEnv;
+
+ if (!ppStdIO)
+ lpStdio=&perlStdIO;
+ else
+ lpStdio=*ppStdIO;
+
+ if (!ppLIO)
+ lpLIO=&perlLIO;
+ else
+ lpLIO=*ppLIO;
+
+ if (!ppDir)
+ lpDir=&perlDir;
+ else
+ lpDir=*ppDir;
+
+ if (!ppSock)
+ lpSock=&perlSock;
+ else
+ lpSock=*ppSock;
+
+ if (!ppProc)
+ lpProc=&perlProc;
+ else
+ lpProc=*ppProc;
+ my_perl = perl_alloc_using(lpMem,
+ lpMem,
+ NULL,
+ lpEnv,
+ lpStdio,
+ lpLIO,
+ lpDir,
+ lpSock,
+ lpProc);
+
+ if (my_perl) {
+ //nw5_internal_host = pHost;
+ }
return my_perl;
}
/*============================================================================================
@@ -198,19 +198,19 @@ perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
EXTERN_C void
nw5_delete_internal_host(void *h)
{
- WCValHashTable<void*>* m_allocList;
- void **listptr;
- BOOL m_dontTouchHashLists;
- if (fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
- m_allocList = (WCValHashTable<void*>*)listptr;
- fnInsertHashListAddrs(m_allocList, TRUE);
- if (m_allocList)
- {
- m_allocList->forAll(fnFreeMemEntry, NULL);
- fnInsertHashListAddrs(NULL, FALSE);
- delete m_allocList;
- }
- }
+ WCValHashTable<void*>* m_allocList;
+ void **listptr;
+ BOOL m_dontTouchHashLists;
+ if (fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
+ m_allocList = (WCValHashTable<void*>*)listptr;
+ fnInsertHashListAddrs(m_allocList, TRUE);
+ if (m_allocList)
+ {
+ m_allocList->forAll(fnFreeMemEntry, NULL);
+ fnInsertHashListAddrs(NULL, FALSE);
+ delete m_allocList;
+ }
+ }
}
#endif /* PERL_IMPLICIT_SYS */
diff --git a/NetWare/nwperlsys.h b/NetWare/nwperlsys.h
index 3d82dd1c8d..34f713d287 100644
--- a/NetWare/nwperlsys.h
+++ b/NetWare/nwperlsys.h
@@ -48,103 +48,103 @@ END_EXTERN_C
void*
PerlMemMalloc(struct IPerlMem* piPerl, size_t size)
{
- void *ptr = NULL;
- ptr = malloc(size);
- if (ptr) {
- void **listptr;
- BOOL m_dontTouchHashLists;
- if(fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
- if (listptr) {
- WCValHashTable<void*>* m_allocList= (WCValHashTable<void*>*)listptr;
- (WCValHashTable<void*>*)m_allocList->insert(ptr);
- }
- }
- }
- return(ptr);
+ void *ptr = NULL;
+ ptr = malloc(size);
+ if (ptr) {
+ void **listptr;
+ BOOL m_dontTouchHashLists;
+ if(fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
+ if (listptr) {
+ WCValHashTable<void*>* m_allocList= (WCValHashTable<void*>*)listptr;
+ (WCValHashTable<void*>*)m_allocList->insert(ptr);
+ }
+ }
+ }
+ return(ptr);
}
void*
PerlMemRealloc(struct IPerlMem* piPerl, void* ptr, size_t size)
{
- void *newptr = NULL;
- WCValHashTable<void*>* m_allocList;
+ void *newptr = NULL;
+ WCValHashTable<void*>* m_allocList;
- newptr = realloc(ptr, size);
+ newptr = realloc(ptr, size);
- if (ptr)
- {
- void **listptr;
- BOOL m_dontTouchHashLists;
- if(fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
- m_allocList= (WCValHashTable<void*>*)listptr;
- (WCValHashTable<void*>*)m_allocList->remove(ptr);
- }
- }
- if (newptr)
- {
- if (m_allocList)
- (WCValHashTable<void*>*)m_allocList->insert(newptr);
- }
+ if (ptr)
+ {
+ void **listptr;
+ BOOL m_dontTouchHashLists;
+ if(fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
+ m_allocList= (WCValHashTable<void*>*)listptr;
+ (WCValHashTable<void*>*)m_allocList->remove(ptr);
+ }
+ }
+ if (newptr)
+ {
+ if (m_allocList)
+ (WCValHashTable<void*>*)m_allocList->insert(newptr);
+ }
- return(newptr);
+ return(newptr);
}
void
PerlMemFree(struct IPerlMem* piPerl, void* ptr)
{
- BOOL m_dontTouchHashLists;
- WCValHashTable<void*>* m_allocList;
-
- void **listptr;
- if(fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
- m_allocList= (WCValHashTable<void*>*)listptr;
- // Final clean up, free all the nodes from the hash list
- if (m_dontTouchHashLists)
- {
- if(ptr)
- {
- free(ptr);
- ptr = NULL;
- }
- }
- else
- {
- if(ptr && m_allocList)
- {
- if ((WCValHashTable<void*>*)m_allocList->remove(ptr))
- {
- free(ptr);
- ptr = NULL;
- }
- else
- {
- // If it comes here, that means that the memory pointer is not contained in the hash list.
- // But no need to free now, since if is deleted here, it will result in an abend!!
- // If the memory is still there, it will be cleaned during final cleanup anyway.
- }
- }
- }
- }
- return;
+ BOOL m_dontTouchHashLists;
+ WCValHashTable<void*>* m_allocList;
+
+ void **listptr;
+ if(fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
+ m_allocList= (WCValHashTable<void*>*)listptr;
+ // Final clean up, free all the nodes from the hash list
+ if (m_dontTouchHashLists)
+ {
+ if(ptr)
+ {
+ free(ptr);
+ ptr = NULL;
+ }
+ }
+ else
+ {
+ if(ptr && m_allocList)
+ {
+ if ((WCValHashTable<void*>*)m_allocList->remove(ptr))
+ {
+ free(ptr);
+ ptr = NULL;
+ }
+ else
+ {
+ // If it comes here, that means that the memory pointer is not contained in the hash list.
+ // But no need to free now, since if is deleted here, it will result in an abend!!
+ // If the memory is still there, it will be cleaned during final cleanup anyway.
+ }
+ }
+ }
+ }
+ return;
}
void*
PerlMemCalloc(struct IPerlMem* piPerl, size_t num, size_t size)
{
- void *ptr = NULL;
+ void *ptr = NULL;
- ptr = calloc(num, size);
- if (ptr) {
- void **listptr;
- BOOL m_dontTouchHashLists;
- if(fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
- if (listptr) {
- WCValHashTable<void*>* m_allocList= (WCValHashTable<void*>*)listptr;
- (WCValHashTable<void*>*)m_allocList->insert(ptr);
- }
- }
- }
- return(ptr);
+ ptr = calloc(num, size);
+ if (ptr) {
+ void **listptr;
+ BOOL m_dontTouchHashLists;
+ if(fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
+ if (listptr) {
+ WCValHashTable<void*>* m_allocList= (WCValHashTable<void*>*)listptr;
+ (WCValHashTable<void*>*)m_allocList->insert(ptr);
+ }
+ }
+ }
+ return(ptr);
}
struct IPerlMem perlMem =
@@ -162,37 +162,37 @@ struct IPerlMem perlMem =
int
PerlDirMakedir(struct IPerlDir* piPerl, const char *dirname, int mode)
{
- return mkdir(dirname);
+ return mkdir(dirname);
}
int
PerlDirChdir(struct IPerlDir* piPerl, const char *dirname)
{
- return nw_chdir(dirname);
+ return nw_chdir(dirname);
}
int
PerlDirRmdir(struct IPerlDir* piPerl, const char *dirname)
{
- return nw_rmdir(dirname);
+ return nw_rmdir(dirname);
}
int
PerlDirClose(struct IPerlDir* piPerl, DIR *dirp)
{
- return nw_closedir(dirp);
+ return nw_closedir(dirp);
}
DIR*
PerlDirOpen(struct IPerlDir* piPerl, const char *filename)
{
- return nw_opendir(filename);
+ return nw_opendir(filename);
}
struct direct *
PerlDirRead(struct IPerlDir* piPerl, DIR *dirp)
{
- return nw_readdir(dirp);
+ return nw_readdir(dirp);
}
void
@@ -215,7 +215,7 @@ PerlDirTell(struct IPerlDir* piPerl, DIR *dirp)
struct IPerlDir perlDir =
{
- PerlDirMakedir,
+ PerlDirMakedir,
PerlDirChdir,
PerlDirRmdir,
PerlDirClose,
@@ -233,23 +233,23 @@ struct IPerlDir perlDir =
char*
PerlEnvGetenv(struct IPerlEnv* piPerl, const char *varname)
{
- return(getenv(varname));
+ return(getenv(varname));
};
int
PerlEnvPutenv(struct IPerlEnv* piPerl, const char *envstring)
{
- return(putenv(envstring));
+ return(putenv(envstring));
};
char*
PerlEnvGetenv_len(struct IPerlEnv* piPerl, const char* varname, unsigned long* len)
{
- *len = 0;
- char *e = getenv(varname);
- if (e)
- *len = strlen(e);
- return e;
+ *len = 0;
+ char *e = getenv(varname);
+ if (e)
+ *len = strlen(e);
+ return e;
}
int
@@ -261,13 +261,13 @@ PerlEnvUname(struct IPerlEnv* piPerl, struct utsname *name)
void
PerlEnvClearenv(struct IPerlEnv* piPerl)
{
-
+
}
struct IPerlEnv perlEnv =
{
- PerlEnvGetenv,
- PerlEnvPutenv,
+ PerlEnvGetenv,
+ PerlEnvPutenv,
PerlEnvGetenv_len,
PerlEnvUname,
PerlEnvClearenv,
@@ -559,17 +559,17 @@ PerlStdIOFdupopen(struct IPerlStdIO* piPerl, FILE* pf)
/* open the file in the same mode */
if(((FILE*)pf)->_flag & _IOREAD) {
- mode[0] = 'r';
- mode[1] = 0;
+ mode[0] = 'r';
+ mode[1] = 0;
}
else if(((FILE*)pf)->_flag & _IOWRT) {
- mode[0] = 'a';
- mode[1] = 0;
+ mode[0] = 'a';
+ mode[1] = 0;
}
else if(((FILE*)pf)->_flag & _IORW) {
- mode[0] = 'r';
- mode[1] = '+';
- mode[2] = 0;
+ mode[0] = 'r';
+ mode[1] = '+';
+ mode[2] = 0;
}
/* it appears that the binmode is attached to the
@@ -580,14 +580,14 @@ PerlStdIOFdupopen(struct IPerlStdIO* piPerl, FILE* pf)
/* move the file pointer to the same position */
if (!fgetpos(pf, &pos)) {
- fsetpos(pfdup, &pos);
+ fsetpos(pfdup, &pos);
}
return pfdup;
}
struct IPerlStdIO perlStdIO =
{
- PerlStdIOStdin,
+ PerlStdIOStdin,
PerlStdIOStdout,
PerlStdIOStderr,
PerlStdIOOpen,
@@ -647,15 +647,15 @@ PerlLIOChmod(struct IPerlLIO* piPerl, const char *filename, int pmode)
int
PerlLIOChown(struct IPerlLIO* piPerl, const char *filename, uid_t owner, gid_t group)
{
- dTHX;
+ dTHX;
Perl_croak(aTHX_ "chown not implemented!\n");
- return 0;
+ return 0;
}
int
PerlLIOChsize(struct IPerlLIO* piPerl, int handle, long size)
{
- return (nw_chsize(handle,size));
+ return (nw_chsize(handle,size));
}
int
@@ -679,7 +679,7 @@ PerlLIODup2(struct IPerlLIO* piPerl, int handle1, int handle2)
int
PerlLIOFlock(struct IPerlLIO* piPerl, int fd, int oper)
{
- //On NetWare simulate flock by locking a range on the file
+ //On NetWare simulate flock by locking a range on the file
return nw_flock(fd, oper);
}
@@ -692,7 +692,7 @@ PerlLIOFileStat(struct IPerlLIO* piPerl, int handle, struct stat *buffer)
int
PerlLIOIOCtl(struct IPerlLIO* piPerl, int i, unsigned int u, char *data)
{
- return 0;
+ return 0;
}
int
@@ -722,7 +722,7 @@ PerlLIOLstat(struct IPerlLIO* piPerl, const char *path, struct stat *buffer)
char*
PerlLIOMktemp(struct IPerlLIO* piPerl, char *Template)
{
- return(nw_mktemp(Template));
+ return(nw_mktemp(Template));
}
int
@@ -793,7 +793,7 @@ PerlLIOWrite(struct IPerlLIO* piPerl, int handle, const void *buffer, unsigned i
struct IPerlLIO perlLIO =
{
- PerlLIOAccess,
+ PerlLIOAccess,
PerlLIOChmod,
PerlLIOChown,
PerlLIOChsize,
@@ -844,26 +844,26 @@ void
PerlProcExit(struct IPerlProc* piPerl, int status)
{
// exit(status);
- dTHX;
- dJMPENV;
- JMPENV_JUMP(2);
+ dTHX;
+ dJMPENV;
+ JMPENV_JUMP(2);
}
void
PerlProc_Exit(struct IPerlProc* piPerl, int status)
{
// _exit(status);
- dTHX;
- dJMPENV;
- JMPENV_JUMP(2);
+ dTHX;
+ dJMPENV;
+ JMPENV_JUMP(2);
}
int
PerlProcExecl(struct IPerlProc* piPerl, const char *cmdname, const char *arg0, const char *arg1, const char *arg2, const char *arg3)
{
- dTHX;
+ dTHX;
Perl_croak(aTHX_ "execl not implemented!\n");
- return 0;
+ return 0;
}
int
@@ -881,31 +881,31 @@ PerlProcExecvp(struct IPerlProc* piPerl, const char *cmdname, const char *const
uid_t
PerlProcGetuid(struct IPerlProc* piPerl)
{
- return 0;
+ return 0;
}
uid_t
PerlProcGeteuid(struct IPerlProc* piPerl)
{
- return 0;
+ return 0;
}
gid_t
PerlProcGetgid(struct IPerlProc* piPerl)
{
- return 0;
+ return 0;
}
gid_t
PerlProcGetegid(struct IPerlProc* piPerl)
{
- return 0;
+ return 0;
}
char *
PerlProcGetlogin(struct IPerlProc* piPerl)
{
- return NULL;
+ return NULL;
}
int
@@ -934,7 +934,7 @@ PerlProcPopen(struct IPerlProc* piPerl, const char *command, const char *mode)
dTHX;
PERL_FLUSHALL_FOR_CHILD;
- return (PerlIO*)nw_Popen((char *)command, (char *)mode, (int *)errno);
+ return (PerlIO*)nw_Popen((char *)command, (char *)mode, (int *)errno);
}
int
@@ -952,13 +952,13 @@ PerlProcPipe(struct IPerlProc* piPerl, int *phandles)
int
PerlProcSetuid(struct IPerlProc* piPerl, uid_t u)
{
- return 0;
+ return 0;
}
int
PerlProcSetgid(struct IPerlProc* piPerl, gid_t g)
{
- return 0;
+ return 0;
}
int
@@ -994,7 +994,7 @@ PerlProcSignal(struct IPerlProc* piPerl, int sig, Sighandler_t subcode)
int
PerlProcFork(struct IPerlProc* piPerl)
{
- return 0;
+ return 0;
}
int
@@ -1068,42 +1068,42 @@ struct IPerlProc perlProc =
u_long
PerlSockHtonl(struct IPerlSock* piPerl, u_long hostlong)
{
- return(nw_htonl(hostlong));
+ return(nw_htonl(hostlong));
}
u_short
PerlSockHtons(struct IPerlSock* piPerl, u_short hostshort)
{
- return(nw_htons(hostshort));
+ return(nw_htons(hostshort));
}
u_long
PerlSockNtohl(struct IPerlSock* piPerl, u_long netlong)
{
- return nw_ntohl(netlong);
+ return nw_ntohl(netlong);
}
u_short
PerlSockNtohs(struct IPerlSock* piPerl, u_short netshort)
{
- return nw_ntohs(netshort);
+ return nw_ntohs(netshort);
}
SOCKET PerlSockAccept(struct IPerlSock* piPerl, SOCKET s, struct sockaddr* addr, int* addrlen)
{
- return nw_accept(s, addr, addrlen);
+ return nw_accept(s, addr, addrlen);
}
int
PerlSockBind(struct IPerlSock* piPerl, SOCKET s, const struct sockaddr* name, int namelen)
{
- return nw_bind(s, name, namelen);
+ return nw_bind(s, name, namelen);
}
int
PerlSockConnect(struct IPerlSock* piPerl, SOCKET s, const struct sockaddr* name, int namelen)
{
- return nw_connect(s, name, namelen);
+ return nw_connect(s, name, namelen);
}
void
@@ -1133,7 +1133,7 @@ PerlSockEndservent(struct IPerlSock* piPerl)
struct hostent*
PerlSockGethostbyaddr(struct IPerlSock* piPerl, const char* addr, int len, int type)
{
- return(nw_gethostbyaddr(addr,len,type));
+ return(nw_gethostbyaddr(addr,len,type));
}
struct hostent*
@@ -1145,13 +1145,13 @@ PerlSockGethostbyname(struct IPerlSock* piPerl, const char* name)
struct hostent*
PerlSockGethostent(struct IPerlSock* piPerl)
{
- return(nw_gethostent());
+ return(nw_gethostent());
}
int
PerlSockGethostname(struct IPerlSock* piPerl, char* name, int namelen)
{
- return nw_gethostname(name,namelen);
+ return nw_gethostname(name,namelen);
}
struct netent *
@@ -1204,115 +1204,115 @@ PerlSockGetservbyname(struct IPerlSock* piPerl, const char* name, const char* pr
struct servent*
PerlSockGetservbyport(struct IPerlSock* piPerl, int port, const char* proto)
{
- return nw_getservbyport(port, proto);
+ return nw_getservbyport(port, proto);
}
struct servent*
PerlSockGetservent(struct IPerlSock* piPerl)
{
- return nw_getservent();
+ return nw_getservent();
}
int
PerlSockGetsockname(struct IPerlSock* piPerl, SOCKET s, struct sockaddr* name, int* namelen)
{
- return nw_getsockname(s, name, namelen);
+ return nw_getsockname(s, name, namelen);
}
int
PerlSockGetsockopt(struct IPerlSock* piPerl, SOCKET s, int level, int optname, char* optval, int* optlen)
{
- return nw_getsockopt(s, level, optname, optval, optlen);
+ return nw_getsockopt(s, level, optname, optval, optlen);
}
unsigned long
PerlSockInetAddr(struct IPerlSock* piPerl, const char* cp)
{
- return(nw_inet_addr(cp));
+ return(nw_inet_addr(cp));
}
char*
PerlSockInetNtoa(struct IPerlSock* piPerl, struct in_addr in)
{
- return NULL;
+ return NULL;
}
int
PerlSockListen(struct IPerlSock* piPerl, SOCKET s, int backlog)
{
- return (nw_listen(s, backlog));
+ return (nw_listen(s, backlog));
}
int
PerlSockRecv(struct IPerlSock* piPerl, SOCKET s, char* buffer, int len, int flags)
{
- return (nw_recv(s, buffer, len, flags));
+ return (nw_recv(s, buffer, len, flags));
}
int
PerlSockRecvfrom(struct IPerlSock* piPerl, SOCKET s, char* buffer, int len, int flags, struct sockaddr* from, int* fromlen)
{
- return nw_recvfrom(s, buffer, len, flags, from, fromlen);
+ return nw_recvfrom(s, buffer, len, flags, from, fromlen);
}
int
PerlSockSelect(struct IPerlSock* piPerl, int nfds, char* readfds, char* writefds, char* exceptfds, const struct timeval* timeout)
{
- return nw_select(nfds, (fd_set*) readfds, (fd_set*) writefds, (fd_set*) exceptfds, timeout);
+ return nw_select(nfds, (fd_set*) readfds, (fd_set*) writefds, (fd_set*) exceptfds, timeout);
}
int
PerlSockSend(struct IPerlSock* piPerl, SOCKET s, const char* buffer, int len, int flags)
{
- return (nw_send(s, buffer, len, flags));
+ return (nw_send(s, buffer, len, flags));
}
int
PerlSockSendto(struct IPerlSock* piPerl, SOCKET s, const char* buffer, int len, int flags, const struct sockaddr* to, int tolen)
{
- return(nw_sendto(s, buffer, len, flags, to, tolen));
+ return(nw_sendto(s, buffer, len, flags, to, tolen));
}
void
PerlSockSethostent(struct IPerlSock* piPerl, int stayopen)
{
- nw_sethostent(stayopen);
+ nw_sethostent(stayopen);
}
void
PerlSockSetnetent(struct IPerlSock* piPerl, int stayopen)
{
- nw_setnetent(stayopen);
+ nw_setnetent(stayopen);
}
void
PerlSockSetprotoent(struct IPerlSock* piPerl, int stayopen)
{
- nw_setprotoent(stayopen);
+ nw_setprotoent(stayopen);
}
void
PerlSockSetservent(struct IPerlSock* piPerl, int stayopen)
{
- nw_setservent(stayopen);
+ nw_setservent(stayopen);
}
int
PerlSockSetsockopt(struct IPerlSock* piPerl, SOCKET s, int level, int optname, const char* optval, int optlen)
{
- return nw_setsockopt(s, level, optname, optval, optlen);
+ return nw_setsockopt(s, level, optname, optval, optlen);
}
int
PerlSockShutdown(struct IPerlSock* piPerl, SOCKET s, int how)
{
- return nw_shutdown(s, how);
+ return nw_shutdown(s, how);
}
SOCKET
PerlSockSocket(struct IPerlSock* piPerl, int af, int type, int protocol)
{
- return nw_socket(af, type, protocol);
+ return nw_socket(af, type, protocol);
}
int
@@ -1326,14 +1326,14 @@ PerlSockSocketpair(struct IPerlSock* piPerl, int domain, int type, int protocol,
int
PerlSockIoctlsocket(struct IPerlSock* piPerl, SOCKET s, long cmd, u_long *argp)
{
- dTHX;
+ dTHX;
Perl_croak(aTHX_ "ioctlsocket not implemented!\n");
- return 0;
+ return 0;
}
struct IPerlSock perlSock =
{
- PerlSockHtonl,
+ PerlSockHtonl,
PerlSockHtons,
PerlSockNtohl,
PerlSockNtohs,
@@ -1361,8 +1361,8 @@ struct IPerlSock perlSock =
PerlSockGetsockname,
PerlSockGetsockopt,
PerlSockInetAddr,
- PerlSockInetNtoa,
- PerlSockListen,
+ PerlSockInetNtoa,
+ PerlSockListen,
PerlSockRecv,
PerlSockRecvfrom,
PerlSockSelect,
@@ -1374,7 +1374,7 @@ struct IPerlSock perlSock =
PerlSockSetservent,
PerlSockSetsockopt,
PerlSockShutdown,
- PerlSockSocket,
+ PerlSockSocket,
PerlSockSocketpair,
};
diff --git a/NetWare/nwpipe.h b/NetWare/nwpipe.h
index 462a73dcf4..1cf58706c1 100644
--- a/NetWare/nwpipe.h
+++ b/NetWare/nwpipe.h
@@ -29,24 +29,24 @@
typedef struct tagTempPipeFile
{
- BOOL m_mode; // FALSE - Read mode ; TRUE - Write mode
- BOOL m_launchPerl;
- BOOL m_doPerlGlob;
+ BOOL m_mode; // FALSE - Read mode ; TRUE - Write mode
+ BOOL m_launchPerl;
+ BOOL m_doPerlGlob;
- int m_argv_len;
+ int m_argv_len;
- char * m_fileName;
- char** m_argv;
- char * m_redirect;
+ char * m_fileName;
+ char** m_argv;
+ char * m_redirect;
- #ifdef MPK_ON
- SEMAPHORE m_perlSynchSemaphore;
- #else
- long m_perlSynchSemaphore;
- #endif
+ #ifdef MPK_ON
+ SEMAPHORE m_perlSynchSemaphore;
+ #else
+ long m_perlSynchSemaphore;
+ #endif
- FILE* m_file;
- PCOMMANDLINEPARSER m_pipeCommand;
+ FILE* m_file;
+ PCOMMANDLINEPARSER m_pipeCommand;
} TEMPPIPEFILE, *PTEMPPIPEFILE;
diff --git a/NetWare/nwplglob.c b/NetWare/nwplglob.c
index 6810fd5e69..fba55da7ab 100644
--- a/NetWare/nwplglob.c
+++ b/NetWare/nwplglob.c
@@ -36,7 +36,7 @@
Description : Perl globbing support: Takes an array of wildcard descriptors
and produces from it a list of files that the wildcards expand into.
- The list of files is written to the temporary file named by fileName.
+ The list of files is written to the temporary file named by fileName.
Parameters : argv (IN) - Input argument vector.
fileName (IN) - Input file name for storing globed file names.
@@ -47,44 +47,44 @@
void fnDoPerlGlob(char** argv, char* fileName)
{
- FILE * redirOut = NULL;
+ FILE * redirOut = NULL;
- if (*argv)
- argv++;
- if (*argv == NULL)
- return;
+ if (*argv)
+ argv++;
+ if (*argv == NULL)
+ return;
- redirOut = fopen((const char *)fileName, (const char *)"w");
- if (!redirOut)
- return;
+ redirOut = fopen((const char *)fileName, (const char *)"w");
+ if (!redirOut)
+ return;
- do
- {
- DIR* dir = NULL;
- DIR* fil = NULL;
- char* pattern = NULL;
+ do
+ {
+ DIR* dir = NULL;
+ DIR* fil = NULL;
+ char* pattern = NULL;
- pattern = *argv++;
+ pattern = *argv++;
- dir = opendir((const char *)pattern);
- if (!dir)
- continue;
+ dir = opendir((const char *)pattern);
+ if (!dir)
+ continue;
- /* find the last separator in pattern, NetWare has three: /\: */
- while (fil = readdir(dir))
- {
- // The below displays the files separated by tab character.
- // Also, it displays only the file names and not directories.
- // If any other format is desired, it needs to be done here.
- fprintf(redirOut, "%s\t", fil->d_name);
- }
+ /* find the last separator in pattern, NetWare has three: /\: */
+ while (fil = readdir(dir))
+ {
+ // The below displays the files separated by tab character.
+ // Also, it displays only the file names and not directories.
+ // If any other format is desired, it needs to be done here.
+ fprintf(redirOut, "%s\t", fil->d_name);
+ }
- closedir(dir);
+ closedir(dir);
- } while (*argv);
+ } while (*argv);
- fclose(redirOut);
+ fclose(redirOut);
- return;
+ return;
}
diff --git a/NetWare/nwtinfo.h b/NetWare/nwtinfo.h
index a08d060422..d8503d2811 100644
--- a/NetWare/nwtinfo.h
+++ b/NetWare/nwtinfo.h
@@ -25,10 +25,10 @@
typedef struct tagThreadInfo
{
- int tid;
- struct tagThreadInfo *next;
- BOOL m_dontTouchHashLists;
- void* m_allocList;
+ int tid;
+ struct tagThreadInfo *next;
+ BOOL m_dontTouchHashLists;
+ void* m_allocList;
}ThreadInfo;
void fnInitializeThreadInfo(void);
@@ -39,17 +39,17 @@ BOOL fnRemoveThreadInfo(int tid);
ThreadInfo* fnGetThreadInfo(int tid);
#ifdef __cplusplus
- //For storing and retrieving Watcom Hash list address
- extern "C" BOOL fnInsertHashListAddrs(void *addrs, BOOL dontTouchHashList);
- //Registering with the Thread table
- extern "C" BOOL fnRegisterWithThreadTable(void);
- extern "C" BOOL fnUnregisterWithThreadTable(void);
+ //For storing and retrieving Watcom Hash list address
+ extern "C" BOOL fnInsertHashListAddrs(void *addrs, BOOL dontTouchHashList);
+ //Registering with the Thread table
+ extern "C" BOOL fnRegisterWithThreadTable(void);
+ extern "C" BOOL fnUnregisterWithThreadTable(void);
#else
- //For storing and retrieving Watcom Hash list address
- BOOL fnInsertHashListAddrs(void *addrs, BOOL dontTouchHashList);
- //Registering with the Thread table
- BOOL fnRegisterWithThreadTable(void);
- BOOL fnUnregisterWithThreadTable(void);
+ //For storing and retrieving Watcom Hash list address
+ BOOL fnInsertHashListAddrs(void *addrs, BOOL dontTouchHashList);
+ //Registering with the Thread table
+ BOOL fnRegisterWithThreadTable(void);
+ BOOL fnUnregisterWithThreadTable(void);
#endif
BOOL fnGetHashListAddrs(void **addrs, BOOL *dontTouchHashList);
@@ -58,9 +58,9 @@ BOOL fnGetHashListAddrs(void **addrs, BOOL *dontTouchHashList);
//or see if the above portion can be removed once this works properly
typedef struct tagThreadCtx
{
- long tid;
- void *tInfo;
- struct tagThreadCtx *next;
+ long tid;
+ void *tInfo;
+ struct tagThreadCtx *next;
}ThreadContext;
diff --git a/NetWare/nwutil.h b/NetWare/nwutil.h
index ff05d1830f..a27161147d 100644
--- a/NetWare/nwutil.h
+++ b/NetWare/nwutil.h
@@ -27,10 +27,10 @@
#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
@@ -43,28 +43,28 @@
typedef struct tagCommandLineParser
{
- BOOL m_noScreen;
- BOOL m_AutoDestroy;
- BOOL m_isValid;
-
- int m_argc;
- int m_argv_len;
-
- #ifdef MPK_ON
- SEMAPHORE m_qSemaphore;
- #else
- long m_qSemaphore;
- #endif
-
- char* m_redirInName;
- char* m_redirOutName;
- char* m_redirErrName;
- char* m_redirBothName;
- char* nextarg;
- char* sSkippedToken;
-
- char** m_argv;
- char** new_argv;
+ BOOL m_noScreen;
+ BOOL m_AutoDestroy;
+ BOOL m_isValid;
+
+ int m_argc;
+ int m_argv_len;
+
+ #ifdef MPK_ON
+ SEMAPHORE m_qSemaphore;
+ #else
+ long m_qSemaphore;
+ #endif
+
+ char* m_redirInName;
+ char* m_redirOutName;
+ char* m_redirErrName;
+ char* m_redirBothName;
+ char* nextarg;
+ char* sSkippedToken;
+
+ char** m_argv;
+ char** new_argv;
}COMMANDLINEPARSER, *PCOMMANDLINEPARSER;
diff --git a/NetWare/nwvmem.h b/NetWare/nwvmem.h
index e82eaeef8b..98b2873044 100644
--- a/NetWare/nwvmem.h
+++ b/NetWare/nwvmem.h
@@ -38,12 +38,12 @@ public:
virtual void* Malloc(size_t size);
virtual void* Realloc(void* pMem, size_t size);
virtual void Free(void* pMem);
- virtual void* Calloc(size_t num, size_t size);
+ virtual void* Calloc(size_t num, size_t size);
protected:
- BOOL m_dontTouchHashLists;
+ BOOL m_dontTouchHashLists;
// WCValHashTable<void*>* m_allocList;
- NWPerlHashList *m_allocList; // CW changes
+ NWPerlHashList *m_allocList; // CW changes
};
@@ -73,10 +73,10 @@ unsigned fnAllocListHash(void* const& invalue)
Function : fnFreeMemEntry
Description : Called for each outstanding memory allocation at the end of a script run.
- Frees the outstanding allocations
+ Frees the outstanding allocations
Parameters : ptr (IN).
- context (IN)
+ context (IN)
Returns : Nothing.
@@ -84,15 +84,15 @@ unsigned fnAllocListHash(void* const& invalue)
void fnFreeMemEntry(void* ptr, void* context)
{
- VMem* pVMem = (VMem*) context;
-
- if(ptr && pVMem)
- {
- pVMem->Free(ptr);
- ptr=NULL;
- pVMem = NULL;
- context = NULL;
- }
+ VMem* pVMem = (VMem*) context;
+
+ if(ptr && pVMem)
+ {
+ pVMem->Free(ptr);
+ ptr=NULL;
+ pVMem = NULL;
+ context = NULL;
+ }
}
@@ -111,11 +111,11 @@ void fnFreeMemEntry(void* ptr, void* context)
VMem::VMem()
{
- //Constructor
- m_dontTouchHashLists = FALSE;
- m_allocList = NULL;
- // m_allocList = new WCValHashTable<void*> (fnAllocListHash, 256);
- m_allocList = new NWPerlHashList(); // CW changes
+ //Constructor
+ m_dontTouchHashLists = FALSE;
+ m_allocList = NULL;
+ // m_allocList = new WCValHashTable<void*> (fnAllocListHash, 256);
+ m_allocList = new NWPerlHashList(); // CW changes
}
@@ -134,16 +134,16 @@ VMem::VMem()
VMem::~VMem(void)
{
- //Destructor
- m_dontTouchHashLists = TRUE;
- if (m_allocList)
- {
- m_allocList->forAll(fnFreeMemEntry, (void*) this);
-
- delete m_allocList;
- m_allocList = NULL;
- }
- m_dontTouchHashLists = FALSE;
+ //Destructor
+ m_dontTouchHashLists = TRUE;
+ if (m_allocList)
+ {
+ m_allocList->forAll(fnFreeMemEntry, (void*) this);
+
+ delete m_allocList;
+ m_allocList = NULL;
+ }
+ m_dontTouchHashLists = FALSE;
}
@@ -162,33 +162,33 @@ VMem::~VMem(void)
void* VMem::Malloc(size_t size)
{
- void *ptr = NULL;
-
- if (size <= 0)
- return NULL;
-
- ptr = malloc(size);
- if (ptr)
- {
- if(m_allocList)
- m_allocList->insert(ptr);
- }
- else
- {
- m_dontTouchHashLists = TRUE;
- if (m_allocList)
- {
- m_allocList->forAll(fnFreeMemEntry, (void*) this);
- delete m_allocList;
- m_allocList = NULL;
- }
- m_dontTouchHashLists = FALSE;
-
- // Serious error since memory allocation falied. So, exiting...
- ExitThread(TSR_THREAD, 1);
- }
-
- return(ptr);
+ void *ptr = NULL;
+
+ if (size <= 0)
+ return NULL;
+
+ ptr = malloc(size);
+ if (ptr)
+ {
+ if(m_allocList)
+ m_allocList->insert(ptr);
+ }
+ else
+ {
+ m_dontTouchHashLists = TRUE;
+ if (m_allocList)
+ {
+ m_allocList->forAll(fnFreeMemEntry, (void*) this);
+ delete m_allocList;
+ m_allocList = NULL;
+ }
+ m_dontTouchHashLists = FALSE;
+
+ // Serious error since memory allocation falied. So, exiting...
+ ExitThread(TSR_THREAD, 1);
+ }
+
+ return(ptr);
}
@@ -200,7 +200,7 @@ void* VMem::Malloc(size_t size)
Description : Reallocates block of memory.
Parameters : block (IN) - Points to a previously allocated memory block.
- size (IN) - Size of memory to be allocated.
+ size (IN) - Size of memory to be allocated.
Returns : Pointer to the allocated memory block.
@@ -208,38 +208,38 @@ void* VMem::Malloc(size_t size)
void* VMem::Realloc(void* block, size_t size)
{
- void *ptr = NULL;
-
- if (size <= 0)
- return NULL;
-
- ptr = realloc(block, size);
- if (ptr)
- {
- if (block)
- {
- if (m_allocList)
- m_allocList->remove(block);
- }
- if (m_allocList)
- m_allocList->insert(ptr);
- }
- else
- {
- m_dontTouchHashLists = TRUE;
- if (m_allocList)
- {
- m_allocList->forAll(fnFreeMemEntry, (void*) this);
- delete m_allocList;
- m_allocList = NULL;
- }
- m_dontTouchHashLists = FALSE;
-
- // Serious error since memory allocation falied. So, exiting...
- ExitThread(TSR_THREAD, 1);
- }
-
- return(ptr);
+ void *ptr = NULL;
+
+ if (size <= 0)
+ return NULL;
+
+ ptr = realloc(block, size);
+ if (ptr)
+ {
+ if (block)
+ {
+ if (m_allocList)
+ m_allocList->remove(block);
+ }
+ if (m_allocList)
+ m_allocList->insert(ptr);
+ }
+ else
+ {
+ m_dontTouchHashLists = TRUE;
+ if (m_allocList)
+ {
+ m_allocList->forAll(fnFreeMemEntry, (void*) this);
+ delete m_allocList;
+ m_allocList = NULL;
+ }
+ m_dontTouchHashLists = FALSE;
+
+ // Serious error since memory allocation falied. So, exiting...
+ ExitThread(TSR_THREAD, 1);
+ }
+
+ return(ptr);
}
@@ -251,7 +251,7 @@ void* VMem::Realloc(void* block, size_t size)
Description : Allocates and clears memory space for an array of objects.
Parameters : num (IN) - Specifies the number of objects.
- size (IN) - Size of each object.
+ size (IN) - Size of each object.
Returns : Pointer to the allocated memory block.
@@ -259,33 +259,33 @@ void* VMem::Realloc(void* block, size_t size)
void* VMem::Calloc(size_t num, size_t size)
{
- void *ptr = NULL;
-
- if (size <= 0)
- return NULL;
-
- ptr = calloc(num, size);
- if (ptr)
- {
- if(m_allocList)
- m_allocList->insert(ptr);
- }
- else
- {
- m_dontTouchHashLists = TRUE;
- if (m_allocList)
- {
- m_allocList->forAll(fnFreeMemEntry, (void*) this);
- delete m_allocList;
- m_allocList = NULL;
- }
- m_dontTouchHashLists = FALSE;
-
- // Serious error since memory allocation falied. So, exiting...
- ExitThread(TSR_THREAD, 1);
- }
-
- return(ptr);
+ void *ptr = NULL;
+
+ if (size <= 0)
+ return NULL;
+
+ ptr = calloc(num, size);
+ if (ptr)
+ {
+ if(m_allocList)
+ m_allocList->insert(ptr);
+ }
+ else
+ {
+ m_dontTouchHashLists = TRUE;
+ if (m_allocList)
+ {
+ m_allocList->forAll(fnFreeMemEntry, (void*) this);
+ delete m_allocList;
+ m_allocList = NULL;
+ }
+ m_dontTouchHashLists = FALSE;
+
+ // Serious error since memory allocation falied. So, exiting...
+ ExitThread(TSR_THREAD, 1);
+ }
+
+ return(ptr);
}
@@ -304,35 +304,35 @@ void* VMem::Calloc(size_t num, size_t size)
void VMem::Free(void* p)
{
- // Final clean up, free all the nodes from the hash list
- if (m_dontTouchHashLists)
- {
- if(p)
- {
- free(p);
- p = NULL;
- }
- }
- else
- {
- if(p && m_allocList)
- {
- if (m_allocList->remove(p))
- {
- free(p);
- p = NULL;
- }
- else
- {
- // If it comes here, that means that the memory pointer is not contained in the hash list.
- // But no need to free now, since if is deleted here, it will result in an abend!!
- // If the memory is still there, it will be cleaned during final cleanup anyway.
- }
- }
- }
-
-
- return;
+ // Final clean up, free all the nodes from the hash list
+ if (m_dontTouchHashLists)
+ {
+ if(p)
+ {
+ free(p);
+ p = NULL;
+ }
+ }
+ else
+ {
+ if(p && m_allocList)
+ {
+ if (m_allocList->remove(p))
+ {
+ free(p);
+ p = NULL;
+ }
+ else
+ {
+ // If it comes here, that means that the memory pointer is not contained in the hash list.
+ // But no need to free now, since if is deleted here, it will result in an abend!!
+ // If the memory is still there, it will be cleaned during final cleanup anyway.
+ }
+ }
+ }
+
+
+ return;
}
diff --git a/NetWare/win32ish.h b/NetWare/win32ish.h
index f6603d50f4..7e94a1c0c2 100644
--- a/NetWare/win32ish.h
+++ b/NetWare/win32ish.h
@@ -22,11 +22,11 @@
#ifndef BOOL
- typedef unsigned int BOOL;
+ typedef unsigned int BOOL;
#endif
#ifndef DWORD
- typedef unsigned long DWORD;
+ typedef unsigned long DWORD;
#endif
typedef DWORD LCID;
@@ -34,11 +34,11 @@ typedef long HRESULT;
typedef void* LPVOID;
#ifndef TRUE
- #define TRUE 1
+ #define TRUE 1
#endif
#ifndef FALSE
- #define FALSE 0
+ #define FALSE 0
#endif