home *** CD-ROM | disk | FTP | other *** search
- /*
- sfile.c
-
- % sfile_Open, sfile_Close (screen file routines)
-
- C-scape 3.2
- Copyright (c) 1986-1989 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- ---------------------
- 2/02/89 jdc changed
- 4/21/89 jdc rewrote for non-global fsymlists
- 5/09/89 jdc fixed sfile->bfile == NULL return(NULL)
- 7/22/89 jdc put file buffer into sfile_struct
-
- 3/28/90 jmd ansi-fied
- 4/15/90 jdc added sfile_ReadOnly, preened
- 5/01/90 jmd changed readonly to onlyread to avoid VMS key word conflict
- */
-
- #include "sed.h"
- #include "sfile.h"
-
- sfile_type sf_open(char *name, fsyminit_struct *fsyminit_list, oslist_type *oslist_array, char *comment, boolean onlyread)
- {
- sfile_type sfile;
- int i;
-
- if ((sfile = (sfile_type)omalloc(OA_SFILE, sizeof(struct sfile_struct))) == NULL) {
- return(NULL);
- }
- if ((sfile->bfile = bf_open(name, SFILE_BSIZE, comment, onlyread)) != NULL) {
- if (oslist_array == NULL) {
- if (!fsym_Init(fsyminit_list, sfile->oslist_array)) {
- ofree(OA_SFILE, (VOID *)sfile);
- return(NULL);
- }
- sfile->oslist_owner = TRUE;
- }
- else {
- for (i = 0; i < TOT_FSYM_COUNT; i++) {
- sfile->oslist_array[i] = oslist_array[i];
- }
- sfile->oslist_owner = FALSE;
- }
- }
- else {
- ofree(OA_SFILE, (VOID *)sfile);
- return(NULL);
- }
- sfile->alloc = FALSE;
-
- return(sfile);
- }
-
- void sfile_Close(sfile_type sfile)
- {
- int i;
-
- if ( sfile != NULL ) {
- bfile_Close(sfile->bfile);
-
- if (sfile->oslist_owner) {
- for (i = 0; i < TOT_FSYM_COUNT; i++) {
-
- /* oslist_Close checks for NULL */
- oslist_Close(sfile->oslist_array[i]);
- }
- }
- ofree(OA_SFILE, (VOID *)sfile);
- }
- }
-
-