unix/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 
91 #define MAX_ADDRESS_NAME_LENGTH 250 /* maximum command environment name */
92 
93 
94 /**
95  * Validate an external address name.
96  *
97  * @param Name The name to validate
98  */
100 {
101  /* name too long? */
102  if (name->getLength() > MAX_ADDRESS_NAME_LENGTH)
103  {
104  /* go report an error */
106  }
107 }
108 
110 /******************************************************************************/
111 /* Function: Produce a system specific source string */
112 /******************************************************************************/
113 {
114  RexxString * source_string; /* final source string */
115  char * outPtr;
116  source_string = raw_string(1+sizeof(ORX_SYS_STR)+callType->getLength()+programName->getLength());
117  outPtr = source_string->getWritableData(); /* point to result Data. */
118 
119  strcpy(outPtr, ORX_SYS_STR); /* copy the system name */
120  outPtr +=sizeof(ORX_SYS_STR) - 1; /* step past the name */
121  *outPtr++ = ' '; /* put a blank between */
122  /* copy the call type */
123  memcpy(outPtr, callType->getStringData(), callType->getLength());
124  outPtr += callType->getLength(); /* step over the call type */
125  *outPtr++ = ' '; /* put a blank between */
126  /* copy the system name */
127  memcpy(outPtr, programName->getStringData(), programName->getLength());
128  return source_string; /* return the source string */
129 }
130 
void reportException(wholenumber_t error)
#define Error_Environment_name_name
RexxString * raw_string(stringsize_t l)
size_t getLength()
const char * getStringData()
char * getWritableData()
static RexxString * getSourceString(RexxString *callType, RexxString *programName)
static void validateAddressName(RexxString *name)
#define MAX_ADDRESS_NAME_LENGTH