update Open Watcom

git-svn-id: svn://kolibrios.org@698 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-01-18 16:44:45 +00:00
parent df2ca4bbd5
commit 25713b7524
106 changed files with 6575 additions and 11959 deletions

View File

@ -0,0 +1,43 @@
40
projectIdent
0
VpeMain
1
WRect
-32
330
10304
9950
2
MProject
3
MCommand
0
4
MCommand
0
1
5
WFileName
10
clib_r.tgt
6
WVList
1
7
VComponent
8
WRect
2760
200
5712
7390
0
0
9
WFileName
10
clib_r.tgt
0
0
7

View File

@ -0,0 +1,171 @@
/*
* _comdef.h Common Macro Definitions
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* This file is automatically generated. Do not edit directly.
*
* =========================================================================
*/
#ifndef _COMDEF_H_INCLUDED
#define _COMDEF_H_INCLUDED
#if !defined(_ENABLE_AUTODEPEND)
#pragma read_only_file;
#endif
#ifdef _WCDATA
#error The macro _WCDATA is reserved for use by the runtime library.
#endif
#ifdef _WCNEAR
#error The macro _WCNEAR is reserved for use by the runtime library.
#endif
#ifdef _WCFAR
#error The macro _WCFAR is reserved for use by the runtime library.
#endif
#ifdef _WCHUGE
#error The macro _WCHUGE is reserved for use by the runtime library.
#endif
#ifdef _WCI86NEAR
#error The macro _WCI86NEAR is reserved for use by the runtime library.
#endif
#ifdef _WCI86FAR
#error The macro _WCI86FAR is reserved for use by the runtime library.
#endif
#ifdef _WCI86HUGE
#error The macro _WCI86HUGE is reserved for use by the runtime library.
#endif
#ifdef _WCINTERRUPT
#error The macro _WCINTERRUPT is reserved for use by the runtime library.
#endif
#ifdef _WCUNALIGNED
#error The macro _WCUNALIGNED is reserved for use by the runtime library.
#endif
#if __WATCOMC__ > 1240
#define _WRTLCALL __declspec(__watcall)
#else
#define _WRTLCALL
#endif
#if defined(_M_IX86)
#define _WCNEAR __near
#define _WCFAR __far
#define _WCHUGE __huge
#define _WCINTERRUPT __interrupt
#define _WCUNALIGNED
#if defined(__386__)
#define _WCI86NEAR
#define _WCI86FAR
#define _WCI86HUGE
#else
#define _WCI86NEAR __near
#define _WCI86FAR __far
#define _WCI86HUGE __huge
#endif
#elif defined(__AXP__)
#define _WCNEAR
#define _WCFAR
#define _WCHUGE
#define _WCI86NEAR
#define _WCI86FAR
#define _WCI86HUGE
#define _WCINTERRUPT
#define _WCUNALIGNED __unaligned
#elif defined(__PPC__)
#define _WCNEAR
#define _WCFAR
#define _WCHUGE
#define _WCI86NEAR
#define _WCI86FAR
#define _WCI86HUGE
#define _WCINTERRUPT
#define _WCUNALIGNED __unaligned
#else
#define _WCNEAR
#define _WCFAR
#define _WCHUGE
#define _WCI86NEAR
#define _WCI86FAR
#define _WCI86HUGE
#define _WCINTERRUPT
#define _WCUNALIGNED
#endif
#if defined(M_I86HM)
#define _WCDATA _WCFAR
#elif defined(__SW_ND) || defined(__FUNCTION_DATA_ACCESS)
#define _WCDATA
#else
#define _WCDATA _WCNEAR
#endif
#if defined(__SW_BR)
#if defined(__NT__)
#define _WCRTLINK __declspec(dllimport) _WRTLCALL
#define _WCRTLINKD __declspec(dllimport)
#define _WMRTLINK __declspec(dllimport) _WRTLCALL
#define _WMRTLINKD __declspec(dllimport)
#define _WPRTLINK __declspec(dllimport) _WRTLCALL
#define _WPRTLINKD __declspec(dllimport)
#elif defined(__OS2__) && (defined(__386__) || defined(__PPC__))
#define _WCRTLINK _WRTLCALL
#define _WCRTLINKD
#define _WMRTLINK _WRTLCALL
#define _WMRTLINKD
#define _WPRTLINK _WRTLCALL
#define _WPRTLINKD
#else
#define _WCRTLINK _WRTLCALL
#define _WCRTLINKD
#define _WMRTLINK _WRTLCALL
#define _WMRTLINKD
#define _WPRTLINK _WRTLCALL
#define _WPRTLINKD
#endif
#else
#ifndef _WCRTLINK
#define _WCRTLINK _WRTLCALL
#endif
#ifndef _WCRTLINKD
#define _WCRTLINKD
#endif
#ifndef _WMRTLINK
#define _WMRTLINK _WRTLCALL
#endif
#ifndef _WMRTLINKD
#define _WMRTLINKD
#endif
#ifndef _WPRTLINK
#define _WPRTLINK _WRTLCALL
#endif
#ifndef _WPRTLINKD
#define _WPRTLINKD
#endif
#endif
/* control import modifier on intrinsic functions */
#ifndef _WCIRTLINK
#if defined(__INLINE_FUNCTIONS__)
#define _WCIRTLINK _WRTLCALL
#else
#define _WCIRTLINK _WCRTLINK
#endif
#endif
#ifndef _WMIRTLINK
#if defined(__NO_MATH_OPS) || defined(__AXP__) || defined(__PPC__)
#define _WMIRTLINK _WMRTLINK
#else
#define _WMIRTLINK _WRTLCALL
#endif
#endif
#ifndef _WPIRTLINK
#define _WPIRTLINK _WPRTLINK
#endif
/* for MS compatibility */
#ifndef _CRTAPI1
#define _CRTAPI1
#endif
#ifndef _CRTAPI2
#define _CRTAPI2
#endif
#ifndef _CRTIMP
#define _CRTIMP _WCRTLINK
#endif
#endif

View File

@ -24,18 +24,19 @@
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
* Description: Implements POSIX filelength() function and Watcom
* _filelength64().
*
****************************************************************************/
#include "variety.h"
/* most includes should go after this line */
#include <stdio.h>
#include <unistd.h>
#include "iomode.h"
#include "rtcheck.h"
#include "seterrno.h"
#include "qread.h"
#include <stdio.h>
typedef struct
{
@ -43,26 +44,30 @@ typedef struct
unsigned int offset;
}__file_handle;
typedef struct
{ DWORD attr;
DWORD flags;
DWORD cr_time;
DWORD cr_date;
DWORD acc_time;
DWORD acc_date;
DWORD mod_time;
DWORD mod_date;
DWORD size;
DWORD size_high;
} FILEINFO;
int _stdcall read_file (const char *name,char *buff,unsigned offset, unsigned count,unsigned *reads);
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
int __qread( int handle, void *buffer, unsigned len )
_WCRTLINK long filelength( int handle )
{
__file_handle *fh;
unsigned amount_read=0;
FILEINFO info;
__handle_check( handle, -1 );
fh = (__file_handle*) __getOSHandle( handle );
if(read_file(fh->name,buffer,fh->offset,len,&amount_read))
{
if ( amount_read == 0)
return (-1);
}
fh->offset+=amount_read;
return( amount_read );
};
fh = (__file_handle*) __getOSHandle( handle);
get_fileinfo(fh->name,&info);
return( info.size );
}

View File

@ -0,0 +1,94 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#ifndef _INT64_H_INCLUDED
#define _INT64_H_INCLUDED
#include "variety.h"
#ifdef __WATCOM_INT64__
#define USE_INT64
#endif
#include "clibi64.h"
#ifdef __INT64__
#define INT_TYPE INT64_TYPE
#define UINT_TYPE UINT64_TYPE
#define LONG_TYPE INT64_TYPE
#define ULONG_TYPE UINT64_TYPE
#define __I64NAME(_n1,_n2) _n2
#if !defined(USE_INT64)
#define __int64 double
#define REAL_INT_TYPE double
#define GET_INT64(__d) ( *( (INT_TYPE*)(&(__d)) ) )
#define GET_UINT64(__d) ( *( (UINT_TYPE*)(&(__d)) ) )
#define GET_REALINT64(__i) ( *( (double*)(&(__i)) ) )
#define GET_REALUINT64(__i) ( *( (double*)(&(__i)) ) )
#define HIGHWORD(__w,__i) (__w) = (unsigned)(__i).u._32[I64HI32]
#define LOWWORD(__w,__i) (__w) = (unsigned)(__i).u._32[I64LO32]
#define MAKE_INT64(__i,__h,__l) { \
(__i).u._32[I64HI32] = (__h); \
(__i).u._32[I64LO32] = (__l); \
}
#define RETURN_INT64(__i) return( GET_REALINT64(__i) )
#else
#define REAL_INT_TYPE __int64
#define GET_INT64(__d) ( __d )
#define GET_UINT64(__d) ( __d )
#define GET_REALINT64(__i) ( __i )
#define GET_REALUINT64(__i) ( __i )
#define HIGHWORD(__w,__i) (__w) = (unsigned)( (__i) >> 32 )
#define LOWWORD(__w,__i) (__w) = (unsigned)(__i)
#define MAKE_INT64(__i,__h,__l) (__i) = ( ((INT_TYPE)(__h)) << 32 ) | (__l)
#define RETURN_INT64(__i) return( __i )
#endif
#else
#define INT_TYPE int
#define UINT_TYPE unsigned int
#define LONG_TYPE long
#define ULONG_TYPE unsigned long
#define __I64NAME(_n1,_n2) _n1
#endif
#define INTSIZE ( sizeof( INT_TYPE ) )
#endif

View File

@ -0,0 +1,286 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: C Runtime write() and _lwrite() implementation.
*
****************************************************************************/
#include "variety.h"
#include "int64.h"
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <malloc.h>
#include <errno.h>
#include <stddef.h>
#include <string.h>
#include "iomode.h"
#include "fileacc.h"
#include "rtcheck.h"
#include "rtdata.h"
#include "seterrno.h"
#include "lseek.h"
/*
The _lwrite function writes data to the specified file.
Note: This function is provided only for compatibility with 16-bit
versions of Windows. Win32-based applications should use the WriteFile
function.
UINT _lwrite(
HFILE hFile, // handle to file
LPCSTR lpBuffer, // write data buffer
UINT uBytes // number of bytes to write
);
*/
extern void __STKOVERFLOW();
/*
Win32 Note:
Note that it is not an error to set the file pointer to a position
beyond the end of the file. The size of the file does not increase
until you call the SetEndOfFile, WriteFile, or WriteFileEx function. A
write operation increases the size of the file to the file pointer
position plus the size of the buffer written, leaving the intervening
bytes uninitialized. Hence, the reason for zero-padding the file
to achieve POSIX conformance.
*/
/*
POSIX Note:
When writing to a file that does not support seek operations (pipe,
device, etc.), the O_APPEND flag is effectively ignored. POSIX does
not explicitly state this, but it is implied. Also, ESPIPE (illegal
seek error) is not listed for write(), only pwrite(). Hence we must
either not attempt to seek on such devices, or ignore the failures.
*/
#define PAD_SIZE 512
typedef union {
unsigned __int64 _64;
long _32[2];
} __i64;
static int zero_pad( int handle ) /* 09-jan-95 */
/*******************************/
{
int rc;
long curPos, eodPos;
long bytesToWrite;
unsigned writeAmt;
char zeroBuf[PAD_SIZE];
// Pad with zeros due to lseek() past EOF (POSIX)
curPos = __lseek( handle, 0L, SEEK_CUR ); /* current offset */
if( curPos == -1 )
return( -1 );
eodPos = __lseek( handle, 0L, SEEK_END ); /* end of data offset */
if( eodPos == -1 )
return( -1 );
if( curPos > eodPos ) {
bytesToWrite = curPos - eodPos; /* amount to pad by */
if( bytesToWrite > 0 ) { /* only write if needed */
memset( zeroBuf, 0x00, PAD_SIZE ); /* zero out a buffer */
do { /* loop until done */
if( bytesToWrite > PAD_SIZE )
writeAmt = 512;
else
writeAmt = (unsigned)bytesToWrite;
rc = write( handle, zeroBuf, writeAmt );
if( rc < 0 )
return( rc );
bytesToWrite -= writeAmt; /* more bytes written */
} while( bytesToWrite != 0 );
}
} else {
curPos = __lseek( handle, curPos, SEEK_SET );
if( curPos == -1 ) {
return( -1 );
}
}
return( 0 ); /* return success code */
}
/*
The os_write function returns 0 meaning no error, -1 meaning error, or
ENOSPC meaning no space left on device.
*/
typedef struct
{
char *name;
unsigned int offset;
}__file_handle;
int _stdcall write_file (const char *name,const void* buff,unsigned offset, unsigned count,unsigned *reads);
static int os_write( int handle, const void *buffer, unsigned len, unsigned *amt )
/********************************************************************************/
{
__file_handle *fh;
int rc;
rc = 0;
fh = (__file_handle*) __getOSHandle( handle );
if(write_file(fh->name,buffer,fh->offset,len,amt))
{
rc = __set_errno_nt();
};
if( *amt != len )
{
rc = ENOSPC;
__set_errno( rc );
}
return( rc );
}
_WCRTLINK int write( int handle, const void *buffer, unsigned len )
/**********************************************************************/
{
unsigned iomode_flags;
char *buf;
unsigned buf_size;
unsigned len_written, i, j;
int rc2;
__file_handle *fh;
__handle_check( handle, -1 );
iomode_flags = __GetIOMode( handle );
if( iomode_flags == 0 )
{
__set_errno( EBADF );
return( -1 );
}
if( !(iomode_flags & _WRITE) ) {
__set_errno( EACCES ); /* changed from EBADF to EACCES 23-feb-89 */
return( -1 );
}
fh = (__file_handle*) __getOSHandle( handle );
// put a semaphore around our writes
_AccessFileH( handle );
if( (iomode_flags & _APPEND) && !(iomode_flags & _ISTTY) )
{
fh->offset = __lseek( handle, 0L, SEEK_END ); /* end of data offset */
}
len_written = 0;
rc2 = 0;
// Pad the file with zeros if necessary
if( iomode_flags & _FILEEXT ) {
// turn off file extended flag
__SetIOMode_nogrow( handle, iomode_flags&(~_FILEEXT) );
// It is not required to pad a file with zeroes on an NTFS file system;
// unfortunately it is required on FAT (and probably FAT32). (JBS)
rc2 = zero_pad( handle );
}
if( rc2 == 0 ) {
if( iomode_flags & _BINARY ) { /* if binary mode */
rc2 = os_write( handle, buffer, len, &len_written );
/* end of binary mode part */
} else { /* text mode */
i = stackavail();
if( i < 0x00b0 ) {
__STKOVERFLOW(); /* not enough stack space */
}
buf_size = 512;
if( i < (512 + 48) ) {
buf_size = 128;
}
buf = __alloca( buf_size );
j = 0;
for( i = 0; i < len; )
{
if( ((const char*)buffer)[i] == '\n' )
{
buf[j] = '\r';
++j;
if( j == buf_size )
{
rc2 = os_write( handle, buf, buf_size, &j );
if( rc2 == -1 )
break;
len_written += j;
if( rc2 == ENOSPC )
break;
len_written = i;
j = 0;
}
}
buf[j] = ((const char*)buffer)[i];
++i;
++j;
if( j == buf_size ) {
rc2 = os_write( handle, buf, buf_size, &j );
if( rc2 == -1 )
break;
len_written += j;
if( rc2 == ENOSPC )
break;
len_written = i;
j = 0;
}
}
if( j ) {
rc2 = os_write( handle, buf, j, &i );
if( rc2 == ENOSPC ) {
len_written += i;
} else {
len_written = len;
}
}
/* end of text mode part */
}
}
_ReleaseFileH( handle );
if( rc2 == -1 ) {
return( rc2 );
} else {
return( len_written );
}
}

View File

@ -1,45 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: prototype for 8087 save/restore state functions and data
*
****************************************************************************/
#if defined(_M_IX86)
typedef struct _87state { /* 80x87 save area */
#if defined( __386__ )
char data[108]; /* 32-bit save area size */
#else
char data[94]; /* 16-bit save area size */
#endif
} _87state;
extern void (*__Save8087)(_87state *);
extern void (*__Rest8087)(_87state *);
#endif

View File

@ -1,64 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <errno.h>
#include "fileacc.h"
//#include <windows.h>
#include "rtcheck.h"
#include "rtdata.h"
#include "iomode.h"
#include "seterrno.h"
//#include "defwin.h"
#include "close.h"
int __close( int hid )
{
int is_closed;
int rc;
HANDLE h;
__handle_check( hid, -1 );
is_closed = 0;
rc = 0;
// h = __getOSHandle( hid );
// if( !is_closed && !CloseHandle( h ) )
// {
// rc = __set_errno_nt();
// }
// __freePOSIXHandle( hid );
// __SetIOMode_nogrow( hid, 0 );
return( rc );
}

View File

@ -1,92 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Platform independent __allocfp() implementation.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "liballoc.h"
#include "fileacc.h"
#include "rtdata.h"
#include "seterrno.h"
#include "streamio.h"
#define KEEP_FLAGS (_READ | _WRITE | _DYNAMIC)
FILE *__allocfp( int handle )
{
FILE *end;
FILE *fp;
__stream_link *link;
unsigned flags;
handle = handle;
_AccessIOB();
/* Try and take one off the recently closed list */
link = _RWD_cstream;
if( link != NULL ) {
_RWD_cstream = link->next;
fp = link->stream;
flags = (fp->_flag & KEEP_FLAGS) | (_READ | _WRITE);
goto got_one;
}
/* See if there is a static FILE structure available. */
end = &_RWD_iob[_NFILES];
for( fp = _RWD_iob; fp < end; ++fp ) {
if( (fp->_flag & (_READ | _WRITE)) == 0 ) {
link = lib_malloc( sizeof( __stream_link ) );
if( link == NULL )
goto no_mem;
flags = _READ | _WRITE;
goto got_one;
}
}
/* Allocate a new dynamic structure */
flags = _DYNAMIC | _READ | _WRITE;
link = lib_malloc( sizeof( __stream_link ) + sizeof( FILE ) );
if( link == NULL )
goto no_mem;
fp = (FILE *)(link + 1);
got_one:
memset( fp, 0, sizeof( *fp ) );
fp->_flag = flags;
link->stream = fp;
link->stream->_link = link; /* point back to link structure */
link->next = _RWD_ostream;
_RWD_ostream = link;
_ReleaseIOB();
return( fp );
no_mem:
__set_errno( ENOMEM );
_ReleaseIOB();
return( NULL ); /* no free slots */
}

View File

@ -1,52 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Implementation of chktty() - check if stream is teletype.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <malloc.h>
#include <unistd.h>
#include "rtdata.h"
#include "fileacc.h"
#include "streamio.h"
void __chktty( FILE *fp )
{
/* if we have not determined that we've got a tty then check for one */
if( !(fp->_flag & _ISTTY) ) {
if( isatty( fileno( fp ) ) ) {
fp->_flag |= _ISTTY;
if( ( fp->_flag & (_IONBF | _IOLBF | _IOFBF) ) == 0 ) {
fp->_flag |= _IOLBF;
}
}
}
}

View File

@ -1,61 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Prototypes and pragmas for handling __int64 values.
*
****************************************************************************/
#ifndef _I64_H_INCLUDED
#define _I64_H_INCLUDED
#include "variety.h"
#include "widechar.h"
#include "watcom.h"
#define INT64_TYPE __int64
#define UINT64_TYPE unsigned __int64
#define _clib_I64Negative( a ) (((__int64)a) < 0)
#define _clib_I64Positive( a ) (((__int64)a) > 0)
#define _clib_I32ToI64( a, b ) b = (__int64)a
#define _clib_U32ToU64( a, b ) b = (unsigned __int64)(unsigned_32)a
#define _clib_I64ToInt( a, b ) b = (signed)a
#define _clib_U64ToUInt( a, b ) b = (unsigned)a
#define _clib_I64ToLong( a, b ) b = (signed long)a
#define _clib_U64ToULong( a, b ) b = (unsigned long)a
#define _clib_I64Neg( a, b ) b = -a
#define _clib_U64Neg( a, b ) _clib_I64Neg( a, b )
#define _clib_U64Zero( a ) (a == 0)
#define _clib_U64Cmp( a, b ) (a > b ? +1 : a < b ? -1 : 0)
#define _clib_U64Mul( a, b, c ) c = a * b
#define _clib_U64Div( a, b, c, d ) (d = a % b, c = a / b)
#define _clib_U64Add( a, b, c ) c = a + b
// conversion functions - use standard ulltoa()/atoll()
#endif

View File

@ -1,32 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: prototype for __close clib internal function
*
****************************************************************************/
extern int __close( int handle );

View File

@ -1,34 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: declaration for set commit mode function
*
****************************************************************************/
/* see note in commode.c */
_WCRTLINK extern void _WCI86FAR __set_commode( void );
#pragma aux __set_commode "*_";

View File

@ -1,47 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Commit mode state variable and accessor.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include "commode.h"
int _commode = 0;
/*
* Before changing any of this, check startup/c/commode.c!
*/
_WCRTLINK void _WCI86FAR __set_commode( void )
{
_commode = _COMMIT;
}

View File

@ -1,35 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#define _ERRNO errno

View File

@ -1,85 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Fatal runtime error handlers.
*
****************************************************************************/
#ifndef _EXITWMSG_H_INCLUDED
#define _EXITWMSG_H_INCLUDED
#include "variety.h"
#ifdef __cplusplus
extern "C" {
#endif
#undef _EWM_PARM1
#undef _EWM_PARM2
#if defined(__386__)
#define _EWM_PARM1 eax
#define _EWM_PARM2 edx
#elif defined(M_I86)
#define _EWM_PARM1 ax dx
#define _EWM_PARM2 bx
#else
#define _EWM_PARM1
#define _EWM_PARM2
#endif
// C interface
// - tracks normal calling convention
// - this is the funtion that is called from ASM and from C, C++
// - note there is no #pragma aborts so that debugger can trace out
_WCRTLINK extern void __exit_with_msg( char _WCI86FAR *, unsigned );
_WCRTLINK extern void __fatal_runtime_error( char _WCI86FAR *, unsigned );
// ASM interface
// - always uses register calling convention
// - this function is only called from the C implementation
// of __exit_with_msg
extern void __do_exit_with_msg( char _WCI86FAR *, unsigned );
#ifdef _M_IX86
#pragma aux __do_exit_with_msg "*__" \
parm caller [_EWM_PARM1] [_EWM_PARM2];
#endif
#undef _EWM_PARM1
#undef _EWM_PARM2
_WCRTLINKD extern char volatile __WD_Present;
// WVIDEO interface
// this function should be called before __exit_with_msg()
// to allow Watcom Debugger (nee WVIDEO) to trap runtime errors.
// this really needs to be far!!!
_WCRTLINK extern int __EnterWVIDEO( char _WCFAR *string );
#ifdef __cplusplus
};
#endif
#endif

View File

@ -1,53 +0,0 @@
;*****************************************************************************
;*
;* Open Watcom Project
;*
;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
;*
;* ========================================================================
;*
;* This file contains Original Code and/or Modifications of Original
;* Code as defined in and that are subject to the Sybase Open Watcom
;* Public License version 1.0 (the 'License'). You may not use this file
;* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
;* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
;* provided with the Original Code and Modifications, and is also
;* available at www.sybase.com/developer/opensource.
;*
;* The Original Code and all software distributed under the License are
;* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
;* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
;* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
;* NON-INFRINGEMENT. Please see the License for the specific language
;* governing rights and limitations under the License.
;*
;* ========================================================================
;*
;* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
;* DESCRIBE IT HERE!
;*
;*****************************************************************************
ifdef __WASM__
ifdef __386__
extrn "C",__fatal_runtime_error : near
else
ifdef __SMALL__
extrn "C",__fatal_runtime_error : near
endif
ifdef __COMPACT__
extrn "C",__fatal_runtime_error : near
endif
ifdef __MEDIUM__
extrn "C",__fatal_runtime_error : far
endif
ifdef __LARGE__
extrn "C",__fatal_runtime_error : far
endif
ifdef __HUGE__
extrn "C",__fatal_runtime_error : far
endif
endif
endif

View File

