home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************/
- /*** ***/
- /*** 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> */
- # include <string.h>
-
- /*--------------------------------------------------------------------------*/
- /* 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 */
- /*--------------------------------------------------------------------------*/
-
-
-