home *** CD-ROM | disk | FTP | other *** search
- /*
- objload.c
-
- % sfile_LoadObj, sfile_SaveObj
-
- C-scape 3.2
- Copyright (c) 1988-1990 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 12/17/89 jdc added name set
- 1/21/90 jdc changed oslist stuff
- 2/14/90 jdc tweeked sf_loadobj
- 3/28/90 jmd ansi-fied
- 4/16/90 jdc renamed _bfile_gets to bf_gets
- 4/23/90 jmd changed class to winclass
- 8/12/90 jdc added opendata arg
- 8/13/90 jdc added loaddefault_classfunc and class handle stuff
- 10/28/90 jdc fixed boolean/int ret conflict
- */
-
- #include <time.h>
-
- #include "sed.h"
- #include "sfile.h"
- #include "sfilpriv.h"
- #include "teddecl.h"
- #include "sled.h"
-
- OGLOBAL class_fptr loaddefault_classfunc = FNULL;
-
- obj_type sfile_LoadObj(sfile_type sfile, char *name, VOID *opendata)
- {
- obj_type obj;
-
- if (oslist_FindHandle(sfile->bfile->dir, name) == -1
- || !sfile_Find(sfile, name, ID_LNFWIN)) {
-
- return(NULL);
- }
- if ((obj = sf_loadobj(sfile, name, opendata)) != NULL) {
-
- /* extra info: time stamp */
- bf_gets(sfile->bfile, sfile->buf, SFILE_BUFLEN, '\0');
- }
- return(obj);
- }
-
- obj_type sf_loadobj(sfile_type sfile, char *name, VOID *opendata)
- {
- obj_type obj;
- class_fptr objclass;
- int handle;
-
- bf_gets(sfile->bfile, sfile->buf, SFILE_BUFLEN, '\0');
-
- if ((objclass = sfile_FindClassFunc(sfile, sfile->buf, &handle)) == FNULL) {
- objclass = loaddefault_classfunc;
- handle = sfile_PutClassFunc(sfile, sfile->buf, objclass);
- }
-
- if (objclass != FNULL && (obj = obj_Open(objclass, opendata)) != NULL) {
-
- obj_SetClassHandle(obj, handle);
- obj_SetName(obj, name);
- if (obj_Do(obj, OBJM_LOAD, sfile, NULL)) {
- return(obj);
- }
- }
- return(NULL);
- }
-
- boolean sfile_SaveObj(sfile_type sfile, obj_type obj, char *name)
- {
- boolean ret;
- TIME_T timep;
-
- if (!sfile_Find(sfile, name, ID_LNFWIN)) {
- return(FALSE);
- }
- if ((ret = sf_saveobj(sfile, obj)) == TRUE) {
-
- /* extra info: time stamp */
- sprintf(sfile->buf, "%ld\n", time(&timep));
- bfile_Write(sfile->bfile, sfile->buf, strlen(sfile->buf));
- }
- obj_SetName(obj, name);
-
- return(ret);
- }
-
- boolean sf_saveobj(sfile_type sfile, obj_type obj)
- {
- sprintf(sfile->buf, "%s\n", (obj_GetClassHandle(obj) == OSLIST_BADNAME) ?
- obj_FindClassName(obj, sfile) : obj_GetClassName(obj, sfile));
-
- bfile_Write(sfile->bfile, sfile->buf, strlen(sfile->buf));
-
- return((obj_Do(obj, OBJM_SAVE, sfile, NULL) == 1) ? TRUE : FALSE);
- }
-