@ -1,106 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Special interface for calls to non-Watcom routines from
* inside clib (x86 specific).
*
****************************************************************************/
#ifndef EXTFUNC_H_INCLUDED
#define EXTFUNC_H_INCLUDED
#include "variety.h"
#if defined(_M_IX86)
#if !defined(__WINDOWS__)
#if defined(__BIG_DATA__)
#define __DS ds
#endif
#endif
#if !defined(__FLAT__)
#define __ES es
#endif
#if defined(__386__)
#if defined(__WINDOWS__) || !defined(__FLAT__)
#define __FS fs
#endif
#define __GS gs
#if defined(__SW_3S)
#define __AX eax
#define __BX ebx
#define __CX ecx
#define __DX edx
#endif
#endif
#ifndef __AX
#define __AX
#endif
#ifndef __BX
#define __BX
#endif
#ifndef __CX
#define __CX
#endif
#ifndef __DX
#define __DX
#endif
#ifndef __DS
#define __DS
#endif
#ifndef __ES
#define __ES
#endif
#ifndef __FS
#define __FS
#endif
#ifndef __GS
#define __GS
#endif
#pragma aux __outside_CLIB modify [__AX __BX __CX __DX __DS __ES __FS __GS];
/*
use as follows:
typedef void vfv( void );
#pragma aux (__outside_CLIB) __vfv;
*/
#undef __AX
#undef __BX
#undef __CX
#undef __DX
#undef __DS
#undef __ES
#undef __FS
#undef __GS
#endif
#endif

View File

@ -1,43 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Macros for switching between far and near function version
*
****************************************************************************/
#ifndef _FARFUNC_H_INCLUDED
#define _FARFUNC_H_INCLUDED
#ifdef __FARFUNC__
#define _FFAR _WCFAR
#define _NEARFAR(n1,n2) n2
#else
#define _FFAR
#define _NEARFAR(n1,n2) n1
#endif
#endif

View File

@ -1,74 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Far pointer support typedefs.
*
****************************************************************************/
#ifndef _FARSUPP_H_INCLUDED
#define _FARSUPP_H_INCLUDED
#include "variety.h"
#include "widechar.h"
#ifdef __LONG_LONG_SUPPORT__
#include "clibi64.h"
#endif
/* Only support near/far pointers on 16-bit targets, extended DOS
* and Win386. Ideally we might want to test for non-flat memory model.
*/
#if defined( _M_I86 ) || defined( __DOS__ ) || defined( __WINDOWS__ )
#define __FAR_SUPPORT__
typedef CHAR_TYPE _WCFAR *FAR_STRING;
typedef char _WCFAR *FAR_ASCII_STRING;
typedef wchar_t _WCFAR *FAR_UNI_STRING;
typedef int _WCFAR *FAR_INT;
typedef signed char _WCFAR *FAR_CHAR;
typedef short _WCFAR *FAR_SHORT;
typedef long _WCFAR *FAR_LONG;
typedef float _WCFAR *FAR_FLOAT;
typedef double _WCFAR *FAR_DOUBLE;
#ifdef __LONG_LONG_SUPPORT__
typedef UINT64_TYPE _WCFAR *FAR_INT64;
#endif
#else
#undef __FAR_SUPPORT__
typedef CHAR_TYPE *FAR_STRING;
typedef char *FAR_ASCII_STRING;
typedef wchar_t *FAR_UNI_STRING;
typedef int *FAR_INT;
typedef signed char *FAR_CHAR;
typedef short *FAR_SHORT;
typedef long *FAR_LONG;
typedef float *FAR_FLOAT;
typedef double *FAR_DOUBLE;
#ifdef __LONG_LONG_SUPPORT__
typedef UINT64_TYPE *FAR_INT64;
#endif
#endif
#endif

View File

@ -1,122 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Platform independent fclose() implementation.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include "liballoc.h"
#include "mf.h"
#include <string.h>
#include "fileacc.h"
#include "tmpfname.h"
#include "rtdata.h"
#include "lseek.h"
#include "streamio.h"
#include "close.h"
#include "flush.h"
#ifndef __UNIX__
void (*__RmTmpFileFn)( FILE *fp );
#endif
int __doclose( FILE *fp, int close_handle )
{
int ret;
if( fp->_flag == 0 ) {
return( -1 ); /* file already closed */
}
ret = 0;
if( fp->_flag & _DIRTY ) {
ret = __flush( fp );
}
_AccessFile( fp );
/*
* 02-nov-92 G.Turcotte Syncronize buffer pointer with the file pointer
* IEEE Std 1003.1-1988 B.8.2.3.2
* 03-nov-03 B.Oldeman Inlined ftell; we already know the buffer isn't
* dirty (because of the flush), so only a "get" applies
*/
if( fp->_cnt != 0 ) { /* if something in buffer */
__lseek( fileno( fp ), -fp->_cnt, SEEK_CUR );
}
if( close_handle ) {
#if defined( __UNIX__ ) || defined( __NETWARE__ )
// we don't get to implement the close function on these systems
ret |= close( fileno( fp ) );
#else
ret |= __close( fileno( fp ) );
#endif
}
if( fp->_flag & _BIGBUF ) { /* if we allocated the buffer */
lib_free( _FP_BASE(fp) );
_FP_BASE(fp) = NULL;
}
#ifndef __UNIX__
/* this never happens under UNIX */
if( fp->_flag & _TMPFIL ) { /* if this is a temporary file */
__RmTmpFileFn( fp );
}
#endif
_ReleaseFile( fp );
return( ret );
}
int __shutdown_stream( FILE *fp, int close_handle )
{
int ret;
ret = __doclose( fp, close_handle );
__freefp( fp );
return( ret );
}
_WCRTLINK int fclose( FILE *fp )
{
__stream_link *link;
_AccessIOB();
link = _RWD_ostream;
for( ;; ) {
if( link == NULL ) {
_ReleaseIOB();
return( -1 ); /* file not open */
}
if( link->stream == fp ) break;
link = link->next;
}
_ReleaseIOB();
return( __shutdown_stream( fp, 1 ) );
}

View File

@ -1,48 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Implementation of fflush() - flush streams.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include "rtdata.h"
#include "fileacc.h"
#include "flush.h"
_WCRTLINK int fflush( FILE *fp )
{
if( fp == NULL ) {
flushall();
return( 0 );
}
_ValidFile( fp, EOF );
return( __flush( fp ) );
}

View File

@ -1,227 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Platform independent fgetc() implementation.
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include <unistd.h>
#ifndef __UNIX__
#include <conio.h>
#endif
#include "fileacc.h"
#include <errno.h>
#include "rtdata.h"
#include "seterrno.h"
#ifdef __WIDECHAR__
#include <mbstring.h>
#include <wchar.h>
#endif
#include "qread.h"
#include "orient.h"
#include "flush.h"
#include "streamio.h"
#define DOS_EOF_CHAR 0x1a
#ifdef __WIDECHAR__
#define CHARMASK 0xffff
#else
#define CHARMASK 0xff
#endif
int __F_NAME(__fill_buffer,__wfill_buffer)( FILE *fp )
{
if( _FP_BASE(fp) == NULL ) {
__ioalloc( fp );
}
if( fp->_flag & _ISTTY ) { /* 20-aug-90 */
if( fp->_flag & (_IONBF | _IOLBF) ) {
__flushall( _ISTTY ); /* flush all TTY output */
}
}
fp->_flag &= ~_UNGET; /* 10-mar-90 */
fp->_ptr = _FP_BASE(fp);
#ifdef __UNIX__
fp->_cnt = __qread( fileno( fp ), fp->_ptr,
(fp->_flag & _IONBF) ? CHARSIZE : fp->_bufsize );
#else
if(( fp->_flag & (_IONBF | _ISTTY)) == (_IONBF | _ISTTY) &&
( fileno( fp ) == STDIN_FILENO ))
{
int c; /* JBS 31-may-91 */
fp->_cnt = 0;
// c = getche();
if( c != EOF ) {
*(CHAR_TYPE *)fp->_ptr = c;
fp->_cnt = CHARSIZE;
}
} else {
fp->_cnt = __qread( fileno( fp ), fp->_ptr,
(fp->_flag & _IONBF) ? CHARSIZE : fp->_bufsize );
}
#endif
if( fp->_cnt <= 0 ) {
if( fp->_cnt == 0 ) {
fp->_flag |= _EOF;
} else {
fp->_flag |= _SFERR;
fp->_cnt = 0;
}
}
return( fp->_cnt );
}
int __F_NAME(__filbuf,__wfilbuf)( FILE *fp )
{
if( __F_NAME(__fill_buffer,__wfill_buffer)( fp ) == 0 ) {
return( EOF );
}
else {
fp->_cnt -= CHARSIZE;
fp->_ptr += CHARSIZE;
return( *(CHAR_TYPE *)(fp->_ptr - CHARSIZE) & CHARMASK );
}
}
#ifndef __WIDECHAR__
_WCRTLINK int fgetc( FILE *fp )
{
int c;
_ValidFile( fp, EOF );
_AccessFile( fp );
/*** Deal with stream orientation ***/
ORIENT_STREAM(fp,EOF);
if( (fp->_flag & _READ) == 0 ) {
__set_errno( EBADF );
fp->_flag |= _SFERR;
c = EOF;
} else {
fp->_cnt--;
// it is important that this remain a relative comparison
// to ensure that the getc() macro works properly
if( fp->_cnt < 0 ) {
c = __F_NAME(__filbuf,__wfilbuf)( fp );
} else {
c = *(char *)fp->_ptr;
fp->_ptr++;
}
}
#ifndef __UNIX__
if( !(fp->_flag & _BINARY) ) {
if( c == '\r' ) {
fp->_cnt--;
// it is important that this remain a relative comparison
// to ensure that the getc() macro works properly
if( fp->_cnt < 0 ) {
c = __F_NAME(__filbuf,__wfilbuf)( fp );
} else {
c = *(CHAR_TYPE*)fp->_ptr & CHARMASK;
fp->_ptr += CHARSIZE;
}
}
if( c == DOS_EOF_CHAR ) {
fp->_flag |= _EOF;
c = EOF;
}
}
#endif
_ReleaseFile( fp );
return( c );
}
#else
static int __read_wide_char( FILE *fp, wchar_t *wc )
/**************************************************/
{
if( fp->_flag & _BINARY ) {
/*** Read a wide character ***/
return( fread( wc, sizeof( wchar_t ), 1, fp ) );
} else {
char mbc[MB_CUR_MAX];
wchar_t wcTemp;
int rc;
/*** Read the multibyte character ***/
if( !fread( &mbc[0], 1, 1, fp ) )
return( 0 );
if( _ismbblead( mbc[0] ) ) {
if( !fread( &mbc[1], 1, 1, fp ) )
return( 0 );
}
/*** Convert it to wide form ***/
rc = mbtowc( &wcTemp, mbc, MB_CUR_MAX );
if( rc >= 0 ) {
*wc = wcTemp;
return( 1 );
} else {
__set_errno( EILSEQ );
return( 0 );
}
}
}
_WCRTLINK wint_t fgetwc( FILE *fp )
{
wchar_t c;
_ValidFile( fp, WEOF );
_AccessFile( fp );
/*** Deal with stream orientation ***/
ORIENT_STREAM(fp,WEOF);
/*** Read the character ***/
if( !__read_wide_char( fp, &c ) ) {
_ReleaseFile( fp );
return( WEOF );
}
if( !(fp->_flag & _BINARY) && (c == L'\r') ) {
if( !__read_wide_char( fp, &c ) ) {
_ReleaseFile( fp );
return( WEOF );
}
}
_ReleaseFile( fp );
return( (wint_t)c );
}
#endif

View File

@ -1,81 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#define _ValidFile( fp, retval ) /* make sure fp is a valid pointer */
#define SetupTGCSandNCS( x ) /* initialization for Netware/386 */
#if defined(__SW_BM)
#define _AccessFile( fp ) _AccessFileH( (fp)->_handle )
#define _ReleaseFile( fp ) _ReleaseFileH( (fp)->_handle )
#if defined(__386__) || defined(__AXP__) || defined(__PPC__)
extern void (*_AccessFileH)( int );
extern void (*_ReleaseFileH)( int );
extern void (*_AccessIOB)( void );
extern void (*_ReleaseIOB)( void );
#else
// 16bit OS/2 multi-thread is different
extern void __AccessFileH( int );
extern void __ReleaseFileH( int );
extern void __AccessIOB( void );
extern void __ReleaseIOB( void );
// define macros to call the access routines directly for OS/2 1.x
#define _AccessFileH( hdl ) __AccessFileH( hdl )
#define _ReleaseFileH( hdl ) __ReleaseFileH( hdl )
#define _AccessIOB() __AccessIOB()
#define _ReleaseIOB() __ReleaseIOB()
#endif
#if defined(__NT__)
extern void (*_AccessFList)( void );
extern void (*_ReleaseFList)( void );
#endif
#else
/* these are for multi thread support */
/* they are not required if not building multi-thread library */
/* note: 32 bit NETWARE, OS/2, NT, QNX libraries are always multi-thread */
#define _AccessFile( fp ) /* gain access to the FILE* pointer */
#define _ReleaseFile( fp ) /* release access */
#define _AccessFileH( hdl ) /* gain access to the file handle */
#define _ReleaseFileH( hdl ) /* release access */
#define _AccessIOB() /* gain access to array of __iob's */
#define _ReleaseIOB() /* release access */
#if defined(__NT__)
#define _AccessFList()
#define _ReleaseFList()
#endif
#endif

View File

@ -1,37 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Fixed-point data type.
*
****************************************************************************/
typedef union t32 {
unsigned long uWhole;
signed long sWhole;
struct { unsigned short int lo, hi; } wd;
struct { unsigned char b1, b2, b3, b4; } bite;
} T32;

View File

@ -1,113 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Implementation of fflush() helper routine.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include "fileacc.h"
#include "rtdata.h"
#include "seterrno.h"
#include "qwrite.h"
#include "lseek.h"
#include "flush.h"
#if defined( __NETWARE__ ) && defined( _THIN_LIB )
/* Take flush from LibC */
_WCRTLINK int __flush( FILE *fp )
{
return( fflush( fp ) );
}
#else
_WCRTLINK int __flush( FILE *fp )
{
int len;
long offset;
int ret;
char *ptr;
unsigned amount;
ret = 0;
_AccessFile( fp );
if( fp->_flag & _DIRTY ) {
fp->_flag &= ~_DIRTY;
if( (fp->_flag & _WRITE) && (_FP_BASE(fp) != NULL) ) {
ptr = _FP_BASE(fp);
amount = fp->_cnt;
while( amount != 0 && ret == 0 ) {
len = __qwrite( fileno( fp ), ptr, amount ); /* 02-aug-90 */
if( len == -1 ) {
fp->_flag |= _SFERR;
ret = EOF;
}
#ifndef __UNIX__
else if( len == 0 ) {
__set_errno( ENOSPC ); /* 12-nov-88 */
fp->_flag |= _SFERR;
ret = EOF;
}
#endif
ptr += len;
amount -= len;
}
}
} else if( _FP_BASE(fp) != NULL ) { /* not dirty */
/* fseek( fp, ftell(fp), SEEK_SET ); */
fp->_flag &= ~_EOF;
if( !(fp->_flag & _ISTTY) ) {
offset = fp->_cnt;
if( offset != 0 ) { /* 10-aug-89 JD */
offset = __lseek( fileno( fp ), -offset, SEEK_CUR );
}
if( offset == -1 ) {
fp->_flag |= _SFERR;
ret = EOF;
}
}
}
fp->_ptr = _FP_BASE(fp); /* reset ptr to start of buffer */
fp->_cnt = 0;
#if !defined( __NETWARE__ ) && !defined( __OSI__ )
if( ret == 0 && (_FP_EXTFLAGS(fp) & _COMMIT) ) {
if( fsync( fileno( fp ) ) == -1 ) {
ret = EOF;
}
}
#endif
_ReleaseFile( fp );
return( ret );
}
#endif

View File

@ -1,34 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Prototype for __flush and __flushall internal routines.
*
****************************************************************************/
/* __flush is used by C++ run-time library */
_WCRTLINK extern int __flush( FILE * );
extern int __flushall( int );

View File

@ -1,65 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Implementation of flushall() - flush all streams.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include "rtdata.h"
#include "fileacc.h"
#include "flush.h"
/* __fill_buffer calls this routine with _ISTTY mask */
int __flushall( int mask )
{
__stream_link *link;
FILE *fp;
int number_of_open_files;
_AccessIOB();
number_of_open_files = 0;
for( link = _RWD_ostream; link != NULL; link = link->next ) {
fp = link->stream;
if( fp->_flag & mask ) { /* if file is a candidate */
++number_of_open_files;
if( fp->_flag & _DIRTY ) {
__flush( fp );
}
}
}
_ReleaseIOB();
return( number_of_open_files );
}
_WCRTLINK int flushall( void )
{
return( __flushall( ~0 ) );
}

View File

@ -1,33 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
/* define _fmode to be _fmode */

View File

@ -1,359 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Platform independent fopen() implementation.
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include <ctype.h>
#ifdef __WIDECHAR__
#include <wctype.h>
#endif
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "fileacc.h"
#include "fmode.h"
#include "openmode.h"
#include "rtdata.h"
#include "seterrno.h"
//#include "defwin.h"
#include "streamio.h"
#ifdef __UNIX__
#define PMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#else
#define PMODE (S_IREAD | S_IWRITE)
#endif
int __F_NAME(__open_flags,__wopen_flags)( const CHAR_TYPE *modestr, int *extflags )
{
int flags;
int alive = 1;
int gotplus = 0;
int gottextbin = 0;
#ifndef __NETWARE__
int gotcommit = 0;
#endif
flags = 0;
if( extflags != NULL ) {
#ifdef __NETWARE__
*extflags = 0;
#else
if( _commode == _COMMIT ) {
*extflags = _COMMIT;
} else {
*extflags = 0;
}
#endif
}
/*
* The first character in modestr must be 'r', 'w', or 'a'.
*/
switch( *modestr ) {
case 'r':
flags |= _READ;
break;
case 'w':
flags |= _WRITE;
break;
case 'a':
flags |= _WRITE | _APPEND;
break;
default:
__set_errno( EINVAL );
return( 0 );
}
modestr++;
/*
* Next we might have, in any order, some additional mode modifier
* characters:
* 1. A '+' character.
* 2. Either a 't' or a 'b'.
* 3. Either a 'c' or a 'n'. (Not available for Netware.)
* For MS compatability, scanning stops when any of the three groups
* is encountered twice; e.g., "wct+b$&!" is valid and will result in
* a text, not binary, stream. Also for MS compatability, scanning
* stops at any unrecognized character, without causing failure.
*/
while( (*modestr != NULLCHAR) && alive ) {
switch( *modestr ) {
case '+':
if( gotplus ) {
alive = 0;
} else {
flags |= _READ | _WRITE;
gotplus = 1;
}
break;
case 't':
if( gottextbin ) {
alive = 0;
} else {
gottextbin = 1;
}
break;
case 'b':
if( gottextbin ) {
alive = 0;
} else {
#ifndef __UNIX__
flags |= _BINARY;
#endif
gottextbin = 1;
}
break;
#ifndef __NETWARE__
case 'c':
if( gotcommit ) {
alive = 0;
} else {
*extflags |= _COMMIT;
gotcommit = 1;
}
break;
case 'n':
if( gotcommit ) {
alive = 0;
} else {
*extflags &= ~_COMMIT;
gotcommit = 1;
}
break;
#endif
default:
break;
}
modestr++;
}
/*
* Handle defaults for any unspecified options.
*/
#ifndef __UNIX__
if( !gottextbin ) {
if( _RWD_fmode == O_BINARY ) flags |= _BINARY;
}
#endif
return( flags );
}
static FILE *__F_NAME(__doopen,__wdoopen)( const CHAR_TYPE *name,
CHAR_TYPE mode,
int file_flags,
int extflags,
int shflag, /* sharing flag */
FILE * fp )
{
int open_mode;
int p_mode;
SetupTGCSandNCS( RETURN_ARG( FILE *, 0 ) ); /* for NW386 */
fp->_flag &= ~(_READ | _WRITE);
fp->_flag |= file_flags;
/* we need the mode character to indicate if the original */
/* intention is to open for read or for write */
mode = __F_NAME(tolower,towlower)( mode );
if( mode == 'r' ) {
open_mode = O_RDONLY;
if( file_flags & _WRITE ) { /* if "r+" mode */
open_mode = O_RDWR;
}
#if defined( __NETWARE__ )
open_mode |= O_BINARY;
#elif defined( __UNIX__ )
#else
if( file_flags & _BINARY ) {
open_mode |= O_BINARY;
} else {
open_mode |= O_TEXT;
}
#endif
p_mode = 0;
} else { /* mode == 'w' || mode == 'a' */
if( file_flags & _READ ) { /* if "a+" or "w+" mode */
open_mode = O_RDWR | O_CREAT;
} else {
open_mode = O_WRONLY | O_CREAT;
}
if( file_flags & _APPEND ) {
open_mode |= O_APPEND;
} else { /* mode == 'w' */
open_mode |= O_TRUNC;
}
#if defined( __NETWARE__ )
open_mode |= O_BINARY;
#elif defined( __UNIX__ )
#else
if( file_flags & _BINARY ) {
open_mode |= O_BINARY;
} else {
open_mode |= O_TEXT;
}
#endif
p_mode = PMODE;
}
fp->_handle = __F_NAME(sopen,_wsopen)( name, open_mode, shflag, p_mode );
if( fp->_handle == -1 ) {
// since we couldn't open the file, release the FILE struct
__freefp( fp );
return( NULL );
}
fp->_cnt = 0;
fp->_bufsize = 0; /* was BUFSIZ JBS 31-may-91 */
#ifndef __NETWARE__
_FP_ORIENTATION(fp) = _NOT_ORIENTED; /* initial orientation */
_FP_EXTFLAGS(fp) = extflags;
#endif
#if defined( __NT__ ) || defined( __OS2__ )
_FP_PIPEDATA(fp).isPipe = 0; /* not a pipe */
#endif
_FP_BASE(fp) = NULL;
if( file_flags & _APPEND ) {
fseek( fp, 0L, SEEK_END );
}
__chktty( fp ); /* JBS 28-aug-90 */
return( fp );
}
_WCRTLINK FILE *__F_NAME(_fsopen,_wfsopen)( const CHAR_TYPE *name,
const CHAR_TYPE *access_mode, int shflag )
{
FILE * fp;
int file_flags;
int extflags;
/* validate access_mode */
file_flags = __F_NAME(__open_flags,__wopen_flags)( access_mode, &extflags );
if( file_flags == 0 ) {
return( NULL );
}
/* specify dummy handle 0 */
fp = __allocfp( 0 ); /* JBS 30-aug-91 */
if( fp != NULL ) {
fp = __F_NAME(__doopen,__wdoopen)( name, *access_mode,
file_flags, extflags,
shflag, fp );
}
return( fp );
}
_WCRTLINK FILE *__F_NAME(fopen,_wfopen)( const CHAR_TYPE *name, const CHAR_TYPE *access_mode )
{
return( __F_NAME(_fsopen,_wfsopen)( name, access_mode, OPENMODE_DENY_COMPAT ) );
}
static FILE *close_file( FILE *fp )
{
__stream_link * link;
__stream_link **owner;
_AccessIOB();
/* See if the file pointer is a currently open file. */
link = _RWD_ostream;
for( ;; ) {
if( link == NULL ) break;
if( link->stream == fp ) {
if( fp->_flag & (_READ|_WRITE) ) {
__doclose( fp, 1 );
}
_ReleaseIOB();
return( fp );
}
link = link->next;
}
/*
It's not on the list of open files, so check the list of
recently closed ones.
*/
owner = &_RWD_cstream;
for( ;; ) {
link = *owner;
if( link == NULL ) break;
if( link->stream == fp ) {
/* remove from closed list and put on open */
*owner = link->next;
link->next = _RWD_ostream;
_RWD_ostream = link;
_ReleaseIOB();
return( fp );
}
owner = &link->next;
}
/* We ain't seen that file pointer ever. Leave things be. */
__set_errno( EBADF );
_ReleaseIOB();
return( NULL );
}
_WCRTLINK FILE *__F_NAME(freopen,_wfreopen)( const CHAR_TYPE *name,
const CHAR_TYPE *access_mode, FILE *fp )
{
int hdl;
int file_flags;
int extflags;
_ValidFile( fp, 0 );
/* validate access_mode */
file_flags = __F_NAME(__open_flags,__wopen_flags)( access_mode, &extflags );
if( file_flags == 0 ) {
return( NULL );
}
hdl = fileno( fp );
_AccessFileH( hdl );
#ifdef DEFAULT_WINDOWING
if( _WindowsRemoveWindowedHandle != 0 ) {
_WindowsRemoveWindowedHandle( hdl );
}
#endif
fp = close_file( fp );
if( fp != NULL ) {
fp->_flag &= _DYNAMIC; /* 24-jul-92 */
fp = __F_NAME(__doopen,__wdoopen)( name, *access_mode,
file_flags, extflags,
0, fp );
}
_ReleaseFileH( hdl );
return( fp );
}

