windows/MiscSystem.cpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.oorexx.org/license.html */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 /*********************************************************************/
39 /* */
40 /* Function: Miscellaneous system specific routines */
41 /* */
42 /*********************************************************************/
43 #include "RexxCore.h"
44 #include "StringClass.hpp"
45 #include "DirectoryClass.hpp"
46 #include "RexxActivity.hpp"
47 #include "RexxActivation.hpp"
48 #include "PointerClass.hpp"
49 #include <stdlib.h>
50 #include <process.h>
51 #include "malloc.h"
52 #include <signal.h>
53 #include "Interpreter.hpp"
54 #include "SystemInterpreter.hpp"
55 
57 /******************************************************************************/
58 /* Function: Get System Name */
59 /******************************************************************************/
60 {
61  char chVerBuf[26]; // buffer for version
62  strcpy(chVerBuf, "WindowsNT"); // Windows NT
63  return new_string(chVerBuf); /* return as a string */
64 }
65 
66 
68  RexxString * callType, /* type of call token */
69  RexxString * programName ) /* program name token */
70 /******************************************************************************/
71 /* Function: Produce a system specific source string */
72 /******************************************************************************/
73 {
74  char *outPtr; /* copy pointer */
75  const char *chSysName; /* copy pointer */
76 
77  RexxString *rsSysName = getSystemName(); /* start with the system stuff */
78  chSysName= rsSysName->getStringData();
79 
80  RexxString *source_string = raw_string(rsSysName->getLength() + 2 + callType->getLength() + programName->getLength());
81 
82  outPtr = source_string->getWritableData(); /* point to the result data */
83  strcpy(outPtr, chSysName); /* copy the system name */
84  outPtr +=rsSysName->getLength(); /* step past the name */
85  *outPtr++ = ' '; /* put a blank between */
86  /* copy the call type */
87  memcpy(outPtr, callType->getStringData(), callType->getLength());
88  outPtr += callType->getLength(); /* step over the call type */
89  *outPtr++ = ' '; /* put a blank between */
90  /* copy the system name */
91  memcpy(outPtr, programName->getStringData(), programName->getLength());
92  return source_string; /* return the source string */
93 }
94 
95 
96 int WinExceptionFilter( int xCode )
97 /******************************************************************************/
98 /* Function: Exception Filter used by Windows exception handling */
99 /******************************************************************************/
100 {
101  return EXCEPTION_CONTINUE_SEARCH;
102 }
103 
104 
105 #define MAX_ADDRESS_NAME_LENGTH 250 /* maximum command environment name */
106 
107 
108 
109 /**
110  * Validate an external address name.
111  *
112  * @param Name The name to validate
113  */
115 {
116  /* name too long? */
117  if (name->getLength() > MAX_ADDRESS_NAME_LENGTH)
118  {
119  /* go report an error */
121  }
122 }
123 
124 
125 /**
126  * This was an undocumented API prior to 4.0, but is known to have been used by
127  * some IBM applications. Therefore this was maintained solely for binary
128  * compatibility.
129  *
130  * However, it is now also used to turn off processing Windows messages in a
131  * special case situation. See the SysSemaphore::waitHandle() comments for more
132  * info. This is done on a per-thread basis, RexxSetProcessMessages() must be
133  * invoked while executing on the proper thread.
134  *
135  * @return TRUE always.
136  */
137 BOOL APIENTRY RexxSetProcessMessages(BOOL turnOn)
138 {
139  if ( ! turnOn )
140  {
142  }
143  return TRUE;
144 }
145 
void reportException(wholenumber_t error)
#define Error_Environment_name_name
RexxString * raw_string(stringsize_t l)
RexxString * new_string(const char *s, stringsize_t l)
size_t getLength()
const char * getStringData()
char * getWritableData()
static void setNoMessageLoop()
static RexxString * getSystemName()
static RexxString * getSourceString(RexxString *callType, RexxString *programName)
static void validateAddressName(RexxString *name)
#define MAX_ADDRESS_NAME_LENGTH
BOOL APIENTRY RexxSetProcessMessages(BOOL turnOn)
int WinExceptionFilter(int xCode)