home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
SNPD9404.ZIP
/
HUGEREAD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-04-03
|
2KB
|
95 lines
.I 30 1
#include <stdio.h>
.I 68 6
unsigned long base, para;
base = (unsigned long)(ptr & 0xffff000fL);
para = (unsigned long)(ptr & 0x0000fff0L);
para <<= 12;
return (void FAR *)(base + para);
.D 69 5
.I 157 83
/*
** Read any size block to anywhere in memory
*/
long hugefread(FILE *fp, char FAR *buf, long size)
{
long count;
size_t bufsiz;
char *tmp;
long ercode = size;
if (4 > sizeof(void *))
{
if (0 == (bufsiz = gettmp(&tmp)))
return -1L;
}
else
{
tmp = (char *)buf;
bufsiz = 0x4000;
}
while (0 < (count = min(size, (long)bufsiz)))
{
int i, numread = fread(tmp, 1, (size_t)count, fp);
if (1 > numread || numread != (int)count)
return -1L;
if (4 > sizeof(void *))
{
for (i = 0; i < count; ++i)
buf[i] = tmp[i];
}
buf = farnormal(buf + count);
size -= count;
if (2 < sizeof(void *))
tmp = (char *)buf;
}
return ercode;
}
/*
** Write any size block from anywhere in memory
*/
long hugefwrite(FILE *fp, char FAR *buf, long size)
{
long count;
size_t bufsiz;
char *tmp;
long ercode = size;
if (4 > sizeof(void *))
{
if (0 == (bufsiz = gettmp(&tmp)))
return -1L;
}
else
{
tmp = (char *)buf;
bufsiz = 0x4000;
}
while (0 < (count = min(size, (long)bufsiz)))
{
int i, numwrite;
if (4 > sizeof(void *))
{
for (i = 0; i < count; ++i)
tmp[i] = buf[i];
}
numwrite = fwrite(tmp, 1, (size_t)count, fp);
if (1 > numwrite || numwrite != (int)count)
return -1L;
buf = farnormal(buf + count);
size -= count;
if (2 < sizeof(void *))
tmp = (char *)buf;
}
return ercode;
}