View File

@ -1,32 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Prototype for __fprtf() internal routine.
*
****************************************************************************/
extern int __F_NAME(__fprtf,__fwprtf)( FILE *fp, const CHAR_TYPE *format, va_list arg );

View File

@ -1,145 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Platform independent fputc() implementation.
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include <errno.h>
#include "fileacc.h"
#include "rtdata.h"
#include "seterrno.h"
#include "orient.h"
#ifdef __WIDECHAR__
#include <mbstring.h>
#include <wchar.h>
#endif
#include "flush.h"
#include "streamio.h"
#ifndef __WIDECHAR__
_WCRTLINK int fputc( int c, FILE *fp )
{
int flags;
_ValidFile( fp, EOF );
_AccessFile( fp );
/*** Deal with stream orientation ***/
ORIENT_STREAM(fp,EOF);
if( !(fp->_flag & _WRITE) ) {
__set_errno( EBADF );
fp->_flag |= _SFERR;
_ReleaseFile( fp );
return( EOF );
}
if( _FP_BASE(fp) == NULL ) {
__ioalloc( fp );
}
flags = _IONBF;
if( c == '\n' ) {
flags = _IONBF | _IOLBF;
#ifndef __UNIX__
if( !(fp->_flag & _BINARY) ) {
fp->_flag |= _DIRTY;
*(char*)fp->_ptr = '\r'; /* '\n' -> '\r''\n' */
fp->_ptr++;
fp->_cnt++;
if( fp->_cnt == fp->_bufsize ) {
if( __flush( fp ) ) {
_ReleaseFile( fp );
return( EOF );
}
}
}
#endif
}
fp->_flag |= _DIRTY;
*(char *)fp->_ptr = c;
fp->_ptr++;
fp->_cnt++;
if( (fp->_flag & flags) || (fp->_cnt == fp->_bufsize) ) {
if( __flush( fp ) ) {
_ReleaseFile( fp );
return( EOF );
}
}
_ReleaseFile( fp );
return( (UCHAR_TYPE)c );
}
#else
static int __write_wide_char( FILE *fp, wchar_t wc )
/**************************************************/
{
if( fp->_flag & _BINARY ) {
/*** Dump the wide character ***/
return( fwrite( &wc, sizeof( wchar_t ), 1, fp ) );
} else {
char mbc[MB_CUR_MAX];
int rc;
/*** Convert the wide character to multibyte form and write it ***/
rc = wctomb( mbc, wc );
if( rc > 0 ) {
return( fwrite( mbc, rc, 1, fp ) );
} else {
__set_errno( EILSEQ );
return( 0 );
}
}
}
_WCRTLINK wint_t fputwc( wint_t c, FILE *fp )
{
_ValidFile( fp, WEOF );
_AccessFile( fp );
/*** Deal with stream orientation ***/
ORIENT_STREAM(fp,WEOF);
/*** Write the character ***/
if( !__write_wide_char( fp, c ) ) {
_ReleaseFile( fp );
return( WEOF );
} else {
_ReleaseFile( fp );
return( c );
}
}
#endif

View File

@ -1,91 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Implementation of fputs() - put string to stream.
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include "fileacc.h"
#include "rtdata.h"
#include "flush.h"
#include "streamio.h"
_WCRTLINK int __F_NAME(fputs,fputws)( const CHAR_TYPE *s, FILE *fp )
{
const CHAR_TYPE *start;
int c;
int not_buffered;
int rc;
_ValidFile( fp, __F_NAME(EOF,WEOF) );
_AccessFile( fp );
if( _FP_BASE(fp) == NULL ) {
__ioalloc( fp ); /* allocate buffer */
}
not_buffered = 0;
if( fp->_flag & _IONBF ) {
not_buffered = 1;
fp->_flag &= ~_IONBF;
fp->_flag |= _IOLBF;
}
rc = 0;
start = s;
while( c = *s ) {
s++;
#ifndef __WIDECHAR__
if( (fputc)( c, fp ) == EOF ) { /* 23-oct-91 */
rc = EOF;
break;
}
#else
if( (fputwc)( c, fp ) == WEOF ) { /* 23-oct-91 */
rc = -1;
break;
}
#endif
}
if( not_buffered ) {
fp->_flag &= ~_IOLBF;
fp->_flag |= _IONBF;
if( rc == 0 ) {
rc = __flush( fp ); /* 23-oct-91 */
}
}
if( rc == 0 ) {
/* return the number of items written */
/* this is ok by ANSI which says that success is */
/* indicated by a non-negative return value */
rc = s - start;
}
_ReleaseFile( fp );
return( rc );
}

View File

@ -1,165 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Implementation of fread() - read data from stream.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#include "fileacc.h"
#include <string.h>
#include <errno.h>
#include "rtdata.h"
#include "seterrno.h"
#include "qread.h"
#include "streamio.h"
#define DOS_EOF_CHAR 0x1a
extern int __fill_buffer( FILE * ); /* located in fgetc */
_WCRTLINK size_t fread( void *_buf, size_t size, size_t n, FILE *fp )
{
char *buf = _buf;
size_t len_read;
_ValidFile( fp, 0 );
_AccessFile( fp );
if( (fp->_flag & _READ) == 0 ) {
__set_errno( EBADF );
fp->_flag |= _SFERR;
_ReleaseFile( fp );
return( 0 );
}
#if 0
/*** If the buffer is _DIRTY, resync it before reading ***/
if( fp->_flag & (_WRITE | _UNGET) ) {
if( fp->_flag & _DIRTY ) {
fseek( fp, 0, SEEK_CUR );
}
}
#endif
n *= size;
if( n == 0 ) {
_ReleaseFile( fp );
return( n );
}
if( _FP_BASE(fp) == NULL ) {
__ioalloc( fp ); /* allocate buffer */
}
len_read = 0;
#if !defined( __UNIX__ )
if( fp->_flag & _BINARY )
#endif
{
size_t bytes_left = n, bytes;
for( ;; ) {
if( fp->_cnt != 0 ) {
bytes = fp->_cnt;
if( bytes > bytes_left ) {
bytes = bytes_left;
}
memcpy( buf, fp->_ptr, bytes );
fp->_ptr += bytes;
buf += bytes;
fp->_cnt -= bytes;
bytes_left -= bytes;
len_read += bytes;
}
if( bytes_left == 0 ) break;
/* if user's buffer is larger than our buffer, OR
_IONBF is set, then read directly into user's buffer. */
if( (bytes_left >= fp->_bufsize) || (fp->_flag & _IONBF) ) {
bytes = bytes_left;
fp->_ptr = _FP_BASE(fp);
fp->_cnt = 0;
if( !(fp->_flag & _IONBF) ) {
/* if more than a sector, set to multiple of sector size*/
if( bytes > 512 ) {
bytes &= -512;
}
}
n = __qread( fileno(fp), buf, bytes );
if( n == -1 ) {
fp->_flag |= _SFERR;
break;
} else if( n == 0 ) {
fp->_flag |= _EOF;
break;
}
buf += n;
bytes_left -= n;
len_read += n;
} else {
if( __fill_buffer( fp ) == 0 ) break;
}
} /* end for */
#if !defined(__UNIX__)
} else {
for( ;; ) {
int c;
// ensure non-empty buffer
if( fp->_cnt == 0 ) {
if( __fill_buffer( fp ) == 0 ) break;
}
// get character
--fp->_cnt;
c = *fp->_ptr++ & 0xff;
// perform new-line translation
if( c == '\r' ) {
// ensure non-empty buffer
if( fp->_cnt == 0 ) {
if( __fill_buffer( fp ) == 0 ) break;
}
// get character
--fp->_cnt;
c = *fp->_ptr++ & 0xff;
}
// check for DOS end of file marker
if( c == DOS_EOF_CHAR ) {
fp->_flag |= _EOF;
break;
}
// store chracter
buf[len_read] = (char)c;
++len_read;
if( len_read == n ) break;
}
#endif
}
_ReleaseFile( fp );
return( len_read / size );
}

View File

@ -1,92 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Platform independent __allocfp() implementation.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include "liballoc.h"
#include "fileacc.h"
#include "rtdata.h"
#include "streamio.h"
#ifdef DLHEAP
void _cdecl dlfree(void*);
void _cdecl mf_init();
#define malloc dlmalloc
#define free dlfree
#define realloc dlrealloc
#define lib_free dlfree
#endif
/*
NOTE: This routine does not actually free the link/FILE structures.
That is because code assumes that it can fclose the file and then
freopen is a short time later. The __purgefp routine can be called
to actually release the storage.
*/
void __freefp( FILE * fp )
{
__stream_link **owner;
__stream_link *link;
_AccessIOB();
owner = &_RWD_ostream;
for( ;; ) {
link = *owner;
if( link == NULL )
return;
if( link->stream == fp )
break;
owner = &link->next;
}
fp->_flag |= _READ | _WRITE;
(*owner) = link->next;
link->next = _RWD_cstream;
_RWD_cstream = link;
_ReleaseIOB();
}
void __purgefp( void )
{
__stream_link *next;
_AccessIOB();
while( _RWD_cstream != NULL ) {
next = _RWD_cstream->next;
lib_free( _RWD_cstream );
_RWD_cstream = next;
}
_ReleaseIOB();
}

View File

@ -1,157 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Implementation of fseek - set stream position.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include "fileacc.h"
#include "rtdata.h"
#include "seterrno.h"
#include "flush.h"
static int __update_buffer( long diff, FILE *fp )
{
/*
diff is relative to fp->_ptr
if diff is within the buffer update the pointers and return 0
otherwise update the pointers and return 1
*/
if( diff <= fp->_cnt && diff >= (_FP_BASE(fp) - fp->_ptr) ) {
fp->_flag &= ~(_EOF);
fp->_ptr += diff;
fp->_cnt -= diff;
return( 0 );
}
return( 1 );
}
/*
* This used to be in __update_buffer(), but we don't want to do this until
* AFTER we've made certain that lseek() will be a successful one.
*/
static void __reset_buffer( FILE *fp )
{
fp->_flag &= ~(_EOF);
fp->_ptr = _FP_BASE(fp);
fp->_cnt = 0;
}
_WCRTLINK int fseek( FILE *fp, long offset, int origin )
{
_ValidFile( fp, -1 );
_AccessFile( fp );
/*
if the file is open for any sort of writing we must ensure that
the buffer is flushed when dirty so that the integrity of the
data is preserved.
if there is an ungotten character in the buffer then the data must
be discarded to ensure the integrity of the data
*/
if( fp->_flag & (_WRITE | _UNGET) ) {
if( fp->_flag & _DIRTY ) {
/*
the __flush routine aligns the DOS file pointer with the
start of the resulting cleared buffer, as such, the SEEK_CUR
code used for the non-_DIRTY buffer case is not required
*/
if( __flush( fp ) ) {
// assume __flush set the errno value
// if erroneous input, override errno value
if( origin == SEEK_SET && offset < 0 ) {
__set_errno( EINVAL );
}
_ReleaseFile( fp );
return( -1 );
}
} else {
if( origin == SEEK_CUR ) {
offset -= fp->_cnt;
}
fp->_ptr = _FP_BASE(fp);
fp->_cnt = 0;
}
fp->_flag &= ~(_EOF|_UNGET);
if( lseek( fileno( fp ), offset, origin ) == -1 ) {
_ReleaseFile( fp );
return( -1 );
}
} else {
// file is open for read only,
// no characters have been ungotten
// the OS file pointer is at fp->_ptr + fp->_cnt relative to the
// FILE* buffer
switch( origin ) {
case SEEK_CUR:
{ long ptr_delta = fp->_cnt;
if( __update_buffer( offset, fp ) ) {
offset -= ptr_delta;
if( lseek( fileno( fp ), offset, origin ) == -1 ) {
_ReleaseFile( fp );
return( -1 );
}
__reset_buffer(fp);
}
} break;
case SEEK_SET:
{ long file_ptr = tell( fileno( fp ) );
file_ptr -= fp->_cnt;
if( __update_buffer( offset - file_ptr, fp ) ) {
if( lseek( fileno( fp ), offset, origin ) == -1 ) {
_ReleaseFile( fp );
return( -1 );
}
__reset_buffer(fp);
}
} break;
case SEEK_END:
fp->_flag &= ~(_EOF);
fp->_ptr = _FP_BASE(fp);
fp->_cnt = 0;
if( lseek( fileno( fp ), offset, origin ) == -1 ) {
_ReleaseFile( fp );
return( -1 );
}
break;
default:
__set_errno( EINVAL );
_ReleaseFile( fp );
return( -1 );
}
}
_ReleaseFile( fp );
return( 0 ); /* indicate success */
}

View File

@ -1,47 +0,0 @@
;*****************************************************************************
;*
;* Open Watcom Project
;*
;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
;*
;* ========================================================================
;*
;* This file contains Original Code and/or Modifications of Original
;* Code as defined in and that are subject to the Sybase Open Watcom
;* Public License version 1.0 (the 'License'). You may not use this file
;* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
;* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
;* provided with the Original Code and Modifications, and is also
;* available at www.sybase.com/developer/opensource.
;*
;* The Original Code and all software distributed under the License are
;* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
;* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
;* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
;* NON-INFRINGEMENT. Please see the License for the specific language
;* governing rights and limitations under the License.
;*
;* ========================================================================
;*
;* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
;* DESCRIBE IT HERE!
;*
;*****************************************************************************
FPE_OK equ 0
FPE_INVALID equ 81h
FPE_DENORMAL equ 82h
FPE_ZERODIVIDE equ 83h
FPE_OVERFLOW equ 84h
FPE_UNDERFLOW equ 85h
FPE_INEXACT equ 86h
FPE_UNEMULATED equ 87h
FPE_SQRTNEG equ 88h
FPE_STACKOVERFLOW equ 8ah
FPE_STACKUNDERFLOW equ 8bh
FPE_EXPLICITGEN equ 8ch
FPE_IOVERFLOW equ 8dh
FPE_LOGERR equ 8eh
FPE_MODERR equ 8fh

View File

@ -1,74 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include <errno.h>
#if defined(__DOS__) || defined(__WINDOWS__)
#elif defined(__NT__)
#elif defined(__OS2__)
#elif defined(__NETWARE__)
#endif
#include <unistd.h>
#include "iomode.h"
#include "rtcheck.h"
#include "seterrno.h"
/*
// take fsync from LIBC import file
*/
#if !defined (_NETWARE_LIBC)
_WCRTLINK int fsync( int handle )
/*******************************/
{
int ret = 0;
__handle_check( handle, -1 );
#if defined(__DOS__) || defined(__WINDOWS__)
#elif defined(__NT__)
// if( !FlushFileBuffers( __getOSHandle( handle ) ) )
// {
// __set_errno_nt();
// ret = -1;
// }
#elif defined(__OS2__)
#elif defined(__NETWARE__)
#else
#error Unknown target system
#endif
return( ret );
}
#endif /* !defined (_NETWARE_LIBC) */

View File

@ -1,61 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Platform independent ftell() implementaiton.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "fileacc.h"
_WCRTLINK long ftell( FILE *fp )
{
long pos;
_ValidFile( fp, -1 );
if( fp->_flag & _APPEND && fp->_flag & _DIRTY ) {
fflush( fp ); /* if data written in append mode, OS must know */
}
pos = tell( fileno( fp ) );
if( pos == -1 ) {
return( -1L );
}
_AccessFile( fp );
if( fp->_cnt != 0 ) { /* if something in buffer */
if( fp->_flag & _DIRTY ) { /* last operation was a put */
pos += fp->_cnt;
} else { /* last operation was a get */
pos -= fp->_cnt;
}
}
_ReleaseFile( fp );
return( pos );
}

View File

@ -1,45 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Prototypes for floating-point formatting routines.
*
****************************************************************************/
#ifndef _FTOS_H_INCLUDED
#define _FTOS_H_INCLUDED
#include "variety.h"
#include "farsupp.h"
_WCRTLINK extern FAR_STRING (*__EFG_printf)();
_WCRTLINK extern void (*__EFG_scanf)();
extern FAR_STRING _EFG_Format();
extern void __cnvs2d();
_WMRTLINK extern FAR_STRING (*__get_EFG_Format())();
_WMRTLINK extern void (*__get__cnvs2d())();
#endif

View File

