home *** CD-ROM | disk | FTP | other *** search
- /* > $.CLIB.C.filestack
- *
- * HASWIN Graphics Library
- * =========================
- *
- * Copyright (C) H.A.Shaw 1990.
- * Howard A. Shaw.
- * The Unit for Space Sciences,
- * Room 165,
- * Physics Building,
- * University of Kent at Canterbury.
- * Canterbury.
- * Kent. CT2 7NJ
- * You may use and distribute this code freely, however please leave
- * it alone. If you find bugs (and there will be many) please contact
- * me and the master source can be modified. If you keep me informed
- * of who you give copies of this to then I can get release upgrades
- * to them.
- *
- * routines to control the stacking of file load/save/auto-load routines
- */
- #include "includes.h"
-
- typedef struct filestore {
- int (*code)(char *, buffer *);
- char name[256];
- char type[8];
- } filestore;
-
- typedef struct autostore {
- int (*code)(char *, buffer *);
- char type[8];
- } autostore;
-
- #define HASWIN_MAXFILES 8
- static filestore haswin_savefilestack[HASWIN_MAXFILES];
- static int haswin_savefilestackptr = 0;
- static filestore haswin_loadfilestack[HASWIN_MAXFILES];
- static int haswin_loadfilestackptr = 0;
- static autostore haswin_autoloadstack[HASWIN_MAXFILES];
- static int haswin_autoloadstackptr = 0;
-
- /*
- * push the current autoloadroutine onto the autoloadroutine stack and
- * set a new one if we can.
- */
- int haswin_pushautoloadroutine(int (*user)(char *, buffer *), char *type) {
-
- if (haswin_autoloadstackptr == HASWIN_MAXFILES)
- return(HASWIN_FALSE);
- haswin_autoloadstack[haswin_autoloadstackptr].code =
- haswin_autoloadroutine;
- haswin_decodefiletype(haswin_autoloadtype, haswin_autoloadstack[haswin_autoloadstackptr].type);
- haswin_autoloadstackptr++;
- haswin_setautoloadroutine(user, type);
- return(HASWIN_TRUE);
- }
-
- /*
- * push the current loadfileroutine onto the loadfileroutine stack and
- * set a new one if we can.
- */
- int haswin_pushloadfileroutine(int (*user)(char *, buffer *), char *name, char *type) {
-
- if (haswin_loadfilestackptr == HASWIN_MAXFILES)
- return(HASWIN_FALSE);
- haswin_loadfilestack[haswin_loadfilestackptr].code =
- haswin_loadfileroutine;
- strcpy(haswin_loadfilestack[haswin_loadfilestackptr].name,
- haswin_defaultloadfile);
- haswin_decodefiletype(haswin_loadfiletype, haswin_loadfilestack[haswin_loadfilestackptr].type);
- haswin_loadfilestackptr++;
- haswin_setloadfileroutine(user, name, type);
- return(HASWIN_TRUE);
- }
-
- /*
- * push the current savefileroutine onto the savefileroutine stack and
- * set a new one if we can.
- */
- int haswin_pushsavefileroutine(int (*user)(char *, buffer *), char *name, char *type) {
-
- if (haswin_savefilestackptr == HASWIN_MAXFILES)
- return(HASWIN_FALSE);
- haswin_savefilestack[haswin_savefilestackptr].code =
- haswin_savefileroutine;
- strcpy(haswin_savefilestack[haswin_savefilestackptr].name,
- haswin_defaultsavefile);
- haswin_decodefiletype(haswin_savefiletype, haswin_savefilestack[haswin_savefilestackptr].type);
- haswin_savefilestackptr++;
- haswin_setsavefileroutine(user, name, type);
- return(HASWIN_TRUE);
- }
-
- /*
- * pull an autoloadroutine from the autoload stack if we can
- */
- int haswin_popautoloadroutine(void) {
-
- if (haswin_autoloadstackptr <= 0) {
- haswin_setautoloadroutine(0, "");
- return(HASWIN_FALSE);
- }
- haswin_autoloadstackptr--;
- haswin_setautoloadroutine(
- haswin_autoloadstack[haswin_autoloadstackptr].code,
- haswin_autoloadstack[haswin_autoloadstackptr].type);
- return(HASWIN_TRUE);
- }
-
- /*
- * pull a loadfileroutine from the loadfile stack if we can
- */
- int haswin_poploadfileroutine(void) {
-
- if (haswin_loadfilestackptr <= 0) {
- haswin_setloadfileroutine(0, "", "");
- return(HASWIN_FALSE);
- }
- haswin_loadfilestackptr--;
- haswin_setloadfileroutine(
- haswin_loadfilestack[haswin_loadfilestackptr].code,
- haswin_loadfilestack[haswin_loadfilestackptr].name,
- haswin_loadfilestack[haswin_loadfilestackptr].type);
- return(HASWIN_TRUE);
- }
-
- /*
- * pull a savefileroutine from the savefile stack if we can
- */
- int haswin_popsavefileroutine(void) {
-
- if (haswin_savefilestackptr <= 0) {
- haswin_setsavefileroutine(0, "", "");
- return(HASWIN_FALSE);
- }
- haswin_savefilestackptr--;
- haswin_setsavefileroutine(
- haswin_savefilestack[haswin_savefilestackptr].code,
- haswin_savefilestack[haswin_savefilestackptr].name,
- haswin_savefilestack[haswin_savefilestackptr].type);
- return(HASWIN_TRUE);
- }
-
-