home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / libnix-0.8-src.lha / libnix-0.8 / sources / stubs / misc / __initlibraries.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-12  |  1.2 KB  |  52 lines

  1. #ifdef __GNUC__
  2. #include <inline/exec.h>
  3.  
  4. #ifdef SMALL_DATA /* Kludge to fix non-working inline function */
  5. static void rawdofmt(UBYTE *a,APTR b,void (*c)(),APTR d)
  6. { RawDoFmt(a,b,c,d); }
  7. #define RawDoFmt rawdofmt
  8. #endif
  9.  
  10. #endif
  11. #include <stabs.h>
  12.  
  13. extern struct lib /* These are the elements pointed to by __LIB_LIST__ */
  14. { struct Library *base;
  15.   char *name;
  16. } *__LIB_LIST__[];
  17.  
  18. extern void __request(const char *text);
  19. extern ULONG __oslibversion;
  20. extern void exit(int returncode);
  21.  
  22. extern void writeone(void);
  23. asm(".text;.even;_writeone:;moveb d0,a3@+;rts");
  24.  
  25. void __initlibraries(void)
  26. { ULONG version=__oslibversion;
  27.   struct lib **list=&__LIB_LIST__[1];
  28.   while(*list!=NULL)
  29.   { if(((*list)->base=OpenLibrary((*list)->name,version))==NULL)
  30.     { char buf[60];
  31.       ULONG a[2];
  32.       a[0]=version;
  33.       a[1]=(ULONG)(*list)->name;
  34.       RawDoFmt("Need version %.10ld of %.32s",a,&writeone,buf);
  35.       __request(buf);
  36.       exit(20);
  37.     }
  38.     list++;
  39.   }
  40. }
  41.  
  42. void __exitlibraries(void)
  43. { struct lib **list=&__LIB_LIST__[1];
  44.   while(*list!=NULL)
  45.   { if((*list)->base!=NULL)
  46.       CloseLibrary((*list)->base);
  47.     *list++=NULL; }
  48. }
  49.  
  50. ADD2INIT(__initlibraries,-60);
  51. ADD2EXIT(__exitlibraries,-60);
  52.