@ -1,161 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Platform independent fwrite() implementation.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include "fileacc.h"
#include "rtdata.h"
#include "seterrno.h"
#include "qwrite.h"
#include "flush.h"
#include "streamio.h"
_WCRTLINK size_t fwrite( const void *buf, size_t size, size_t n, FILE *fp )
{
size_t count;
unsigned oflag;
_ValidFile( fp, 0 );
_AccessFile( fp );
if( (fp->_flag & _WRITE) == 0 ) {
__set_errno( EBADF );
fp->_flag |= _SFERR;
_ReleaseFile( fp );
return( 0 ); /* POSIX says return 0 */
}
n *= size;
if( n == 0 ) {
_ReleaseFile( fp );
return( n );
}
if( _FP_BASE(fp) == NULL ) {
__ioalloc( fp ); /* allocate buffer */
}
oflag = fp->_flag & (_SFERR | _EOF); /* JBS 27-jan-92 */
fp->_flag &= ~(_SFERR | _EOF); /* JBS 27-jan-92 */
count = 0;
#if !defined( __UNIX__ )
if( fp->_flag & _BINARY ) { /* binary I/O */
#else
{
#endif
size_t bytes_left = n, bytes;
do {
/* if our buffer is empty, and user's buffer is larger,
then write directly from user's buffer. 28-apr-90 */
if( fp->_cnt == 0 && bytes_left >= fp->_bufsize ) {
bytes = bytes_left & -512; /* multiple of 512 */
if( bytes == 0 ) {
bytes = bytes_left; /* bufsize < 512 */
}
n = __qwrite( fileno( fp ), buf, bytes );
if( n == -1 ) {
fp->_flag |= _SFERR;
}
#if !defined( __UNIX__ )
else if( n == 0 ) {
_RWD_errno = ENOSPC;
fp->_flag |= _SFERR;
}
#endif
bytes = n;
} else {
bytes = fp->_bufsize - fp->_cnt;
if( bytes > bytes_left ) {
bytes = bytes_left;
}
memcpy( fp->_ptr, buf, bytes );
fp->_ptr += bytes;
fp->_cnt += bytes;
fp->_flag |= _DIRTY;
if( (fp->_cnt == fp->_bufsize) || (fp->_flag & _IONBF) ) {
__flush(fp);
}
}
buf = ((const char *)buf) + bytes;
count += bytes;
bytes_left -= bytes;
} while( bytes_left && !ferror( fp ) );
#if !defined( __UNIX__ )
} else { /* text I/O */
const char *bufptr;
int not_buffered;
#ifndef __NETWARE__
int old_orientation;
#endif
/* temporarily enable buffering saving the previous setting */
not_buffered = 0;
if( fp->_flag & _IONBF ) {
not_buffered = 1;
fp->_flag &= ~_IONBF;
fp->_flag |= _IOFBF;
}
/*** Use fputc, and make it think the stream is byte-oriented ***/
#ifndef __NETWARE__
old_orientation = _FP_ORIENTATION(fp);
_FP_ORIENTATION(fp) = _BYTE_ORIENTED;
#endif
bufptr = (const char *)buf;
do {
fputc( *(bufptr++), fp );
if( fp->_flag & (_EOF | _SFERR) ) break;
++count;
} while( count != n );
#ifndef __NETWARE__
_FP_ORIENTATION(fp) = old_orientation;
#endif
if( not_buffered ) { /* if wasn't buffered, then reset */
fp->_flag &= ~_IOFBF;
fp->_flag |= _IONBF;
__flush( fp );
}
#endif
}
if( fp->_flag & _SFERR ) {
/*
* Quantum 11-17-92 Temporary buffering confuses the return
* value if the call is interrupted.
* kludge: return 0 on error
*/
count = 0;
}
fp->_flag |= oflag; /* JBS 27-jan-92 */
_ReleaseFile( fp );
return( count / size );
}

View File

@ -1,50 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include <conio.h>
#include <stdio.h>
#include "rtdata.h"
_WCRTLINK int getche()
{
unsigned c;
unsigned stashed;
stashed = _RWD_cbyte;
c = getch();
if( c != EOF && stashed == 0 ) {
putch( c );
}
return( c );
}

View File

@ -1,41 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: prototypes for handleio internal functions
*
****************************************************************************/
/* __plusplus_fstat and __plusplus_open are used by C++ run-time library */
_WCRTLINK extern int __plusplus_fstat( int handle, int *pios_mode );
_WCRTLINK extern int __plusplus_open( const char *name, int *pios_mode, int prot );
extern unsigned __IOMode( int handle );
extern void __set_handles( int num );
extern void __grow_iomode( int num );
extern void __shrink_iomode( void );
extern unsigned *__io_mode;

View File

@ -1,257 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Handle manager routines.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <stdlib.h>
#include "liballoc.h"
#include <string.h>
#ifdef _M_IX86
#include <i86.h>
#endif
#include <unistd.h>
#include <errno.h>
#if defined(__OS2__)
#elif defined(__WINDOWS__) || defined(__NT__)
#endif
#include "iomode.h"
#include "fileacc.h"
#include "rtinit.h"
#include "seterrno.h"
#include "handleio.h"
#undef __getOSHandle
extern unsigned __NFiles; // the size of the iomode array
extern void __grow_iomode( int num );
unsigned __NHandles = 0;
#if defined(__NT__)
HANDLE *__OSHandles = NULL;
unsigned __growPOSIXHandles( unsigned num )
{
HANDLE *new2;
unsigned i;
if( num > __NHandles )
{
_AccessFList();
if( __OSHandles == NULL )
{
new2 = lib_malloc( num * sizeof( int ) );
}
else
{
new2 = lib_realloc( __OSHandles, num * sizeof( int ) );
}
if( new2 == NULL )
{
__set_errno( ENOMEM );
num = __NHandles;
}
else
{
for( i = __NHandles; i < num; i++ )
{
new2[ i ] = NULL_HANDLE;
}
__OSHandles = new2;
__NHandles = num;
}
_ReleaseFList();
}
return( __NHandles );
}
int __allocPOSIXHandle( HANDLE hdl )
{
int i;
_AccessFList();
for( i = 0; i < __NHandles; i++ )
{
if( __OSHandles[i] == NULL_HANDLE ) break;
}
if( i >= __NHandles )
{
// 20 -> (20+10+1) -> 31
// 31 -> (31+15+1) -> 47
// 47 -> (47+23+1) -> 71
__growPOSIXHandles( i + (i >> 1) + 1 );
// keep iomode array in sync
if( __NHandles > __NFiles ) __grow_iomode( __NHandles );
for( ; i < __NHandles; i++ )
{
if( __OSHandles[i] == NULL_HANDLE ) break;
}
}
if( i >= __NHandles )
{
i = -1;
} else {
__OSHandles[i] = hdl;
}
_ReleaseFList();
return( i );
}
void __freePOSIXHandle( int hid )
{
__OSHandles[ hid ] = NULL_HANDLE;
}
HANDLE __getOSHandle( int hid )
{
return( __OSHandles[ hid ] );
}
int __setOSHandle( unsigned hid, HANDLE hdl )
{
// call the Win32 API for a standard file handle
switch( hid ) {
case STDIN_FILENO:
// SetStdHandle( STD_INPUT_HANDLE, hdl );
break;
case STDOUT_FILENO:
// SetStdHandle( STD_OUTPUT_HANDLE, hdl );
break;
case STDERR_FILENO:
// SetStdHandle( STD_ERROR_HANDLE, hdl );
break;
}
if( hid < __NHandles )
{
__OSHandles[ hid ] = hdl;
}
else
{
hid = (unsigned)-1; // this should never happen
}
return( hid );
}
HANDLE *__FakeHandles = 0;
static int __topFakeHandle = 0;
HANDLE __NTGetFakeHandle( void )
{
HANDLE os_handle;
static DWORD fakeHandle = 0x80000000L;
_AccessFList();
fakeHandle++;
os_handle = (HANDLE)fakeHandle;
_ReleaseFList();
return( os_handle );
}
// called from library startup code
void __initPOSIXHandles( void )
{
HANDLE h;
// __OSHandles = NULL;
// __NHandles = 0;
__growPOSIXHandles( __NFiles );
h = 0; //GetStdHandle( STD_INPUT_HANDLE );
if( h == 0 || h == INVALID_HANDLE_VALUE ) {
h = (HANDLE)__NTGetFakeHandle();
}
__allocPOSIXHandle( h ); // should return 0==STDIN_FILENO
h = 0; //GetStdHandle( STD_OUTPUT_HANDLE );
if( h == 0 || h == INVALID_HANDLE_VALUE ) {
h = (HANDLE)__NTGetFakeHandle();
}
__allocPOSIXHandle( h ); // should return 1==STDOUT_FILENO
h = 0; //GetStdHandle( STD_ERROR_HANDLE );
if( h == 0 || h == INVALID_HANDLE_VALUE ) {
h = (HANDLE)__NTGetFakeHandle();
}
__allocPOSIXHandle( h ); // should return 3==STDERR_FILENO
}
static void __finiPOSIXHandles( void )
{
if( __OSHandles != NULL ) {
lib_free( __OSHandles );
__OSHandles = NULL;
}
if( __FakeHandles != NULL )
{
int i;
for( i = 0 ; i < __topFakeHandle ; i++ )
{
// CloseHandle( __FakeHandles[i] );
}
lib_free( __FakeHandles );
__FakeHandles = 0;
}
}
AYI( __finiPOSIXHandles, INIT_PRIORITY_LIBRARY-1 )
#endif
void __set_handles( int num )
{
__NHandles = num;
}
_WCRTLINK int _grow_handles( int num )
{
if( num > __NHandles )
{
#if defined(MSDOS)
#elif defined( __OS2_286__ )
#elif defined( __WARP__ )
#elif defined(__WINDOWS__)
#elif defined(__NT__)
{
num = __growPOSIXHandles( num );
}
#elif defined(__NETWARE__)
#elif defined(__UNIX__)
#endif
if( num > __NFiles ) {
__grow_iomode( num ); // sets new __NFiles if successful
}
__NHandles = num;
}
return( __NHandles );
}

View File

@ -1,34 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
_WCRTLINKD unsigned short const _HUGEDATA _HugeValue[] = { 0x0000, 0x0000, 0x0000, 0x7ff0 };

View File

@ -1,83 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Stream I/O initializer.
*
****************************************************************************/
//#include "dll.h" // needs to be first
#include "variety.h"
#include <stdio.h>
#include <stdlib.h>
#include "liballoc.h"
#include "mf.h"
#include "rtdata.h"
#include "exitwmsg.h"
#ifdef DLHEAP
void* _cdecl dlmalloc(size_t);
void _cdecl dlfree(void*);
void _cdecl mf_init();
#define malloc dlmalloc
#define free dlfree
#define realloc dlrealloc
#define lib_malloc dlmalloc
#define lib_free dlfree
#define lib_realloc dlrealloc
#endif
void __InitFiles( void )
{
__stream_link *link;
FILE *fp;
fp = _RWD_iob;
stderr->_flag &= ~(_IONBF | _IOLBF | _IOFBF);
stderr->_flag |= _IONBF;
for( fp = _RWD_iob; fp->_flag != 0; ++fp )
{
link = lib_malloc( sizeof( __stream_link ) );
if( link == NULL )
{
__fatal_runtime_error(
"Not enough memory to allocate file structures\r\n", 1 );
}
link->stream = fp;
link->next = _RWD_ostream;
_RWD_ostream = link;
fp->_link = link;
fp->_link->_base = NULL;
fp->_link->_tmpfchar = 0;
fp->_link->_orientation = _NOT_ORIENTED;
}
_RWD_cstream = NULL;
}

View File

@ -1,68 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Platform independent __ioalloc() implementation.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include "liballoc.h"
#include <unistd.h>
#include "rtdata.h"
#include "streamio.h"
void __ioalloc( FILE *fp )
{
__chktty( fp ); /* JBS 28-aug-90 */
if( fp->_bufsize == 0 ) {
if( fp->_flag & _IOLBF ) {
fp->_bufsize = 134;
} else if( fp->_flag & _IONBF ) {
/* Use small but reasonably sized buffer; otherwise we will end
* up calling into the OS for every character, completely killing
* performance on unbuffered stream output through printf() etc.,
* especially in extended DOS because of mode switches.
*/
fp->_bufsize = 64;
} else {
fp->_bufsize = BUFSIZ;
}
}
_FP_BASE(fp) = lib_malloc( fp->_bufsize );
if( _FP_BASE(fp) == NULL ) {
fp->_flag &= ~(_IONBF | _IOLBF | _IOFBF);
fp->_flag |= _IONBF; /* can't get big buffer */
_FP_BASE(fp) = (char *)&(fp->_ungotten);
fp->_bufsize = 1;
} else {
fp->_flag |= _BIGBUF; /* got big buffer */
}
fp->_ptr = _FP_BASE(fp);
fp->_cnt = 0;
}

View File

@ -1,62 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Definition of __iob array.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include "rtdata.h"
#include "rtinit.h"
#include "tmpfname.h"
_WCRTLINKD FILE _WCNEAR __iob[_NFILES] = {
{ NULL, 0, NULL, _READ, 0, 0, 0 } /* stdin */
,{ NULL, 0, NULL, _WRITE, 1, 0, 0 } /* stdout */
,{ NULL, 0, NULL, _WRITE, 2, 0, 0 } /* stderr */
#if defined( __DOS__ ) || defined( __WINDOWS__ ) || defined( __OSI__ )
,{ NULL, 0, NULL, _READ|_WRITE, 3, 0, 0 } /* stdaux */
,{ NULL, 0, NULL, _WRITE, 4, 0, 0 } /* stdprn */
#endif
};
__stream_link *__ClosedStreams;
__stream_link *__OpenStreams;
#if !defined( __UNIX__ )
_WCRTLINKD int _WCNEAR _fmode = O_TEXT; /* default file translation mode */
#endif
extern void __InitFiles();
extern void __full_io_exit();
AXI(__InitFiles,INIT_PRIORITY_LIBRARY);
AYI(__full_io_exit,INIT_PRIORITY_LIBRARY);

View File

@ -1,140 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Standard stream/file accessor routines.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include "rtdata.h"
#if !defined( __NETWARE__ ) && !defined( _THIN_LIB )
_WCRTLINK FILE *__get_std_stream( unsigned handle )
{
if( handle > NUM_STD_STREAMS ) {
return( NULL );
} else {
return( &_RWD_iob[handle] );
}
}
_WCRTLINK FILE *__get_std_file( unsigned handle )
{
return( __get_std_stream( handle ) );
}
#else
#include <io.h>
#if defined( _NETWARE_LIBC )
extern FILE **___stdin ( void );
extern FILE **___stdout( void );
extern FILE **___stderr( void );
extern FILE **___cin ( void );
extern FILE **___cout ( void );
_WCRTLINK FILE *__get_std_stream( unsigned handle )
{
FILE *pFile = NULL;
switch( handle ) {
case STDIN_FILENO:
pFile = *___stdin();
break;
case STDOUT_FILENO:
pFile = *___stdout();
break;
case STDERR_FILENO:
pFile = *___stderr();
break;
default:
break;
}
return( pFile );
}
#elif defined( _NETWARE_CLIB )
extern FILE **__get_stdin ( void );
extern FILE **__get_stdout( void );
extern FILE **__get_stderr( void );
_WCRTLINK FILE *__get_std_stream( unsigned handle )
{
FILE *pFile = NULL;
switch( handle ) {
case STDIN_FILENO:
pFile = *__get_stdin();
break;
case STDOUT_FILENO:
pFile = *__get_stdout();
break;
case STDERR_FILENO:
pFile = *__get_stderr();
break;
default:
break;
}
return( pFile );
}
#endif
#endif
#if defined( __NETWARE__ ) && !defined( _THIN_LIB )
#include <io.h>
FILE **__get_stdin( void )
{
static FILE *stdin_ptr;
stdin_ptr = __get_std_stream( STDIN_FILENO );
return( &stdin_ptr );
}
FILE **__get_stdout( void )
{
static FILE *stdout_ptr;
stdout_ptr = __get_std_stream( STDOUT_FILENO );
return( &stdout_ptr );
}
FILE **__get_stderr( void )
{
static FILE *stderr_ptr;
stderr_ptr = __get_std_stream( STDERR_FILENO );
return( &stderr_ptr );
}
#endif

View File

@ -1,84 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: I/O streams shutdown.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include "rtdata.h"
extern void __purgefp(void);
extern int __shutdown_stream( FILE *fp, int );
static int docloseall( unsigned dont_close )
{
FILE *fp;
int number_of_files_closed;
__stream_link *link;
__stream_link *next;
FILE *bottom;
FILE *standards;
int close_handle;
bottom = &_RWD_iob[dont_close];
standards = &_RWD_iob[NUM_STD_STREAMS];
number_of_files_closed = 0;
for( link = _RWD_ostream; link != NULL; link = next ) {
next = link->next;
fp = link->stream;
close_handle = 1;
if ((fp->_flag & _DYNAMIC) || (fp->_flag & _TMPFIL))
{
__shutdown_stream( fp, close_handle );
++number_of_files_closed;
}
else if( fp >= bottom ) {
#ifndef __NETWARE__
/* close the file, but leave the handle open */
if( fp < standards ) {
close_handle = 0;
}
#endif
__shutdown_stream( fp, close_handle );
++number_of_files_closed;
}
}
return( number_of_files_closed );
}
_WCRTLINK int fcloseall( void )
{
return( docloseall( NUM_STD_STREAMS ) );
}
void __full_io_exit( void )
{
docloseall( 0 );
__purgefp();
}

View File

@ -1,80 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: io_mode handle information array manipulation
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include "rtdata.h"
//#include "liballoc.h"
#include "fileacc.h"
#include "rtinit.h"
#include "seterrno.h"
#include "iomode.h"
unsigned __NFiles = _NFILES; /* maximum # of files we can open */
#if defined(__NETWARE__)
#error NO IO MODE MANAGER UNDER NETWARE
#endif
#if !defined(__UNIX__)
unsigned _HUGEDATA __init_mode[_NFILES] = { /* file mode information (flags) */
_READ, /* stdin */
_WRITE, /* stdout */
_WRITE, /* stderr */
_READ|_WRITE, /* stdaux */
_WRITE /* stdprn */
};
unsigned *__io_mode = __init_mode; /* initially points to static array */
unsigned __GetIOMode( int handle )
{
if( handle >= __NFiles )
{
return( 0 );
}
return( __io_mode[handle] );
}
void __SetIOMode_nogrow( int handle, unsigned value )
{
if( handle < __NFiles )
{
__io_mode[handle] = value; /* we're closing it; smite _INITIALIZED */
}
}
#endif

View File

@ -1,70 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: prototypes and definitions for iomode array manipulation
*
****************************************************************************/
#ifndef _IOMODE_H_INCLUDED
#define _IOMODE_H_INCLUDED
#if defined(__NT__)
#include <windows.h>
#define NULL_HANDLE (HANDLE)-1
#define DUMMY_HANDLE (HANDLE)-2
extern unsigned __NHandles;
extern void __initPOSIXHandles( void );
extern unsigned __growPOSIXHandles( unsigned num );
extern int __allocPOSIXHandle( HANDLE hdl );
extern void __freePOSIXHandle( int hid );
extern HANDLE __getOSHandle( int hid );
extern int __setOSHandle( unsigned hid, HANDLE hdl );
extern HANDLE __NTGetFakeHandle( void );
extern HANDLE *__OSHandles;
#define __getOSHandle( hid ) __OSHandles[ hid ]
#define NT_STDIN_FILENO (__getOSHandle( STDIN_FILENO ))
#define NT_STDOUT_FILENO (__getOSHandle( STDOUT_FILENO ))
#define NT_STDERR_FILENO (__getOSHandle( STDERR_FILENO ))
#endif
#if !defined(__NETWARE__)
extern unsigned __GetIOMode( int __handle );
extern int __SetIOMode( int __handle, unsigned __value );
extern void __SetIOMode_nogrow( int __handle, unsigned __value );
extern void __ChkTTYIOMode( int __handle );
#endif
#endif

View File

@ -1,59 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: check tty for standard handles in the iomode array
*
****************************************************************************/
#include "variety.h"
#include <unistd.h>
#include "rtdata.h"
//#include "liballoc.h"
#include "fileacc.h"
#include "handleio.h"
#include "iomode.h"
#define _INITIALIZED _DYNAMIC
void __ChkTTYIOMode( int handle )
{
if( handle < NUM_STD_STREAMS && !(__io_mode[handle] & _INITIALIZED) )
{
__io_mode[handle] |= _INITIALIZED;
if( isatty( handle ) )
{
__io_mode[handle] |= _ISTTY;
}
}
}
// For F77 to call
unsigned __IOMode( int handle )
{
__ChkTTYIOMode( handle );
return( __GetIOMode( handle ) );
}

View File

@ -1,54 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Implementation of isatty() for Win32.
*
****************************************************************************/
#include "variety.h"
#include <unistd.h>
//#include <windows.h>
//#include "defwin.h"
#include "iomode.h"
#include "fileacc.h"
/*
DWORD GetFileType(
HANDLE hFile // handle to file
);
Return value can be:
FILE_TYPE_CHAR The specified file is a character file,
typically an LPT device or a console
*/
_WCRTLINK int isatty( int hid )
{
// if( GetFileType( __getOSHandle( hid ) ) == FILE_TYPE_CHAR ) {
// return( 1 );
// }
return( 0 );
}

View File

@ -1,295 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Character classification table.
*
****************************************************************************/
#include "variety.h"
#include <ctype.h>
_WCRTLINKD const char _HUGEDATA _IsTable[257] = {
#define ___0__ 0
/* -1,EOF */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 00,NUL */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 01,SOH */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 02,STX */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 03,ETX */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 04,EOT */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 05,ENQ */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 06,NAK */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 07,BEL */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 08,BS */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 09,TAB */ ___0__|___0__|___0__|___0__|___0__|___0__|_SPACE|_CNTRL,
/* 0A,LF */ ___0__|___0__|___0__|___0__|___0__|___0__|_SPACE|_CNTRL,
/* 0B,VT */ ___0__|___0__|___0__|___0__|___0__|___0__|_SPACE|_CNTRL,
/* 0C,FF */ ___0__|___0__|___0__|___0__|___0__|___0__|_SPACE|_CNTRL,
/* 0D,CR */ ___0__|___0__|___0__|___0__|___0__|___0__|_SPACE|_CNTRL,
/* 0E,SI */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 0F,SO */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 10, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 11, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 12, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 13, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 14, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 15, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 16, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 17, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 18, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 19, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 1A, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 1B, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 1C, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 1D, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 1E, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 1F, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 20, */ ___0__|___0__|___0__|___0__|_PRINT|___0__|_SPACE|___0__,
/* 21, ! */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 22, " */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 23, # */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 24, $ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 25, % */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 26, & */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 27, ' */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 28, ( */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 29, ) */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 2A, * */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 2B, + */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 2C, , */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 2D, - */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 2E, . */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 2F, / */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 30, 0 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 31, 1 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 32, 2 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 33, 3 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 34, 4 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 35, 5 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 36, 6 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 37, 7 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 38, 8 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 39, 9 */ ___0__|___0__|_DIGIT|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 3A, : */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 3B, ; */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 3C, < */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 3D, = */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 3E, > */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 3F, ? */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 40, @ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 41, A */ ___0__|_UPPER|___0__|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 42, B */ ___0__|_UPPER|___0__|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 43, C */ ___0__|_UPPER|___0__|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 44, D */ ___0__|_UPPER|___0__|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 45, E */ ___0__|_UPPER|___0__|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 46, F */ ___0__|_UPPER|___0__|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 47, G */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 48, H */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 49, I */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 4A, J */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 4B, K */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 4C, L */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 4D, M */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 4E, N */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 4F, O */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 50, P */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 51, Q */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 52, R */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 53, S */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 54, T */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 55, U */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 56, V */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 57, W */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 58, X */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 59, Y */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 5A, Z */ ___0__|_UPPER|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 5B, [ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 5C, \ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 5D, ] */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 5E, ^ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 5F, _ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 60, ` */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 61, a */ _LOWER|___0__|___0__|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 62, b */ _LOWER|___0__|___0__|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 63, c */ _LOWER|___0__|___0__|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 64, d */ _LOWER|___0__|___0__|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 65, e */ _LOWER|___0__|___0__|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 66, f */ _LOWER|___0__|___0__|_XDIGT|_PRINT|___0__|___0__|___0__,
/* 67, g */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 68, h */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 69, i */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 6A, j */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 6B, k */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 6C, l */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 6D, m */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 6E, n */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 6F, o */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 70, p */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 71, q */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 72, r */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 73, s */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 74, t */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 75, u */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 76, v */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 77, w */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 78, x */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 79, y */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 7A, z */ _LOWER|___0__|___0__|___0__|_PRINT|___0__|___0__|___0__,
/* 7B, { */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 7C, | */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 7D, } */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 7E, ~ */ ___0__|___0__|___0__|___0__|_PRINT|_PUNCT|___0__|___0__,
/* 7F,DEL */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|_CNTRL,
/* 80, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 81, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 82, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 83, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 84, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 85, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 86, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 87, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 88, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 89, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 8A, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 8B, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 8C, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 8D, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 8E, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 8F, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 90, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 91, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 92, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 93, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 94, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 95, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 96, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 97, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 98, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 99, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 9A, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 9B, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 9C, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 9D, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 9E, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* 9F, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* A0, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* A1, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* A2, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* A3, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* A4, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* A5, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* A6, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* A7, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* A8, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* A9, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* AA, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* AB, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* AC, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* AD, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* AE, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* AF, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* B0, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* B1, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* B2, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* B3, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* B4, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* B5, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* B6, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* B7, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* B8, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* B9, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* BA, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* BB, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* BC, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* BD, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* BE, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* BF, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* C0, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* C1, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* C2, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* C3, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* C4, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* C5, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* C6, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* C7, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* C8, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* C9, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* CA, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* CB, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* CC, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* CD, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* CE, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* CF, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* D0, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* D1, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* D2, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* D3, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* D4, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* D5, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* D6, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* D7, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* D8, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* D9, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* DA, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* DB, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* DC, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* DD, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* DE, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* DF, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* E0, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* E1, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* E2, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* E3, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* E4, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* E5, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* E6, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* E7, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* E8, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* E9, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* EA, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* EB, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* EC, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* ED, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* EE, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* EF, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* F0, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* F1, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* F2, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* F3, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* F4, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* F5, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* F6, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* F7, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* F8, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* F9, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* FA, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* FB, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* FC, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* FD, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* FE, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__,
/* FF, */ ___0__|___0__|___0__|___0__|___0__|___0__|___0__|___0__ };

View File

@ -1,105 +0,0 @@
#ifdef __cplusplus
extern "C"
{
#endif
#define FONT0 0x00000000
#define FONT1 0x10000000
#define BT_NORMAL 0x00000000
#define BT_NOFRAME 0x20000000
#define BT_HIDE 0x40000000
#define BT_DEL 0x80000000
#define EV_REDRAW 1
#define EV_KEY 2
#define EV_BUTTON 3
#define REL_SCREEN 0
#define REL_WINDOW 1
#define FILE_NOT_FOUND 5
#define FILE_EOF 6
typedef unsigned int DWORD;
typedef unsigned short int WORD;
typedef struct
{ DWORD pci_cmd;
DWORD irq;
DWORD glob_cntrl;
DWORD glob_sta;
DWORD codec_io_base;
DWORD ctrl_io_base;
DWORD codec_mem_base;
DWORD ctrl_mem_base;
DWORD codec_id;
} CTRL_INFO;
typedef struct
{ DWORD cmd;
DWORD offset;
DWORD r1;
DWORD count;
DWORD buff;
char r2;
char *name;
} FILEIO;
typedef struct
{ DWORD attr;
DWORD flags;
DWORD cr_time;
DWORD cr_date;
DWORD acc_time;
DWORD acc_date;
DWORD mod_time;
DWORD mod_date;
DWORD size;
DWORD size_high;
} FILEINFO;
void _stdcall InitHeap(int heap_size);
void* _stdcall UserAlloc(int size);
int _stdcall UserFree(void* p);
void _stdcall GetNotify(void *event);
void _stdcall CreateThread(void *fn, char *p_stack);
DWORD _stdcall GetMousePos(DWORD rel_type);
void _stdcall debug_out_hex(DWORD val);
void debug_out_str(char* str);
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
int _stdcall read_file (const char *name,char*buff,DWORD offset, DWORD count,DWORD *reads);
int _stdcall write_file(const char *name,char*buff,int offset,int count,int *writes);
//void exit();
int _stdcall get_key(int *key);
int _stdcall remap_key(int key);
int _cdecl get_button_id();
void delay(int val);
int wait_for_event(int time);
int wait_for_event_infinite();
void BeginDraw(void);
void EndDraw(void);
void _stdcall GetScreenSize(int *x, int*y);
void _stdcall DrawWindow(int x,int y, int sx, int sy,int workcolor,int style,
int captioncolor,int windowtype,int bordercolor);
void _stdcall debug_out(int ch);
void _stdcall make_button(int x, int y, int xsize, int ysize, int id, int color);
void _stdcall draw_bar(int x, int y, int xsize, int ysize, int color);
void _stdcall write_text(int x,int y,int color,char* text,int len);
#ifdef __cplusplus
extern "C"
}
#endif

View File

@ -1,113 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Establish common stuff for a target environment for
* language-related processors.
*
****************************************************************************/
#ifndef __LANGENV_H__
#define __LANGENV_H__
// This file uses __TGT_SYS to figure out the required target.
//
// langenvd.h contains the possible values.
//
// __TGT_SYS_X86 is the default
//
#include "langenvd.h"
#ifndef __TGT_SYS
#define __TGT_SYS __TGT_SYS_X86
#endif
#if __TGT_SYS == __TGT_SYS_X86
#define TS_SEG_CODE "_TEXT"
#define TS_SEG_CONST "CONST"
#define TS_SEG_CONST2 "CONST2"
#define TS_SEG_DATA "_DATA"
#define TS_SEG_TIB "TIB"
#define TS_SEG_TI "TI"
#define TS_SEG_TIE "TIE"
#define TS_SEG_XIB "XIB"
#define TS_SEG_XI "XI"
#define TS_SEG_XIE "XIE"
#define TS_SEG_YIB "YIB"
#define TS_SEG_YI "YI"
#define TS_SEG_YIE "YIE"
#define TS_SEG_YC "YC"
#define TS_SEG_BSS "_BSS"
#define TS_SEG_STACK "STACK"
#define TS_SEG_DEPENDS "not used"
#define TS_SEG_TLSB ".tls"
#define TS_SEG_TLS ".tls$"
#define TS_SEG_TLSE ".tls$ZZZ"
#define TS_SEG_TLS_CLASS "TLS"
#define TS_MAX_OBJNAME 256
#define TS_DATA_MANGLE "_*"
#define TS_CODE_MANGLE "*_"
#elif __TGT_SYS == __TGT_SYS_AXP_NT || __TGT_SYS == __TGT_SYS_PPC_NT || __TGT_SYS == __TGT_SYS_MIPS
#define TS_SEG_CODE ".text"
#define TS_SEG_CONST ".const"
#define TS_SEG_CONST2 ".const2"
#define TS_SEG_DATA ".data"
#define TS_SEG_TIB ".rtl$tib"
#define TS_SEG_TI ".rtl$tid"
#define TS_SEG_TIE ".rtl$tie"
#define TS_SEG_XIB ".rtl$xib"
#define TS_SEG_XI ".rtl$xid"
#define TS_SEG_XIE ".rtl$xie"
#define TS_SEG_YIB ".rtl$yib"
#define TS_SEG_YI ".rtl$yid"
#define TS_SEG_YIE ".rtl$yie"
#define TS_SEG_YC ".rtl$yc"
#define TS_SEG_BSS ".bss"
#define TS_SEG_STACK ".stack"
#define TS_SEG_DEPENDS ".depend"
#define TS_SEG_TLSB ".tls"
#define TS_SEG_TLS ".tls$"
#define TS_SEG_TLSE ".tls$ZZZ"
#define TS_SEG_TLS_CLASS NULL
#define TS_MAX_OBJNAME 1024
#define TS_DATA_MANGLE "*"
#define TS_CODE_MANGLE "*"
#else
#error Invalid target system
#endif
#undef __TGT_SYS
#endif

