home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ======================================================================== */ /* = Programmname : ControlPadDemo V7.1 = */ /* = = */ /* ======================================================================== */ /* = Author/Copyright : (c) 1993-94 by Andreas Ralph Kleinert. = */ /* = Freeware. All rights reserved. = */ /* = = */ /* = Use it as an example for programming = */ /* = superview.library ! = */ /* = = */ /* ======================================================================== */ /* = Function : Demonstrates handling and creation of = */ /* = standard superview ControlPads = */ /* = with superviewsupport.library. = */ /* = = */ /* ======================================================================== */ /* = Last Update : 15.7.1994 = */ /* = = */ /* ======================================================================== */ /* = Remarks : Needs "superview.library" V7+ = */ /* = and "superviewsupport.library" V2+. = */ /* = = */ /* ======================================================================== */ /* = Compiler : SAS/C V6.51 = */ /* = (smakefile) = */ /* ======================================================================== */ #include <exec/types.h> #include <exec/memory.h> #include <superview/superview.h> #include <superviewsupport/superviewsupport.h> #include <proto/exec.h> #include <proto/dos.h> #include <proto/superview.h> #include <proto/superviewsupport.h> #include <stdio.h> #include <stdlib.h> #include <string.h> /* Help- and Info- Texts */ char entry1_text [] = "\2331;32;40mControlPadDemo V7.1 \2330;32;40m\2333;32;40m(FREEWARE)\2330;32;40m\n(c) 1993-94 by Andreas Ralph Kleinert.\nAndreas R. Kleinert, Grube Hohe Grethe 23, D-57074 Siegen, Germany.\n"; char entry2_text [] = "Tests some superviewsupport.library functions.\n"; char entry3_text [] = "USAGE : \2330;33;40mControlPadDemo\2330;31;40m\n"; char ver_text [] = "\0$VER: ControlPadDemo V7.1 (15.7.94)"; /* *************************************************** */ /* * * */ /* * Error-Messages for Leave() and KF_Message() * */ /* * * */ /* *************************************************** */ char svlib_text [] = "You need \42superview.library\42 V7+ !"; char svslib_text [] = "You need \42superviewsupport.library\42 V2+ !"; /* *************************************************** */ /* * * */ /* * Function Declarations * */ /* * * */ /* *************************************************** */ void __regargs Load_Test(void); /* calls Save_Test, also */ void __regargs Save_Test(struct SV_ControlPad *pad); void __regargs Leave(char *endtext, long code); /* Functions from module "Test_Subs.o" : */ extern void __stdargs K_Printf(char *formatstring, ...); /* *************************************************** */ /* * * */ /* * Additional Base Declarations * */ /* * * */ /* *************************************************** */ extern struct ExecBase *SysBase; struct SuperViewBase *SuperViewBase = N; struct SVSupportBase *SVSupportBase = N; /* *************************************************** */ /* * * */ /* * MAIN * */ /* * * */ /* *************************************************** */ void main(long argc, char **argv) { if(!argc) Leave(N, 0); if( argc > 3 || (argv[1][0] =='?')||(argv[2][0] =='?')) { K_Printf("%s%s%s", entry1_text, entry2_text, entry3_text); Leave(N, 0); } SuperViewBase = (struct SuperViewBase *) OpenLibrary("superview.library", 7); if(!SuperViewBase) Leave(svlib_text, 103); SVSupportBase = (struct SVSupportBase *) OpenLibrary("superviewsupport.library", 2); if(!SVSupportBase) Leave(svslib_text, 103); Load_Test(); Leave("\n", 0); } void __regargs Load_Test(void) { struct SV_ControlPad *pad; struct SV_ControlPad *fpad; K_Printf("\nTesting LOADING of ControlPads (from PAD)"); if(SVSUP_LoadControlPad("PAD", &pad)) { fpad = pad; while(pad) { if(pad->svc_EntryContent) K_Printf("\nContent : \42%s\42=\42%s\42", pad->svc_EntryName, pad->svc_EntryContent); else K_Printf("\nContent : \42%s\42", pad->svc_EntryName); pad = pad->svc_NextEntry; } if(fpad) { char *content; K_Printf("\n\nIs there a ControlPad called TEST_PAD ?"); if(SVSUP_FindControlPad(fpad, "TEST_PAD", &content)) { if(content) K_Printf("\nIts Content is \42%s\42 !", content); else K_Printf("\nIt has no content !"); }else K_Printf("\n No, actually not."); K_Printf("\n\n*** OK, testing SAVING of ControlPads (to NEWPAD)"); Save_Test(fpad); SVSUP_FreeControlPad(fpad); } }else Leave("Can't open Test-File \42PAD\42 !", 10); } void __regargs Save_Test(struct SV_ControlPad *pad) { if(SVSUP_SaveControlPad("NEWPAD", pad)) K_Printf("\n*** OK, now compare the two files : \n*** All comments should be missing in NEWPAD."); else K_Printf("\n*** Can't write to NEWPAD."); } /* *************************************************** */ /* * * */ /* * LEAVE : Global Exit Function Replacement * */ /* * * */ /* *************************************************** */ void __regargs Leave(char *endtext, long code) { if(SVSupportBase) CloseLibrary((APTR) SVSupportBase); if(SuperViewBase) CloseLibrary((APTR) SuperViewBase); if(endtext) K_Printf("%s\n", endtext); exit(code); }