home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD v1.2 / amidev_cd_12.iso / reference / amiga_mail_vol2 / iii-29 / dillo_test.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  4KB  |  132 lines

  1. ;/* dillo_test.c - Execute me to compile me with SAS/C 6.56
  2. sc data=far nominc strmer streq nostkchk saveds ign=73 dillo_test.c
  3. slink FROM LIB:c.o,dillo_test.o TO dillo_test LIB LIB:SC.lib,LIB:Amiga.lib
  4. quit
  5. */
  6.  
  7. /*
  8. **  dillo_test.c
  9. **
  10. **  This is the sample program to test the functions inside
  11. **  armadillo.library.  It creates a small array of Armadillos
  12. **  and after assigning various values, prints out their status.
  13. **
  14. */
  15.  
  16. #include    <exec/types.h>
  17. #include    <exec/libraries.h>
  18.  
  19. #include    <clib/exec_protos.h>
  20. #include    <pragmas/exec_pragmas.h>
  21.  
  22. #include    <stdio.h>
  23.  
  24. #include    "dillo_protos.h"
  25. #include    "armadillo_pragmas.h"
  26.  
  27. extern struct ExecBase *SysBase;    /* olsen 30-Jan-96 */
  28.  
  29. /* Global data for the test program */
  30.  
  31. struct Library *DilloBase;      /* armadillo.library library base */
  32.  
  33. APTR dillo[5];                  /* Array of generic pointers to     */
  34.                                 /* armadillos, since programs don't */
  35.                                 /* need to know what the insides of */
  36.                                 /* an armadillo look like.          */
  37.  
  38. STRPTR names[5] = { "Alex", "Bob", "Chris", "Daniel", "Eustace" };
  39. ULONG namlen[5] = { 5, 4, 6, 7, 8 };
  40. ULONG weight[5] = { 18, 20, 19, 17, 354 };
  41.  
  42. void
  43. main(void)
  44. {
  45.     BOOL okay = FALSE;
  46.     ULONG i = 0L;
  47.  
  48.     if (DilloBase = OpenLibrary("armadillo.library",0))
  49.     {
  50.  
  51.         for (i=0;i<5;i++)
  52.         {
  53.             if (dillo[i] = CreateArmadillo())
  54.             {
  55.                 if (okay = NameArmadillo( dillo[i], names[i], namlen[i] ))
  56.                 {
  57.                     printf("Armadillo %ld named %s.\n",i,names[i]);
  58.                 }
  59.                 else
  60.                 {
  61.                     printf("Armadillo %ld naming failure, it's anonymous.\n",i);
  62.                 }
  63.  
  64.                 if (okay = FillArmadillo( dillo[i], weight[i] ))
  65.                 {
  66.                     printf("Armadillo %ld weighs %ld.\n",i,weight[i]);
  67.                 }
  68.                 else
  69.                 {
  70.                     printf("Armadillo %ld fill failure, it's dieting.\n",i);
  71.                 }
  72.  
  73.                 if (i>2)
  74.                 {
  75.                     if (okay = FlattenArmadillo( dillo[i], TRUE ))
  76.                     {
  77.                         printf("Armadillo %ld had a slight mishap.\n",i);
  78.                     }
  79.                 }
  80.             }
  81.             else
  82.             {
  83.                 printf("Couldn't create Armadillo %ld\n",i);
  84.             }
  85.         }
  86.  
  87.         /* Okay, all the armadillos are created (hopefully) and */
  88.         /* so as proof of concept and to test the data access   */
  89.         /* functions, now the program shows the status of each  */
  90.         /* of the armadillos.                                   */
  91.  
  92.         printf("\nArmadillo Status Report\n");
  93.         printf("-----------------------\n");
  94.  
  95.         for(i=0;i<5;i++)
  96.         {
  97.             UBYTE namebuf[33];
  98.  
  99.             printf("Armadillo #%ld\n",i);
  100.             if (DilloName(dillo[i],(STRPTR)&namebuf,32))
  101.             {
  102.                 printf("  Name   = \"%s\"\n",namebuf);
  103.             }
  104.             else
  105.             {
  106.                 printf("  Name is invalid.\n");
  107.             }
  108.             printf("  Weight = %ld pounds\n\n",DilloWeight(dillo[i]));
  109.             printf("  Dillo is %s\n",
  110.                    (DilloFlat(dillo[i])?"flat":"lucky"));
  111.             printf("-----\n");
  112.         }
  113.  
  114.         printf("Total Dillos created: %ld\n\n",DilloBirths());
  115.  
  116.         /* Now that the armadillos have been tested, we can */
  117.         /* delete them with gleeful abandon.                */
  118.  
  119.         for(i=0;i<5;i++)
  120.         {
  121.             DeleteArmadillo( dillo[i] );
  122.         }
  123.  
  124.         /* We're done, so close the library... */
  125.         CloseLibrary(DilloBase);
  126.     }
  127.     else
  128.     {
  129.         printf("Couldn't open armadillo.library!\n");
  130.     }
  131. }
  132.