home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / GCC / GERLIB_USR08B.LHA / gerlib / examples / test / startup / ger_test.c next >
Encoding:
C/C++ Source or Header  |  1993-12-12  |  1.5 KB  |  57 lines

  1. #include <stdio.h>
  2.  
  3. #include <exec/types.h>
  4. #include <inline/exec.h>
  5. #include <clib/alib_protos.h>
  6.  
  7. int     atexit (void (*)(void));
  8.  
  9. struct Library *MathTransBase;
  10. struct Library *MathBase;
  11. struct Library *MathIeeeDoubBasBase;
  12. struct Library *MathIeeeDoubTransBase;
  13. struct Library *UtilityBase;
  14.  
  15.  
  16. void close_math(void)
  17. {
  18.     struct Library *lib;
  19.     if(MathBase)                 { lib=(struct Library *)MathBase;                CloseLibrary(lib); }
  20.     if(MathTransBase)            { lib=(struct Library *)MathTransBase;         CloseLibrary(lib); }
  21.     if(MathIeeeDoubBasBase)     { lib=(struct Library *)MathIeeeDoubBasBase;    CloseLibrary(lib); }
  22.     if(MathIeeeDoubTransBase)    { lib=(struct Library *)MathIeeeDoubTransBase;    CloseLibrary(lib); }
  23.     if(UtilityBase)                { lib=(struct Library *)UtilityBase;            CloseLibrary(lib); }
  24. }
  25.  
  26. BOOL init_math(void)
  27. {
  28.     atexit(close_math);
  29.  
  30.     MathBase              = OpenLibrary((STRPTR)"mathffp.library",0L);
  31.     MathTransBase         = OpenLibrary((STRPTR)"mathtrans.library",0L);
  32.     MathIeeeDoubTransBase = OpenLibrary((STRPTR)"mathieeedoubtrans.library",0L);
  33.     MathIeeeDoubBasBase   = OpenLibrary((STRPTR)"mathieeedoubbas.library",0L);
  34.     UtilityBase           = OpenLibrary((STRPTR)"utility.library",0L);
  35.  
  36.     if(MathBase && MathTransBase && MathIeeeDoubTransBase && MathIeeeDoubBasBase && UtilityBase)
  37.         return TRUE;
  38.     else return FALSE;
  39. }
  40.  
  41.  
  42. extern int u_random(void);
  43.  
  44. int main(void)
  45. {
  46.     if(init_math())
  47.     {
  48.         printf("Dies ist ein Test !!\n");
  49.         printf("Zufall: %ld\n", u_random()&0xffff);
  50.     }
  51.     else
  52.     {
  53.         printf("Not able to open all math-libraries !\n");
  54.         return 20;
  55.     }
  56. }
  57.