View File

@ -1,40 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Define values for language targets.
*
****************************************************************************/
#ifndef __LANGENVD_H__
#define __LANGENVD_H__
#define __TGT_SYS_X86 0 // All x86 systems to date
#define __TGT_SYS_AXP_NT 1 // Win32 on DEC Alpha AXP
#define __TGT_SYS_PPC_NT 2 // Win32 on IBM/Motorola PowerPC
#define __TGT_SYS_MIPS 3 // MIPS RISC Architecture
#endif

View File

@ -1,90 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: These are macros that define the 'real' functions that
* the library memory allocators use.
*
****************************************************************************/
#ifndef _LIBALLOC_H_INCLUDED
#define _LIBALLOC_H_INCLUDED
#include "variety.h"
#include <malloc.h>
#ifdef __NETWARE__
/*
// NetWare uses Alloc and Free because the heap will not have
// been initialised at _Prelude time...
*/
#define lib_malloc( x ) _NW_malloc( x )
#define lib_free( x ) _NW_free( x )
#if defined (_NETWARE_CLIB)
#define lib_realloc( x, y, z) _NW_realloc( x, y, z )
#else
#define lib_realloc( x, y) _NW_realloc( x, y)
#endif
#define lib_calloc( x, y ) _NW_calloc( x, y )
extern void *_NW_calloc( size_t __n,size_t __size );
extern void *_NW_malloc( size_t );
#if defined (_NETWARE_CLIB)
extern void *_NW_realloc( void *ptr,size_t size,size_t old);
#else
extern void *_NW_realloc( void *ptr,size_t size);
#endif
extern void _NW_free( void *ptr );
#else
#define lib_malloc( x ) malloc( x )
#define lib_free( x ) free( x )
#define lib_realloc( x, y ) realloc( x, y )
#define lib_nmalloc( x ) _nmalloc( x )
#define lib_nfree( x ) _nfree( x )
#define lib_nrealloc( x, y ) _nrealloc( x, y )
#define lib_fmalloc( x ) _fmalloc( x )
#define lib_ffree( x ) _ffree( x )
#define lib_frealloc( x, y ) _frealloc( x, y )
#define lib_calloc( x, y ) calloc( x, y )
#endif
// these are used by the C++ library
// they are real routines so that the C++ library
// remains platform independent.
#ifdef __cplusplus
extern "C" {
#endif
_WCRTLINK extern void _plib_free( void *ptr );
_WCRTLINK extern void *_plib_malloc( size_t size );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,55 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: lseek wrapper with positive -> extend file check
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#ifdef __NT__
#include <windows.h>
#endif
#include "iomode.h"
#include "rtcheck.h"
#include "seterrno.h"
#include "lseek.h"
_WCRTLINK long lseek( int handle, long offset, int origin )
{
unsigned iomode_flags;
__handle_check( handle, -1 );
/*** Set the _FILEEXT iomode_flags bit if positive offset ***/
iomode_flags = __GetIOMode( handle );
if( offset > 0 && !(iomode_flags & _APPEND) )
__SetIOMode( handle, iomode_flags | _FILEEXT );
return( __lseek( handle, offset, origin ) );
}

View File

@ -1,41 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: basic __lseek (without file extend) definition/prototype
*
****************************************************************************/
#ifndef _LSEEK_H_INCLUDED
#define _LSEEK_H_INCLUDED
#if defined(__DOS__) || defined(__OS2__) || defined(__NT__) || defined(__WINDOWS__)
_WCRTLINK extern long __lseek( int handle, long offset, int origin );
#else
#define __lseek lseek
#endif
#endif

View File

@ -1,105 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.*
* ========================================================================
*
* Description: low level lseek without file extend for Windows NT
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#include "iomode.h"
#include "rtcheck.h"
#include "seterrno.h"
#include "lseek.h"
#include "handleio.h"
/*
DWORD SetFilePointer(
HANDLE hFile, // handle to file
LONG lDistanceToMove, // bytes to move pointer
PLONG lpDistanceToMoveHigh, // bytes to move pointer
DWORD dwMoveMethod // starting point
);
*/
#ifndef INVALID_SET_FILE_POINTER
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
#endif
typedef struct
{
char *name;
unsigned int offset;
}__file_handle;
typedef struct
{ DWORD attr;
DWORD flags;
DWORD cr_time;
DWORD cr_date;
DWORD acc_time;
DWORD acc_date;
DWORD mod_time;
DWORD mod_date;
DWORD size;
DWORD size_high;
} FILEINFO;
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
_WCRTLINK long __lseek( int hid, long offset, int origin )
{
__file_handle *fh;
long rc;
__handle_check( hid, -1 );
fh = (__file_handle*) __getOSHandle( hid );
switch(origin)
{
case SEEK_SET:
rc = offset;
break;
case SEEK_CUR:
rc = fh->offset + offset;
break;
case SEEK_END:
{
FILEINFO info;
get_fileinfo(fh->name,&info);
rc = offset + info.size;
break;
}
default:
return -1;
};
fh->offset = rc;
return( rc );
}

View File

@ -1,57 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#if !defined(MBCHARdotH)
#define MBCHARdotH
/* Prototype for initialization function */
extern int __mbinit( int codepage );
#define _MBINIT_CP_ANSI (-1)
#define _MBINIT_CP_OEM (-2)
#define _MBINIT_CP_SBCS (-3)
#define _MBINIT_CP_932 (-4)
/* Current code page */
#if !defined(__UNIX__)
extern unsigned int __MBCodePage;
#define _MB_CODE_PAGE_DEFINED
#endif
/* See if a packed DBCS char has no lead byte, i.e. is a skinny char */
#define SINGLE_BYTE_CHAR(__c) ( !( (__c)&0xFF00 ) )
#endif

View File

@ -1,306 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include <string.h>
#include <mbstring.h>
#include "mbchar.h"
unsigned int __MBCodePage = 0; /* default code page */
static void set_dbcs_table( int low, int high )
{
memset( __MBCSIsTable + low + 1, _MB_LEAD, high - low + 1 );
}
static void clear_dbcs_table( void )
{
__IsDBCS = 0; /* SBCS for now */
__MBCodePage = 0;
memset( __MBCSIsTable, 0, 257 );
}
/****
***** Initialize a multi-byte character set. Returns 0 on success.
****/
int __mbinit( int codepage )
{
/*** Handle values from _setmbcp ***/
if( codepage == _MBINIT_CP_ANSI )
{
codepage = 0;
}
else
if( codepage == _MBINIT_CP_OEM )
{
codepage = 0;
}
else
if( codepage == _MBINIT_CP_SBCS )
{
clear_dbcs_table();
return( 0 );
}
else
if( codepage == _MBINIT_CP_932 )
{
clear_dbcs_table();
set_dbcs_table( 0x81, 0x9F );
set_dbcs_table( 0xE0, 0xFC );
__IsDBCS = 1;
__MBCodePage = 932;
return( 0 );
}
return( 0 ); /* return success code */
}
/****
***** Query DOS to find the valid lead byte ranges.
****/
#if defined(__DOS__) && !defined(__OSI__)
#ifndef __386__
// for some unknown reason NT DPMI returns for DOS service 6300h
// Carry=0, odd SI value and DS stay unchanged
// this case is also tested as wrong int 21h result
#if 1
#pragma aux dos_get_dbcs_lead_table = \
"push ds" \
"xor ax,ax" \
"mov ds,ax" \
"mov ah,63h" /* get DBCS vector table */ \
"int 21h" \
"mov di,ds" \
"jnc label1" \
"xor di,di" \
"label1:" \
"test di,di" \
"jnz exit1" \
"mov si,di" \
"exit1:" \
"pop ds" \
value [di si] \
modify [ax bx cx dx si di es];
#else
unsigned short _WCFAR *dos_get_dbcs_lead_table( void )
/****************************************************/
{
union REGS regs;
struct SREGS sregs;
regs.w.ax = 0x6300; /* get lead byte table code */
sregs.ds = 0;
sregs.es = 0;
intdosx( &regs, &regs, &sregs ); /* call DOS */
if( regs.w.cflag || ( sregs.ds == 0 )) /* ensure function succeeded */
return( NULL );
return( MK_FP( sregs.ds, regs.w.si ) ); /* return pointer to table */
}
#endif
#if 0
unsigned short dos_get_code_page( void )
/**************************************/
{
union REGS regs;
struct SREGS sregs;
unsigned char buf[7];
regs.w.ax = 0x6501; /* get international info */
regs.w.bx = 0xFFFF; /* global code page */
regs.w.cx = 7; /* buffer size */
regs.w.dx = 0xFFFF; /* current country */
regs.w.di = FP_OFF( (void __far*)buf ); /* buffer offset */
sregs.es = FP_SEG( (void __far*)buf ); /* buffer segment */
sregs.ds = 0; /* in protected mode (dos16m) DS must be initialized */
intdosx( &regs, &regs, &sregs ); /* call DOS */
if( regs.w.cflag ) return( 0 ); /* ensure function succeeded */
return( * (unsigned short*)(buf+5) ); /* return code page */
}
#else
#pragma aux dos_get_code_page = \
"push ds" \
"push bp" \
"mov bp,sp" \
"sub sp,8" \
"xor ax,ax" \
"mov ds,ax" \
"mov ax,6501h" /* get international info */ \
"mov bx,0ffffh" /* global code page */ \
"mov cx,0007h" /* buffer size */ \
"mov dx,0ffffh" /* current country */ \
"lea di,[bp-8]" /* buffer offset */ \
"push ss" \
"pop es" /* buffer segment */ \
"int 21h" /* call DOS */ \
"mov ax,[bp-8+5]" /* code page */ \
"jnc NoError" \
"xor ax,ax" \
"NoError:" \
"mov sp,bp" \
"pop bp" \
"pop ds" \
value [ax] \
modify [ax bx cx dx di es];
#endif
#else
#pragma pack(__push,1);
typedef struct {
unsigned short int_num;
unsigned short real_ds;
unsigned short real_es;
unsigned short real_fs;
unsigned short real_gs;
unsigned long real_eax;
unsigned long real_edx;
} PHARLAP_block;
#pragma pack(__pop);
unsigned short _WCFAR *dos_get_dbcs_lead_table( void )
/****************************************************/
{
union REGPACK regs;
if( _IsPharLap() ) {
PHARLAP_block pblock;
memset( &pblock, 0, sizeof( pblock ) );
memset( &regs, 0, sizeof( regs ) );
pblock.real_eax = 0x6300; /* get DBCS vector table */
pblock.int_num = 0x21; /* DOS call */
regs.x.eax = 0x2511; /* issue real-mode interrupt */
regs.x.edx = FP_OFF( &pblock ); /* DS:EDX -> parameter block */
regs.w.ds = FP_SEG( &pblock );
intr( 0x21, &regs );
if( pblock.real_ds != 0xFFFF ) { /* weird OS/2 value */
return( MK_FP( _ExtenderRealModeSelector,
(((unsigned)pblock.real_ds)<<4) + regs.w.si ) );
}
} else if( _IsRational() ) {
rm_call_struct dblock;
memset( &dblock, 0, sizeof( dblock ) );
dblock.eax = 0x6300; /* get DBCS vector table */
DPMISimulateRealModeInterrupt( 0x21, 0, 0, &dblock );
if( (dblock.flags & 1) == 0 ) {
return( MK_FP( _ExtenderRealModeSelector,
(((unsigned)dblock.ds)<<4) + dblock.esi ) );
}
}
return( NULL );
}
unsigned short dos_get_code_page( void )
/**************************************/
{
union REGPACK regs;
unsigned short __far * temp;
unsigned short real_seg;
unsigned short codepage = 0;
/*** Get the code page ***/
if( _IsPharLap() ) {
union REGS r;
PHARLAP_block pblock;
/*** Alloc DOS Memory under Phar Lap ***/
memset( &r, 0, sizeof( r ) );
r.x.ebx = 1;
r.x.eax = 0x25c0;
intdos( &r, &r );
real_seg = r.w.ax;
memset( &pblock, 0, sizeof( pblock ) );
memset( &regs, 0, sizeof( regs ) );
pblock.real_eax = 0x6501; /* get international info */
pblock.real_edx = 0xFFFF; /* current country */
pblock.real_es = real_seg; /* buffer segment */
regs.x.ebx = 0xFFFF; /* global code page */
regs.x.ecx = 7; /* buffer size */
regs.x.edi = 0; /* buffer offset */
pblock.int_num = 0x21; /* DOS call */
regs.x.eax = 0x2511; /* issue real-mode interrupt */
regs.x.edx = FP_OFF( &pblock ); /* DS:EDX -> parameter block */
regs.w.ds = FP_SEG( &pblock );
intr( 0x21, &regs );
if( pblock.real_ds != 0xFFFF ) { /* weird OS/2 value */
temp = MK_FP( _ExtenderRealModeSelector, (real_seg<<4) + 5 );
codepage = *temp;
}
/*** Free DOS Memory under Phar Lap ***/
r.x.ecx = real_seg;
r.x.eax = 0x25c1;
intdos( &r, &r );
} else if( _IsRational() ) {
unsigned long dpmi_rc;
unsigned short selector;
rm_call_struct dblock;
/*** Allocate some DOS memory with DPMI ***/
dpmi_rc = DPMIAllocateDOSMemoryBlock( 1 ); /* one paragraph is enough */
real_seg = (unsigned short) dpmi_rc;
selector = (unsigned short) (dpmi_rc>>16);
memset( &dblock, 0, sizeof( dblock ) );
dblock.eax = 0x6501; /* get international info */
dblock.ebx = 0xFFFF; /* global code page */
dblock.ecx = 7; /* buffer size */
dblock.edx = 0xFFFF; /* current country */
dblock.edi = 0; /* buffer offset */
dblock.es = real_seg; /* buffer segment */
DPMISimulateRealModeInterrupt( 0x21, 0, 0, &dblock );
if( (dblock.flags & 1) == 0 ) {
temp = MK_FP( _ExtenderRealModeSelector, (real_seg<<4) + 5 );
codepage = *temp;
}
/*** Free DOS memory with DPMI ***/
DPMIFreeDOSMemoryBlock( selector );
}
return( codepage );
}
#endif
#endif

View File

@ -1,37 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include <mbstring.h>
#include "rtinit.h"
_WCRTLINKD int __IsDBCS;

View File

@ -1,59 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include <mbstring.h>
#include "mbchar.h"
#include "rtinit.h"
_WCRTLINKD unsigned char __MBCSIsTable[257];
/**
* Determine whether or not the specified byte is a lead byte.
*/
_WCRTLINK int (_ismbblead)( const unsigned int ch )
{
return( __MBCSIsTable[ch+1] & _MB_LEAD );
}
/**
* If this module is linked in, the startup code will call this function,
* which will initialize the default multibyte code page.
*/
static void __mbInitOnStartup( void )
{
__mbinit( 0 );
}
AXI( __mbInitOnStartup, INIT_PRIORITY_LIBRARY )

View File

@ -1,70 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include <mbstring.h>
#include "farfunc.h"
/****
***** Convert a multibyte character to a wide character.
****/
_WCRTLINK int _NEARFAR(mbtowc,_fmbtowc)( wchar_t _FFAR *pwc, const char _FFAR *ch, size_t n )
{
/*** Catch special cases ***/
if( ch == NULL ) return( 0 );
if( n == 0 ) return( -1 );
if( *ch == '\0' ) {
if( pwc != NULL ) *pwc = L'\0';
return( 0 );
}
if( _ismbblead( ch[0] ) && ch[1] == '\0' ) return( -1 ); /* invalid */
/*** Convert the character ***/
if( _ismbblead(*ch) && n>=2 ) { /* lead byte present? */
if( pwc != NULL ) {
*pwc = (((wchar_t)ch[0])<<8) | /* convert to lead:trail */
(wchar_t)ch[1];
}
return( 2 ); /* return char size */
} else if( !_ismbblead(*ch) ) {
if( pwc != NULL ) {
*pwc = (wchar_t)ch[0]; /* convert to 00:byte */
}
return( 1 ); /* return char size */
} else {
return( -1 ); /* n==1, but char 2 bytes */
}
}

View File

@ -1,358 +0,0 @@
;*****************************************************************************
;*
;* Open Watcom Project
;*
;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
;*
;* ========================================================================
;*
;* This file contains Original Code and/or Modifications of Original
;* Code as defined in and that are subject to the Sybase Open Watcom
;* Public License version 1.0 (the 'License'). You may not use this file
;* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
;* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
;* provided with the Original Code and Modifications, and is also
;* available at www.sybase.com/developer/opensource.
;*
;* The Original Code and all software distributed under the License are
;* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
;* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
;* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
;* NON-INFRINGEMENT. Please see the License for the specific language
;* governing rights and limitations under the License.
;*
;* ========================================================================
;*
;* Description: Memory model setup for interfacing with C code.
;*
;*****************************************************************************
_SMALL_CODE = 00h
_BIG_CODE = 01h
_SMALL_DATA = 00h
_BIG_DATA = 02h
_HUGE_DATA = 04h
_LONG_INTS = 08h
_USE_32_SEGS = 10h
_386 = 10h ; from old clib
_DS_PEGGED = 20h ; from old clib (used for Windows)
_TINY = 40h ; from old clib (formerly 10h)
_FLAT = ( _SMALL_CODE or _SMALL_DATA or _USE_32_SEGS )
_SMALL = ( _SMALL_CODE or _SMALL_DATA )
_COMPACT = ( _SMALL_CODE or _BIG_DATA )
_MEDIUM = ( _BIG_CODE or _SMALL_DATA )
_LARGE = ( _BIG_CODE or _BIG_DATA )
_HUGE = ( _BIG_CODE or _HUGE_DATA )
_EMULATION = 00h
_8087 = 01h
ifdef __WASM__
ifdef __FLAT__
_MODEL = _FLAT
endif
ifdef __SMALL__
_MODEL = _SMALL
endif
ifdef __COMPACT__
_MODEL = _COMPACT
endif
ifdef __MEDIUM__
_MODEL = _MEDIUM
endif
ifdef __LARGE__
_MODEL = _LARGE
endif
ifdef __HUGE__
_MODEL = _HUGE
endif
ifdef __386__
_MODEL = ( _MODEL or _USE_32_SEGS )
endif
ifdef __WINDOWS__
if _MODEL and (_BIG_DATA or _HUGE_DATA)
_MODEL = ( _MODEL or _DS_PEGGED )
endif
endif
ifdef __FPC__
_MATH = _EMULATION
endif
ifdef __FPI__
_MATH = _8087
endif
ifdef __FPI87__
_MATH = _8087
endif
else
include .\model.inc ; defines _MODEL, _MATH symbols
endif
if _MODEL and _BIG_CODE
modstart macro modname,alignment
ifdef NDEBUG
name modname
endif
ifb <alignment>
_TEXT segment word public 'CODE'
else
_TEXT segment alignment public 'CODE'
endif
assume cs:_TEXT
endm
calli macro regname
call dword ptr [regname]
endm
codeptr macro p1,p2
ifb <p2>
extrn p1 : dword
else
extrn "&p1",p2 : dword
endif
endm
docall macro dest
call far ptr dest
endm
dojmp macro dest
jmp far ptr dest
endm
defp macro dsym,exp
dsym proc far exp
endm
defpe macro dsym
ifdef _EXPORT
dsym proc far export
else
dsym proc far
endif
endm
defn macro dsym
dsym proc near
endm
endproc macro dsym
dsym endp
endm
epilog macro
if _MODEL and _USE_32_SEGS
pop EBP
dec EBP
mov ESP,EBP
else
pop BP
dec BP
endif
endm
prolog macro
if _MODEL and _USE_32_SEGS
inc EBP
push EBP
mov EBP,ESP
else
inc BP
push BP
mov BP,SP
endif
endm
xdefp macro p1,p2
ifb <p2>
public p1
else
public "&p1",p2
endif
endm
xref macro p1,p2
ifb <p2>
extrn `p1` : far
else
extrn "&p1",`p2` : far
endif
endm
lcall macro dest
push cs
call near ptr dest
endm
else
modstart macro modname,alignment
ifdef NDEBUG
name modname
endif
if _MODEL and _USE_32_SEGS
_TEXT segment use32 alignment public 'CODE'
else
_TEXT segment alignment public 'CODE'
endif
assume cs:_TEXT
endm
calli macro regname
call regname
endm
codeptr macro p1,p2
if _MODEL and _USE_32_SEGS
ifb <p2>
extrn p1 : dword
else
extrn "&p1",p2 : dword
endif
else
ifb <p2>
extrn p1 : word
else
extrn "&p1",p2 : word
endif
endif
endm
defn macro dsym
dsym proc near
endm
defp macro dsym,exp
dsym proc near exp
endm
defpe macro dsym
ifdef _EXPORT
dsym proc near export
else
dsym proc near
endif
endm
docall macro dest
call dest
endm
dojmp macro dest
jmp dest
endm
endproc macro dsym
dsym endp
endm
epilog macro
if _MODEL and _USE_32_SEGS
pop EBP
else
pop BP
endif
endm
prolog macro
if _MODEL and _USE_32_SEGS
push EBP
mov EBP,ESP
else
push BP
mov BP,SP
endif
endm
xdefp macro p1,p2
ifb <p2>
public p1
else
public "&p1",p2
endif
endm
xref macro p1,p2
ifb <p2>
extrn `p1` : near
else
extrn "&p1",`p2` : near
endif
endm
lcall macro dest
call dest
endm
endif
endmod macro
_TEXT ends
endm
dataseg macro
DGROUP group _DATA
assume ds:DGROUP,ss:DGROUP
if _MODEL and _USE_32_SEGS
_DATA segment use32 dword public 'DATA'
else
_DATA segment word public 'DATA'
endif
endm
datasegment macro
dataseg ; should be phased out
endm
enddata macro
_DATA ends
endm
bss_segment macro
if _MODEL and _USE_32_SEGS
_BSS segment use32 dword public 'BSS'
else
_BSS segment word public 'BSS'
endif
DGROUP group _BSS
assume ds:DGROUP
endm
endbss macro
_BSS ends
endm
alias_function macro alias, function
ifb <function>
xref "C",_&alias
else
xref "C",function
endif
.code
public "C",`alias`
ifdef _EXPORT
`alias` proc export
else
`alias` proc
endif
ifb <function>
jmp _&alias
else
jmp `function`
endif
`alias` endp
endm
xred macro p1,p2,p3
ifb <p3>
extrn p1 : p2
else
extrn "&p1",p2 : p3
endif
endm

View File

@ -1,100 +0,0 @@
//#include "kolibc.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef unsigned int dword;
typedef unsigned int size_t;
#define PINUSE_BIT 1
#define CINUSE_BIT 2
#define INUSE_BITS 3
struct m_seg
{
char* base; /* base address */
dword size; /* allocated size */
struct m_seg* next; /* ptr to next segment */
dword flags; /* mmap and extern flag */
};
struct m_chunk
{
dword prev_foot; /* Size of previous chunk (if free). */
dword head; /* Size and inuse bits. */
struct m_chunk* fd; /* double links -- used only if free. */
struct m_chunk* bk;
};
typedef struct m_chunk* mchunkptr;
struct t_chunk
{
/* The first four fields must be compatible with malloc_chunk */
dword prev_foot;
dword head;
struct t_chunk* fd;
struct t_chunk* bk;
struct t_chunk* child[2];
struct t_chunk* parent;
dword index;
};
typedef struct t_chunk* tchunkptr;
typedef struct t_chunk* tbinptr;
typedef struct m_state
{
dword smallmap;
dword treemap;
// DWORD dvsize;
dword topsize;
char* least_addr;
// mchunkptr dv;
mchunkptr top;
dword magic;
struct m_chunk smallbins[32];
tbinptr treebins[32];
};
void _cdecl init_malloc(void* p);
void* _cdecl dlmalloc(size_t);
void _cdecl dlfree(void*);
void* _cdecl dlrealloc(void *,size_t);
dword compute_tree_index(size_t s);
static void insert_chunk(mchunkptr P, size_t S);
static void insert_large_chunk(tchunkptr X, size_t S);
static void unlink_large_chunk(tchunkptr X);
//void replace_dv(mchunkptr P, size_t S);
static void* malloc_small(size_t nb);
static void* malloc_large(size_t nb);
#define leftshift_for_tree_index(i) \
((i == 31)? 0 : (31 - (i >> 1) + 8 - 2))
#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1])
#define chunk2mem(p) (void*)((char*)p + 8)
#define mem2chunk(mem) (mchunkptr)((char*)mem - 8)
#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s)))
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -1,49 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Mask differences between platforms where va_list is an
* array and platforms where it's not.
*
****************************************************************************/
#ifndef _MYVALIST_H_INCLUDED
#include "variety.h"
#include <stdarg.h>
typedef struct my_va_list {
va_list v;
} my_va_list;
#if defined(__AXP__) || defined(__PPC__) || defined(__MIPS__)
#define MY_VA_LIST( a ) (*(my_va_list *)&(a))
#else
#define MY_VA_LIST( a ) (*(my_va_list *)(a))
#endif
#define _MYVALIST_H_INCLUDED
#endif

View File

@ -1,399 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Win32 implementation of open() and sopen().
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <share.h>
#include "liballoc.h"
#include "iomode.h"
#include "fileacc.h"
#include "openmode.h"
#include "rtdata.h"
#include "seterrno.h"
extern unsigned __NFiles;
extern char *__appcwd;
extern int __appcwdlen;
#if (defined(__WINDOWS__) || defined(__NT__))
typedef struct
{ DWORD attr;
DWORD flags;
DWORD cr_time;
DWORD cr_date;
DWORD acc_time;
DWORD acc_date;
DWORD mod_time;
DWORD mod_date;
DWORD size;
DWORD size_high;
} FILEINFO;
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
int _stdcall create_file(const char *name);
typedef struct
{
char *name;
unsigned int offset;
}__file_handle;
char* getfullpath(const char* path)
{
int prev_is_slash=0;
int len=0, depth=0, i;
char* buff;
char c;
if(*path == '/')
{
buff = (char*)lib_malloc(strlen(path)+1);
buff[0] = '\0';
len=0;
}
else
{
len= __appcwdlen;
buff = (char*)lib_malloc(len+strlen(path)+1);
strncpy(buff, __appcwd, __appcwdlen);
prev_is_slash = 1;
buff[len] = 0;
for(i=0; buff[i]; i++)
if(buff[i] == '/' && i < len-1) depth++;
}
while(c=*path++)
{
switch (c)
{
case '.':
if((*path == '.')&&
(*path+1)== '/')
{ if(!depth)
{ free(buff);
return 0;
};
buff[len-1] = 0;
len = strrchr(buff, '/') + 1 - buff;
buff[len] = 0;
depth--;
path +=2;
prev_is_slash = 1;
continue;
}
if(*path == '/')
{
path++;
prev_is_slash = 1;
continue;
}
buff[len++] = c;
continue;
case '/':
prev_is_slash = 1;
buff[len++] = c;
continue;
default:
prev_is_slash = 0;
buff[len++] = c;
continue;
};
};
buff[len]= '\0';
return buff;
};
size_t FileSize(FILE *fp)
{
int hdl;
__file_handle *fh;
FILEINFO info;
hdl = fileno( fp );
// __handle_check( hdl, -1 );
fh = (__file_handle*) __getOSHandle(hdl);
get_fileinfo(fh->name,&info);
return info.size;
}
int access(const char *path, int mode)
{ size_t retval;
FILEINFO info;
char *p;
p = getfullpath(path);
retval=get_fileinfo(p,&info);
free(p);
return retval;
}
static HANDLE __openFileHandle(const CHAR_TYPE *name, int mode)
{
FILEINFO info;
__file_handle *handle;
char *path;
int err;
path = getfullpath(name);
if(err=get_fileinfo(path,&info))
{
// printf("failed getfileinfo %s\n\r", path);
if(mode & O_CREAT)
err=create_file(path);
if(err)
{
lib_free(path);
return (HANDLE)-1;
};
};
if ( !(handle=(__file_handle*)lib_malloc(sizeof( __file_handle) )))
{ lib_free(path);
return (HANDLE)-1;
};
handle->name = path;
handle->offset = 0;
return (HANDLE)handle;
};
static int __F_NAME(_sopen,__wsopen)( const CHAR_TYPE *name, int mode, int share, va_list args )
{
HANDLE handle;
int hid, rwmode;
unsigned iomode_flags;
// First try to get the required slot.
// No point in creating a file only to not use it. JBS 99/10/26
hid = __allocPOSIXHandle( DUMMY_HANDLE );
if( hid == -1 )
{
return( -1 );
}
rwmode = mode;
/*** Open the file ***/
handle = __openFileHandle( name, mode);
if( handle==(HANDLE)-1 )
{
__freePOSIXHandle( hid );
return( -1 ); //error
}
// Now use the slot we got.
__setOSHandle( hid, handle ); // JBS 99/11/01
iomode_flags = 0;
if( rwmode == O_RDWR ) iomode_flags |= _READ | _WRITE;
else if( rwmode == O_RDONLY) iomode_flags |= _READ;
else if( rwmode == O_WRONLY) iomode_flags |= _WRITE;
if( mode & O_APPEND ) iomode_flags |= _APPEND;
if( mode & (O_BINARY|O_TEXT) ) {
if( mode & O_BINARY ) iomode_flags |= _BINARY;
} else {
if( _RWD_fmode == O_BINARY ) iomode_flags |= _BINARY;
}
__SetIOMode( hid, iomode_flags );
return( hid );
}
#elif
static int __F_NAME(_sopen,__wsopen)( const CHAR_TYPE *name, int mode, int share, va_list args )
{
DWORD create_disp, exists_disp;
DWORD perm, fileattr;
DWORD desired_access, share_mode;
SECURITY_ATTRIBUTES security;
HANDLE handle;
int hid, rwmode;
unsigned iomode_flags;
// First try to get the required slot.
// No point in creating a file only to not use it. JBS 99/10/26
hid = __allocPOSIXHandle( DUMMY_HANDLE );
if( hid == -1 ) {
return( -1 );
}
rwmode = mode & OPENMODE_ACCESS_MASK;
__GetNTAccessAttr( rwmode, &desired_access, &perm );
__GetNTShareAttr( share|rwmode, &share_mode );
fileattr = FILE_ATTRIBUTE_NORMAL;
security.nLength = sizeof( SECURITY_ATTRIBUTES );
security.lpSecurityDescriptor = NULL;
security.bInheritHandle = mode&O_NOINHERIT ? FALSE : TRUE;
#ifdef DEFAULT_WINDOWING
#ifdef __WIDECHAR__
if( _WindowsNewWindow != 0 && !_wcsicmp( name, L"con" ) )
#else
if( _WindowsNewWindow != 0 && !stricmp( name, "con" ) )
#endif
{
handle = (HANDLE) __NTGetFakeHandle();
// Now use the slot we got.
__setOSHandle( hid, handle ); // JBS 99/11/01
_WindowsNewWindow( NULL, hid, -1 );
iomode_flags = _ISTTY;
} else {
#endif
if( mode & O_CREAT ) {
perm = va_arg( args, int );
va_end( args );
perm &= ~_RWD_umaskval; /* 05-jan-95 */
if( ( perm & S_IREAD ) && !( perm & S_IWRITE ) ) {
fileattr = FILE_ATTRIBUTE_READONLY;
}
if( mode & O_EXCL ) {
create_disp = CREATE_NEW;
exists_disp = CREATE_NEW;
} else if( mode & O_TRUNC ) {
create_disp = CREATE_ALWAYS;
exists_disp = CREATE_NEW;
} else {
create_disp = OPEN_ALWAYS;
exists_disp = OPEN_EXISTING;
}
} else if( mode & O_TRUNC ) {
exists_disp = TRUNCATE_EXISTING;
} else {
exists_disp = OPEN_EXISTING;
}
/*** Open the file ***/
#ifdef __WIDECHAR__
handle = __lib_CreateFileW( name, desired_access, share_mode,
&security, exists_disp, fileattr,
NULL );
#else
handle = CreateFileA( name, desired_access, share_mode,
&security, exists_disp, fileattr, NULL );
#endif
if( handle==(HANDLE)-1 ) {
if( mode&O_CREAT ) {
#ifdef __WIDECHAR__
handle = __lib_CreateFileW( name, desired_access,
share_mode, NULL, create_disp,
fileattr, NULL );
#else
handle = CreateFileA( name, desired_access,
share_mode, NULL, create_disp,
fileattr, NULL );
#endif
}
if( handle == (HANDLE)-1 ) {
__freePOSIXHandle( hid );
return( __set_errno_nt() );
}
}
// Now use the slot we got.
__setOSHandle( hid, handle ); // JBS 99/11/01
iomode_flags = 0;
if( isatty(hid) ) {
iomode_flags = _ISTTY;
}
#ifdef DEFAULT_WINDOWING
}
#endif
if( rwmode == O_RDWR ) iomode_flags |= _READ | _WRITE;
else if( rwmode == O_RDONLY) iomode_flags |= _READ;
else if( rwmode == O_WRONLY) iomode_flags |= _WRITE;
if( mode & O_APPEND ) iomode_flags |= _APPEND;
if( mode & (O_BINARY|O_TEXT) ) {
if( mode & O_BINARY ) iomode_flags |= _BINARY;
} else {
if( _RWD_fmode == O_BINARY ) iomode_flags |= _BINARY;
}
__SetIOMode( hid, iomode_flags );
return( hid );
}
#endif
_WCRTLINK int __F_NAME(open,_wopen)( const CHAR_TYPE *name, int mode, ... )
{
int permission;
va_list args;
va_start( args, mode );
permission = va_arg( args, int );
va_end( args );
return( __F_NAME(sopen,_wsopen)( name, mode, SH_COMPAT, permission ) );
}
_WCRTLINK int __F_NAME(sopen,_wsopen)( const CHAR_TYPE *name, int mode, int shflag, ... )
{
va_list args;
va_start( args, shflag );
return( __F_NAME(_sopen,__wsopen)( name, mode, shflag, args ) );
}

View File

@ -1,75 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#ifndef _OPENMODE_H_INCLUDED
#define _OPENMODE_H_INCLUDED
enum {
FILEATTR_MASK = 0x003f,
FILEATTR_NORMAL = 0x0000,
FILEATTR_READONLY = 0x0001,
FILEATTR_HIDDEN = 0x0002,
FILEATTR_SYSTEM = 0x0004,
FILEATTR_DIRECTORY = 0x0010,
FILEATTR_ARCHIVED = 0x0020
};
enum {
OPENFLAG_FAIL_IF_EXISTS = 0x0000,
OPENFLAG_OPEN_IF_EXISTS = 0x0001,
OPENFLAG_REPLACE_IF_EXISTS = 0x0002,
OPENFLAG_FAIL_IF_NOT_EXISTS = 0x0000,
OPENFLAG_CREATE_IF_NOT_EXISTS = 0x0010
};
enum {
OPENMODE_DASD = 0x8000,
OPENMODE_WRITE_THROUGH = 0x4000,
OPENMODE_FAIL_ERRORS = 0x2000,
OPENMODE_NO_CACHE = 0x1000,
OPENMODE_LOCALITY_MASK = 0x0700,
OPENMODE_LOCALITY_RANDSEQ = 0x0300,
OPENMODE_LOCALITY_RANDOM = 0x0200,
OPENMODE_LOCALITY_SEQUENTIAL = 0x0100,
OPENMODE_LOCALITY_NONE = 0x0000,
OPENMODE_INHERITANCE = 0x0080,
OPENMODE_SHARE_MASK = 0x0070,
OPENMODE_DENY_COMPAT = 0x0000,
OPENMODE_DENY_ALL = 0x0010,
OPENMODE_DENY_WRITE = 0x0020,
OPENMODE_DENY_READ = 0x0030,
OPENMODE_DENY_NONE = 0x0040,
OPENMODE_ACCESS_MASK = 0x0007,
OPENMODE_ACCESS_RDONLY = 0x0000,
OPENMODE_ACCESS_WRONLY = 0x0001,
OPENMODE_ACCESS_RDWR = 0x0002
};
#endif

View File

@ -1,57 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Macro to deal with stream orientation.
*
****************************************************************************/
#ifdef __NETWARE__
/* One less thing to worry about */
#define ORIENT_STREAM(stream,error_return)
#else
#ifdef __WIDECHAR__
#define ORIENT_STREAM(stream,error_return) \
if( _FP_ORIENTATION(stream) != _WIDE_ORIENTED ) { \
if( _FP_ORIENTATION(stream) == _NOT_ORIENTED ) { \
_FP_ORIENTATION(stream) = _WIDE_ORIENTED; \
} else { \
_ReleaseFile( stream ); \
return( error_return ); \
} \
}
#else
#define ORIENT_STREAM(stream,error_return) \
if( _FP_ORIENTATION(stream) != _BYTE_ORIENTED ) { \
if( _FP_ORIENTATION(stream) == _NOT_ORIENTED ) { \
_FP_ORIENTATION(stream) = _BYTE_ORIENTED; \
} else { \
_ReleaseFile( stream ); \
return( error_return ); \
} \
}
#endif
#endif

View File

@ -1,73 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Implementation of printf() - formatted output.
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include <stdarg.h>
#include "farsupp.h"
#include "printf.h"
#include "fprtf.h"
void debug_out_str(const char* str);
void _stdcall debug_out(int ch);
static char _dest[512];
_WCRTLINK int __F_NAME(printf,wprintf)( const CHAR_TYPE *format, ... )
{
int retval;
auto va_list args;
va_start( args, format );
// return( __F_NAME(__fprtf,__fwprtf)( stdout, format, args ) );
va_start( args, format );
#ifdef __WIDECHAR__
retval = _vswprintf( _dest, format, args );
#else
retval = vsprintf( _dest, format, args );
#endif
debug_out_str(_dest);
return retval;
}
void debug_out_str(const char* str)
{
while (*str != 0)
{
debug_out(*str);
str++;
}
}

View File

@ -1,183 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Definitions needed by callers to internal string formatter
* __prtf() for printf() style handling.
*
****************************************************************************/
#ifndef _PRINTF_H_INCLUDED
#define _PRINTF_H_INCLUDED
#include "variety.h"
#include "widechar.h"
#if defined(__QNX__)
#if defined(__386__)
#define __SLIB_CALLBACK _WCFAR
#define __SLIB
#pragma aux slib_callback_t __far parm [eax] [edx] modify [eax edx];
#elif defined( __SMALL_DATA__ )
#define __SLIB_CALLBACK _WCFAR __loadds
#define __SLIB _WCFAR
#else
#define __SLIB_CALLBACK _WCFAR
#define __SLIB _WCFAR
#endif
#else
#if defined( __HUGE__ )
#define __SLIB _WCFAR
#define __SLIB_CALLBACK
#else
#define __SLIB
#define __SLIB_CALLBACK
#endif
#endif
#define SPECS_VERSION 200
/*
* This is the __prtf specs structure. NB - should be naturally aligned.
*
* There are both wide and MBCS versions explicitly because part of __wprtf
* needs to access both kinds of structure.
*/
typedef struct
{
char __SLIB *_dest;
short _flags; // flags (see below)
short _version; // structure version # (2.0 --> 200)
int _fld_width; // field width
int _prec; // precision
int _output_count; // # of characters outputted for %n
int _n0; // number of chars to deliver first
int _nz0; // number of zeros to deliver next
int _n1; // number of chars to deliver next
int _nz1; // number of zeros to deliver next
int _n2; // number of chars to deliver next
int _nz2; // number of zeros to deliver next
char _character; // format character
char _pad_char;
char _padding[2]; // to keep struct aligned
} _mbcs_SPECS;
typedef struct
{
wchar_t __SLIB *_dest;
short _flags; // flags (see below)
short _version; // structure version # (2.0 --> 200)
int _fld_width; // field width
int _prec; // precision
int _output_count; // # of characters outputted for %n
int _n0; // number of chars to deliver first
int _nz0; // number of zeros to deliver next
int _n1; // number of chars to deliver next
int _nz1; // number of zeros to deliver next
int _n2; // number of chars to deliver next
int _nz2; // number of zeros to deliver next
wchar_t _character; // format character
wchar_t _pad_char;
} _wide_SPECS;
#ifdef __WIDECHAR__
#define SPECS _wide_SPECS
#else
#define SPECS _mbcs_SPECS
#endif
typedef void (__SLIB_CALLBACK slib_callback_t)( SPECS __SLIB *, int );
/* specification flags... (values for _flags field above) */
#define SPF_ALT 0x0001
#define SPF_BLANK 0x0002
#define SPF_FORCE_SIGN 0x0004
#define SPF_LEFT_ADJUST 0x0008
#define SPF_CHAR 0x0010
#define SPF_SHORT 0x0020
#define SPF_LONG 0x0040
#define SPF_LONG_LONG 0x0080
#define SPF_LONG_DOUBLE 0x0100 // may be also used for __int64
#define SPF_NEAR 0x0200
#define SPF_FAR 0x0400
#define SPF_CVT 0x0800 // __cvt function
#ifdef __QNX__
#define SPF_ZERO_PAD 0x8000
#endif // __QNX__
#if defined( __STDC_WANT_LIB_EXT1__ ) && __STDC_WANT_LIB_EXT1__ == 1
#if !defined( __WIDECHAR__ )
int __prtf_s( void __SLIB *dest, /* parm for use by out_putc */
const char * __restrict format, /* pointer to format string */
va_list args, /* pointer to pointer to args*/
const char **errmsg, /* constraint violation msg */
slib_callback_t *out_putc ); /* character output routine */
#else
int __wprtf_s( void __SLIB *dest, /* parm for use by out_putc */
const CHAR_TYPE * __restrict format,/* pointer to format string */
va_list args, /* pointer to pointer to args*/
const char **errmsg, /* constraint violation msg */
slib_callback_t *out_putc ); /* character output routine */
#endif
#else
#if !defined(__WIDECHAR__)
int __prtf( void __SLIB *dest, /* parm for use by out_putc */
const char *format, /* pointer to format string */
va_list args, /* pointer to pointer to args*/
slib_callback_t *out_putc ); /* character output routine */
#else
int __wprtf( void __SLIB *dest, /* parm for use by out_putc */
const CHAR_TYPE *format, /* pointer to format string */
va_list args, /* pointer to pointer to args*/
slib_callback_t *out_putc ); /* character output routine */
#endif
#ifdef __QNX__
int __prtf_slib( void __SLIB *dest, /* parm for use by out_putc */
const char * format, /* pointer to format string */
char **args, /* pointer to pointer to args*/
slib_callback_t *out_putc, /* character output routine */
int ptr_size );
#if !defined(IN_SLIB) && !defined(__386__)
extern int ( _WCFAR * ( _WCFAR *__f)) ();
#define __prtf(a,b,c,d) __prtf_slib(a,b,c,d,sizeof(void *))
#define __prtf_slib(a,b,c,d,e) ((int(_WCFAR *) (void _WCFAR *,const char _WCFAR *,char * _WCFAR *args,void (_WCFAR *__out)(SPECS _WCFAR *,int),int)) __f[24])(a,b,c,d,e)
#endif
#endif
#endif /* Safer C */
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,91 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Configure 'j', 'z', and 't' modifiers for __scnf and __prtf.
*
****************************************************************************/
#ifndef PTRSCNF_H_INCLUDED
#define PTRSCNF_H_INCLUDED
#include <limits.h>
#include <stdint.h>
/* Currently size_t is always 'unsigned int', but won't be on LP64 systems */
#if SIZE_MAX == UINT_MAX
#define ZSPEC_IS_INT
#elif SIZE_MAX == ULONG_MAX
#define ZSPEC_IS_LONG
#else
#error Could not configure zspec
#endif
/* Currently intmax_t is always 'long long int' but might be something
* else, in theory at least
*/
#if INTMAX_MAX == LLONG_MAX
#define JSPEC_IS_LLONG
#define JSPEC_CASE_LLONG case 'j':
#else
#error Could not configure jspec
#endif
/* Currently ptrdiff_t can be either 'long int' or 'int' */
#if PTRDIFF_MAX == INT_MAX
#define TSPEC_IS_INT
#elif PTRDIFF_MAX == LONG_MAX
#define TSPEC_IS_LONG
#else
#error Could not configure tspec
#endif
#ifdef ZSPEC_IS_INT
#define ZSPEC_CASE_INT case 'z':
#else
#define ZSPEC_CASE_INT
#endif
#ifdef ZSPEC_IS_LONG
#define ZSPEC_CASE_LONG case 'z':
#else
#define ZSPEC_CASE_LONG
#endif
#ifdef TSPEC_IS_INT
#define TSPEC_CASE_INT case 't':
#else
#define TSPEC_CASE_INT
#endif
#ifdef TSPEC_IS_LONG
#define TSPEC_CASE_LONG case 't':
#else
#define TSPEC_CASE_LONG
#endif
#endif

View File

@ -1,36 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Prototype for __qread() internal helper.
*
****************************************************************************/
#ifdef __NETWARE__
#define __qread( h, b, l ) read( h, b, l )
#else
extern int __qread( int handle, void *buffer, unsigned len );
#endif

View File

@ -1,129 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <errno.h>
#include "iomode.h"
#include "fileacc.h"
#include "rtcheck.h"
#include "rtdata.h"
#include "seterrno.h"
#include "qwrite.h"
#include "liballoc.h"
/*
Use caution when setting the file pointer in a multithreaded
application. You must synchronize access to shared resources. For
example, an application whose threads share a file handle, update the
file pointer, and read from the file must protect this sequence by
using a critical section object or a mutex object.
*/
typedef struct
{ DWORD attr;
DWORD flags;
DWORD cr_time;
DWORD cr_date;
DWORD acc_time;
DWORD acc_date;
DWORD mod_time;
DWORD mod_date;
DWORD size;
DWORD size_high;
} FILEINFO;
typedef struct
{
char *name;
unsigned int offset;
}__file_handle;
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
int _stdcall write_file(const char *name,const void *buff,unsigned offset,unsigned count,unsigned *writes);
char* getfullpath(const char* path);
int __qwrite( int handle, const void *buffer, unsigned len )
{
int atomic;
__file_handle *fh;
unsigned len_written;
__handle_check( handle, -1 );
fh = (__file_handle*) __getOSHandle( handle );
atomic = 0;
if( __GetIOMode( handle ) & _APPEND )
{
FILEINFO info;
_AccessFileH( handle );
atomic = 1;
get_fileinfo(fh->name,&info);
fh->offset = info.size;
};
if(write_file(fh->name,buffer,fh->offset,len,&len_written))
{
if ( len_written == 0)
{
if( atomic == 1 )
_ReleaseFileH( handle );
return (-1);
};
};
fh->offset+=len_written;
if( atomic == 1 )
{
_ReleaseFileH( handle );
}
return( len_written );
}
int write_once(const char *name, void *buffer, unsigned len)
{ char *path;
unsigned count;
path= getfullpath(name);
write_file(path,buffer,0,len,&count);
lib_free(path);
return count;
}

View File

@ -1,36 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Prototype for __qwrite() internal helper.
*
****************************************************************************/
#ifdef __NETWARE__
#define __qwrite( h, b, l ) write( h, (void *)b, l )
#else
extern int __qwrite( int, const void *, unsigned );
#endif

View File

@ -1,41 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Platform independent implementation of rewind().
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
_WCRTLINK void rewind( FILE *fp )
{
__stream_check( fp, 0 );
clearerr( fp );
fseek( fp, 0, SEEK_SET );
}

View File

@ -1,359 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: RISC oriented string functions designed to access memory
* as aligned 32- or 64-bit words whenever possible.
*
****************************************************************************/
#ifndef _RISCSTR_H_INCLUDED
#define _RISCSTR_H_INCLUDED
/*
* Determine if we're building RISC versions of string/memory routines.
*/
#if defined(__AXP__) || defined(__PPC__)
#define __RISCSTR__
#endif
#ifdef __RISCSTR__ /* do nothing if not RISC target */
#include "variety.h"
#include "widechar.h"
#include <string.h>
#include <wchar.h>
#include "watcom.h"
/*
* Choose between 32- and 64-bit words.
*/
#define USE_INT64 0 /* no 64-bit stuff for now */
#ifndef USE_INT64
#ifdef __AXP__
#define USE_INT64 1
#else
#define USE_INT64 0
#endif
#endif
#if USE_INT64
#define INT __int64
#define UINT unsigned __int64
#else
#define INT int
#define UINT uint_32
#endif
#define BYTES_PER_WORD ( sizeof( UINT ) )
#define INT_SIZE ( BYTES_PER_WORD * 8 )
#define CHARS_PER_WORD ( BYTES_PER_WORD / CHARSIZE )
#define MOD_BYTES_PER_WORD(__n) ( (__n) & (BYTES_PER_WORD-1) )
/*
* Macros to mask off a single character.
*/
#if USE_INT64
#define BYTE1 ( _riscdata->byteMasks[0].val )
#define BYTE2 ( _riscdata->byteMasks[1].val )
#define BYTE3 ( _riscdata->byteMasks[2].val )
#define BYTE4 ( _riscdata->byteMasks[3].val )
#define BYTE5 ( _riscdata->byteMasks[4].val )
#define BYTE6 ( _riscdata->byteMasks[5].val )
#define BYTE7 ( _riscdata->byteMasks[6].val )
#define BYTE8 ( _riscdata->byteMasks[7].val )
#else
#define BYTE1 ( 0x000000FF )
#define BYTE2 ( 0x0000FF00 )
#define BYTE3 ( 0x00FF0000 )
#define BYTE4 ( 0xFF000000 )
#endif
#ifdef __WIDECHAR__
#define CHR1MASK ( BYTE1 | BYTE2 )
#define CHR2MASK ( BYTE3 | BYTE4 )
#else
#define CHR1MASK ( BYTE1 )
#define CHR2MASK ( BYTE2 )
#define CHR3MASK ( BYTE3 )
#define CHR4MASK ( BYTE4 )
#endif
#ifdef __WIDECHAR__
#define CHR1(__w) ( (__w) & CHR1MASK )
#define CHR2(__w) ( (__w) & CHR2MASK )
#else
#define CHR1(__w) ( (__w) & BYTE1 )
#define CHR2(__w) ( (__w) & BYTE2 )
#define CHR3(__w) ( (__w) & BYTE3 )
#define CHR4(__w) ( (__w) & BYTE4 )
#if USE_INT64
#define CHR5(__w) ( (__w) & BYTE5 )
#define CHR6(__w) ( (__w) & BYTE6 )
#define CHR7(__w) ( (__w) & BYTE7 )
#define CHR8(__w) ( (__w) & BYTE8 )
#endif
#endif
/*
* Macros for extracting the first characters in a word.
*/
#if USE_INT64
#define FRONT_BYTES(__n) ( _riscdata->frontCharsMasks[(__n)].val )
#define FRONT_CHRS(__w,__o) ( (__w) & FRONT_BYTES_riscdata[(__o)].val )
#else
// extern UINT __FRONT_BYTES[];
// #define FRONT_BYTES __FRONT_BYTES
#define FRONT_BYTES ( _riscdata->frontCharsMasks )
#define FRONT_CHRS(__w,__o) ( (__w) & FRONT_BYTES[(__o)] )
#endif
/*
* Macros for ignoring the first characters in a word.
*/
#if USE_INT64
#define SKIP_CHRS_MASKS(__n) ( _riscdata->skipCharsMasks[(__n)].val )
#define SKIP_CHRS(__w,__o) ( (__w) & SKIP_CHRS_MASKS(__o) )
#else
// extern UINT __SKIP_CHRS_MASKS[];
// #define SKIP_CHRS_MASKS __SKIP_CHRS_MASKS
#define SKIP_CHRS_MASKS(__n) ( _riscdata->skipCharsMasks[(__n)] )
#define SKIP_CHRS(__w,__o) ( (__w) & SKIP_CHRS_MASKS(__o) )
#endif
/*
* Macros for checking if a word contains a null byte.
*/
#if USE_INT64
#define SUB_M ( _riscdata->_01Mask.val )
#define NIL_M ( _riscdata->_80Mask.val )
#define SUB_MASK(__n) ( _riscdata->subMasks[(__n)].val )
#else
#ifdef __WIDECHAR__
#define SUB_M ( 0x00010001 )
#define NIL_M ( 0x80008000 )
#else
#define SUB_M ( 0x01010101 )
#define NIL_M ( 0x80808080 )
#endif
// extern UINT __SubMask[];
// #define SUB_MASK __SubMask
#define SUB_MASK(__n) ( _riscdata->subMasks[(__n)] )
#endif
#define GOT_NIL(__w) ( ( (~(__w)) & ((__w) - SUB_M) ) & NIL_M )
#ifdef __WIDECHAR__
#define OFFSET_GOT_NIL(__w,__o) ( ( (~(__w)) & ((__w) - SUB_MASK((__o)/CHARSIZE)) ) & NIL_M )
#else
#define OFFSET_GOT_NIL(__w,__o) ( ( (~(__w)) & ((__w) - SUB_MASK(__o)) ) & NIL_M )
#endif
/*
* Some handy pointer manipulation macros.
*/
#define ROUND(__p) ( (UINT*) ( (UINT)(__p) & (-sizeof(UINT)) ) )
#define OFFSET(__p) ( ((unsigned int)(__p)) & (sizeof(UINT)-1) )
/*
* Macros for uppercase and lowercase stuff.
*/
#ifdef __WIDECHAR__
#define CHR1_A ( 0x00000041 )
#define CHR2_A ( 0x00410000 )
#define CHR1_Z ( 0x0000005A )
#define CHR2_Z ( 0x005A0000 )
#define CHR1_A2a(s) ( s | 0x00000020 )
#define CHR2_A2a(s) ( s | 0x00200000 )
#else
#define CHR1_A ( 0x00000041 )
#define CHR2_A ( 0x00004100 )
#define CHR3_A ( 0x00410000 )
#define CHR4_A ( 0x41000000 )
#define CHR1_Z ( 0x0000005A )
#define CHR2_Z ( 0x00005A00 )
#define CHR3_Z ( 0x005A0000 )
#define CHR4_Z ( 0x5A000000 )
#define CHR1_A2a(s) ( s | 0x00000020 )
#define CHR2_A2a(s) ( s | 0x00002000 )
#define CHR3_A2a(s) ( s | 0x00200000 )
#define CHR4_A2a(s) ( s | 0x20000000 )
#endif
#ifdef __WIDECHAR__
#define TO_LOW_CHR1(s) ( ( (s>=CHR1_A) && (s<=CHR1_Z) ) ? CHR1_A2a(s) : s )
#define TO_LOW_CHR2(s) ( ( (s>=CHR2_A) && (s<=CHR2_Z) ) ? CHR2_A2a(s) : s )
#else
#define TO_LOW_CHR1(s) ( ( (s>=CHR1_A) && (s<=CHR1_Z) ) ? CHR1_A2a(s) : s )
#define TO_LOW_CHR2(s) ( ( (s>=CHR2_A) && (s<=CHR2_Z) ) ? CHR2_A2a(s) : s )
#define TO_LOW_CHR3(s) ( ( (s>=CHR3_A) && (s<=CHR3_Z) ) ? CHR3_A2a(s) : s )
#define TO_LOW_CHR4(s) ( ( (s>=CHR4_A) && (s<=CHR4_Z) ) ? CHR4_A2a(s) : s )
#endif
#ifdef __WIDECHAR__
#define CHR1_a ( 0x00000061 )
#define CHR2_a ( 0x00610000 )
#define CHR1_z ( 0x0000007A )
#define CHR2_z ( 0x007A0000 )
#define CHR1_a2A(s) ( s & 0x000000DF )
#define CHR2_a2A(s) ( s & 0x00DF0000 )
#else
#define CHR1_a ( 0x00000061 )
#define CHR2_a ( 0x00006100 )
#define CHR3_a ( 0x00610000 )
#define CHR4_a ( 0x61000000 )
#define CHR1_z ( 0x0000007A )
#define CHR2_z ( 0x00007A00 )
#define CHR3_z ( 0x007A0000 )
#define CHR4_z ( 0x7A000000 )
#define CHR1_a2A(s) ( s & 0x000000DF )
#define CHR2_a2A(s) ( s & 0x0000DF00 )
#define CHR3_a2A(s) ( s & 0x00DF0000 )
#define CHR4_a2A(s) ( s & 0xDF000000 )
#endif
#ifdef __WIDECHAR__
#define TO_UPR_CHR1(s) ( ( (s>=CHR1_a) && (s<=CHR1_z) ) ? CHR1_a2A(s) : s )
#define TO_UPR_CHR2(s) ( ( (s>=CHR2_a) && (s<=CHR2_z) ) ? CHR2_a2A(s) : s )
#else
#define TO_UPR_CHR1(s) ( ( (s>=CHR1_a) && (s<=CHR1_z) ) ? CHR1_a2A(s) : s )
#define TO_UPR_CHR2(s) ( ( (s>=CHR2_a) && (s<=CHR2_z) ) ? CHR2_a2A(s) : s )
#define TO_UPR_CHR3(s) ( ( (s>=CHR3_a) && (s<=CHR3_z) ) ? CHR3_a2A(s) : s )
#define TO_UPR_CHR4(s) ( ( (s>=CHR4_a) && (s<=CHR4_z) ) ? CHR4_a2A(s) : s )
#endif
/*
* Tweak characters within a word.
*/
#ifdef __WIDECHAR__
#define REVERSE_CHARS(__w) ( (CHR1(__w)<<16) | (CHR2(__w)>>16) )
#else
#define REVERSE_CHARS(__w) ( (CHR1(__w)<<24) | (CHR2(__w)<<8) | \
(CHR3(__w)>>8) | (CHR4(__w)>>24) )
#endif
#define SWAP_BYTES(__w) ( (((__w)&BYTE1)<<8) | (((__w)&BYTE2)>>8) | \
(((__w)&BYTE3)<<8) | (((__w)&BYTE4)>>8) )
/*
* Data used by the RISC string functions.
*/
struct __F_NAME(__RISC_StrData,__wRISC_StrData) {
#if USE_INT64
unsigned_64 byteMasks[8];
unsigned_64 frontCharsMasks[8];
unsigned_64 skipCharsMasks[8];
unsigned_64 _01Mask;
unsigned_64 _80Mask;
unsigned_64 subMasks[8];
#else
#ifdef __WIDECHAR__
uint_32 frontCharsMasks[2];
uint_32 skipCharsMasks[2];
uint_32 subMasks[2];
#else
uint_32 frontCharsMasks[4];
uint_32 skipCharsMasks[4];
uint_32 subMasks[4];
#endif
#endif
};
#ifdef __WIDECHAR__
extern struct __wRISC_StrData __wRISC_StringData;
#define RISC_DATA_LOCALREF struct __wRISC_StrData *_riscdata = &__wRISC_StringData
#else
extern struct __RISC_StrData __RISC_StringData;
#define RISC_DATA_LOCALREF struct __RISC_StrData *_riscdata = &__RISC_StringData
#endif
/*
* Prototype functions called by the RISC-oriented string functions.
*/
_WCRTLINK extern wchar_t * __simple_wcschr( const wchar_t *str, wint_t ch );
_WCRTLINK extern int __simple_wcscmp( const wchar_t *s1, const wchar_t *s2 );
_WCRTLINK extern wchar_t * __simple_wcscpy( wchar_t *dest, const wchar_t *src );
_WCRTLINK extern int __simple__wcsicmp( const wchar_t *s1, const wchar_t *s2 );
_WCRTLINK extern size_t __simple_wcslen( const wchar_t *str );
_WCRTLINK extern wchar_t * __simple__wcslwr( wchar_t *str );
_WCRTLINK extern int __simple_wcsncmp( const wchar_t *s1, const wchar_t *s2, size_t n );
_WCRTLINK extern wchar_t * __simple_wcsncpy( wchar_t *dest, const wchar_t *src, size_t n );
_WCRTLINK extern int __simple__wcsnicmp( const wchar_t *s1, const wchar_t *s2, size_t n );
_WCRTLINK extern wchar_t * __simple__wcsnset( wchar_t *str, int ch, size_t n );
_WCRTLINK extern wchar_t * __simple_wcsrchr( const wchar_t *str, wint_t ch );
_WCRTLINK extern wchar_t * __simple__wcsset( wchar_t *str, wchar_t ch );
_WCRTLINK extern wchar_t * __simple__wcsupr( wchar_t *str );
#endif /* #ifdef __RISCSTR__ */
#endif

