ooRexx  4.2.0-source
About: ooRexx (Open Object Rexx) is a free implementation of Object Rexx. Object Rexx is an enhancement of the classic Rexx interpreter; a full-featured programming language with a human-oriented syntax.
  Fossies Dox: ooRexx-4.2.0-source.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

SysInterpreterInstance.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 /* Implementation of the SysInterpreterInstance class */
40 /* */
41 /******************************************************************************/
42 
43 #include "InterpreterInstance.hpp"
44 #include "SystemInterpreter.hpp"
45 #include "RexxActivation.hpp"
46 
47 
56 {
57  instance = i;
58 
59  externalTraceEnabled = false; // off by default
60  /* scan current environment, */
61  const char *rxTraceBuf = getenv("RXTRACE");
62  if (rxTraceBuf != NULL)
63  {
64  if (!Utilities::strCaselessCompare(rxTraceBuf, "ON")) /* request to turn on? */
65  {
66  externalTraceEnabled = true; // turn on tracing of top-level activations for this instance
67  }
68  }
69 
70  // add our default search extension as both upper and lower case
71  addSearchExtension(".REX");
72  addSearchExtension(".rex");
73 }
74 
75 
80 {
81 }
82 
83 
90 {
91  // if the extension is not already in the extension list, add it
92  RexxString *ext = new_string(name);
94  {
96  }
97 }
98 
100 /******************************************************************************/
101 /* Function: Do system specific program setup */
102 /******************************************************************************/
103 {
104  // trace this activation if turned on externally when the instance was started
106  {
107  activation->enableExternalTrace();
108  }
109 }
110 
118 SysSearchPath::SysSearchPath(const char *parentDir, const char *extensionPath)
119 {
120  const char *sysPath = getenv("PATH");
121  const char *rexxPath = getenv("REXX_PATH");
122  size_t sysPathSize = sysPath == NULL ? 0 : strlen(sysPath);
123  size_t rexxPathSize = rexxPath == NULL ? 0 : strlen(rexxPath);
124  size_t parentSize = parentDir == NULL ? 0 : strlen(parentDir);
125  size_t extensionSize = extensionPath == NULL ? 0 : strlen(extensionPath);
126 
127 
128  // enough room for separators and a terminating null
129  path = (char *)SystemInterpreter::allocateResultMemory(sysPathSize + rexxPathSize + parentSize + extensionSize + 16);
130  *path = '\0'; // add a null character so strcat can work
131  if (parentDir != NULL)
132  {
133  strcpy(path, parentDir);
134  strcat(path, ":");
135  }
136 
137  // add on the current directory
138  strcat(path, ".:");
139 
140  if (extensionPath != NULL)
141  {
142  strcat(path, extensionPath);
143  if (path[strlen(path) - 1] != ':')
144  {
145  strcat(path, ":");
146  }
147  }
148 
149  // the rexxpath
150  if (rexxPath != NULL)
151  {
152  strcat(path, rexxPath);
153  if (path[strlen(path) - 1] != ':')
154  {
155  strcat(path, ":");
156  }
157  }
158 
159  // and finally the normal path
160  if (sysPath != NULL)
161  {
162  strcat(path, sysPath);
163  if (path[strlen(path) - 1] != ':')
164  {
165  strcat(path, ":");
166  }
167  }
168 }
169 
170 
175 {
177 }
SystemInterpreter::releaseResultMemory
static void releaseResultMemory(void *)
Definition: MemorySupport.cpp:75
TheFalseObject
#define TheFalseObject
Definition: RexxCore.h:184
RexxActivation.hpp
SysInterpreterInstance::terminate
void terminate()
Definition: SysInterpreterInstance.cpp:79
SysSearchPath::path
char * path
Definition: SysInterpreterInstance.hpp:75
InterpreterInstance::searchExtensions
RexxList * searchExtensions
Definition: InterpreterInstance.hpp:141
SystemInterpreter::allocateResultMemory
static void * allocateResultMemory(size_t)
Definition: MemorySupport.cpp:63
SysSearchPath::SysSearchPath
SysSearchPath(const char *parent, const char *extension)
Definition: SysInterpreterInstance.cpp:118
SysInterpreterInstance::initialize
void initialize(InterpreterInstance *i, RexxOption *options)
Definition: SysInterpreterInstance.cpp:55
SysInterpreterInstance::setupProgram
void setupProgram(RexxActivation *activation)
Definition: SysInterpreterInstance.cpp:99
SysSearchPath::~SysSearchPath
~SysSearchPath()
Definition: SysInterpreterInstance.cpp:174
new_string
RexxString * new_string(const char *s, stringsize_t l)
Definition: StringClass.hpp:524
RexxList::hasItem
RexxObject * hasItem(RexxObject *)
Definition: ListClass.cpp:993
SystemInterpreter.hpp
RexxList::append
RexxObject * append(RexxObject *)
Definition: ListClass.cpp:537
RexxOption
Definition: oorexxapi.h:416
SysInterpreterInstance::addSearchExtension
void addSearchExtension(const char *name)
Definition: SysInterpreterInstance.cpp:89
RexxActivation::enableExternalTrace
void enableExternalTrace()
Definition: RexxActivation.cpp:3617
RexxActivation
Definition: RexxActivation.hpp:156
InterpreterInstance
Definition: InterpreterInstance.hpp:55
SysInterpreterInstance::instance
InterpreterInstance * instance
Definition: SysInterpreterInstance.hpp:64
SysInterpreterInstance::externalTraceEnabled
bool externalTraceEnabled
Definition: SysInterpreterInstance.hpp:65
InterpreterInstance.hpp
Utilities::strCaselessCompare
static int strCaselessCompare(const char *opt1, const char *opt2)
Definition: Utilities.cpp:82
RexxString
Definition: StringClass.hpp:119