2 static char *RCSid
= "$Id$";
6 * The Regina Rexx Interpreter
7 * Copyright (C) 1992-1994 Anders Christensen <anders@pvv.unit.no>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 # define INCL_DOSPROCESS
29 # define DONT_TYPEDEF_PFN
51 # include <sys/stat.h>
55 #elif defined(__WATCOMC__) || defined(_MSC_VER)
56 # include <sys/stat.h>
61 # if defined(_MSC_VER) && !defined(__WINS__)
68 # include <sys/stat.h>
92 # if defined(__BORLANDC__)
95 # if defined(_MSC_VER)
97 /* Stupid MSC can't compile own headers without warning at least in VC 5.0 */
98 # pragma warning(disable: 4115 4201 4214)
101 # include <windows.h>
103 # if _MSC_VER >= 1100
104 # pragma warning(default: 4115 4201 4214)
107 # if defined(__WATCOMC__)
113 * Since development of Ultrix has ceased, and they never managed to
114 * fix a few things, we want to define a few things, just in order
115 * to kill a few warnings ...
117 #if defined(FIX_PROTOS) && defined(FIX_ALL_PROTOS) && defined(ultrix)
118 int fstat( int fd
, struct stat
*buf
) ;
119 int stat( char *path
, struct stat
*buf
) ;
122 streng
*os2_directory( tsd_t
*TSD
, cparamboxptr parms
)
130 checkparam( parms
, 0, 1 , "DIRECTORY" ) ;
132 if (parms
&&parms
->value
)
134 path
= str_of( TSD
, parms
->value
) ;
138 return nullstringptr() ;
143 #if defined(HAVE__FULLPATH)
144 result
= Str_makeTSD( REXX_PATH_MAX
);
145 _fullpath(result
->value
, ".", REXX_PATH_MAX
);
146 # if defined(__EMX__)
148 * Convert / to \ as the API call doesn't do this for us
150 result
->len
= strlen( result
->value
) ;
151 for ( i
=0; i
< result
->len
; i
++)
153 if ( result
->value
[i
] == '/' )
154 result
->value
[i
] = '\\';
157 #elif defined(HAVE__TRUENAME)
158 result
= Str_makeTSD( _MAX_PATH
) ;
159 _truename(".", result
->value
);
161 result
= Str_makeTSD( 1024 ) ;
162 if (my_fullpath(result
->value
, ".", 1024) == -1)
163 result
= nullstringptr() ;
165 result
->len
= strlen( result
->value
) ;
170 streng
*os2_beep( tsd_t
*TSD
, cparamboxptr parms
)
174 checkparam( parms
, 2, 1 , "BEEP" ) ;
176 if (parms
&& parms
->value
)
178 freq
= atopos( TSD
, parms
->value
, "BEEP", 1 ) ;
179 if (freq
< 37 || freq
> 32767)
180 exiterror( ERR_INCORRECT_CALL
, 0 );
182 if (parms
->next
&& parms
->next
->value
)
184 dur
= atopos( TSD
, parms
->next
->value
, "BEEP", 2 ) ;
185 if (dur
< 1 || freq
> 60000)
186 exiterror( ERR_INCORRECT_CALL
, 0 );
190 Beep( (DWORD
)freq
, (DWORD
)dur
);
191 #elif defined (__EMX__)
192 if (_osmode
!= DOS_MODE
)
193 DosBeep( freq
, dur
);
198 /* stdout and/or stderr may be redirected */
199 if ((hdl
= open("con", O_WRONLY
)) != -1)
201 write(hdl
, "\x07" /* ^G == bell */, 1);
208 DosBeep( freq
, dur
);
209 #elif defined(__QNX__)
211 #elif defined(__WATCOMC__)
215 #elif defined(__DJGPP__)
219 #elif defined(__WINS__) || defined(__EPOC32__)
222 return nullstringptr();
225 streng
*os2_filespec( tsd_t
*TSD
, cparamboxptr parms
)
227 streng
*result
=NULL
;
231 char fdrive
[MAXDRIVE
], fdir
[MAXDIR
], fname
[MAXFILE
], fext
[MAXEXT
];
232 #elif defined(__EMX__)
233 char fdrive
[_MAX_DRIVE
], fdir
[_MAX_DIR
], fname
[_MAX_FNAME
], fext
[_MAX_EXT
];
234 #elif defined(HAVE__SPLITPATH2)
235 char fpath
[_MAX_PATH2
], *fdrive
=NULL
, *fdir
=NULL
, *fname
=NULL
, *fext
=NULL
;
236 #elif defined(HAVE__SPLITPATH)
237 char fdrive
[_MAX_PATH
], fdir
[_MAX_PATH
], fname
[_MAX_PATH
], fext
[_MAX_PATH
];
239 char fpath
[REXX_PATH_MAX
+5],*fdrive
=NULL
,*fdir
=NULL
,*fname
=NULL
,*fext
=NULL
;
242 checkparam( parms
, 2, 2 , "FILESPEC" ) ;
243 format
= getoptionchar( TSD
, parms
->value
, "FILESPEC", 1, "DNP", "?" ) ;
244 inpath
= Str_dupstrTSD( parms
->next
->value
) ;
246 fnsplit( inpath
->value
, fdrive
, fdir
, fname
, fext
);
247 #elif defined(__EMX__)
248 _splitpath( inpath
->value
, fdrive
, fdir
, fname
, fext
);
249 #elif defined(HAVE__SPLITPATH2)
250 _splitpath2( inpath
->value
, fpath
, &fdrive
, &fdir
, &fname
, &fext
);
251 #elif defined(HAVE__SPLITPATH)
252 _splitpath( inpath
->value
, fdrive
, fdir
, fname
, fext
);
254 my_splitpath2( inpath
->value
, fpath
, &fdrive
, &fdir
, &fname
, &fext
);
259 result
= Str_creTSD( fdrive
);
262 result
= Str_makeTSD( strlen( fname
) + strlen( fext
) );
263 Str_catstrTSD( result
, fname
);
264 Str_catstrTSD( result
, fext
);
267 result
= Str_creTSD( fdir
);