home *** CD-ROM | disk | FTP | other *** search
- ;/* filehook.c - Execute me to compile me with Lattice 5.10
- LC -b1 -cfistq -v -y -j73 filehook.c
- Blink FROM LIB:c.o,filehook.o TO filehook LIBRARY LIB:LC.lib,LIB:Amiga.lib
- quit
- */
-
- /*(c) Copyright 1991 Commodore-Amiga, Inc. All rights reserved.
- The information contained herein is subject to change without notice,
- and is provided "as is" without warranty of any kind, either expressed
- or implied. The entire risk as to the use of this information is
- assumed by the user.
- */
-
-
- #include <clib/asl_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/alib_stdio_protos.h>
- #include <dos/dosasl.h>
- #include <intuition/intuition.h>
- #include <exec/libraries.h>
-
- #ifdef LATTICE
- int CXBRK(void) { return(0); } /* Disable Lattice CTRL/C handling */
- int chkabort(void) { return(0); } /* really */
- #endif
-
- #define DESTPATLENGTH 20
-
- UBYTE *vers = "\0$VER: filehook 1.0";
-
- void main(void);
-
- struct Library *AslBase;
- struct IntuitionBase *IntuitionBase;
- struct Window *window;
-
- CPTR HookFunc();
-
- /* this is the pattern matching string that the hook function uses */
- UBYTE *sourcepattern = "(#?.info)";
- UBYTE pat[DESTPATLENGTH];
-
-
- void main()
- {
-
- struct FileRequester *fr;
-
- /* This is a dos.library function that turns a pattern matching
- ** string into something the DOS pattern matching functions
- ** can understand.
- */
- ParsePattern(sourcepattern, pat, DESTPATLENGTH);
-
- if (AslBase = OpenLibrary("asl.library", 36L))
- {
- if (IntuitionBase = (struct IntuitionBase *)
- OpenLibrary("intuition.library", 36L))
- {
- /* open a window that gets ACTIVEWINDOW events */
- if (window = (struct Window *)OpenWindowTags(NULL,
- WA_Title, "ASL Hook Function Example",
- WA_IDCMP, IDCMP_ACTIVEWINDOW,
- WA_Flags, WINDOWDEPTH,
- TAG_END))
- {
- if (fr = AllocFileRequest())
- {
- /* application body here... */
-
-
- if (AslRequestTags(fr,
- ASL_Window, window,
- ASL_TopEdge, 0L,
- ASL_Height, 200L,
- ASL_Hail, (ULONG)"Pick an icon to save",
- ASL_HookFunc, (ULONG)HookFunc,
- ASL_FuncFlags, FILF_DOWILDFUNC | FILF_DOMSGFUNC | FILF_SAVE,
- ASL_OKText, (ULONG)"Save",
- TAG_DONE))
- {
- printf("You picked %s%s\n", fr->rf_Dir, fr->rf_File);
- }
-
- /* more application body here */
-
- FreeFileRequest(fr);
- }
- CloseWindow(window);
- }
- CloseLibrary(IntuitionBase);
- }
- CloseLibrary(AslBase);
- }
- }
-
-
- CPTR HookFunc(LONG type, CPTR obj, struct FileRequester *fr)
- {
- static BOOL returnvalue;
- switch(type)
- {
- case FILF_DOMSGFUNC:
- /* We got a message meant for the window */
- printf("You activated the window\n");
- return(obj);
- break;
- case FILF_DOWILDFUNC:
- /* We got an AnchorPath structure, should
- ** the requester display this file? */
-
- /* MatchPattern() is a dos.library function that
- ** compares a matching pattern (parsed by the
- ** ParsePattern() DOS function) to a string and
- ** returns true if they match. */
- returnvalue = MatchPattern(pat,
- ((struct AnchorPath *)obj)->ap_Info.fib_FileName);
-
- /* we have to negate MatchPattern()'s return value
- ** because the file requester expects a zero for
- ** a match not a TRUE value */
- return( (CPTR)(! returnvalue) );
- break;
- }
- }
-
-