View File

@ -1,63 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Perform runtime file handle checks.
*
****************************************************************************/
#ifndef _RTCHECK_H_INCLUDED
#define _RTCHECK_H_INCLUDED
#include "variety.h"
#include <errno.h>
#include "seterrno.h"
/***********
#if ( defined(__NT__) || defined(__RUNTIME_HANDLE_CHECKS__) ) \
&& ( !defined(__NETWARE__) && !defined(__UNIX__) \
&& !defined(__OSI__) )
extern unsigned __NFiles;
#define __handle_check( __h, __r ) \
if( (__h) < 0 || (__h) > __NFiles ) { \
__set_errno( EBADF ); \
return( __r ); \
}
#else
#define __handle_check( __h, __r )
#endif
**************/
#define __handle_check( __h, __r )
#endif

View File

@ -1,211 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Internal CLIB structures and variables.
*
****************************************************************************/
#ifndef _RTDATA_H_INCLUDED
#define _RTDATA_H_INCLUDED
#include "variety.h"
#include <stdio.h>
#include "errorno.h"
/* DOS based platforms have stdaux/stdprn in addition to stdin/out/err */
#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OSI__)
#define NUM_STD_STREAMS 5
#else
#define NUM_STD_STREAMS 3
#endif
#if defined(__NT__) || defined(__OS2__)
struct __pipe_info {
int isPipe; /* non-zero if it's a pipe */
int pid; /* PID of spawned process */
};
#endif
typedef struct __stream_link {
struct __stream_link * next;
struct __iobuf * stream;
unsigned char * _base; /* location of buffer */
int _orientation; /* wide/byte/not oriented */
int _extflags; /* extended flags */
unsigned char _tmpfchar; /* tmpfile number */
unsigned char _filler[sizeof(int)-1];/* explicit padding */
#if defined(__NT__) || defined(__OS2__)
struct __pipe_info pipeInfo; /* pipe-related fields */
#endif
} __stream_link;
typedef void _WCI86FAR FPEhandler( int );
#define _FP_BASE(__fp) ((__fp)->_link->_base)
#ifndef __NETWARE__
#define _FP_ORIENTATION(__fp) ((__fp)->_link->_orientation)
#define _FP_EXTFLAGS(__fp) ((__fp)->_link->_extflags)
#endif
#define _FP_TMPFCHAR(__fp) ((__fp)->_link->_tmpfchar)
#ifndef __NETWARE__
#define _FP_PIPEDATA(__fp) ((__fp)->_link->pipeInfo)
#endif
extern __stream_link *__OpenStreams;
extern __stream_link *__ClosedStreams;
extern char * _WCNEAR __env_mask; /* ptr to char array of flags */
extern FPEhandler *__FPE_handler;
extern void (*__FPE_handler_exit)( void );
#if !defined(__NETWARE__)
extern int _cbyte;
extern int _cbyte2;
extern int _child;
extern int __umaskval;
extern unsigned _curbrk;
extern int _commode;
#endif
#if !defined (_NETWARE_LIBC)
extern unsigned _STACKTOP;
#endif
#if !defined(__QNX__) && !defined(__LINUX__)
extern void (*__Save8087)();/* Ptr to FP state save rtn (spawn) */
extern void (*__Rest8087)();/* Ptr to FP state restore rtn (spawn) */
#endif
extern unsigned short _8087cw; /* control word initializer */
extern unsigned char _no87; /* NO87 environment var defined */
extern unsigned char _8087; /* type of 8087/emulator present */
extern unsigned char _real87; /* 8087 coprocessor hardware present */
#if defined(_M_IX86)
#pragma aux _8087cw "_*";
#pragma aux _no87 "_*";
#pragma aux _8087 "_*";
#pragma aux _real87 "_*";
#endif
#if !defined(__SW_BM)
extern unsigned _STACKLOW;
#endif
#define _RWD_ostream __OpenStreams
#define _RWD_cstream __ClosedStreams
#define _RWD_iob __iob
#if !defined(__NETWARE__)
#define _RWD_threadid _threadid
#endif
#define _RWD_environ environ
#define _RWD_wenviron _wenviron
#define _RWD_env_mask __env_mask
#define _RWD_abort __abort
#define _RWD_sigtab __SIGNALTABLE
#define _RWD_FPE_handler_exit __FPE_handler_exit
#define _RWD_FPE_handler __FPE_handler
#define _RWD_fmode _fmode
#if !defined(__NETWARE__)
#define _RWD_umaskval __umaskval
#define _RWD_cbyte _cbyte
#define _RWD_cbyte2 _cbyte2
#define _RWD_child _child
#define _RWD_amblksiz _amblksiz
#define _RWD_curbrk _curbrk
#define _RWD_dynend _dynend
#define _RWD_psp _psp
#endif
#if !defined (_NETWARE_LIBC)
#define _RWD_stacktop _STACKTOP
#endif
#if !defined(__QNX__) && !defined(__LINUX__)
#define _RWD_Save8087 __Save8087
#define _RWD_Rest8087 __Rest8087
#endif
#define _RWD_8087cw _8087cw
#define _RWD_no87 _no87
#define _RWD_8087 _8087
#define _RWD_real87 _real87
#if !defined(__NETWARE__)
#define _RWD_HShift _HShift
#define _RWD_osmajor _osmajor
#define _RWD_osminor _osminor
#define _RWD_osmode _osmode
#if defined(__NT__)
#define _RWD_osbuild _osbuild
#define _RWD_osver _osver
#define _RWD_winmajor _winmajor
#define _RWD_winminor _winminor
#define _RWD_winver _winver
#endif
#define _RWD_doserrno _DOSERRNO
#endif
#define _RWD_tmpfnext __tmpfnext
#if !defined(_RWD_errno)
#define _RWD_errno _ERRNO
#endif
#define _RWD_nexttok _NEXTTOK
#define _RWD_nextftok _NEXTFTOK
#define _RWD_nextmbtok _NEXTMBTOK
#define _RWD_nextmbftok _NEXTMBFTOK
#define _RWD_nextwtok _NEXTWTOK
#define _RWD_tzname tzname
#define _RWD_timezone timezone
#define _RWD_daylight daylight
#define _RWD_dst_adjust __dst_adjust
#define _RWD_start_dst __start_dst
#define _RWD_end_dst __end_dst
#define _RWD_asctime _RESULT
#ifdef __SW_BM
#define _RWD_cvtbuf __THREADDATAPTR->__cvt_buffer
#else
#define _RWD_cvtbuf cvt_buffer
#endif
#if defined(__NETWARE__)
#define _RWD_ioexit __ioexit
#define _RWD_tmpnambuf (__THREADDATAPTR->__tmpnambuf)
#define _RWD_randnextinit (__THREADDATAPTR->__randnextinit)
#else
#define _RWD_tmpnambuf _tmpname
#define _RWD_randnextinit THREAD_PTR.__randnextinit
#endif
#define _RWD_stacklow _STACKLOW
#define _RWD_randnext _RANDNEXT
#define _RWD_ThreadData _ThreadData
#define _RWD_StaticInitSema _StaticInitSema
#define _RWD_PureErrorFlag _PureErrorFlag
#define _RWD_UndefVfunFlag _UndefVfunFlag
#define _RWD_ModuleInit _ModuleInit
/*
For the sake of efficiency, tell the compiler
that the __exit... routines never return.
*/
_WCRTLINK extern void __exit( unsigned );
#if defined(_M_IX86)
#pragma aux __exit aborts;
#endif
extern void (*__abort)( void ); // Defined in abort.c
extern void __terminate( void ); // Defined in abort.c
#endif // _RTDATA_H_INCLUDED

