/* Listing #1 */ #include #include #include #include #include #include int main(int argc, char *argv[]) { struct IntuitionBase *IntuitionBase; struct GfxBase *GfxBase; struct Library *MathTransBase; struct Library *lib; /* Proba otwarcia "intuition.library" (z ROMu) */ IntuitionBase=(struct IntuitionBase*)OpenLibrary("intuition.library", 0); if (IntuitionBase) printf("Udalo sie otworzyc biblioteke Intuition z ROMu.\n"); /* Sprobujmy otworzyc kolejna. Uwaga: skrot myslowy rodem z C */ if (GfxBase=(struct GfxBase*)OpenLibrary("graphics.library", 0)) printf("Z ubolewaniem stwierdzam, ze udalo sieZotworzyc biblioteke graficzna.\n"); /* Sprobujmy z jakas biblioteka dyskowa */ if (MathTransBase=OpenLibrary("mathtrans.library", 0)) printf("Udalo sie otworzyc cos z dysku. To cos to \"mathtrans.library\".\n"); /* Sprobujmy otworzyc cos, czego po prostu nie ma */ if (lib=OpenLibrary("nieznana_biblioteka.library", 0)) printf("Takiej biblioteki w zyciu bysmy sie nie spodziewali.\n"); /* Nie wiemy co to i skad, ale zamknac trzeba bedzie */ else printf("Skoro takiej biblioteki nie ma, to nic dziwnego, ze sie nie udalo jej otworzyc.\n"); /* Jesli udalo sie "cos" otworzyc, to rowniez nalezalo by to "cos" zamknac */ if (IntuitionBase) CloseLibrary((struct Library*)IntuitionBase); if (GfxBase) CloseLibrary((struct Library*)GfxBase); if (MathTransBase) CloseLibrary(MathTransBase); if (lib) /* Co prawda takiej biblioteki nie znamy, ale skoro jest, to rowniez nalezy ja zamknac */ CloseLibrary(lib); return 0; }