forked from KolibriOS/kolibrios
doom beta
git-svn-id: svn://kolibrios.org@550 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
d7d49c0feb
commit
9b1d2c1c51
34
programs/develop/open watcom/trunk/clib/h/commode.h
Normal file
34
programs/develop/open watcom/trunk/clib/h/commode.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* 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 "*_";
|
33
programs/develop/open watcom/trunk/clib/h/fmode.h
Normal file
33
programs/develop/open watcom/trunk/clib/h/fmode.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* 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 */
|
75
programs/develop/open watcom/trunk/clib/h/openmode.h
Normal file
75
programs/develop/open watcom/trunk/clib/h/openmode.h
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* 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
|
36
programs/develop/open watcom/trunk/clib/h/qread.h
Normal file
36
programs/develop/open watcom/trunk/clib/h/qread.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* 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
|
@ -44,18 +44,6 @@
|
|||||||
#include "close.h"
|
#include "close.h"
|
||||||
#include "flush.h"
|
#include "flush.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_free dlfree
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __UNIX__
|
#ifndef __UNIX__
|
||||||
void (*__RmTmpFileFn)( FILE *fp );
|
void (*__RmTmpFileFn)( FILE *fp );
|
||||||
|
161
programs/develop/open watcom/trunk/clib/src/fwrite.c
Normal file
161
programs/develop/open watcom/trunk/clib/src/fwrite.c
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* 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 );
|
||||||
|
}
|
@ -67,6 +67,7 @@ typedef struct
|
|||||||
} FILEINFO;
|
} FILEINFO;
|
||||||
|
|
||||||
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
|
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
|
||||||
|
int _stdcall create_file(const char *name);
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -76,7 +77,7 @@ typedef struct
|
|||||||
}__file_handle;
|
}__file_handle;
|
||||||
|
|
||||||
|
|
||||||
static char* getfullpath(const char* path)
|
char* getfullpath(const char* path)
|
||||||
{
|
{
|
||||||
int prev_is_slash=0;
|
int prev_is_slash=0;
|
||||||
int len=0, depth=0, i;
|
int len=0, depth=0, i;
|
||||||
@ -177,20 +178,27 @@ int access(const char *path, int mode)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HANDLE __openFileHandle(const CHAR_TYPE *name, int mode)
|
||||||
static HANDLE __createFileHandle(const CHAR_TYPE *name)
|
|
||||||
{
|
{
|
||||||
FILEINFO info;
|
FILEINFO info;
|
||||||
__file_handle *handle;
|
__file_handle *handle;
|
||||||
char *path;
|
char *path;
|
||||||
|
int err;
|
||||||
|
|
||||||
path = getfullpath(name);
|
path = getfullpath(name);
|
||||||
|
|
||||||
if(get_fileinfo(path,&info))
|
if(err=get_fileinfo(path,&info))
|
||||||
{
|
{
|
||||||
// printf("failed getfileinfo %s\n\r", path);
|
// printf("failed getfileinfo %s\n\r", path);
|
||||||
lib_free(path);
|
|
||||||
return (HANDLE)-1;
|
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) )))
|
if ( !(handle=(__file_handle*)lib_malloc(sizeof( __file_handle) )))
|
||||||
@ -205,7 +213,6 @@ static HANDLE __createFileHandle(const CHAR_TYPE *name)
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int __F_NAME(_sopen,__wsopen)( const CHAR_TYPE *name, int mode, int share, va_list args )
|
static int __F_NAME(_sopen,__wsopen)( const CHAR_TYPE *name, int mode, int share, va_list args )
|
||||||
{
|
{
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
@ -225,24 +232,12 @@ static int __F_NAME(_sopen,__wsopen)( const CHAR_TYPE *name, int mode, int share
|
|||||||
|
|
||||||
/*** Open the file ***/
|
/*** Open the file ***/
|
||||||
|
|
||||||
handle = __createFileHandle( name);
|
handle = __openFileHandle( name, mode);
|
||||||
|
|
||||||
if( handle==(HANDLE)-1 )
|
if( handle==(HANDLE)-1 )
|
||||||
{
|
{
|
||||||
|
__freePOSIXHandle( hid );
|
||||||
printf("handle = -1 \n\r");
|
return( -1 ); //error
|
||||||
|
|
||||||
if( mode&O_CREAT )
|
|
||||||
{
|
|
||||||
// handle = CreateFileA( name, desired_access,
|
|
||||||
// share_mode, NULL, create_disp,
|
|
||||||
// fileattr, NULL );
|
|
||||||
}
|
|
||||||
if( handle == (HANDLE)-1 )
|
|
||||||
{
|
|
||||||
__freePOSIXHandle( hid );
|
|
||||||
return( -1 ); //error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now use the slot we got.
|
// Now use the slot we got.
|
||||||
|
@ -1,138 +1,129 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* Open Watcom Project
|
* Open Watcom Project
|
||||||
*
|
*
|
||||||
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
|
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
*
|
*
|
||||||
* This file contains Original Code and/or Modifications of Original
|
* This file contains Original Code and/or Modifications of Original
|
||||||
* Code as defined in and that are subject to the Sybase Open Watcom
|
* 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
|
* 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
|
* 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
|
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
|
||||||
* provided with the Original Code and Modifications, and is also
|
* provided with the Original Code and Modifications, and is also
|
||||||
* available at www.sybase.com/developer/opensource.
|
* available at www.sybase.com/developer/opensource.
|
||||||
*
|
*
|
||||||
* The Original Code and all software distributed under the License are
|
* The Original Code and all software distributed under the License are
|
||||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||||
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
|
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
|
||||||
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
|
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
|
||||||
* NON-INFRINGEMENT. Please see the License for the specific language
|
* NON-INFRINGEMENT. Please see the License for the specific language
|
||||||
* governing rights and limitations under the License.
|
* governing rights and limitations under the License.
|
||||||
*
|
*
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
*
|
*
|
||||||
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
|
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
|
||||||
* DESCRIBE IT HERE!
|
* DESCRIBE IT HERE!
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "variety.h"
|
#include "variety.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
//#if defined(__NT__)
|
#include "iomode.h"
|
||||||
//#elif defined(__OS2__)
|
#include "fileacc.h"
|
||||||
//#else
|
#include "rtcheck.h"
|
||||||
// #include "tinyio.h"
|
#include "rtdata.h"
|
||||||
//#endif
|
#include "seterrno.h"
|
||||||
|
#include "qwrite.h"
|
||||||
#include "iomode.h"
|
#include "liballoc.h"
|
||||||
#include "fileacc.h"
|
|
||||||
#include "rtcheck.h"
|
|
||||||
#include "rtdata.h"
|
/*
|
||||||
#include "seterrno.h"
|
Use caution when setting the file pointer in a multithreaded
|
||||||
//#include "defwin.h"
|
application. You must synchronize access to shared resources. For
|
||||||
#include "qwrite.h"
|
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.
|
||||||
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
|
typedef struct
|
||||||
file pointer, and read from the file must protect this sequence by
|
{ DWORD attr;
|
||||||
using a critical section object or a mutex object.
|
DWORD flags;
|
||||||
*/
|
DWORD cr_time;
|
||||||
|
DWORD cr_date;
|
||||||
|
DWORD acc_time;
|
||||||
int __qwrite( int handle, const void *buffer, unsigned len )
|
DWORD acc_date;
|
||||||
{
|
DWORD mod_time;
|
||||||
int atomic;
|
DWORD mod_date;
|
||||||
#if defined(__NT__)
|
DWORD size;
|
||||||
DWORD len_written;
|
DWORD size_high;
|
||||||
HANDLE h;
|
} FILEINFO;
|
||||||
int error;
|
|
||||||
|
typedef struct
|
||||||
#elif defined(__WARP__)
|
{
|
||||||
#elif defined(__OS2_286__)
|
char *name;
|
||||||
#else
|
unsigned int offset;
|
||||||
#endif
|
}__file_handle;
|
||||||
#if !defined(__NT__)
|
|
||||||
tiny_ret_t rc;
|
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
|
||||||
#endif
|
int _stdcall write_file(const char *name,const void *buff,unsigned offset,unsigned count,unsigned *writes);
|
||||||
|
char* getfullpath(const char* path);
|
||||||
__handle_check( handle, -1 );
|
|
||||||
|
int __qwrite( int handle, const void *buffer, unsigned len )
|
||||||
#if defined(__NT__)
|
{
|
||||||
h = __getOSHandle( handle );
|
int atomic;
|
||||||
#endif
|
__file_handle *fh;
|
||||||
atomic = 0;
|
unsigned len_written;
|
||||||
if( __GetIOMode( handle ) & _APPEND )
|
|
||||||
{
|
|
||||||
_AccessFileH( handle );
|
__handle_check( handle, -1 );
|
||||||
atomic = 1;
|
|
||||||
#if defined(__NT__)
|
fh = (__file_handle*) __getOSHandle( handle );
|
||||||
// if( SetFilePointer( h, 0, NULL, FILE_END ) == -1 )
|
|
||||||
// {
|
atomic = 0;
|
||||||
// error = GetLastError();
|
if( __GetIOMode( handle ) & _APPEND )
|
||||||
// _ReleaseFileH( handle );
|
{
|
||||||
// return( __set_errno_dos( error ) );
|
FILEINFO info;
|
||||||
// }
|
|
||||||
#elif defined(__OS2__)
|
_AccessFileH( handle );
|
||||||
#else
|
atomic = 1;
|
||||||
rc = TinySeek( handle, 0L, SEEK_END );
|
get_fileinfo(fh->name,&info);
|
||||||
#endif
|
fh->offset = info.size;
|
||||||
#if !defined(__NT__)
|
};
|
||||||
if( TINY_ERROR( rc ) ) {
|
|
||||||
_ReleaseFileH( handle );
|
if(write_file(fh->name,buffer,fh->offset,len,&len_written))
|
||||||
return( __set_errno_dos( TINY_INFO( rc ) ) );
|
{
|
||||||
}
|
if ( len_written == 0)
|
||||||
#endif
|
{
|
||||||
}
|
if( atomic == 1 )
|
||||||
#if defined(__NT__)
|
_ReleaseFileH( handle );
|
||||||
|
|
||||||
// if( !WriteFile( h, buffer, len, &len_written, NULL ) )
|
return (-1);
|
||||||
// {
|
};
|
||||||
// error = GetLastError();
|
};
|
||||||
// if( atomic == 1 ) {
|
|
||||||
// _ReleaseFileH( handle );
|
fh->offset+=len_written;
|
||||||
// }
|
|
||||||
// return( __set_errno_dos( error ) );
|
|
||||||
// }
|
if( atomic == 1 )
|
||||||
|
{
|
||||||
#elif defined(__OS2__)
|
_ReleaseFileH( handle );
|
||||||
#elif defined(__WINDOWS_386__)
|
}
|
||||||
#else
|
return( len_written );
|
||||||
rc = TinyWrite( handle, buffer, len );
|
}
|
||||||
len_written = TINY_LINFO( rc );
|
|
||||||
#endif
|
int write_once(const char *name, void *buffer, unsigned len)
|
||||||
|
{ char *path;
|
||||||
#if !defined(__NT__)
|
unsigned count;
|
||||||
if( TINY_ERROR( rc ) ) {
|
|
||||||
if( atomic == 1 ) {
|
path= getfullpath(name);
|
||||||
_ReleaseFileH( handle );
|
write_file(path,buffer,0,len,&count);
|
||||||
}
|
lib_free(path);
|
||||||
return( __set_errno_dos( TINY_INFO( rc ) ) );
|
return count;
|
||||||
}
|
|
||||||
#endif
|
}
|
||||||
if( len_written != len ) {
|
|
||||||
__set_errno( ENOSPC );
|
|
||||||
}
|
|
||||||
if( atomic == 1 )
|
|
||||||
{
|
|
||||||
_ReleaseFileH( handle );
|
|
||||||
}
|
|
||||||
return( len_written );
|
|
||||||
}
|
|
||||||
|
@ -7,8 +7,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SOUND_VERSION 5
|
#define SOUND_VERSION 0x0100
|
||||||
|
|
||||||
#define PCM_ALL 0
|
#define PCM_ALL 0
|
||||||
|
|
||||||
#define PCM_OUT 0x08000000
|
#define PCM_OUT 0x08000000
|
||||||
@ -58,7 +57,7 @@ extern "C"
|
|||||||
#define SND_CREATE_BUFF 1
|
#define SND_CREATE_BUFF 1
|
||||||
#define SND_DESTROY_BUFF 2
|
#define SND_DESTROY_BUFF 2
|
||||||
#define SND_SETFORMAT 3
|
#define SND_SETFORMAT 3
|
||||||
#define SND_GETFORMAT 4
|
#define SND_GETFORMAT 4
|
||||||
#define SND_RESET 5
|
#define SND_RESET 5
|
||||||
#define SND_SETPOS 6
|
#define SND_SETPOS 6
|
||||||
#define SND_GETPOS 7
|
#define SND_GETPOS 7
|
||||||
@ -81,8 +80,8 @@ int _stdcall InitSound(int *version);
|
|||||||
int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf);
|
int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf);
|
||||||
int _stdcall DestroyBuffer(SNDBUF hBuff);
|
int _stdcall DestroyBuffer(SNDBUF hBuff);
|
||||||
|
|
||||||
int _stdcall SetFormat(SNDBUF hBuff, unsigned int format);
|
int _stdcall SetFormat(SNDBUF hBuff, unsigned int format);
|
||||||
int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format);
|
int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format);
|
||||||
|
|
||||||
int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags);
|
int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags);
|
||||||
int _stdcall SetBufferPos(SNDBUF hBuff, int offset);
|
int _stdcall SetBufferPos(SNDBUF hBuff, int offset);
|
||||||
@ -94,12 +93,12 @@ int _stdcall SetBuffer(SNDBUF hBuff,void* buff,
|
|||||||
int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size);
|
int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size);
|
||||||
int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags);
|
int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags);
|
||||||
int _stdcall StopBuffer(SNDBUF hBuff);
|
int _stdcall StopBuffer(SNDBUF hBuff);
|
||||||
|
|
||||||
int _stdcall SetVolume(SNDBUF hBuff, int left, int right);
|
int _stdcall SetVolume(SNDBUF hBuff, int left, int right);
|
||||||
int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right);
|
int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right);
|
||||||
int _stdcall SetPan(SNDBUF hBuff, int pan);
|
int _stdcall SetPan(SNDBUF hBuff, int pan);
|
||||||
int _stdcall GetPan(SNDBUF hBuff, int *pan);
|
int _stdcall GetPan(SNDBUF hBuff, int *pan);
|
||||||
|
|
||||||
int _stdcall GetMasterVol(int* vol);
|
int _stdcall GetMasterVol(int* vol);
|
||||||
int _stdcall SetMasterVol(int vol);
|
int _stdcall SetMasterVol(int vol);
|
||||||
|
|
||||||
|
@ -1168,9 +1168,9 @@ void D_DoomMain (void)
|
|||||||
if (p && p < myargc-1)
|
if (p && p < myargc-1)
|
||||||
{
|
{
|
||||||
if (M_CheckParm("-cdrom"))
|
if (M_CheckParm("-cdrom"))
|
||||||
sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
|
sprintf(file, "c:\\doomdata\\doomsav%c.dsg",myargv[p+1][0]);
|
||||||
else
|
else
|
||||||
sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
|
sprintf(file, "doomsav%c.dsg",myargv[p+1][0]);
|
||||||
G_LoadGame (file);
|
G_LoadGame (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1206,7 +1206,7 @@ void G_DoLoadGame (void)
|
|||||||
char vcheck[VERSIONSIZE];
|
char vcheck[VERSIONSIZE];
|
||||||
|
|
||||||
gameaction = ga_nothing;
|
gameaction = ga_nothing;
|
||||||
|
|
||||||
length = M_ReadFile (savename, &savebuffer);
|
length = M_ReadFile (savename, &savebuffer);
|
||||||
save_p = savebuffer + SAVESTRINGSIZE;
|
save_p = savebuffer + SAVESTRINGSIZE;
|
||||||
|
|
||||||
@ -1266,20 +1266,20 @@ G_SaveGame
|
|||||||
strcpy (savedescription, description);
|
strcpy (savedescription, description);
|
||||||
sendsave = true;
|
sendsave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void G_DoSaveGame (void)
|
void G_DoSaveGame (void)
|
||||||
{
|
{
|
||||||
char name[100];
|
char name[128];
|
||||||
char name2[VERSIONSIZE];
|
char name2[VERSIONSIZE];
|
||||||
char* description;
|
char* description;
|
||||||
int length;
|
int length;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sprintf (name,"%d.dsg",savegameslot);
|
sprintf (name,"doomsav%d.dsg",savegameslot);
|
||||||
description = savedescription;
|
description = savedescription;
|
||||||
|
|
||||||
save_p = savebuffer = screens[1]+0x4000;
|
save_p = savebuffer = screens[1]+0x4000;
|
||||||
|
|
||||||
memcpy (save_p, description, SAVESTRINGSIZE);
|
memcpy (save_p, description, SAVESTRINGSIZE);
|
||||||
save_p += SAVESTRINGSIZE;
|
save_p += SAVESTRINGSIZE;
|
||||||
memset (name2,0,sizeof(name2));
|
memset (name2,0,sizeof(name2));
|
||||||
@ -1305,7 +1305,8 @@ void G_DoSaveGame (void)
|
|||||||
|
|
||||||
length = save_p - savebuffer;
|
length = save_p - savebuffer;
|
||||||
if (length > SAVEGAMESIZE)
|
if (length > SAVEGAMESIZE)
|
||||||
I_Error ("Savegame buffer overrun");
|
I_Error ("Savegame buffer overrun");
|
||||||
|
|
||||||
M_WriteFile (name, savebuffer, length);
|
M_WriteFile (name, savebuffer, length);
|
||||||
gameaction = ga_nothing;
|
gameaction = ga_nothing;
|
||||||
savedescription[0] = 0;
|
savedescription[0] = 0;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
// $Log:$
|
// $Log:$
|
||||||
//
|
//
|
||||||
// DESCRIPTION:
|
// DESCRIPTION:
|
||||||
// DOOM strings, by language.
|
// DOOM strings, by language.
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -38,7 +38,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Misc. other strings.
|
// Misc. other strings.
|
||||||
#define SAVEGAMENAME "doomsav"
|
//#define SAVEGAMENAME "doomsav"
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1,177 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef kolibc_h
|
|
||||||
#define kolibc_h
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef unsigned char byte;
|
|
||||||
typedef unsigned short int word;
|
|
||||||
typedef unsigned int dword;
|
|
||||||
|
|
||||||
typedef unsigned int fpos_t;
|
|
||||||
typedef unsigned int size_t;
|
|
||||||
|
|
||||||
#//define NULL (void*)0
|
|
||||||
|
|
||||||
#define SEEK_SET 0
|
|
||||||
#define SEEK_CUR 1
|
|
||||||
#define SEEK_END 2
|
|
||||||
|
|
||||||
#define FILE_OPEN_READ 0x01
|
|
||||||
#define FILE_OPEN_WRITE 0x02
|
|
||||||
#define FILE_OPEN_APPEND 0x04
|
|
||||||
#define FILE_OPEN_TEXT 0x08
|
|
||||||
#define FILE_OPEN_PLUS 0x10
|
|
||||||
#define EOF -1
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
char *buffer;
|
|
||||||
char *stream;
|
|
||||||
size_t strpos;
|
|
||||||
size_t remain;
|
|
||||||
|
|
||||||
size_t filepos;
|
|
||||||
|
|
||||||
size_t buffersize;
|
|
||||||
size_t filesize;
|
|
||||||
char* filename;
|
|
||||||
int mode;
|
|
||||||
} FILE;
|
|
||||||
|
|
||||||
extern FILE* fopen(const char* filename, const char *mode);
|
|
||||||
extern int fclose(FILE* file);
|
|
||||||
extern int feof(FILE* file);
|
|
||||||
extern int fflush(FILE* file);
|
|
||||||
extern int fgetc(FILE* file);
|
|
||||||
extern int fgetpos(FILE* file,fpos_t* pos);
|
|
||||||
extern int fsetpos(FILE* file,const fpos_t* pos);
|
|
||||||
extern int fputc(int c,FILE* file);
|
|
||||||
extern int fread(void* buffer,size_t size,size_t count,FILE* file);
|
|
||||||
extern int fwrite(const void* buffer,size_t size,size_t count,FILE* file);
|
|
||||||
extern long ftell(FILE* file);
|
|
||||||
extern int fseek(FILE* file,long offset,int origin);
|
|
||||||
extern void rewind(FILE* file);
|
|
||||||
extern int fprintf(FILE* file, const char* format, ...);
|
|
||||||
extern int fscanf(FILE* file,const char* format, ...);
|
|
||||||
extern int ungetc(int c,FILE* file);
|
|
||||||
|
|
||||||
extern int sprintf(char *dest, const char *format,...);
|
|
||||||
extern int printf(const char *format,...);
|
|
||||||
|
|
||||||
typedef char *va_list;
|
|
||||||
#define _roundsize(n) ( (sizeof(n) + 3) & ~3 )
|
|
||||||
#define va_start(ap,v) (ap = (va_list)&v+_roundsize(v))
|
|
||||||
#define va_arg(ap,t) ( *(t *)((ap += _roundsize(t)) - _roundsize(t)) )
|
|
||||||
#define va_end(ap) (ap = (va_list)0)
|
|
||||||
|
|
||||||
/*
|
|
||||||
** All character classification functions except isascii().
|
|
||||||
** Integer argument (c) must be in ASCII range (0-127) for
|
|
||||||
** dependable answers.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define ALNUM 1
|
|
||||||
#define ALPHA 2
|
|
||||||
#define CNTRL 4
|
|
||||||
#define DIGIT 8
|
|
||||||
#define GRAPH 16
|
|
||||||
#define LOWER 32
|
|
||||||
#define PRINT 64
|
|
||||||
#define PUNCT 128
|
|
||||||
#define BLANK 256
|
|
||||||
#define UPPER 512
|
|
||||||
#define XDIGIT 1024
|
|
||||||
|
|
||||||
extern short int _is[128];
|
|
||||||
|
|
||||||
#define isalnum(c)(_is[c] & ALNUM ) /* 'a'-'z', 'A'-'Z', '0'-'9' */
|
|
||||||
#define isalpha(c)(_is[c] & ALPHA ) /* 'a'-'z', 'A'-'Z' */
|
|
||||||
#define iscntrl(c)(_is[c] & CNTRL ) /* 0-31, 127 */
|
|
||||||
#define isdigit(c)(_is[c] & DIGIT ) /* '0'-'9' */
|
|
||||||
#define isgraph(c)(_is[c] & GRAPH ) /* '!'-'~' */
|
|
||||||
#define islower(c)(_is[c] & LOWER ) /* 'a'-'z' */
|
|
||||||
#define isprint(c)(_is[c] & PRINT ) /* ' '-'~' */
|
|
||||||
#define ispunct(c)(_is[c] & PUNCT ) /* !alnum && !cntrl && !space */
|
|
||||||
#define isspace(c)(_is[c] & BLANK ) /* HT, LF, VT, FF, CR, ' ' */
|
|
||||||
#define isupper(c)(_is[c] & UPPER ) /* 'A'-'Z' */
|
|
||||||
#define isxdigit(c)(_is[c] & XDIGIT) /* '0'-'9', 'a'-'f', 'A'-'F' */
|
|
||||||
|
|
||||||
|
|
||||||
#define _LOWER 0x80
|
|
||||||
#define _UPPER 0x40
|
|
||||||
#define _DIGIT 0x20
|
|
||||||
#define _XDIGT 0x10
|
|
||||||
#define _PRINT 0x08
|
|
||||||
#define _PUNCT 0x04
|
|
||||||
#define _SPACE 0x02
|
|
||||||
#define _CNTRL 0x01
|
|
||||||
|
|
||||||
#define abs(i) (((i)<0)?(-(i)):(i))
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
extern int atoib(char *s,int b);
|
|
||||||
extern int atoi(char *s);
|
|
||||||
extern char tolower(char c);
|
|
||||||
extern char toupper(char c);
|
|
||||||
extern void itoab(int n,char* s,int b);
|
|
||||||
extern void itoa(int n,char* s);
|
|
||||||
|
|
||||||
extern char* strcat(char*,const char*);
|
|
||||||
extern char* strchr(const char*,int);
|
|
||||||
extern int strcmp(const char*,const char*);
|
|
||||||
extern int strcoll(const char*,const char*);
|
|
||||||
extern char* strcpy(char*,const char*);
|
|
||||||
extern int strcspn(const char*,const char*);
|
|
||||||
extern size_t strlen(const char*);
|
|
||||||
extern char* strncat(char*,const char*,int);
|
|
||||||
extern int strncmp(const char*,const char*,int);
|
|
||||||
extern char* strncpy(char*,const char*,int);
|
|
||||||
extern char* strpbrk(const char*,const char*);
|
|
||||||
extern char* strrchr(const char*,int);
|
|
||||||
extern int strspn(const char*,const char*);
|
|
||||||
extern char* strstr(const char*,const char*);
|
|
||||||
extern char* strtok(char*,const char*);
|
|
||||||
extern int strxfrm(char*,const char*,int);
|
|
||||||
extern char* strdup(const char*);
|
|
||||||
extern char toupper(char c);
|
|
||||||
#define isascii(char) ( (unsigned)char < 0x80 )
|
|
||||||
|
|
||||||
extern void* memchr(const void*,int,int);
|
|
||||||
extern extern void* memchr(const void*,int,int);
|
|
||||||
extern int memcmp(const void*,const void*,int);
|
|
||||||
extern void* memcpy(void*,const void*,size_t);
|
|
||||||
void kmemset (void *dst, int val, size_t count);
|
|
||||||
|
|
||||||
extern void* memmove(void*,const void*,int);
|
|
||||||
extern void* memset(void*,int,int);
|
|
||||||
int memcmp(const void*,const void*,int);
|
|
||||||
extern void* memcpy(void*,const void*,size_t);
|
|
||||||
void kmemset (void *dst, int val, size_t count);
|
|
||||||
|
|
||||||
extern void* memmove(void*,const void*,int);
|
|
||||||
extern void* memset(void*,int,int);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void debug_out_str(char* str);
|
|
||||||
|
|
||||||
void* _cdecl dlmalloc(size_t size);
|
|
||||||
void* _cdecl dlrealloc(void* oldmem, size_t bytes);
|
|
||||||
void _cdecl dlfree(void *mem);
|
|
||||||
|
|
||||||
//double pow_test(x,y);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif //kolibc_h
|
|
||||||
|
|
||||||
|
|
@ -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 mf_init();
|
|
||||||
void* _cdecl dlmalloc(size_t);
|
|
||||||
void* _cdecl dlrealloc(void *,size_t);
|
|
||||||
void _cdecl dlfree(void*);
|
|
||||||
|
|
||||||
|
|
||||||
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 */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,6 @@ rcsid[] = "$Id: m_misc.c,v 1.6 1997/02/03 22:45:10 b1 Exp $";
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
//#include "//kolibc.h"
|
|
||||||
|
|
||||||
//extern int access(char *file, int mode);
|
//extern int access(char *file, int mode);
|
||||||
|
|
||||||
@ -106,22 +105,29 @@ M_DrawText
|
|||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int write_once(const char *name, void *buffer, unsigned len);
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
M_WriteFile
|
M_WriteFile
|
||||||
( char const* name,
|
( char const* name,
|
||||||
void* source,
|
void* source,
|
||||||
int length )
|
int length )
|
||||||
{
|
{
|
||||||
FILE *handle;
|
// FILE *handle;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
handle = fopen ( name, "wb");
|
// handle = fopen ( name, "wb");
|
||||||
|
|
||||||
if (handle == NULL)
|
// if (handle == NULL)
|
||||||
return false;
|
// return false;
|
||||||
|
|
||||||
// count = fwrite (source, 1, length, handle);
|
// printf("writeFile %s, &s, %d \n\r", name, source, length);
|
||||||
fclose (handle);
|
count = write_once(name, source, length);
|
||||||
|
|
||||||
|
// printf("%d \n\r", count);
|
||||||
|
|
||||||
|
// count = fwrite (source, 1, length, handle);
|
||||||
|
// fclose (handle);
|
||||||
|
|
||||||
if (count < length)
|
if (count < length)
|
||||||
return false;
|
return false;
|
||||||
|
@ -256,11 +256,23 @@ void sound_proc(void)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(ver< SOUND_VERSION)
|
if( SOUND_VERSION>(ver&0xFFFF))
|
||||||
|
{
|
||||||
|
printf("Sound version mismatch\n\r");
|
||||||
|
printf("Current version: %d, required version %d\n\r",
|
||||||
|
ver&0xFFFF, SOUND_VERSION);
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
mov eax, -1
|
||||||
|
int 0x40
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if(SOUND_VERSION<(ver >> 16))
|
||||||
{
|
{
|
||||||
printf("Sound service version mismatch\n\r");
|
printf("Sound version obsolete\n\r");
|
||||||
printf("Installed version: %d, required version %d\n\r",
|
printf("Compatible version: %d, required version %d\n\r",
|
||||||
ver, SOUND_VERSION);
|
ver, SOUND_VERSION);
|
||||||
_asm
|
_asm
|
||||||
{
|
{
|
||||||
|
@ -64,28 +64,21 @@ typedef struct
|
|||||||
|
|
||||||
void _stdcall InitHeap(int heap_size);
|
void _stdcall InitHeap(int heap_size);
|
||||||
void* _stdcall UserAlloc(int size);
|
void* _stdcall UserAlloc(int size);
|
||||||
void _stdcall GetNotify(DWORD *event);
|
int _stdcall UserFree(void* p);
|
||||||
|
|
||||||
|
void _stdcall GetNotify(void *event);
|
||||||
|
|
||||||
|
void _stdcall CreateThread(void *fn, char *p_stack);
|
||||||
|
|
||||||
//void _stdcall CreateThread(void *fn, char *p_stack);
|
|
||||||
DWORD _stdcall GetMousePos(DWORD rel_type);
|
DWORD _stdcall GetMousePos(DWORD rel_type);
|
||||||
int _stdcall GetService(char *srv_name);
|
|
||||||
void _stdcall GetDevInfo(DWORD hSrv,CTRL_INFO *pInfo);
|
|
||||||
int _stdcall GetMasterVol(DWORD hSrv,int* vol);
|
|
||||||
int _stdcall SetMasterVol(DWORD hSrv, int vol);
|
|
||||||
DWORD _stdcall CreateBuffer(DWORD hSrv, DWORD format);
|
|
||||||
int _stdcall DestroyBuffer(DWORD hSrv, DWORD hBuff);
|
|
||||||
int _stdcall SetBuffer(DWORD hSrv, DWORD hBuff,char* buff,
|
|
||||||
DWORD offs, int size);
|
|
||||||
int _stdcall PlayBuffer(DWORD hSrv, DWORD hBuff);
|
|
||||||
int _stdcall StopBuffer(DWORD hSrv, DWORD hBuff);
|
|
||||||
|
|
||||||
void _stdcall debug_out_hex(DWORD val);
|
void _stdcall debug_out_hex(DWORD val);
|
||||||
|
void debug_out_str(char* str);
|
||||||
|
|
||||||
//void debug_out_str(char* str);
|
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
|
||||||
|
int _stdcall create_file(const char *name);
|
||||||
int _stdcall get_fileinfo(char *name,FILEINFO* pinfo);
|
int _stdcall read_file (const char *name,char*buff,DWORD offset,DWORD count,DWORD *reads);
|
||||||
int _stdcall read_file (char *name,char*buff,int offset, int count,int *reads);
|
int _stdcall write_file(const char *name,const void *buff,DWORD offset,DWORD count,DWORD *writes);
|
||||||
int _stdcall write_file(char *name,char*buff,int offset,int count,int *writes);
|
|
||||||
|
|
||||||
//void exit();
|
//void exit();
|
||||||
int _stdcall get_key(int *key);
|
int _stdcall get_key(int *key);
|
||||||
@ -94,13 +87,12 @@ int _stdcall remap_key(int key);
|
|||||||
int _cdecl get_button_id();
|
int _cdecl get_button_id();
|
||||||
|
|
||||||
void delay(int val);
|
void delay(int val);
|
||||||
|
|
||||||
int wait_for_event(int time);
|
int wait_for_event(int time);
|
||||||
int wait_for_event_infinite();
|
int wait_for_event_infinite();
|
||||||
|
void BeginDraw(void);
|
||||||
|
void EndDraw(void);
|
||||||
|
|
||||||
//void BeginDraw(void);
|
void _stdcall GetScreenSize(int *x, int*y);
|
||||||
//void EndDraw(void);
|
|
||||||
|
|
||||||
void _stdcall DrawWindow(int x,int y, int sx, int sy,int workcolor,int style,
|
void _stdcall DrawWindow(int x,int y, int sx, int sy,int workcolor,int style,
|
||||||
int captioncolor,int windowtype,int bordercolor);
|
int captioncolor,int windowtype,int bordercolor);
|
||||||
void _stdcall debug_out(int ch);
|
void _stdcall debug_out(int ch);
|
||||||
@ -108,13 +100,6 @@ 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 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);
|
void _stdcall write_text(int x,int y,int color,char* text,int len);
|
||||||
|
|
||||||
void _cdecl mf_init();
|
|
||||||
void* _cdecl dlmalloc(size_t size);
|
|
||||||
void _cdecl dlfree(void *mem);
|
|
||||||
void* _cdecl dlrealloc(void* oldmem, size_t bytes);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
}
|
}
|
@ -7,8 +7,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SOUND_VERSION 5
|
#define SOUND_VERSION 0x0100
|
||||||
|
|
||||||
#define PCM_ALL 0
|
#define PCM_ALL 0
|
||||||
|
|
||||||
#define PCM_OUT 0x08000000
|
#define PCM_OUT 0x08000000
|
||||||
@ -58,7 +57,7 @@ extern "C"
|
|||||||
#define SND_CREATE_BUFF 1
|
#define SND_CREATE_BUFF 1
|
||||||
#define SND_DESTROY_BUFF 2
|
#define SND_DESTROY_BUFF 2
|
||||||
#define SND_SETFORMAT 3
|
#define SND_SETFORMAT 3
|
||||||
#define SND_GETFORMAT 4
|
#define SND_GETFORMAT 4
|
||||||
#define SND_RESET 5
|
#define SND_RESET 5
|
||||||
#define SND_SETPOS 6
|
#define SND_SETPOS 6
|
||||||
#define SND_GETPOS 7
|
#define SND_GETPOS 7
|
||||||
@ -81,8 +80,8 @@ int _stdcall InitSound(int *version);
|
|||||||
int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf);
|
int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf);
|
||||||
int _stdcall DestroyBuffer(SNDBUF hBuff);
|
int _stdcall DestroyBuffer(SNDBUF hBuff);
|
||||||
|
|
||||||
int _stdcall SetFormat(SNDBUF hBuff, unsigned int format);
|
int _stdcall SetFormat(SNDBUF hBuff, unsigned int format);
|
||||||
int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format);
|
int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format);
|
||||||
|
|
||||||
int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags);
|
int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags);
|
||||||
int _stdcall SetBufferPos(SNDBUF hBuff, int offset);
|
int _stdcall SetBufferPos(SNDBUF hBuff, int offset);
|
||||||
@ -94,12 +93,12 @@ int _stdcall SetBuffer(SNDBUF hBuff,void* buff,
|
|||||||
int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size);
|
int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size);
|
||||||
int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags);
|
int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags);
|
||||||
int _stdcall StopBuffer(SNDBUF hBuff);
|
int _stdcall StopBuffer(SNDBUF hBuff);
|
||||||
|
|
||||||
int _stdcall SetVolume(SNDBUF hBuff, int left, int right);
|
int _stdcall SetVolume(SNDBUF hBuff, int left, int right);
|
||||||
int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right);
|
int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right);
|
||||||
int _stdcall SetPan(SNDBUF hBuff, int pan);
|
int _stdcall SetPan(SNDBUF hBuff, int pan);
|
||||||
int _stdcall GetPan(SNDBUF hBuff, int *pan);
|
int _stdcall GetPan(SNDBUF hBuff, int *pan);
|
||||||
|
|
||||||
int _stdcall GetMasterVol(int* vol);
|
int _stdcall GetMasterVol(int* vol);
|
||||||
int _stdcall SetMasterVol(int vol);
|
int _stdcall SetMasterVol(int vol);
|
||||||
|
|
@ -42,22 +42,10 @@ rcsid[] = "$Id: w_wad.c,v 1.5 1997/02/03 16:47:57 b1 Exp $";
|
|||||||
|
|
||||||
extern char *main_file;
|
extern char *main_file;
|
||||||
|
|
||||||
#ifdef DLHEAP
|
|
||||||
|
|
||||||
void* _cdecl dlmalloc(size_t);
|
|
||||||
void _cdecl dlfree(void*);
|
|
||||||
void _cdecl mf_init();
|
|
||||||
|
|
||||||
#define malloc dlmalloc
|
|
||||||
#define free dlfree
|
|
||||||
#define realloc dlrealloc
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
size_t FileSize(FILE *handle);
|
size_t FileSize(FILE *handle);
|
||||||
|
|
||||||
int _stdcall read_file (char *name, void *buff,
|
//int _stdcall read_file (char *name, void *buff,
|
||||||
size_t offset, size_t count, size_t *reads);
|
// size_t offset, size_t count, size_t *reads);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -196,7 +184,6 @@ void W_AddFile (char *filename)
|
|||||||
length = header.numlumps*sizeof(filelump_t);
|
length = header.numlumps*sizeof(filelump_t);
|
||||||
|
|
||||||
fileinfo = alloca(length);
|
fileinfo = alloca(length);
|
||||||
|
|
||||||
fseek (handle, header.infotableofs, SEEK_SET);
|
fseek (handle, header.infotableofs, SEEK_SET);
|
||||||
fread (fileinfo, 1, length, handle);
|
fread (fileinfo, 1, length, handle);
|
||||||
numlumps += header.numlumps;
|
numlumps += header.numlumps;
|
||||||
|
Loading…
Reference in New Issue
Block a user