View File

@ -1,131 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Structures for run-time initialization/finalization.
*
****************************************************************************/
#ifndef __RTINIT_H__
#define __RTINIT_H__
#include "langenvd.h"
#if defined( __PPC__ )
#define __TGT_SYS __TGT_SYS_AXP_PPC
typedef unsigned __type_rtp;
typedef unsigned __type_pad;
typedef void( *__type_rtn ) ( void );
#elif defined( __AXP__ )
#define __TGT_SYS __TGT_SYS_AXP_NT
typedef unsigned __type_rtp;
typedef unsigned __type_pad;
typedef void( *__type_rtn ) ( void );
#elif defined( __MIPS__ )
#define __TGT_SYS __TGT_SYS_MIPS
typedef unsigned __type_rtp;
typedef unsigned __type_pad;
typedef void( *__type_rtn ) ( void );
#else
#define __TGT_SYS __TGT_SYS_X86
typedef unsigned char __type_rtp;
typedef unsigned short __type_pad;
#if defined( __386__ )
typedef void __near( *__type_rtn ) ( void );
#else
typedef void( *__type_rtn ) ( void );
#endif
#endif
#include "langenv.h"
#if defined( __MEDIUM__ ) || defined( __LARGE__ ) || defined( __HUGE__ )
#define __LARGE_CODE__
#endif
// initialization progresses from highest priority to lowest
// finalization progresses from lowest to highest
#pragma pack( 1 )
struct rt_init // structure placed in XI/YI segment
{
__type_rtp rtn_type; // - near=0/far=1 routine indication
// also used when walking table to flag
// completed entries
__type_rtp priority; // - priority (0-highest 255-lowest)
__type_rtn rtn; // - routine
#if !( defined( __LARGE_CODE__ ) || defined( __386__ ) ) || defined( COMP_CFG_COFF )
__type_pad padding; // - padding, when small code ptr
// or when risc cpu
#endif
};
#pragma pack()
#if defined( M_I86 )
#if defined( __LARGE_CODE__ ) /* segmented large code models */
#define YIXI( seg, label, routine, priority ) \
struct rt_init __based( __segname( seg ) ) label = \
{ 1, priority, routine };
#else /* other segmented models */
#define YIXI( seg, label, routine, priority ) \
struct rt_init __based( __segname( seg ) ) label = \
{ 0, priority, routine, 0 };
#endif
#else /* non-segmented architectures */
#define YIXI( seg, label, routine, priority ) \
struct rt_init __based( __segname( seg ) ) label = \
{ 0, priority, routine };
#endif
/*
Use these when you want a global label for the XI/YI structure
*/
#define XI( label, routine, priority ) YIXI( TS_SEG_XI, label, routine, priority )
#define YI( label, routine, priority ) YIXI( TS_SEG_YI, label, routine, priority )
/*
Use these when you don't care about the label on the XI/YI structure
*/
#define __ANON( x ) __anon ## x
#define ANON( x ) __ANON( x )
#define AXI( routine, priority ) static XI( ANON( __LINE__ ), routine, priority )
#define AYI( routine, priority ) static YI( ANON( __LINE__ ), routine, priority )
enum {
INIT_PRIORITY_THREAD = 1, // priority for thread data init
INIT_PRIORITY_FPU = 2, // priority for FPU/EMU init
INIT_PRIORITY_RUNTIME = 10, // priority for run/time initialization
INIT_PRIORITY_IOSTREAM = 20, // priority for IOSTREAM
INIT_PRIORITY_LIBRARY = 32, // default library-initialization priority
INIT_PRIORITY_PROGRAM = 64, // default program-initialization priority
FINI_PRIORITY_DTOR = 40, // priority for module DTOR
DTOR_PRIORITY = 40, // priority for module DTOR
FINI_PRIORITY_EXIT = 16 // when exit() is called, functions between
// 255 and this are called, the rest of the
// fini routines are called from __exit().
};
/* have to turn off, or we get unref'd warnings for AXI & AYI stuff */
#pragma off( unreferenced )
#endif

View File

