home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / gfx / superview-lib-9.12.lha / SuperView-Lib / Programmers / Example_Tools / ControlPad / CPD.c < prev    next >
C/C++ Source or Header  |  1994-12-28  |  6KB  |  185 lines

  1. /* ======================================================================== */
  2. /* = Programmname    : ControlPadDemo V7.1                                = */
  3. /* =                                      = */
  4. /* ======================================================================== */
  5. /* = Author/Copyright : (c) 1993-94 by Andreas Ralph Kleinert.            = */
  6. /* =               Freeware. All rights reserved.              = */
  7. /* =                                      = */
  8. /* =                   Use it as an example for programming               = */
  9. /* =                   superview.library !                                = */
  10. /* =                                      = */
  11. /* ======================================================================== */
  12. /* = Function          : Demonstrates handling and creation of             = */
  13. /* =                standard superview ControlPads                    = */
  14. /* =                with superviewsupport.library.                    = */
  15. /* =                                      = */
  16. /* ======================================================================== */
  17. /* = Last Update      : 15.7.1994                      = */
  18. /* =                                      = */
  19. /* ======================================================================== */
  20. /* = Remarks          : Needs "superview.library" V7+                     = */
  21. /* =                and "superviewsupport.library" V2+.               = */
  22. /* =                                      = */
  23. /* ======================================================================== */
  24. /* = Compiler          : SAS/C V6.51                        = */
  25. /* =                (smakefile)                                       = */
  26. /* ======================================================================== */
  27.  
  28. #include <exec/types.h>
  29. #include <exec/memory.h>
  30.  
  31. #include <superview/superview.h>
  32. #include <superviewsupport/superviewsupport.h>
  33.  
  34. #include <proto/exec.h>
  35. #include <proto/dos.h>
  36. #include <proto/superview.h>
  37. #include <proto/superviewsupport.h>
  38.  
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include <string.h>
  42.  
  43.  
  44.    /* Help- and Info- Texts */
  45.  
  46. 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";
  47. char entry2_text  [] = "Tests some superviewsupport.library functions.\n";
  48. char entry3_text  [] = "USAGE : \2330;33;40mControlPadDemo\2330;31;40m\n";
  49.  
  50.  
  51. char ver_text [] = "\0$VER: ControlPadDemo V7.1 (15.7.94)";
  52.  
  53.  
  54. /* *************************************************** */
  55. /* *                             * */
  56. /* * Error-Messages for Leave() and KF_Message()     * */
  57. /* *                             * */
  58. /* *************************************************** */
  59.  
  60. char svlib_text  [] = "You need \42superview.library\42 V7+ !";
  61. char svslib_text [] = "You need \42superviewsupport.library\42 V2+ !";
  62.  
  63.  
  64. /* *************************************************** */
  65. /* *                             * */
  66. /* * Function Declarations                 * */
  67. /* *                             * */
  68. /* *************************************************** */
  69.  
  70. void __regargs Load_Test(void);                     /* calls Save_Test, also */
  71. void __regargs Save_Test(struct SV_ControlPad *pad);
  72.  
  73. void __regargs Leave(char *endtext, long code);
  74.  
  75.  
  76.    /* Functions from module "Test_Subs.o" : */
  77.  
  78. extern void __stdargs K_Printf(char *formatstring, ...);
  79.  
  80.  
  81. /* *************************************************** */
  82. /* *                             * */
  83. /* * Additional Base Declarations             * */
  84. /* *                             * */
  85. /* *************************************************** */
  86.  
  87. extern struct ExecBase *SysBase;
  88.  
  89. struct SuperViewBase *SuperViewBase = N;
  90. struct SVSupportBase *SVSupportBase = N;
  91.  
  92.  
  93. /* *************************************************** */
  94. /* *                             * */
  95. /* * MAIN                         * */
  96. /* *                             * */
  97. /* *************************************************** */
  98.  
  99. void main(long argc, char **argv)
  100. {
  101.  if(!argc) Leave(N, 0);
  102.  
  103.  if( argc > 3 || (argv[1][0] =='?')||(argv[2][0] =='?'))
  104.   {
  105.    K_Printf("%s%s%s", entry1_text, entry2_text, entry3_text);
  106.  
  107.    Leave(N, 0);
  108.   }
  109.  
  110.  SuperViewBase = (struct SuperViewBase *) OpenLibrary("superview.library", 7);
  111.  if(!SuperViewBase) Leave(svlib_text, 103);
  112.  
  113.  SVSupportBase = (struct SVSupportBase *) OpenLibrary("superviewsupport.library", 2);
  114.  if(!SVSupportBase) Leave(svslib_text, 103);
  115.  
  116.  Load_Test();
  117.  
  118.  Leave("\n", 0);
  119. }
  120.  
  121. void __regargs Load_Test(void)
  122. {
  123.  struct SV_ControlPad *pad;
  124.  struct SV_ControlPad *fpad;
  125.  
  126.  K_Printf("\nTesting LOADING of ControlPads (from PAD)");
  127.  
  128.  if(SVSUP_LoadControlPad("PAD", &pad))
  129.   {
  130.    fpad = pad;
  131.  
  132.    while(pad)
  133.     {
  134.      if(pad->svc_EntryContent) K_Printf("\nContent : \42%s\42=\42%s\42", pad->svc_EntryName, pad->svc_EntryContent);
  135.       else                     K_Printf("\nContent : \42%s\42", pad->svc_EntryName);
  136.  
  137.      pad = pad->svc_NextEntry;
  138.     }
  139.  
  140.    if(fpad)
  141.     {
  142.      char *content;
  143.  
  144.      K_Printf("\n\nIs there a ControlPad called TEST_PAD ?");
  145.  
  146.      if(SVSUP_FindControlPad(fpad, "TEST_PAD", &content))
  147.       {
  148.        if(content) K_Printf("\nIts Content is \42%s\42 !", content);
  149.         else       K_Printf("\nIt has no content !");
  150.  
  151.       }else K_Printf("\n No, actually not.");
  152.  
  153.  
  154.      K_Printf("\n\n*** OK, testing SAVING of ControlPads (to NEWPAD)");
  155.  
  156.      Save_Test(fpad);
  157.  
  158.      SVSUP_FreeControlPad(fpad);
  159.     }
  160.  
  161.   }else Leave("Can't open Test-File \42PAD\42 !", 10);
  162. }
  163.  
  164. void __regargs Save_Test(struct SV_ControlPad *pad)
  165. {
  166.  if(SVSUP_SaveControlPad("NEWPAD", pad)) K_Printf("\n*** OK, now compare the two files : \n*** All comments should be missing in NEWPAD.");
  167.   else                                   K_Printf("\n*** Can't write to NEWPAD.");
  168. }
  169.  
  170. /* *************************************************** */
  171. /* *                             * */
  172. /* * LEAVE : Global Exit Function Replacement         * */
  173. /* *                             * */
  174. /* *************************************************** */
  175.  
  176. void __regargs Leave(char *endtext, long code)
  177. {
  178.  if(SVSupportBase) CloseLibrary((APTR) SVSupportBase);
  179.  if(SuperViewBase) CloseLibrary((APTR) SuperViewBase);
  180.  
  181.  if(endtext)       K_Printf("%s\n", endtext);
  182.  
  183.  exit(code);
  184. }
  185.