1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
/*
* SMAPI; Modified Squish MSGAPI
*
* Squish MSGAPI0 is copyright 1991 by Scott J. Dudley. All rights reserved.
* Modifications released to the public domain.
*
* Use of this file is subject to the restrictions contain in the Squish
* MSGAPI0 licence agreement. Please refer to licence.txt for complete
* details of the licencing restrictions. If you do not find the text
* of this agreement in licence.txt, or if you do not have this file,
* you should contact Scott Dudley at FidoNet node 1:249/106 or Internet
* e-mail Scott.Dudley@f106.n249.z1.fidonet.org.
*
* In no event should you proceed to use any of the source files in this
* archive without having accepted the terms of the MSGAPI0 licensing
* agreement, or such other agreement as you are able to reach with the
* author.
*/
#include <stdlib.h>
#include "compiler.h"
#include "prog.h"
#include "unused.h"
#if defined(HAS_IO_H)
#include <io.h>
#endif
#if defined(HAS_UNISTD_H)
#include <unistd.h>
#endif
#if defined(HAS_DOS_H)
#include <dos.h>
#endif
#ifdef __OS2__
# define INCL_NOPM
# include <os2.h>
# if defined(__WATCOMC__)
# ifndef DosBufReset
# define DosBufReset DosResetBuffer
# endif
# elif defined(__EMX__) || defined(__FLAT__)
# undef DosBufReset
# define DosBufReset DosResetBuffer
# endif
#endif
#if defined(__NT__) || defined(__MINGW32__)
# define WIN32_LEAN_AND_MEAN
# define NOGDI
# define NOUSER
# define NOMSG
# include <windows.h>
#endif
#if defined(__DJGPP__)
/*
void pascal far flush_handle2(int fh)
{
fsync(fh);
}
*/
#define flush_handle2(f) fsync(f)
#elif defined(__UNIX__) || defined(SASC)
/*
void pascal far flush_handle2(int fh)
{
unused(fh);
}
*/
#define flush_handle2(f) unused(f)
#elif defined(__OS2__)
/*
void pascal far flush_handle2(int fh)
{
DosBufReset((HFILE) fh);
}
*/
#define flush_handle2(f) DosBufReset((HFILE) f)
#elif defined(__NT__) || defined(__MINGW32__)
#ifdef __RSXNT__
# include <emx/syscalls.h>
# ifndef F_GETOSFD
# define F_GETOSFD 6
# endif
# define flush_handle2(fh) FlushFileBuffers((HANDLE) __fcntl((fh), F_GETOSFD, 0))
#else
# define flush_handle2(fh) FlushFileBuffers((HANDLE) (fh))
#endif
/*
void pascal far flush_handle2(int fh)
{
#ifdef __RSXNT__
int nt_handle = __fcntl(fh, F_GETOSFD, 0);
#else
int nt_handle = fh;
#endif
FlushFileBuffers((HANDLE) nt_handle);
}
*/
#elif defined(__WATCOMC__DOS__)
#include <dos.h>
/*
void pascal far flush_handle2(int fh)
{
_dos_commit(fh);
}
*/
# define flush_handle2(fh) _dos_commit(fh)
#elif defined (__DOS__)
/* refer to MS-DOS flush_handle2 code in FLUSHASM.ASM */
void pascal far flush_handle2(int fd);
#else
#error unknown compiler
#endif
/*
* This makes sure a file gets flushed to disk. Thanks to Ray Duncan
* for this tip in his _Advanced MS-DOS_ book.
*/
void _fast flush_handle(FILE * fp)
{
fflush(fp);
#if defined(__OS2__) || defined(__DOS__) || defined(__NT__) || defined(__TURBOC__) || defined(SASC) || defined(__DJGPP__)
flush_handle2(fileno(fp));
#else
{
int nfd;
nfd = dup(fileno(fp));
if (nfd != -1)
{
close(nfd);
}
}
#endif
}
|