@ -1,103 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Internal data and routines for "Safer C", or bounds-checking
* library extension.
*
****************************************************************************/
#ifndef _SAFERLIB_H_INCLUDED
#define _SAFERLIB_H_INCLUDED
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>
#include <stdint.h>
// Maximum length of runtime-constraint error message
#define RTCT_MSG_MAX 128
#define _RWD_rtcthandler __runtime_constraint_handler
extern constraint_handler_t __runtime_constraint_handler;
extern void __rtct_fail( const char *fn, const char *reason, void *reserved );
// Runtime-constraint validation macros. Call the handler and return zero if check
// failed, return non-zero value if check succeeded.
#define __check_constraint_nullptr( arg ) \
((arg == NULL) ? __rtct_fail( __func__, #arg " == NULL", NULL ), 0 : 1)
#define __check_constraint_maxsize( arg ) \
((arg > RSIZE_MAX) ? __rtct_fail( __func__, #arg " > RSIZE_MAX", NULL ), 0 : 1)
#define __check_constraint_zero( arg ) \
((arg == 0) ? __rtct_fail( __func__, #arg " == 0", NULL ), 0 : 1)
#define __check_constraint_toosmall( name, left ) \
((left == 0) ? __rtct_fail( __func__, #name " is too small to hold data", NULL ), 0 : 1)
// Runtime-constraint validation macros. Construct the message and return
// zero if check failed, return non-zero value if check succeeded.
// __rtct_fail has to be explicitly called later.
#define __check_constraint_nullptr_msg( msg, arg ) \
((arg == NULL) ? ( msg = #arg " == NULL" ), 0 : 1)
#define __check_constraint_maxsize_msg( msg, arg ) \
((arg > RSIZE_MAX) ? ( msg = #arg " > RSIZE_MAX" ), 0 : 1)
#define __check_constraint_zero_msg( msg, arg ) \
((arg == 0) ? ( msg = #arg " == 0" ), 0 : 1)
#define __check_constraint_toosmall_msg( msg, name, left ) \
((left == 0) ? ( msg = #name " is too small to hold data" ), 0 : 1)
#define __check_constraint_a_gt_b_msg( msg, a, b ) \
((a > b) ? ( msg = #a " > " #b ), 0 : 1)
#define __check_constraint_overlap_msg( msg, p1, len1, p2, len2 ) \
(((p1 == p2) || ( (p1 > p2) && ( p1 < (CHAR_TYPE *)p2 + len2 * sizeof( CHAR_TYPE ))) \
|| ( (p2 > p1) && ( p2 < (CHAR_TYPE *)p1 + len1 * sizeof( CHAR_TYPE )))) \
? ( msg = #p1 " overlap " #p2 ), 0 : 1)
// For 16-bit targets, the RSIZE_MAX check is effectively no-op. Object sizes
// up to SIZE_MAX are legal and not uncommon.
#if RSIZE_MAX == SIZE_MAX
#undef __check_constraint_maxsize
#define __check_constraint_maxsize( arg ) 1
#undef __check_constraint_maxsize_msg
#define __check_constraint_maxsize_msg( msg, arg ) 1
#define __lte_rsizmax( arg ) 1
#else
#define __lte_rsizmax( arg ) (arg <= RSIZE_MAX)
#endif
#endif // _SAFERLIB_H_INCLUDED

View File

@ -1,77 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Format specification descriptor for scanf family.
*
****************************************************************************/
#ifndef _SCANF_H_INCLUDED
#define _SCANF_H_INCLUDED
#include "variety.h"
#include "widechar.h"
#include <stdarg.h>
typedef struct {
int (*cget_rtn)(); /* character get rtn */
void (*uncget_rtn)(); /* unget a character rtn */
CHAR_TYPE *ptr; /* file or string pointer */
int width; /* conversion field width */
unsigned assign : 1; /* assignment flag for current argument */
unsigned eoinp : 1; /* end of input reached */
unsigned far_ptr : 1; /* F - far pointer */
unsigned near_ptr : 1; /* N - near pointer */
unsigned char_var : 1; /* hh - char variable */
unsigned short_var : 1; /* h - short variable */
unsigned long_var : 1; /* l - long variable */
unsigned long_long_var : 1; /* ll - long long variable */
unsigned long_double_var: 1; /* L - long double variable */
unsigned p_format : 1; /* %p (pointer conversion) */
} SCNF_SPECS;
#if defined(__HUGE__)
#define PTR_SCNF_SPECS SCNF_SPECS _WCFAR *
#else
#define PTR_SCNF_SPECS SCNF_SPECS *
#endif
#if defined( __STDC_WANT_LIB_EXT1__ ) && __STDC_WANT_LIB_EXT1__ == 1
#if defined(__WIDECHAR__)
extern int __wscnf_s( PTR_SCNF_SPECS, const CHAR_TYPE *, const char **msg, va_list );
#else
extern int __scnf_s( PTR_SCNF_SPECS, const CHAR_TYPE *, const char **msg, va_list );
#endif
#else
#if defined(__WIDECHAR__)
extern int __wscnf( PTR_SCNF_SPECS, const CHAR_TYPE *, va_list );
#else
extern int __scnf( PTR_SCNF_SPECS, const CHAR_TYPE *, va_list );
#endif
#endif
//#pragma off(unreferenced);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Routine to bring in real floating-point formatting code.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include "ftos.h"
#include "farsupp.h"
/* This routine will be called by cstart if "_fltused" is referenced. */
void __setEFGfmt( void )
{
#ifdef __SW_BR
__EFG_printf = __get_EFG_Format();
__EFG_scanf = __get__cnvs2d(); /* 27-mar-90 */
#else
__EFG_printf = _EFG_Format;
__EFG_scanf = __cnvs2d; /* 27-mar-90 */
#endif
}

View File

@ -1,76 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Implementation of __set_errno().
*
****************************************************************************/
#ifdef __WATCOMC__
#include "variety.h"
#include <stdlib.h>
#include <errno.h>
#include "rtdata.h"
#include "seterrno.h"
_WCRTLINK void __set_errno( unsigned int err )
{
_RWD_errno = err;
}
_WCRTLINK void __set_EDOM()
{
__set_errno( EDOM );
}
_WCRTLINK void __set_ERANGE()
{
__set_errno( ERANGE );
}
_WCRTLINK int __set_EINVAL()
{
__set_errno( EINVAL );
return( -1 );
}
//#if !defined(__UNIX__) && !defined(__NETWARE__)
//_WCRTLINK void __set_doserrno( unsigned int err )
//{
// _RWD_doserrno = err;
//}
//#endif
#else
#include <errno.h>
void __set_errno( unsigned int err )
{
errno = err;
}
#endif

View File

@ -1,52 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: errno related CLIB internal declarations.
*
****************************************************************************/
#ifndef _SETERNO_H_INCLUDED
#define _SETERNO_H_INCLUDED
#include "variety.h"
// defined in _dos\c\dosret.c
_WCRTLINK extern int __set_errno_dos( unsigned int );
#if defined(__NT__)
_WCRTLINK extern int __set_errno_nt( void );
#endif
// defined in startup\c\seterrno.c
_WCRTLINK extern void __set_errno( unsigned int );
_WCRTLINK extern int __set_EINVAL( void );
_WCRTLINK extern void __set_EDOM( void );
_WCRTLINK extern void __set_ERANGE( void );
#if !defined(__UNIX__)
_WCRTLINK extern void __set_doserrno( unsigned int );
#endif
#endif

View File

@ -1,175 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include "rtdata.h"
#include "liballoc.h"
#include "fileacc.h"
#include "rtinit.h"
#include "seterrno.h"
#include "iomode.h"
#include "handleio.h"
#ifdef DLHEAP
void* _cdecl dlmalloc(size_t);
void _cdecl dlfree(void*);
void _cdecl mf_init();
#define malloc dlmalloc
#define free dlfree
#define realloc dlrealloc
#define lib_malloc dlmalloc
#define lib_free dlfree
#define lib_realloc dlrealloc
#endif
#if defined(__NETWARE__)
#error NO IO MODE MANAGER UNDER NETWARE
#endif
extern unsigned _HUGEDATA __init_mode[_NFILES];
extern unsigned __NFiles; /* maximum # of files we can open */
static unsigned _init_NFiles; // original __NFiles value;
void __grow_iomode( int num )
{
unsigned *new;
_AccessIOB();
if( __io_mode == __init_mode )
{
_init_NFiles = __NFiles;
new = (unsigned *) lib_malloc( num * sizeof( unsigned ) );
if( new != NULL ) {
memcpy( new, __init_mode, __NFiles * sizeof(unsigned) );
}
}
else
{
#if defined(__NETWARE__)
#else
new = (unsigned *) lib_realloc( __io_mode, num * sizeof( unsigned ) );
#endif
}
if( new == NULL )
{
__set_errno( ENOMEM );
}
else
{
memset( &new[__NFiles], 0, (num-__NFiles)*sizeof(unsigned) );
__io_mode = new;
__NFiles = num;
}
_ReleaseIOB();
}
void __shrink_iomode( void )
{
_AccessIOB();
// free any malloc'd iomode array
if( __io_mode != __init_mode )
{
lib_free( __io_mode );
__io_mode = __init_mode;
__NFiles = _init_NFiles;
}
_ReleaseIOB();
}
AYI(__shrink_iomode,INIT_PRIORITY_IOSTREAM);
#if defined(__WARP__)
extern unsigned __NHandles;
static void __preinit_iomode_os2(void)
{
LONG req_count;
ULONG curr_max_fh;
APIRET rc;
// Ensure that the clib and OS file handle limits match
req_count = 0;
rc = DosSetRelMaxFH( &req_count, &curr_max_fh );
if( rc == 0 ) {
__grow_iomode( curr_max_fh );
__NHandles = curr_max_fh; // same as __set_handles
}
}
AXI( __preinit_iomode_os2, INIT_PRIORITY_RUNTIME );
#endif
#define _INITIALIZED _DYNAMIC
signed __SetIOMode( int handle, unsigned value )
{
int i;
if( handle >= __NFiles )
{
i = __NFiles; // 20 -> (20+10+1) -> 31
// 31 -> (31+15+1) -> 47
// 47 -> (47+23+1) -> 71
__grow_iomode( i + (i > 1) + 1 );
}
if( handle >= __NFiles )
{
// return an error indication (errno should be set to ENOMEM)
return( -1 );
}
else
{
if( value != 0 )
{
__ChkTTYIOMode( handle );
__io_mode[handle] = value | _INITIALIZED;
}
else
{
__io_mode[handle] = value; /* we're closing it; smite _INITIALIZED */
}
return( handle );
}
}

View File

@ -1,58 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include "riscstr.h"
#include "xstring.h"
#undef strcmp
/* return <0 if s<t, 0 if s==t, >0 if s>t */
#if defined(__RISCSTR__) && defined(__WIDECHAR__)
_WCRTLINK int __simple_wcscmp( const CHAR_TYPE *s, const CHAR_TYPE *t )
#else
_WCRTLINK int __F_NAME(strcmp,wcscmp)( const CHAR_TYPE *s, const CHAR_TYPE *t )
#endif
{
#if defined(__INLINE_FUNCTIONS__) && !defined(__WIDECHAR__) && defined(_M_IX86)
return( _inline_strcmp( s, t ) );
#else
for( ; *s == *t; s++, t++ )
if( *s == NULLCHAR )
return( 0 );
return( *s - *t );
#endif
}

View File

@ -1,41 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#ifndef __STRDUP_H_INCLUDED
#define __STRDUP_H_INCLUDED
#include "variety.h"
#include "widechar.h"
_WCRTLINK extern char *__clib_strdup( const char *str );
_WCRTLINK extern wchar_t *__clib_wcsdup( const wchar_t *str );
#endif

View File

@ -1,37 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Prototypes for various streamio internal routines.
*
****************************************************************************/
extern FILE *__allocfp( int handle );
extern void __freefp( FILE * );
extern void __chktty( FILE *fp );
extern void __ioalloc( FILE * );
extern int __doclose( FILE *fp, int close_handle );
extern int __shutdown_stream( FILE *fp, int close_handle );

View File

@ -1,220 +0,0 @@
;*****************************************************************************
;*
;* Open Watcom Project
;*
;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
;*
;* ========================================================================
;*
;* This file contains Original Code and/or Modifications of Original
;* Code as defined in and that are subject to the Sybase Open Watcom
;* Public License version 1.0 (the 'License'). You may not use this file
;* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
;* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
;* provided with the Original Code and Modifications, and is also
;* available at www.sybase.com/developer/opensource.
;*
;* The Original Code and all software distributed under the License are
;* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
;* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
;* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
;* NON-INFRINGEMENT. Please see the License for the specific language
;* governing rights and limitations under the License.
;*
;* ========================================================================
;*
;* Description: Structured macros for MASM/WASM.
;*
;*****************************************************************************
__label = 0
__depth = 0
__inner_loop = 0
_guess macro name
__depth = __depth + 1
__label = __label + 1
_set __astk,%__depth,__label,<>
__label = __label + 1
_set __estk,%__depth,__label,<>
ifnb <name>
name = __label
endif
endm
_quif macro cc,name
ifnb <name>
_set __elbl,,name,<>
_j cc,_l,%__elbl
else
_set __albl,,__astk,%__depth
_j cc,_l,%__albl
endif
endm
_quit macro name
_quif ,name
endm
_admit macro
_set __albl,,__astk,%__depth
__label = __label + 1
_set __astk,%__depth,__label,<>
_set __elbl,,__estk,%__depth
_j ,_l,%__elbl
_label _l,%__albl
endm
_endguess macro
_set __albl,,__astk,%__depth
_label _l,%__albl
_set __elbl,,__estk,%__depth
_label _l,%__elbl
__depth = __depth - 1
endm
_loop macro name
_guess name
_set __albl,,__astk,%__depth
_label _m,%__albl
_set __elbl,,__estk,%__depth
_label _m,%__elbl
_set __llbl,%__depth,%__inner_loop,<>
_set __inner_loop,,%__depth,<>
endm
_loopif macro cc,name
ifnb <name>
_set __elbl,,name,<>
_j cc,_m,%__elbl
else
_set __albl,,__astk,%__inner_loop
_j cc,_m,%__albl
endif
endm
_until macro cc
_set __albl,,__astk,%__depth
_jn cc,_m,%__albl
_set __inner_loop,,__llbl,%__depth
_endguess
endm
_endloop macro
_set __albl,,__astk,%__depth
_j ,_m,%__albl
_set __inner_loop,,__llbl,%__depth
_endguess
endm
_if macro cc
_guess
_set __albl,,__astk,%__depth
_jn cc,_l,%__albl
endm
_else macro
_admit
endm
_endif macro
_endguess
endm
_set macro base1,ext1,base2,ext2
base1&ext1 = base2&ext2
endm
_label macro base,ext
base&ext:
endm
_j macro cc,base,ext
j&cc base&ext
endm
_jn macro cc,base,ext
jn&cc base&ext
endm
jnna macro label
ja label
endm
jnnae macro label
jae label
endm
jnnb macro label
jb label
endm
jnnbe macro label
jbe label
endm
jnnc macro label
jc label
endm
jnne macro label
je label
endm
jnng macro label
jg label
endm
jnnge macro label
jge label
endm
jnnl macro label
jl label
endm
jnnle macro label
jle label
endm
jnno macro label
jo label
endm
jnnp macro label
jp label
endm
jnns macro label
js label
endm
jnnz macro label
jz label
endm
jnpe macro label
jpo label
endm
jnpo macro label
jpe label
endm
j macro label
jmp label
endm
jn macro label
nop
endm
_shl macro reg,count
add reg,reg
endm
_rcl macro reg,count
adc reg,reg
endm

View File

@ -1,41 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include <sys/types.h>
#include <unistd.h>
#include "lseek.h"
_WCRTLINK long int tell( int handle )
{
return( __lseek( handle, 0L, SEEK_CUR ) );
}

View File

@ -1,33 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Temporary file filename related definitions.
*
****************************************************************************/
#define _TMPFNAME_LENGTH 13
#define _TMP_INIT_CHAR 32

View File

@ -1,37 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
// this file should remain an indirected file
// it is done this way to support the reuse of the source file
#define __WIDECHAR__
#undef __INLINE_FUNCTIONS__
#include "lltoa.c"

View File

@ -1,37 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
// this file should remain an indirected file
// it is done this way to support the reuse of the source file
#define __WIDECHAR__
#undef __INLINE_FUNCTIONS__
#include "ltoa.c"

View File

@ -1,293 +0,0 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Configuration for clib builds.
*
****************************************************************************/
#ifndef _VARIETY_H_INCLUDED
#define _VARIETY_H_INCLUDED
//
// Note: for the DLL versions of the runtime libraries, this file must be
// included before any of the runtime header files.
//
#ifndef _COMDEF_H_INCLUDED
#include <_comdef.h>
#endif
// specialized data reference macro
#define _HUGEDATA _WCDATA
// memory model macros
#if defined(__SMALL__)
#define __SMALL_DATA__
#define __SMALL_CODE__
#elif defined(__FLAT__)
#define __SMALL_DATA__
#define __SMALL_CODE__
#elif defined(__MEDIUM__)
#define __SMALL_DATA__
#define __BIG_CODE__
#elif defined(__COMPACT__)
#define __BIG_DATA__
#define __SMALL_CODE__
#elif defined(__LARGE__)
#define __BIG_DATA__
#define __BIG_CODE__
#elif defined(__HUGE__)
#define __BIG_DATA__
#define __BIG_CODE__
#elif defined(__AXP__) || defined(__PPC__) || defined(__MIPS__)
// these effectively use near data references
#define __SMALL_DATA__
#define __SMALL_CODE__
#else
#error unable to configure memory model
#endif
// operating system and processor macros
#if defined(__GENERIC__)
#if defined(__386__)
#define __PROTECT_MODE__
#define __GENERIC_386__
#elif defined(M_I86)
#define __REAL_MODE__
#define __GENERIC_086__
#else
#error unrecognized processor for GENERIC
#endif
#elif defined(__OS2__)
#if defined(M_I86)
#define __REAL_MODE__
#define __OS2_286__
#elif defined(__386__)
#define __PROTECT_MODE__
#define __OS2_386__
#define __WARP__
#elif defined(__PPC__)
#define __PROTECT_MODE__
#define __OS2_PPC__
#define __WARP__
#else
#error unrecognized processor for OS2
#endif
#elif defined(__NT__)
#if !defined(WIN32_LEAN_AND_MEAN) && !defined(WIN32_NICE_AND_FAT)
#define WIN32_LEAN_AND_MEAN
#endif
#define __PROTECT_MODE__
#if defined(__386__)
#define __NT_386__
#elif defined(__AXP__)
#define __NT_AXP__
#elif defined(__PPC__)
#define __NT_PPC__
#else
#error unrecognized processor for NT
#endif
#elif defined(__WINDOWS__) || defined(__WINDOWS_386__)
#define __PROTECT_MODE__
#if defined(__386__)
#define __WINDOWS__
#elif defined(M_I86)
#define __WINDOWS_286__
#else
#error unrecognized processor for WINDOWS
#endif
#elif defined(__DOS__)
#if defined(__386__)
#define __PROTECT_MODE__
#define __DOS_386__
#elif defined(M_I86)
#define __REAL_MODE__
#define __DOS_086__
#else
#error unrecognized processor for DOS
#endif
#elif defined(__OSI__)
#if defined(__386__)
#define __PROTECT_MODE__
#define __OSI_386__
#else
#error unrecognized processor for OSI
#endif
#elif defined(__QNX__)
#define __PROTECT_MODE__
#define __UNIX__
#if defined(__386__)
#define __QNX_386__
#elif defined(M_I86)
#define __QNX_286__
#else
#error unrecognized processor for QNX
#endif
#elif defined(__LINUX__)
#define __PROTECT_MODE__
#define __UNIX__
#if defined(__386__)
#define __LINUX_386__
#elif defined(__PPC__)
#define __LINUX_PPC__
#elif defined(__MIPS__)
#define __LINUX_MIPS__
#else
#error unrecognized processor for Linux
#endif
#elif defined(__NETWARE__)
#define __PROTECT_MODE__
#if defined(__386__)
#define __NETWARE_386__
#else
#error unrecognized processor for NETWARE
#endif
#else
#error unable to configure operating system and processor
#endif
// handle building dll's with appropriate linkage
#if !defined(__SW_BR) && (defined(__WARP__) || defined(__NT__))
#if defined(__MAKE_DLL_CLIB)
#undef _WCRTLINK
#undef _WCIRTLINK
#undef _WCRTLINKD
#undef _WMRTLINK
#undef _WMIRTLINK
#undef _WMRTLINKD
#undef _WPRTLINK
#undef _WPIRTLINK
#undef _WPRTLINKD
#if defined(__NT__)
#define _WCRTLINK __declspec(dllexport) _WRTLCALL
#define _WCIRTLINK __declspec(dllexport) _WRTLCALL
#define _WCRTLINKD __declspec(dllexport)
#define _WMRTLINK __declspec(dllimport) _WRTLCALL
#define _WMIRTLINK __declspec(dllimport) _WRTLCALL
#define _WMRTLINKD __declspec(dllimport)
#define _WPRTLINK __declspec(dllimport) _WRTLCALL
#define _WPIRTLINK __declspec(dllimport) _WRTLCALL
#define _WPRTLINKD __declspec(dllimport)
#elif defined(__WARP__)
#define _WCRTLINK __declspec(dllexport) _WRTLCALL
#define _WCIRTLINK __declspec(dllexport) _WRTLCALL
#define _WCRTLINKD __declspec(dllexport)
#define _WMRTLINK _WRTLCALL
#define _WMIRTLINK _WRTLCALL
#define _WMRTLINKD
#define _WPRTLINK _WRTLCALL
#define _WPIRTLINK _WRTLCALL
#define _WPRTLINKD
#endif
#elif defined(__MAKE_DLL_MATHLIB)
#define _RTDLL
#undef _WCRTLINK
#undef _WCIRTLINK
#undef _WCRTLINKD
#undef _WMRTLINK
#undef _WMIRTLINK
#undef _WMRTLINKD
#undef _WPRTLINK
#undef _WPIRTLINK
#undef _WPRTLINKD
#if defined(__NT__)
#define _WCRTLINK __declspec(dllimport) _WRTLCALL
#define _WCIRTLINK __declspec(dllimport) _WRTLCALL
#define _WCRTLINKD __declspec(dllimport)
#define _WMRTLINK __declspec(dllexport) _WRTLCALL
#define _WMIRTLINK __declspec(dllexport) _WRTLCALL
#define _WMRTLINKD __declspec(dllexport)
#define _WPRTLINK __declspec(dllimport) _WRTLCALL
#define _WPIRTLINK __declspec(dllimport) _WRTLCALL
#define _WPRTLINKD __declspec(dllimport)
#elif defined(__WARP__)
#define _WCRTLINK _WRTLCALL
#define _WCIRTLINK _WRTLCALL
#define _WCRTLINKD
#define _WMRTLINK __declspec(dllexport) _WRTLCALL
#define _WMIRTLINK __declspec(dllexport) _WRTLCALL
#define _WMRTLINKD __declspec(dllexport)
#define _WPRTLINK _WRTLCALL
#define _WPIRTLINK _WRTLCALL
#define _WPRTLINKD
#endif
#elif defined(__MAKE_DLL_CPPLIB)
#define _RTDLL
#undef _WCRTLINK
#undef _WCIRTLINK
#undef _WCRTLINKD
#undef _WMRTLINK
#undef _WMIRTLINK
#undef _WMRTLINKD
#undef _WPRTLINK
#undef _WPIRTLINK
#undef _WPRTLINKD
#if defined(__NT__)
#define _WCRTLINK __declspec(dllimport) _WRTLCALL
#define _WCIRTLINK __declspec(dllimport) _WRTLCALL
#define _WCRTLINKD __declspec(dllimport)
#define _WMRTLINK __declspec(dllimport) _WRTLCALL
#define _WMIRTLINK __declspec(dllimport) _WRTLCALL
#define _WMRTLINKD __declspec(dllimport)
#define _WPRTLINK __declspec(dllexport) _WRTLCALL
#define _WPIRTLINK __declspec(dllexport) _WRTLCALL
#define _WPRTLINKD __declspec(dllexport)
#elif defined(__WARP__)
#define _WCRTLINK _WRTLCALL
#define _WCIRTLINK _WRTLCALL
#define _WCRTLINKD
#define _WMRTLINK _WRTLCALL
#define _WMIRTLINK _WRTLCALL
#define _WMRTLINKD
#define _WPRTLINK __declspec(dllexport) _WRTLCALL
#define _WPIRTLINK __declspec(dllexport) _WRTLCALL
#define _WPRTLINKD __declspec(dllexport)
#endif
#endif
#endif
#define __ptr_check( p, a )
#define __null_check( p, a )
#define __stream_check( s, a )
#define __ROUND_UP_SIZE( __x, __amt ) (((__x)+((__amt)-1))&(~((__amt)-1)))
///
/// This doesn't work for far pointer's
///
///#define __ROUND_UP_PTR( __x, __amt ) ((void *)__ROUND_UP_SIZE((unsigned)(__x),__amt))
#if defined(M_I86)
#define __ALIGN_SIZE( __x ) __ROUND_UP_SIZE( __x, 2 )
// #define __ALIGN_PTR( __x ) __ROUND_UP_PTR( __x, 2 )
#elif defined(__386__)
#define __ALIGN_SIZE( __x ) __ROUND_UP_SIZE( __x, 4 )
/// #define __ALIGN_PTR( __x ) __ROUND_UP_PTR( __x, 4 )
#else
#define __ALIGN_SIZE( __x ) __ROUND_UP_SIZE( __x, 8 )
// #define __ALIGN_PTR( __x ) __ROUND_UP_PTR( __x, 8 )
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More