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)  

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 /* REXX AIX Support aixmisc.c */
40 /* */
41 /* Miscellaneous AIX specific routines. */
42 /* */
43 /******************************************************************************/
44 
45 /*********************************************************************/
46 /* */
47 /* Function: Miscellaneous system specific routines */
48 /* */
49 /*********************************************************************/
50 #ifdef HAVE_CONFIG_H
51  #include "config.h"
52 #endif
53 
54 #include "RexxCore.h"
55 #include "StringClass.hpp"
56 // #include "RexxNativeAPI.h" /* THUTHUREXX native interface*/
57 #include "DirectoryClass.hpp"
58 #include "RexxActivity.hpp"
59 #include "RexxActivation.hpp"
60 #include "ActivityManager.hpp"
61 #include "PointerClass.hpp"
62 #include "SystemInterpreter.hpp"
63 #include <stdlib.h>
64 #include <unistd.h>
65 #include <errno.h>
66 
67 #if defined( HAVE_SIGNAL_H )
68  #include <signal.h>
69 #endif
70 
71 #if defined( HAVE_SYS_SIGNAL_H )
72  #include <sys/signal.h>
73 #endif
74 
75 #if defined( HAVE_SYS_LDR_H )
76  #include <sys/ldr.h>
77 #endif
78 
79 #if defined( HAVE_FILEHDR_H )
80  #include <filehdr.h>
81 #endif
82 
83 #include <dlfcn.h>
84 
85 #if defined( HAVE_SYS_UTSNAME_H )
86  #include <sys/utsname.h> /* get the uname() function */
87 #endif
88 
89 #define LOADED_OBJECTS 100
90 
92 {
93  return getSystemName(); // this is the same
94 }
95 
97 /******************************************************************************/
98 /* Function: Get System Name */
99 /******************************************************************************/
100 {
101 #if defined(AIX)
102  return new_string("AIX");
103 #elif defined(OPSYS_SUN)
104  return new_string("SUNOS");
105 #else
106  return new_string("LINUX");
107 #endif
108 
109 }
110 
111 
113 /******************************************************************************/
114 /* Function: Return the system specific version identifier that is stored */
115 /* in the image. */
116 /******************************************************************************/
117 {
118  struct utsname info; /* info structur */
119 
120  uname(&info); /* get the info */
121 
122  return new_string(info.release); /* return as a string */
123 }
124 
125 
126 #define MAX_ADDRESS_NAME_LENGTH 250 /* maximum command environment name */
127 
128 
135 {
136  /* name too long? */
137  if (name->getLength() > MAX_ADDRESS_NAME_LENGTH)
138  {
139  /* go report an error */
141  }
142 }
143 
145 /******************************************************************************/
146 /* Function: Produce a system specific source string */
147 /******************************************************************************/
148 {
149  RexxString * source_string; /* final source string */
150  char * outPtr;
151  source_string = raw_string(1+sizeof(ORX_SYS_STR)+callType->getLength()+programName->getLength());
152  outPtr = source_string->getWritableData(); /* point to result Data. */
153 
154  strcpy(outPtr, ORX_SYS_STR); /* copy the system name */
155  outPtr +=sizeof(ORX_SYS_STR) - 1; /* step past the name */
156  *outPtr++ = ' '; /* put a blank between */
157  /* copy the call type */
158  memcpy(outPtr, callType->getStringData(), callType->getLength());
159  outPtr += callType->getLength(); /* step over the call type */
160  *outPtr++ = ' '; /* put a blank between */
161  /* copy the system name */
162  memcpy(outPtr, programName->getStringData(), programName->getLength());
163  return source_string; /* return the source string */
164 }
165 
SystemInterpreter::getSystemVersion
static RexxString * getSystemVersion()
Definition: MiscSystem.cpp:112
RexxActivation.hpp
SystemInterpreter::getSystemName
static RexxString * getSystemName()
Definition: MiscSystem.cpp:96
ActivityManager.hpp
PointerClass.hpp
RexxString::getLength
size_t getLength()
Definition: StringClass.hpp:330
reportException
void reportException(wholenumber_t error)
Definition: ActivityManager.hpp:136
RexxString::getWritableData
char * getWritableData()
Definition: StringClass.hpp:334
MAX_ADDRESS_NAME_LENGTH
#define MAX_ADDRESS_NAME_LENGTH
Definition: MiscSystem.cpp:126
SystemInterpreter::validateAddressName
static void validateAddressName(RexxString *name)
Definition: MiscSystem.cpp:134
RexxString::getStringData
const char * getStringData()
Definition: StringClass.hpp:333
raw_string
RexxString * raw_string(stringsize_t l)
Definition: StringClass.hpp:529
new_string
RexxString * new_string(const char *s, stringsize_t l)
Definition: StringClass.hpp:524
SystemInterpreter.hpp
StringClass.hpp
Error_Environment_name_name
#define Error_Environment_name_name
Definition: RexxErrorCodes.h:245
SystemInterpreter::getInternalSystemName
static RexxString * getInternalSystemName()
Definition: MiscSystem.cpp:91
SystemInterpreter::getSourceString
static RexxString * getSourceString(RexxString *callType, RexxString *programName)
Definition: MiscSystem.cpp:144
RexxActivity.hpp
RexxCore.h
DirectoryClass.hpp
RexxString
Definition: StringClass.hpp:119