X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/78196db058807d48f2c755ea8e4fa61c11bee0cc..bd4675851936488a7b28a813c5b60248be3e733b:/NetWare/Nwmain.c diff --git a/NetWare/Nwmain.c b/NetWare/Nwmain.c index 0e8bf0b..0b9728a 100644 --- a/NetWare/Nwmain.c +++ b/NetWare/Nwmain.c @@ -1,6 +1,6 @@ /* - * Copyright © 2001 Novell, Inc. All Rights Reserved. + * Copyright © 2001 Novell, Inc. All Rights Reserved. * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -119,7 +119,11 @@ int fnFpSetMode(FILE* fp, int mode, int *err); void fnGetPerlScreenName(char *sPerlScreenName); - +void fnGetPerlScreenName(char *sPerlScreenName); +void fnSetupNamespace(void); +char *getcwd(char [], int); +void fnRunScript(ScriptData* psdata); +void nw_freeenviron(); /*============================================================================================ @@ -160,12 +164,12 @@ void main(int argc, char *argv[]) // Ensure that we have a "temp" directory fnSetupNamespace(); - if (access(DEFPERLTEMP, 0) != 0) - mkdir(DEFPERLTEMP); + 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 verions were creating temporary files (in perl.c file) 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. @@ -176,8 +180,8 @@ void main(int argc, char *argv[]) { char sNUL[MAX_DN_BYTES] = {'\0'}; - strcpy(sNUL, DEFPERLROOT); - strcat(sNUL, "\\nul"); + strcpy(sNUL, NWDEFPERLROOT); + strcat(sNUL, "\\nwnul"); if (access((const char *)sNUL, 0) != 0) { // The file, "nul" is not found and so create the file. @@ -299,7 +303,7 @@ void fnSigTermHandler(int sig) // while (!fnTerminateThreadInfo() && k < 5) { - sleep(1); + nw_sleep(1); k++; } } @@ -308,8 +312,8 @@ void fnSigTermHandler(int sig) { char sNUL[MAX_DN_BYTES] = {'\0'}; - strcpy(sNUL, DEFPERLROOT); - strcat(sNUL, "\\nul"); + strcpy(sNUL, NWDEFPERLROOT); + strcat(sNUL, "\\nwnul"); if (access((const char *)sNUL, 0) == 0) { // The file, "nul" is found and so delete it. @@ -525,12 +529,11 @@ void fnLaunchPerl(void* context) errno = 0; - if (psdata->m_fromConsole) { // get the default working directory name // - defaultDir = fnNwGetEnvironmentStr("PERL_ROOT", DEFPERLROOT); + defaultDir = fnNwGetEnvironmentStr("PERL_ROOT", NWDEFPERLROOT); } else defaultDir = getcwd(curdir, sizeof(curdir)-1); @@ -544,12 +547,10 @@ void fnLaunchPerl(void* context) 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 @@ -561,7 +562,6 @@ void fnLaunchPerl(void* context) (*ucsterminate)(); } - if (psdata->m_fromConsole) { // change thread groups for the call to free the memory @@ -603,7 +603,6 @@ void fnLaunchPerl(void* context) // ExitThread(EXIT_THREAD, 0); #endif - return; } @@ -650,13 +649,11 @@ void fnRunScript(ScriptData* psdata) 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 // @@ -667,7 +664,6 @@ void fnRunScript(ScriptData* psdata) return; } - // Initialise the variables pclp->m_isValid = TRUE; pclp->m_redirInName = NULL; @@ -690,7 +686,6 @@ void fnRunScript(ScriptData* psdata) 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) @@ -715,7 +710,6 @@ void fnRunScript(ScriptData* psdata) return; } - // Parse the command line fnCommandLineParser(pclp, (char *)psdata->m_commandLine, FALSE); if (!pclp->m_isValid) @@ -767,7 +761,6 @@ void fnRunScript(ScriptData* psdata) pclp->m_redirBothName = NULL; } - // Signal a semaphore, if indicated by "-{" option, to indicate that // the script has terminated and files are closed // @@ -787,7 +780,6 @@ void fnRunScript(ScriptData* psdata) 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, @@ -836,7 +828,6 @@ void fnRunScript(ScriptData* psdata) else if (use_system_console) CreateScreen((char *)"System Console", 0); - if (pclp->m_redirInName) { if ((stdin_fd = fileno(stdin)) != -1) @@ -938,14 +929,12 @@ void fnRunScript(ScriptData* psdata) } } - 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) @@ -1000,9 +989,14 @@ void fnRunScript(ScriptData* psdata) 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); +**/ + setmode(stdin, O_TEXT); + setmode(stdout, O_TEXT); // Cleanup if(pclp->m_argv) @@ -1052,7 +1046,6 @@ void fnRunScript(ScriptData* psdata) pclp->m_redirBothName = NULL; } - // Signal a semaphore, if indicated by -{ option, to indicate that // the script has terminated and files are closed // @@ -1072,12 +1065,15 @@ void fnRunScript(ScriptData* psdata) } if(env) + { fnDestroyEnvBlock(env); + env = NULL; + } + fnUnregisterWithThreadTable(); // Remove the thread context set during Perl_set_context Remove_Thread_Ctx(); - return; } @@ -1114,7 +1110,6 @@ void fnSetUpEnvBlock(char*** penv) // add one for null termination totalcnt++; - env = (char **) malloc (totalcnt * sizeof(char *)); if (env) { @@ -1223,7 +1218,6 @@ int fnFpSetMode(FILE* fp, int mode, int *err) PFFSETMODE pf_fsetmode; - if (mode == O_BINARY || mode == O_TEXT) { if (fp) @@ -1244,7 +1238,6 @@ int fnFpSetMode(FILE* fp, int mode, int *err) } if (errno) err = &errno; - } else { @@ -1258,7 +1251,6 @@ int fnFpSetMode(FILE* fp, int mode, int *err) err = &errno; } - return ret; } @@ -1282,7 +1274,6 @@ void fnInternalPerlLaunchHandler(char* cmdLine) 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.