windows/SystemInterpreter.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.ibm.com/developerworks/oss/CPLv1.0.htm */
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 /* REXX Windows Support */
40 /* */
41 /* Main Windows interpreter control. This is the preferred location for */
42 /* all platform dependent global variables. */
43 /* The interpreter does not instantiate an instance of this */
44 /* class, so most variables and methods should be static. */
45 /* */
46 /* */
47 /*****************************************************************************/
48 
49 #include "RexxCore.h"
50 #include "SystemInterpreter.hpp"
51 #include "Interpreter.hpp"
52 
53 #include <stdlib.h>
54 
60 
62 
63 
64 HINSTANCE SystemInterpreter::moduleHandle = 0; // handle to the interpeter DLL
65 
67 {
68  moduleHandle = mod;
69  // startup timeslice processing
71  // now do the platform independent startup
73 }
74 
75 
77 {
78  stopTimeSlice(); // shutdown the timer thread
79  // now do the platform independent shutdown
81 }
82 
83 
85 {
86 }
87 
88 
90 {
91 }
92 
93 
94 
95 void SystemInterpreter::live(size_t liveMark)
96 {
97 }
98 
99 void SystemInterpreter::liveGeneral(int reason)
100 {
101  if (!memoryObject.savingImage())
102  {
103  }
104 }
105 
106 
107 /**
108  * Load a message from the system message resources.
109  *
110  * @param code The error message identifier.
111  * @param buffer The buffer for the returned message.
112  * @param bufferLength
113  * The length of th message buffer.
114  *
115  * @return The success/failure indicator.
116  */
117 bool SystemInterpreter::loadMessage(wholenumber_t code, char *buffer, size_t bufferLength)
118 {
119  return LoadString(moduleHandle, (UINT)code, buffer, (int)bufferLength) != 0;
120 }
121 
122 /**
123  * Process a signal based on current command handler settings.
124  *
125  * @param dwCtrlType The type of exception.
126  *
127  * @return true if we handled the signal, false if it should be
128  * passed up the handler chain.
129  */
130 bool SystemInterpreter::processSignal(DWORD dwCtrlType)
131 {
132  /* Ignore Ctrl+C if console is running in console */
133  if (exceptionConsole)
134  {
135  GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, exceptionHostProcessId);
136  return true; /* ignore signal */
137  }
138 
140  {
141  GenerateConsoleCtrlEvent(CTRL_C_EVENT, exceptionHostProcessId);
142  TerminateProcess(exceptionHostProcess, -1);
143  }
144  // if this is a ctrl_C, try to halt all of the activities. If we hit this
145  // in a situation where we still have one pending, then we'll allow the system
146  // to kill the process.
147  if (dwCtrlType == CTRL_C_EVENT)
148  {
150  }
151  return true; /* ignore signal */
152 }
153 
#define OREF_NULL
Definition: RexxCore.h:60
RexxMemory memoryObject
Definition: RexxMemory.cpp:85
static void processStartup()
static bool haltAllActivities(RexxString *)
static void processShutdown()
bool savingImage()
Definition: RexxMemory.hpp:217
static bool processSignal(DWORD dwCtrlType)
static bool loadMessage(wholenumber_t code, char *buffer, size_t bufferLength)
static void startTimeSlice()
static void terminateInterpreter()
static void liveGeneral(int reason)
static void live(size_t)
ssize_t wholenumber_t
Definition: rexx.h:230