1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
|
/*
* The Regina Rexx Interpreter
* Copyright (C) 1992-1994 Anders Christensen <anders@pvv.unit.no>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef OS2
# define INCL_DOSPROCESS
#endif
#ifdef __EMX__
# define DONT_TYPEDEF_PFN
# include <io.h>
# include <os2emx.h>
# include <fcntl.h>
#endif
#if defined(__WATCOMC__) && defined(OS2)
# include <os2.h>
# define DONT_TYPEDEF_PFN
#endif
#if defined(__WATCOMC__) && !defined(__QNX__)
# include <i86.h>
# if defined(OS2)
# define DONT_TYPEDEF_PFN
# include <os2.h>
# endif
#endif
#include "rexx.h"
#include <errno.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_ASSERT_H
# include <assert.h>
#endif
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#include <time.h>
#if defined(VMS)
# include <stat.h>
#elif defined(OS2)
# include <sys/stat.h>
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
#elif defined(__WATCOMC__) || defined(_MSC_VER)
# include <sys/stat.h>
# include <fcntl.h>
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
# if defined(_MSC_VER) && !defined(__WINS__)
# include <direct.h>
# include <io.h>
# endif
#elif defined(MAC)
# include "mac.h"
#else
# include <sys/stat.h>
# ifdef HAVE_PWD_H
# include <pwd.h>
# endif
# ifdef HAVE_GRP_H
# include <grp.h>
# endif
# include <fcntl.h>
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
#endif
#ifdef DJGPP
# include <pc.h>
# include <dir.h>
#endif
#ifdef HAVE_DIRECT_H
# include <direct.h>
#endif
#ifdef WIN32
# if defined(__BORLANDC__)
# include <dir.h>
# endif
# if defined(_MSC_VER)
# if _MSC_VER >= 1100
/* Stupid MSC can't compile own headers without warning at least in VC 5.0 */
# pragma warning(disable: 4115 4201 4214 4514)
# endif
# endif
# include <windows.h>
# ifdef _MSC_VER
# if _MSC_VER >= 1100
# pragma warning(default: 4115 4201 4214)
# endif
# endif
# if defined(__WATCOMC__)
# include <io.h>
# endif
#endif
/*
* Since development of Ultrix has ceased, and they never managed to
* fix a few things, we want to define a few things, just in order
* to kill a few warnings ...
*/
#if defined(FIX_PROTOS) && defined(FIX_ALL_PROTOS) && defined(ultrix)
int fstat( int fd, struct stat *buf ) ;
int stat( char *path, struct stat *buf ) ;
#endif
streng *os2_directory( tsd_t *TSD, cparamboxptr parms )
{
streng *result=NULL ;
int ok=HOOK_GO_ON ;
char *path;
checkparam( parms, 0, 1 , "DIRECTORY" ) ;
if (parms&&parms->value)
{
if (TSD->systeminfo->hooks & HOOK_MASK(HOOK_SETCWD))
ok = hookup_output( TSD, HOOK_SETCWD, parms->value ) ;
if (ok==HOOK_GO_ON)
{
path = str_of( TSD, parms->value ) ;
if (chdir( path ) )
{
FreeTSD( path ) ;
return nullstringptr() ;
}
FreeTSD( path ) ;
}
}
/*
* The remainder of this is for obtaining the current working directory...
*/
if (TSD->systeminfo->hooks & HOOK_MASK(HOOK_GETCWD))
ok = hookup_input( TSD, HOOK_GETCWD, &result ) ;
if (ok==HOOK_GO_ON)
{
result = Str_makeTSD( REXX_PATH_MAX );
my_fullpath( result->value, "." );
result->len = strlen( result->value );
}
return result;
}
streng *os2_beep( tsd_t *TSD, cparamboxptr parms )
{
int freq=0,dur=1;
checkparam( parms, 1, 2 , "BEEP" ) ;
if (parms && parms->value)
{
freq = atopos( TSD, parms->value, "BEEP", 1 ) ;
if (freq < 37 || freq > 32767)
exiterror( ERR_INCORRECT_CALL, 0 );
}
if (parms->next && parms->next->value)
{
dur = atopos( TSD, parms->next->value, "BEEP", 2 ) ;
if (dur < 1 || freq > 60000)
exiterror( ERR_INCORRECT_CALL, 0 );
}
#if defined(WIN32)
Beep( (DWORD)freq, (DWORD)dur );
#elif defined (__EMX__)
if (_osmode != DOS_MODE)
DosBeep( freq, dur );
else
{
int hdl;
/* stdout and/or stderr may be redirected */
if ((hdl = open("con", O_WRONLY)) != -1)
{
write(hdl, "\x07" /* ^G == bell */, 1);
close(hdl);
}
}
#elif defined(DOS)
putchar(7);
#elif defined(OS2)
DosBeep( freq, dur );
#elif defined(__QNX__)
printf("\a");
#elif defined(__WATCOMC__)
sound( freq );
delay( dur );
nosound( );
#elif defined(__DJGPP__)
sound( freq );
delay( dur );
nosound( );
#elif defined(__WINS__) || defined(__EPOC32__)
beep( freq, dur );
#endif
return nullstringptr();
}
streng *os2_filespec( tsd_t *TSD, cparamboxptr parms )
{
streng *result=NULL ;
streng *inpath=NULL;
char format = '?' ;
#if defined(DJGPP)
char fdrive[MAXDRIVE], fdir[MAXDIR], fname[MAXFILE], fext[MAXEXT];
#elif defined(__EMX__)
char fdrive[_MAX_DRIVE], fdir[_MAX_DIR], fname[_MAX_FNAME], fext[_MAX_EXT];
#elif defined(HAVE__SPLITPATH2)
char fpath[_MAX_PATH2], *fdrive=NULL, *fdir=NULL, *fname=NULL, *fext=NULL;
#elif defined(HAVE__SPLITPATH)
char fdrive[_MAX_PATH], fdir[_MAX_PATH], fname[_MAX_PATH], fext[_MAX_PATH];
#else
char fpath[REXX_PATH_MAX+5],*fdrive=NULL,*fdir=NULL,*fname=NULL,*fext=NULL;
#endif
checkparam( parms, 2, 2 , "FILESPEC" ) ;
format = getoptionchar( TSD, parms->value, "FILESPEC", 1, "DNP", "?" ) ;
inpath = Str_dupstrTSD( parms->next->value ) ;
#if defined(DJGPP)
fnsplit( inpath->value, fdrive, fdir, fname, fext );
#elif defined(__EMX__)
_splitpath( inpath->value, fdrive, fdir, fname, fext );
#elif defined(HAVE__SPLITPATH2)
_splitpath2( inpath->value, fpath, &fdrive, &fdir, &fname, &fext );
#elif defined(HAVE__SPLITPATH)
_splitpath( inpath->value, fdrive, fdir, fname, fext );
#else
my_splitpath2( inpath->value, fpath, &fdrive, &fdir, &fname, &fext );
#endif
switch( format )
{
case 'D':
result = Str_creTSD( fdrive );
break;
case 'N':
result = Str_makeTSD( strlen( fname) + strlen( fext ) );
Str_catstrTSD( result, fname );
Str_catstrTSD( result, fext );
break;
case 'P':
result = Str_creTSD( fdir );
break;
}
FreeTSD( inpath );
return result;
}
|