home *** CD-ROM | disk | FTP | other *** search
- /*
- lnfpack.c
-
- % A utility for removing free blocks and session info from screen files.
-
- works at the bfile level
-
- Look & Feel 3.2
- Copyright (c) 1989-1990, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- */
-
- #include <stdio.h>
- #include <stdlib.h>
-
- #include "cscape.h"
- #include "sfile.h"
-
- #define TEMPNAME "lnfpack.tmp"
-
- int main(int argc, char *argv[]); /* Prototype for main */
-
- int main(int argc, char *argv[])
- {
- int j;
- unsigned int len;
- char *bname;
- bfile_type bfile, destfile;
- char buffer[1001];
-
- if (argc <= 1
- || *argv[1] == '?'
- || ((*argv[1] == '-' || *argv[1] == '/') && *(argv[1]+1) == '?')) {
-
- printf("\npacks .lnf files");
- exit(0);
- }
-
- if ((destfile = bfile_Open(TEMPNAME, 500, "LNFVER 3.2")) == NULL) {
- printf("\nError opening temporay file.\n");
- exit(1);
- }
-
- if ((bfile = bfile_Open(argv[1], 500, "LNFVER 3.2")) != NULL) {
-
- for (j = 0; j < bfile_GetDirSize(bfile); j++) {
-
- if (*(bname = bfile_GetDirName(bfile, j)) == '_') {
- /* strip off system working areas */
- continue;
- }
- bfile_Find(bfile, bname, 0);
- bfile_Find(destfile, bname, bfile_GetID(bfile, j));
-
- while ((len = bfile_Read(bfile, buffer, 1000)) > 0) {
- bfile_Write(destfile, buffer, len);
- }
- }
- bfile_Close(bfile);
- bfile_Close(destfile);
-
- remove(argv[1]);
- rename(TEMPNAME, argv[1]);
- }
- else if (destfile != NULL) {
- bfile_Close(destfile);
- }
-
- return(0);
- }
-