/programs/develop/open watcom/trunk/clib/h/commode.h |
---|
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 "*_"; |
/programs/develop/open watcom/trunk/clib/h/fmode.h |
---|
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 */ |
/programs/develop/open watcom/trunk/clib/h/kolibri.h |
---|
0,0 → 1,105 |
#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 |
/programs/develop/open watcom/trunk/clib/h/openmode.h |
---|
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 |
/programs/develop/open watcom/trunk/clib/h/qread.h |
---|
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 |
/programs/develop/open watcom/trunk/clib/src/fclose.c |
---|
44,19 → 44,7 |
#include "close.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__ |
void (*__RmTmpFileFn)( FILE *fp ); |
#endif |
/programs/develop/open watcom/trunk/clib/src/fwrite.c |
---|
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 ); |
} |
/programs/develop/open watcom/trunk/clib/src/openklbr.c |
---|
67,6 → 67,7 |
} FILEINFO; |
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo); |
int _stdcall create_file(const char *name); |
typedef struct |
76,7 → 77,7 |
}__file_handle; |
static char* getfullpath(const char* path) |
char* getfullpath(const char* path) |
{ |
int prev_is_slash=0; |
int len=0, depth=0, i; |
177,21 → 178,28 |
} |
static HANDLE __createFileHandle(const CHAR_TYPE *name) |
static HANDLE __openFileHandle(const CHAR_TYPE *name, int mode) |
{ |
FILEINFO info; |
__file_handle *handle; |
char *path; |
int err; |
path = getfullpath(name); |
if(get_fileinfo(path,&info)) |
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); |
205,7 → 213,6 |
}; |
static int __F_NAME(_sopen,__wsopen)( const CHAR_TYPE *name, int mode, int share, va_list args ) |
{ |
HANDLE handle; |
225,25 → 232,13 |
/*** Open the file ***/ |
handle = __createFileHandle( name); |
handle = __openFileHandle( name, mode); |
if( handle==(HANDLE)-1 ) |
{ |
printf("handle = -1 \n\r"); |
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. |
__setOSHandle( hid, handle ); // JBS 99/11/01 |
/programs/develop/open watcom/trunk/clib/src/qwrit.c |
---|
34,20 → 34,15 |
#include <stdio.h> |
#include <errno.h> |
//#if defined(__NT__) |
//#elif defined(__OS2__) |
//#else |
// #include "tinyio.h" |
//#endif |
#include "iomode.h" |
#include "fileacc.h" |
#include "rtcheck.h" |
#include "rtdata.h" |
#include "seterrno.h" |
//#include "defwin.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 |
56,80 → 51,65 |
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; |
#if defined(__NT__) |
DWORD len_written; |
HANDLE h; |
int error; |
__file_handle *fh; |
unsigned len_written; |
#elif defined(__WARP__) |
#elif defined(__OS2_286__) |
#else |
#endif |
#if !defined(__NT__) |
tiny_ret_t rc; |
#endif |
__handle_check( handle, -1 ); |
#if defined(__NT__) |
h = __getOSHandle( handle ); |
#endif |
fh = (__file_handle*) __getOSHandle( handle ); |
atomic = 0; |
if( __GetIOMode( handle ) & _APPEND ) |
{ |
FILEINFO info; |
_AccessFileH( handle ); |
atomic = 1; |
#if defined(__NT__) |
// if( SetFilePointer( h, 0, NULL, FILE_END ) == -1 ) |
// { |
// error = GetLastError(); |
// _ReleaseFileH( handle ); |
// return( __set_errno_dos( error ) ); |
// } |
#elif defined(__OS2__) |
#else |
rc = TinySeek( handle, 0L, SEEK_END ); |
#endif |
#if !defined(__NT__) |
if( TINY_ERROR( rc ) ) { |
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( __set_errno_dos( TINY_INFO( rc ) ) ); |
} |
#endif |
} |
#if defined(__NT__) |
// if( !WriteFile( h, buffer, len, &len_written, NULL ) ) |
// { |
// error = GetLastError(); |
// if( atomic == 1 ) { |
// _ReleaseFileH( handle ); |
// } |
// return( __set_errno_dos( error ) ); |
// } |
return (-1); |
}; |
}; |
#elif defined(__OS2__) |
#elif defined(__WINDOWS_386__) |
#else |
rc = TinyWrite( handle, buffer, len ); |
len_written = TINY_LINFO( rc ); |
#endif |
fh->offset+=len_written; |
#if !defined(__NT__) |
if( TINY_ERROR( rc ) ) { |
if( atomic == 1 ) { |
_ReleaseFileH( handle ); |
} |
return( __set_errno_dos( TINY_INFO( rc ) ) ); |
} |
#endif |
if( len_written != len ) { |
__set_errno( ENOSPC ); |
} |
if( atomic == 1 ) |
{ |
_ReleaseFileH( handle ); |
136,3 → 116,14 |
} |
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; |
} |