home *** CD-ROM | disk | FTP | other *** search
- /*
- ** savscrn.c
- ** contains: savscrn()
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include "gfuncts.h"
-
-
-
- #ifndef _MSC
- #ifndef TURBOC
- int fwrite();
- #endif
- #endif
-
-
- /*
- ** int
- ** savscrn(char *filename)
- **
- ** ARGUMENT(s)
- ** filename - filename of file to receive screen image
- **
- ** DESCRIPTION
- ** Saves character/attribute pairs of the entire screen in a file. This
- ** file can later be read by restscrn() which will display it on the
- ** screen.
- **
- ** RETURNS
- ** GFSUCCESS,
- ** NOTENOUGHMEMORY,
- ** CANTOPENFILE,
- ** CANTWRITEDEST,
- **
- **
- ** AUTHOR
- ** "" Wed 21-Dec-1988 10:21:13
- ** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- **
- ** MODIFICATIONS
- **
- */
- int GF_CONV savscrn(filename)
- char *filename;
- {
- char *opstring;
- union GFSCRNFILE *gfshdr=(union GFSCRNFILE *)0;
- struct GFREGS out;
- unsigned *screenimage=(unsigned *)0;
- FILE *fp=(FILE *)0;
- int retval=GFSUCCESS;
-
- #ifndef AZTEC
- opstring="wb";
- #else
- opstring="w";
- #endif
- if((gfshdr=(union GFSCRNFILE *)calloc(sizeof(union GFSCRNFILE),1))==(union GFSCRNFILE *)0)
- return(NOTENOUGHMEMORY);
- gfshdr->f.gffileid=SCRNFILID;
- gfshdr->f.gfuversion=GFVERSION;
- gfshdr->f.gfurevision=GFREVISION;
- gfshdr->f.gfsumcheck=SCRNFILID+GFVERSION+GFREVISION;
- gfshdr->f.gfstructsize=sizeof(union GFSCRNFILE);
- gfshdr->f.gfcurrow=(getcur(0)>>8)&0x00ff;
- gfshdr->f.gfcurcol=getcur(0)&0x00ff;
- vstate(&out);
- gfshdr->f.gfrows=out.dx;
- gfshdr->f.gfcols=out.bx;
- gfshdr->f.gfvidmode=out.ax;
- gfshdr->f.gfreadsize=(out.dx*out.bx)*2;
- if((screenimage=(unsigned *)malloc((gfshdr->f.gfrows*gfshdr->f.gfcols)*2))==(unsigned *)0) {
- free((char *)gfshdr);
- return(NOTENOUGHMEMORY);
- }
- getscrn(0,0,gfshdr->f.gfrows-1,gfshdr->f.gfcols-1,screenimage);
- if((fp=fopen(filename,opstring))==(FILE *)0) {
- free((char *)screenimage);
- free((char *)gfshdr);
- return(CANTOPENFILE);
- }
- if(fwrite((char *)gfshdr,sizeof(union GFSCRNFILE),(int)1,fp)!=(int)1 ||
- fwrite((char *)screenimage,gfshdr->f.gfreadsize,(int)1,fp)!=(int)1 )
- retval=CANTWRITEDEST;
- fclose(fp);
- free((char *)screenimage);
- free((char *)gfshdr);
- return(retval);
- }
-