home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
OS2OMMM.SRC
/
OMMMCOPY.C
< prev
next >
Wrap
Text File
|
1989-02-12
|
5KB
|
144 lines
/***************************************************************************/
/*** ***/
/*** oMMM - The Outbound Matrix Message Masher ***/
/*** Copyright 1989 BS Software ***/
/*** ***/
/*** FILENAME: OMMMCOPY.C ***/
/*** ***/
/*** Packet/Message read/write functions ***/
/*** ***/
/*** Based on the original oMMM, a portion of ***/
/*** the Opus Computer-Based Conversation System ***/
/*** Copyright 1986, Wynn Wagner III ***/
/*** ***/
/***************************************************************************/
/*** ***/
/*** Tabs set at every 4th column ***/
/*** ***/
/***************************************************************************/
/*
Polytron Version Control System Comments:
The revision of this file is *** $Revision: 1.40 $ ***
History of changes from 1.30 release version
$Log: C:/OMMM/PROJFILE/OMMMCOPY.C_V $
*
* Rev 1.40 12 Feb 1989 4:55:50 Marshall Presnell
* Public Release Version 1.40
*
* Rev 1.31 31 Jan 1989 0:58:00 Marshall Presnell
* oMMM 1.35 Beta Release Version
*
* Rev 1.30 23 Jan 1989 17:54:06 Marshall Presnell
* Public Source Code Release - Version 1.30
*/
/*--------------------------------------------------------------------------*/
/* Include files */
/*--------------------------------------------------------------------------*/
#include "ommm.h"
#include <io.h>
#ifdef MSC
# include <memory.h>
#endif
#ifdef TURBO_C
# include <mem.h>
#endif
#ifdef ZTC
# include <string.h>
#endif
/*--------------------------------------------------------------------------*/
/* Static function declarations */
/*--------------------------------------------------------------------------*/
/* ... NONE ... */
/*--------------------------------------------------------------------------*/
/* Static variable definitions */
/*--------------------------------------------------------------------------*/
/* ... NONE ... */
/*--------------------------------------------------------------------------*/
/* External variable declarations */
/*--------------------------------------------------------------------------*/
extern int errno;
/****************************************************************************/
/*--------------------------------------------------------------------------*/
/* OPEN READ AND CLOSE */
/*--------------------------------------------------------------------------*/
int
open_read_and_close(char * filename, char * buffer, int bufsize)
{
FILE * fp;
if ((fp = fopen(filename,"rb")) == NULL)
return(-1);
memset(buffer,0,bufsize);
fread(buffer,1,(unsigned) bufsize,fp);
fclose(fp);
fp = NULL;
return(0);
}
/*--------------------------------------------------------------------------*/
/* COPY MSG */
/*--------------------------------------------------------------------------*/
int
copy_msg(FILE * sf, FILE * df, char * buffer, int bufsize)
{
int length;
length = fread(buffer,1,(unsigned) bufsize,sf);
while (length == bufsize) {
if (fwrite(buffer,1,(unsigned) length,df) != length)
return(-1);
length = fread(buffer,1,(unsigned) bufsize,sf);
}
if (fwrite(buffer,1,(unsigned) length,df) != length)
return(-1);
if (*(buffer + length - 1) != 0)
fputc('\0',df);
return(0);
}
/*--------------------------------------------------------------------------*/
/* COPY OUT */
/*--------------------------------------------------------------------------*/
int
copy_out(FILE * sf, FILE * df, char * buffer, int bufsize)
{
int length;
length = fread(buffer,1,(unsigned) bufsize,sf);
while (length) {
if (fwrite(buffer,1,(unsigned) length,df) != length)
return(-1);
length = fread(buffer,1,(unsigned) bufsize,sf);
}
return(0);
}
/*--------------------------------------------------------------------------*/
/* END OF FILE */
/*--------------------------------------------------------------------------*/