2 * The Regina Rexx Interpreter
3 * Copyright (C) 1992-1994 Anders Christensen <anders@pvv.unit.no>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 # define INCL_DOSPROCESS
25 # define DONT_TYPEDEF_PFN
31 #if defined(__WATCOMC__) && defined(OS2)
33 # define DONT_TYPEDEF_PFN
36 #if defined(__WATCOMC__) && !defined(__QNX__)
39 # define DONT_TYPEDEF_PFN
59 # include <sys/stat.h>
63 #elif defined(__WATCOMC__) || defined(_MSC_VER)
64 # include <sys/stat.h>
69 # if defined(_MSC_VER) && !defined(__WINS__)
76 # include <sys/stat.h>
99 # if defined(__BORLANDC__)
102 # if defined(_MSC_VER)
103 # if _MSC_VER >= 1100
104 /* Stupid MSC can't compile own headers without warning at least in VC 5.0 */
105 # pragma warning(disable: 4115 4201 4214 4514)
108 # include <windows.h>
110 # if _MSC_VER >= 1100
111 # pragma warning(default: 4115 4201 4214)
114 # if defined(__WATCOMC__)
120 * Since development of Ultrix has ceased, and they never managed to
121 * fix a few things, we want to define a few things, just in order
122 * to kill a few warnings ...
124 #if defined(FIX_PROTOS) && defined(FIX_ALL_PROTOS) && defined(ultrix)
125 int fstat( int fd
, struct stat
*buf
) ;
126 int stat( char *path
, struct stat
*buf
) ;
129 streng
*os2_directory( tsd_t
*TSD
, cparamboxptr parms
)
131 streng
*result
=NULL
;
135 checkparam( parms
, 0, 1 , "DIRECTORY" ) ;
137 if (parms
&&parms
->value
)
139 if (TSD
->systeminfo
->hooks
& HOOK_MASK(HOOK_SETCWD
))
140 ok
= hookup_output( TSD
, HOOK_SETCWD
, parms
->value
) ;
144 path
= str_of( TSD
, parms
->value
) ;
148 return nullstringptr() ;
155 * The remainder of this is for obtaining the current working directory...
157 if (TSD
->systeminfo
->hooks
& HOOK_MASK(HOOK_GETCWD
))
158 ok
= hookup_input( TSD
, HOOK_GETCWD
, &result
) ;
162 result
= Str_makeTSD( REXX_PATH_MAX
);
163 my_fullpath( result
->value
, "." );
164 result
->len
= strlen( result
->value
);
169 streng
*os2_beep( tsd_t
*TSD
, cparamboxptr parms
)
173 checkparam( parms
, 2, 1 , "BEEP" ) ;
175 if (parms
&& parms
->value
)
177 freq
= atopos( TSD
, parms
->value
, "BEEP", 1 ) ;
178 if (freq
< 37 || freq
> 32767)
179 exiterror( ERR_INCORRECT_CALL
, 0 );
181 if (parms
->next
&& parms
->next
->value
)
183 dur
= atopos( TSD
, parms
->next
->value
, "BEEP", 2 ) ;
184 if (dur
< 1 || freq
> 60000)
185 exiterror( ERR_INCORRECT_CALL
, 0 );
189 Beep( (DWORD
)freq
, (DWORD
)dur
);
190 #elif defined (__EMX__)
191 if (_osmode
!= DOS_MODE
)
192 DosBeep( freq
, dur
);
197 /* stdout and/or stderr may be redirected */
198 if ((hdl
= open("con", O_WRONLY
)) != -1)
200 write(hdl
, "\x07" /* ^G == bell */, 1);
207 DosBeep( freq
, dur
);
208 #elif defined(__QNX__)
210 #elif defined(__WATCOMC__)
214 #elif defined(__DJGPP__)
218 #elif defined(__WINS__) || defined(__EPOC32__)
221 return nullstringptr();
224 streng
*os2_filespec( tsd_t
*TSD
, cparamboxptr parms
)
226 streng
*result
=NULL
;
230 char fdrive
[MAXDRIVE
], fdir
[MAXDIR
], fname
[MAXFILE
], fext
[MAXEXT
];
231 #elif defined(__EMX__)
232 char fdrive
[_MAX_DRIVE
], fdir
[_MAX_DIR
], fname
[_MAX_FNAME
], fext
[_MAX_EXT
];
233 #elif defined(HAVE__SPLITPATH2)
234 char fpath
[_MAX_PATH2
], *fdrive
=NULL
, *fdir
=NULL
, *fname
=NULL
, *fext
=NULL
;
235 #elif defined(HAVE__SPLITPATH)
236 char fdrive
[_MAX_PATH
], fdir
[_MAX_PATH
], fname
[_MAX_PATH
], fext
[_MAX_PATH
];
238 char fpath
[REXX_PATH_MAX
+5],*fdrive
=NULL
,*fdir
=NULL
,*fname
=NULL
,*fext
=NULL
;
241 checkparam( parms
, 2, 2 , "FILESPEC" ) ;
242 format
= getoptionchar( TSD
, parms
->value
, "FILESPEC", 1, "DNP", "?" ) ;
243 inpath
= Str_dupstrTSD( parms
->next
->value
) ;
245 fnsplit( inpath
->value
, fdrive
, fdir
, fname
, fext
);
246 #elif defined(__EMX__)
247 _splitpath( inpath
->value
, fdrive
, fdir
, fname
, fext
);
248 #elif defined(HAVE__SPLITPATH2)
249 _splitpath2( inpath
->value
, fpath
, &fdrive
, &fdir
, &fname
, &fext
);
250 #elif defined(HAVE__SPLITPATH)
251 _splitpath( inpath
->value
, fdrive
, fdir
, fname
, fext
);
253 my_splitpath2( inpath
->value
, fpath
, &fdrive
, &fdir
, &fname
, &fext
);
258 result
= Str_creTSD( fdrive
);
261 result
= Str_makeTSD( strlen( fname
) + strlen( fext
) );
262 Str_catstrTSD( result
, fname
);
263 Str_catstrTSD( result
, fext
);
266 result
= Str_creTSD( fdir
);