Example #1
0
ULONG freeBase(struct LibraryHeader *lib)
{
  ENTER();

  D(DBF_STARTUP, "freeing all resources of codesets.library");

  // cleanup also the internal public codesets list
  codesetsCleanup(&lib->codesets);

  // close locale.library
  if(LocaleBase != NULL)
  {
    DROPINTERFACE(ILocale);
    CloseLibrary((struct Library *)LocaleBase);
    LocaleBase = NULL;
  }

  #if defined(__amigaos4__)
  // close diskfont.library
  if(DiskfontBase != NULL)
  {
    DROPINTERFACE(IDiskfont);
    CloseLibrary((struct Library *)DiskfontBase);
    DiskfontBase = NULL;
  }
  #endif

  // delete our private memory pool
  if(lib->pool != NULL)
  {
    #if defined(__amigaos4__)
    FreeSysObject(ASOT_MEMPOOL, lib->pool);
    #else
    DeletePool(lib->pool);
    #endif
    lib->pool = NULL;
  }

  // close utility.library
  if(UtilityBase != NULL)
  {
    DROPINTERFACE(IUtility);
    CloseLibrary((struct Library *)UtilityBase);
    UtilityBase = NULL;
  }

  // close dos.library
  if(DOSBase != NULL)
  {
    DROPINTERFACE(IDOS);
    CloseLibrary((struct Library *)DOSBase);
    DOSBase = NULL;
  }

  RETURN(TRUE);
  return TRUE;
}
Example #2
0
static BOOL
ClassExpunge(UNUSED struct Library *base)
{
  ENTER();

  #if defined(__amigaos3__)
  if(!(lib_flags & BASEFLG_MUI20))
  {
    freePopbackground();
    freePoppen();
    freeBackgroundadjust();
    freePenadjust();
    freeColoradjust();
  }
  #endif

  #if !defined(__amigaos4__)
  if(CyberGfxBase != NULL)
  {
    DROPINTERFACE(ICyberGfx);
    CloseLibrary(CyberGfxBase);
    CyberGfxBase = NULL;
  }
  #endif

  // close the catalog
  CloseCat();

  if(LocaleBase != NULL)
  {
    DROPINTERFACE(ILocale);
    CloseLibrary((struct Library *)LocaleBase);
    LocaleBase = NULL;
  }

  if(IFFParseBase != NULL)
  {
    DROPINTERFACE(IIFFParse);
    CloseLibrary(IFFParseBase);
    IFFParseBase = NULL;
  }

  if(DataTypesBase != NULL)
  {
    DROPINTERFACE(IDataTypes);
    CloseLibrary(DataTypesBase);
    DataTypesBase = NULL;
  }

  lib_flags &= ~(BASEFLG_Init|BASEFLG_MUI20|BASEFLG_MUI4);

  RETURN(TRUE);
  return TRUE;
}
Example #3
0
static VOID ClassExpunge(UNUSED struct Library *base)
{
  if(KeymapBase != NULL)
  {
    DROPINTERFACE(IKeymap);
    CloseLibrary(KeymapBase);
    KeymapBase = NULL;
  }
}
Example #4
0
VOID PostClassExitFunc(void)
{
  if(LocaleBase)
  {
    DROPINTERFACE(ILocale);
    CloseLibrary(LocaleBase);
    LocaleBase = NULL;
  }
}
Example #5
0
static BOOL ClassInit(UNUSED struct Library *base)
{
  if((LocaleBase = OpenLibrary("locale.library", 38)) &&
     GETINTERFACE(ILocale, struct LocaleIFace *, LocaleBase))
  {
    if((LayersBase = OpenLibrary("layers.library", 36)) &&
       GETINTERFACE(ILayers, struct LayersIFace *, LayersBase))
    {
      if((KeymapBase = OpenLibrary("keymap.library", 37)) &&
         GETINTERFACE(IKeymap, struct KeymapIFace *, KeymapBase))
      {
        if((DiskfontBase = OpenLibrary("diskfont.library", 38)) &&
           GETINTERFACE(IDiskfont, struct DiskfontIFace *, DiskfontBase))
        {
          if((IFFParseBase = OpenLibrary("iffparse.library", 36)) &&
             GETINTERFACE(IIFFParse, struct IFFParseIFace *, IFFParseBase))
          {
            return(TRUE);
          }

          DROPINTERFACE(IDiskfont);
          CloseLibrary(DiskfontBase);
          DiskfontBase = NULL;
        }

        DROPINTERFACE(IKeymap);
        CloseLibrary(KeymapBase);
        KeymapBase  = NULL;
      }

      DROPINTERFACE(ILayers);
      CloseLibrary(LayersBase);
      LayersBase  = NULL;
    }

    DROPINTERFACE(ILocale);
    CloseLibrary(LocaleBase);
    LocaleBase  = NULL;
  }

  return(FALSE);
}
Example #6
0
static VOID ClassExpunge(UNUSED struct Library *base)
{
  // close the catalog
  CloseCat();

  if(LocaleBase != NULL)
  {
    DROPINTERFACE(ILocale);
    CloseLibrary(LocaleBase);
    LocaleBase = NULL;
  }
}
Example #7
0
static VOID ClassExpunge(UNUSED struct Library *base)
{
  if(IFFParseBase)
  {
    DROPINTERFACE(IIFFParse);
    CloseLibrary(IFFParseBase);
    IFFParseBase = NULL;
  }

  if(DiskfontBase)
  {
    DROPINTERFACE(IDiskfont);
    CloseLibrary(DiskfontBase);
    DiskfontBase = NULL;
  }

  if(KeymapBase)
  {
    DROPINTERFACE(IKeymap);
    CloseLibrary(KeymapBase);
    KeymapBase = NULL;
  }

  if(LayersBase)
  {
    DROPINTERFACE(ILayers);
    CloseLibrary(LayersBase);
    LayersBase = NULL;
  }

  if(LocaleBase)
  {
    DROPINTERFACE(ILocale);
    CloseLibrary(LocaleBase);
    LocaleBase = NULL;
  }
}
Example #8
0
int main(int argc,char **argv)
{
    int            res;

    if((CodesetsBase = OpenLibrary(CODESETSNAME,CODESETSVER)) &&
        GETINTERFACE(ICodesets, CodesetsBase))
    {
        const char *str;

        if(argc>1)
          str = argv[1];
        else
          str = STR;

        // check that the string only contains UTF8
        // sequences.
        if(CodesetsIsValidUTF8(str))
        {
          CodesetsUTF8ToStr(CSA_Source,   (Tag)str,
                            CSA_DestLen,  32,
                            CSA_DestHook, (Tag)&destHook,
                            TAG_DONE);
        }
        else
          printf("Error: example string wasn't recognized as UTF8!\n");

        res = 0;

        DROPINTERFACE(ICodesets);
        CloseLibrary(CodesetsBase);
        CodesetsBase = NULL;
    }
    else
    {
        printf("can't open %s %d+\n",CODESETSNAME,CODESETSVER);
        res = 20;
    }

    return res;
}
Example #9
0
int main(void)
{
  LONG ret = 0;

  if((UtilityBase = OpenLibrary("utility.library", 37)))
  {
    if(GETINTERFACE(IUtility, UtilityBase))
    {
      printf("Hello! I am a ");

      ret = CallHook(&HelloHook, "portable Hook");

      printf("%ld\n", (long int)ret);

      DROPINTERFACE(IUtility);
    }

    CloseLibrary(UtilityBase);
  }

  return 0;
}
Example #10
0
static VOID ClassExpunge(UNUSED struct Library *base)
{
  ENTER();

  #ifdef USEMUISTRINGS
  if(StringClass)
  {
    MUI_DeleteCustomClass(StringClass);
    StringClass = NULL;
  }
  #endif

  if(ScrollGroupClass)
  {
    MUI_DeleteCustomClass(ScrollGroupClass);
    ScrollGroupClass = NULL;
  }

  if(CyberGfxBase)
  {
    DROPINTERFACE(ICyberGfx);
    CloseLibrary(CyberGfxBase);
    CyberGfxBase = NULL;
  }

  if(DataTypesBase)
  {
    DROPINTERFACE(IDataTypes);
    CloseLibrary(DataTypesBase);
    DataTypesBase = NULL;
  }

  if(DiskfontBase)
  {
    DROPINTERFACE(IDiskfont);
    CloseLibrary(DiskfontBase);
    DiskfontBase = NULL;
  }

  if(CxBase)
  {
    DROPINTERFACE(ICommodities);
    CloseLibrary(CxBase);
    CxBase = NULL;
  }

  if(KeymapBase)
  {
    DROPINTERFACE(IKeymap);
    CloseLibrary(KeymapBase);
    KeymapBase = NULL;
  }

  if(LayersBase)
  {
    DROPINTERFACE(ILayers);
    CloseLibrary(LayersBase);
    LayersBase = NULL;
  }

  _fini();

  LEAVE();
}
Example #11
0
int main(void)
{
  if((DiskfontBase = OpenLibrary("diskfont.library", 38)) &&
    GETINTERFACE(IDiskfont, DiskfontBase))
  if((GfxBase = OpenLibrary("graphics.library", 38)) &&
    GETINTERFACE(IGraphics, GfxBase))
  if((IntuitionBase = (APTR)OpenLibrary("intuition.library", 38)) &&
    GETINTERFACE(IIntuition, IntuitionBase))
  if((KeymapBase = OpenLibrary("keymap.library", 37)) &&
    GETINTERFACE(IKeymap, KeymapBase))
  if((LocaleBase = OpenLibrary("locale.library", 38)) &&
    GETINTERFACE(ILocale, LocaleBase))
  if((LayersBase = OpenLibrary("layers.library", 38)) &&
    GETINTERFACE(ILayers, LayersBase))
  if((UtilityBase = (APTR)OpenLibrary("utility.library", 38)) &&
    GETINTERFACE(IUtility, UtilityBase))
  if((MUIMasterBase = OpenLibrary("muimaster.library", MUIMASTER_VMIN)) &&
    GETINTERFACE(IMUIMaster, MUIMasterBase))
  if((IFFParseBase = OpenLibrary("iffparse.library", 36)) &&
    GETINTERFACE(IIFFParse, IFFParseBase))
  {
    struct MUI_CustomClass *mcc;
    Object *a1, *a2, *app, *window, *bstring, *bstring2, *bpos, *ssize, *button, *numbutton;
    Object *menu;
    const char *classes[] = {"BetterString.mcp", NULL};

    #if defined(DEBUG)
    SetupDebug();
    #endif

    mcc = MUI_CreateCustomClass(NULL, "Area.mui", NULL, sizeof(struct InstData), ENTRY(_Dispatcher));

    /*
    menu = MenustripObject,
            MUIA_Family_Child, MenuObject, MUIA_Menu_Title, "Test",
              MUIA_Family_Child, MenuitemObject,
                MUIA_Menuitem_Title,    "Dummy",
                MUIA_Menuitem_Enabled,  TRUE,
                MUIA_Menuitem_Shortcut, "V",
              End,
            End,
           End,
    */

    app =  ApplicationObject,
          MUIA_Application_Author,      "BetterString.mcc Open Source Team",
          MUIA_Application_Base,        "BetterString-Test",
          MUIA_Application_Copyright,    "(C) 2005-2009 by BetterString.mcc Open Source Team",
          MUIA_Application_Description,  "BetterString.mcc demonstration program",
          MUIA_Application_Title,        "BetterString-Test",
          MUIA_Application_Version,      "$VER: BetterString-Demo V1.0 (18.05.2007)",
          MUIA_Application_UsedClasses, classes,

          MUIA_Application_Window, window = WindowObject,
            MUIA_Window_Title,  "BetterString-Test",
            MUIA_Window_ID,      MAKE_ID('M','A','I','N'),
            //MUIA_Window_Menustrip, menu,
            MUIA_Window_RootObject, VGroup,

            Child, PopaslObject,
                MUIA_Popstring_String,  NewObject(mcc->mcc_Class, NULL, StringFrame, MUIA_BetterString_NoInput, TRUE, MUIA_CycleChain, TRUE, End,
                MUIA_Popstring_Button,  MUI_MakeObject(MUIO_PopButton, MUII_PopUp),
                MUIA_Popasl_Type,       ASL_FontRequest,
                End,

            Child, ColGroup(2), StringFrame,
                MUIA_Background, MUII_GroupBack,
                Child, TextObject,
                    MUIA_Weight, 0,
                    MUIA_Text_Contents, "\33rName:",
                    End,
                Child, a1 = (Object *)NewObject(mcc->mcc_Class, NULL,
                    MUIA_CycleChain, TRUE,
                    MUIA_Background, MUII_GroupBack,
                    MUIA_String_AdvanceOnCR, TRUE,
                    MUIA_String_MaxLen, 10,
                    MUIA_ObjectID, MAKE_ID('N','A','M','E'),
                    End,
                Child, TextObject,
                    MUIA_Weight, 0,
                    MUIA_Text_Contents, "\33rStreet:",
                    End,
                Child, a2 = (Object *)NewObject(mcc->mcc_Class, NULL,
                    MUIA_CycleChain, TRUE,
                    MUIA_Background, MUII_GroupBack,
                    MUIA_String_AdvanceOnCR, TRUE,
                    MUIA_ObjectID, MAKE_ID('S','T','R','T'),
                    End,
                Child, TextObject,
                    MUIA_Weight, 0,
                    MUIA_Text_Contents, "\33rZip, City:",
                    End,
                Child, NewObject(mcc->mcc_Class, NULL,
                    MUIA_CycleChain, TRUE,
                    MUIA_Background, MUII_GroupBack,
                    MUIA_String_AdvanceOnCR, TRUE,
                    MUIA_ObjectID, MAKE_ID('C','I','T','Y'),
                    End,
                End,

              Child, TextObject,
                MUIA_Font, MUIV_Font_Tiny,
                MUIA_Text_Contents, "\33cBetterString.mcc",
                End,
              Child, NewObject(mcc->mcc_Class, NULL,
                StringFrame,
                MUIA_CycleChain, TRUE,
                MUIA_String_Secret, TRUE,
  //                  MUIA_String_MaxLen, 20,
                MUIA_String_AdvanceOnCR, TRUE,
                MUIA_BetterString_StayActive, TRUE,
  //                  MUIA_String_Accept, "0123456789",
                MUIA_String_Contents, "This is a wonderful example string!",
                End,
              Child, NewObject(mcc->mcc_Class, NULL,
                  StringFrame,
                  MUIA_CycleChain, TRUE,
                  MUIA_BetterString_InactiveContents, "This is a wonderful example string!",
                  End,
              Child, NewObject(mcc->mcc_Class, NULL,
                  StringFrame,
                  MUIA_CycleChain, TRUE,
                  MUIA_String_Secret, TRUE,
                  MUIA_BetterString_InactiveContents, "This is a wonderful example string!",
                  End,
              Child, TextObject,
                MUIA_Font, MUIV_Font_Tiny,
                MUIA_Text_Contents, "\33cCentered",
                End,
              Child, bstring = (Object *)NewObject(mcc->mcc_Class, NULL,
                ButtonFrame,
                MUIA_Font, MUIV_Font_Big,
  //                  StringFrame,
                MUIA_String_AdvanceOnCR, TRUE,
                MUIA_String_Format, MUIV_String_Format_Center,
                MUIA_String_Contents, "This is a wonderful example string!",
                MUIA_CycleChain, TRUE,
                End,
              Child, TextObject,
                MUIA_Font, MUIV_Font_Tiny,
                MUIA_Text_Contents, "\33cRight-Aligned",
                End,
              Child, bstring2 = NewObject(mcc->mcc_Class, NULL,
                MUIA_CycleChain, TRUE,
  //                  StringFrame,
                MUIA_String_AdvanceOnCR, TRUE,
                MUIA_String_Contents, "This is a wonderful example string!",
                MUIA_String_Format, MUIV_String_Format_Right,
                End,
              Child, TextObject,
                MUIA_Font, MUIV_Font_Tiny,
                MUIA_Text_Contents, "\33cStringObject",
                End,
              Child, StringObject,
                StringFrame,
                MUIA_String_AdvanceOnCR, TRUE,
                MUIA_String_Contents, "This is a standard StringObject",
                MUIA_String_Format, MUIV_String_Format_Right,
                MUIA_String_MaxLen, 1024,
                MUIA_CycleChain, TRUE,
                End,
              Child, HGroup,
                Child, button = SimpleButton("Insert"),
                Child, bpos = SliderObject,
                  MUIA_Slider_Horiz, TRUE,
                  MUIA_Numeric_Max, 60,
                  End,
                Child, ssize = SliderObject,
                  MUIA_Slider_Horiz, TRUE,
                  MUIA_Numeric_Min, -30,
                  MUIA_Numeric_Max, 30,
                  MUIA_Numeric_Value, 0,
                  End,
                Child, numbutton = NumericbuttonObject,
                  MUIA_Numeric_Min, -30,
                  MUIA_Numeric_Max, 30,
                  MUIA_Numeric_Value, 0,
                  MUIA_Disabled, TRUE,
                  End,
                End,
              End,
            End,
          End;

    if(app)
    {
      ULONG sigs;

      DoMethod(app, MUIM_Application_Load, MUIV_Application_Load_ENV);

      DoMethod(a1, MUIM_Notify, MUIA_String_Contents, MUIV_EveryTime, a2, 3, MUIM_Set, MUIA_String_Contents, MUIV_TriggerValue);
      DoMethod(a2, MUIM_Notify, MUIA_String_Contents, MUIV_EveryTime, a1, 3, MUIM_Set, MUIA_String_Contents, MUIV_TriggerValue);

      DoMethod(ssize, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, numbutton, 3, MUIM_Set, MUIA_Numeric_Value, MUIV_TriggerValue);
      DoMethod(bpos, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, bstring, 3, MUIM_Set, MUIA_String_BufferPos, MUIV_TriggerValue);
      DoMethod(ssize, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, bstring, 3, MUIM_Set, MUIA_BetterString_SelectSize, MUIV_TriggerValue);
      DoMethod(button, MUIM_Notify, MUIA_Pressed, FALSE, bstring, 3, MUIM_BetterString_Insert, "*Test*", MUIV_BetterString_Insert_BufferPos);
      DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Application, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

      set(bstring, MUIA_BetterString_KeyDownFocus, bstring2);
      set(bstring2, MUIA_BetterString_KeyUpFocus, bstring);

      set(window, MUIA_Window_ActiveObject, bstring);
      set(window, MUIA_Window_DefaultObject, bstring);
      set(window, MUIA_Window_Open, TRUE);

        while((LONG)DoMethod(app, MUIM_Application_NewInput, &sigs) != MUIV_Application_ReturnID_Quit)
        {
            if(sigs)
            {
                sigs = Wait(sigs | SIGBREAKF_CTRL_C);
                if(sigs & SIGBREAKF_CTRL_C)
                    break;
            }
        }
        DoMethod(app, MUIM_Application_Save, MUIV_Application_Save_ENV);

        MUI_DisposeObject(app);
        if(mcc)
            MUI_DeleteCustomClass(mcc);
    }

    DROPINTERFACE(IMUIMaster);
    CloseLibrary(MUIMasterBase);
    MUIMasterBase = NULL;
  }

  if(IFFParseBase)
  {
    DROPINTERFACE(IIFFParse);
    CloseLibrary(IFFParseBase);
    IFFParseBase = NULL;
  }

  if(UtilityBase)
  {
    DROPINTERFACE(IUtility);
    CloseLibrary((struct Library *)UtilityBase);
  }

  if(LayersBase)
  {
    DROPINTERFACE(ILayers);
    CloseLibrary(LayersBase);
  }

  if(LocaleBase)
  {
    DROPINTERFACE(ILocale);
    CloseLibrary(LocaleBase);
  }

  if(KeymapBase)
  {
    DROPINTERFACE(IKeymap);
    CloseLibrary(KeymapBase);
  }

  if(IntuitionBase)
  {
    DROPINTERFACE(IIntuition);
    CloseLibrary((struct Library *)IntuitionBase);
  }

  if(GfxBase)
  {
    DROPINTERFACE(IGraphics);
    CloseLibrary(GfxBase);
  }

  if(DiskfontBase)
  {
    DROPINTERFACE(IDiskfont);
    CloseLibrary(DiskfontBase);
  }

  return 0;
}
Example #12
0
int main(void)
{
#if 1
{
	printf("single base test\n");
	AmiSSLBase = OpenLibrary(LIBNAME, 0);
	printf("base %08lx\n", AmiSSLBase);
	if(AmiSSLBase != NULL &&
     GETINTERFACE(IAmiSSL, AmiSSLBase))
	{
		printf("checking base %08lx...", AmiSSLBase);
    #if defined(__amigaos4__)
		printf(" iface %08lx...", IAmiSSL);
    #endif
		InitAmiSSL(TAG_DONE);
		CleanupAmiSSL(TAG_DONE);
		printf(" done\n");
    DROPINTERFACE(IAmiSSL);
		CloseLibrary(AmiSSLBase);
	}
	printf("single base test finished\n");
}
#endif

#if 1
{
	struct Library *base1 = NULL;
	struct Library *base2 = NULL;
  #if defined(__amigaos4__)
  struct AmiSSLIFace *ibase1 = NULL;
  struct AmiSSLIFace *ibase2 = NULL;
  #endif

	printf("multi base test\n");

	kprintf("########################\n");
	kprintf("OpenLibrary(base1)\n");
	base1 = OpenLibrary(LIBNAME, 0);
	printf("base1 %08lx\n", base1);
	kprintf("# done #################\n");

	kprintf("########################\n");
	kprintf("OpenLibrary(base2)\n");
	base2 = OpenLibrary(LIBNAME, 0);
	printf("base2 %08lx\n", base2);
	kprintf("# done #################\n");

	if(base1 != NULL && base2 != NULL &&
     GETINTERFACE(ibase1, base1) &&
     GETINTERFACE(ibase2, base2))
	{
    LONG ret = 0;

		AmiSSLBase = base1;
    #if defined(__amigaos4__)
    IAmiSSL = ibase1;
    #endif
		kprintf("########################\n");
		kprintf("checking base1 %08lx\n", AmiSSLBase);
		printf("checking base1 %08lx...", AmiSSLBase);
    #if defined(__amigaos4__)
		printf(" iface %08lx...", IAmiSSL);
    #endif
		ret = InitAmiSSL(TAG_DONE);
		printf(" done: %ld\n", ret);
		CleanupAmiSSL(TAG_DONE);
		kprintf("# done #################\n");

		AmiSSLBase = base2;
    #if defined(__amigaos4__)
    IAmiSSL = ibase2;
    #endif
		kprintf("########################\n");
		kprintf("checking base2 %08lx\n", AmiSSLBase);
		printf("checking base2 %08lx...", AmiSSLBase);
    #if defined(__amigaos4__)
		printf(" iface %08lx...", IAmiSSL);
    #endif
		ret = InitAmiSSL(TAG_DONE);
		printf(" done: %ld\n", ret);
		CleanupAmiSSL(TAG_DONE);
		kprintf("# done #################\n");

		AmiSSLBase = base1;
    #if defined(__amigaos4__)
    IAmiSSL = ibase1;
    #endif
		kprintf("########################\n");
		kprintf("checking base1 %08lx\n", AmiSSLBase);
		printf("checking base1 %08lx...", AmiSSLBase);
    #if defined(__amigaos4__)
		printf(" iface %08lx...", IAmiSSL);
    #endif
		ret = InitAmiSSL(TAG_DONE);
		printf(" done: %ld\n", ret);
		CleanupAmiSSL(TAG_DONE);
		kprintf("# done #################\n");

		AmiSSLBase = base2;
    #if defined(__amigaos4__)
    IAmiSSL = ibase2;
    #endif
		kprintf("########################\n");
		kprintf("checking base2 %08lx\n", AmiSSLBase);
		printf("checking base2 %08lx...", AmiSSLBase);
    #if defined(__amigaos4__)
		printf(" iface %08lx...", IAmiSSL);
    #endif
		ret = InitAmiSSL(TAG_DONE);
		printf(" done: %ld\n", ret);
		CleanupAmiSSL(TAG_DONE);
		kprintf("# done #################\n");
	}

	if(base1 != NULL)
  {
    DROPINTERFACE(ibase1);
		CloseLibrary(base1);
  }

	if(base2 != NULL)
  {
    DROPINTERFACE(ibase2);
		CloseLibrary(base2);
  }
	printf("multi base test finished\n");
}
#endif

// lets perform a full-fledged amissl test case
#if 1
{
  printf("\ncomplex amissl test\n");
  if((AmiSSLMasterBase = OpenLibrary("amisslmaster.library", 0)) != NULL &&
     GETINTERFACE(IAmiSSLMaster, AmiSSLMasterBase))
  {
    printf("amisslmaster.library opened: %08lx\n", AmiSSLMasterBase);

    if(InitAmiSSLMaster(AMISSL_CURRENT_VERSION, TRUE))
    {
      printf("amisslmaster.library initialized\n");

      if((AmiSSLBase = OpenAmiSSL()) != NULL &&
         GETINTERFACE(IAmiSSL, AmiSSLBase))
      {
        char tmp[24+1];

        printf("successfully opened AmiSSL library %d.%d (%s): %08lx\n", AmiSSLBase->lib_Version, AmiSSLBase->lib_Revision, (char *)AmiSSLBase->lib_IdString, AmiSSLBase);

        // initialize AmiSSL/OpenSSL related stuff
        printf("initializing internal OpenSSL strings:\n");
        ERR_load_BIO_strings();
        printf("ERR_load_BIO_string() done.\n");
        SSL_load_error_strings();
        printf("SSL_load_error_strings() done.\n");
        OpenSSL_add_all_algorithms();
        printf("OpenSSL_add_all_algorithms() done.\n");
        SSL_library_init();
        printf("SSL_library_init() done.\n");

        // seed the random number generator with some valuable entropy
        snprintf(tmp, sizeof(tmp), "%08lx%08lx%08lx", (unsigned long)time((time_t *)NULL), (unsigned long)FindTask(NULL), (unsigned long)rand());
        printf("about to seed random number generator\n");
        RAND_seed(tmp, strlen(tmp));
        printf("RAND_seed() done!\n");

        // cleanup
        printf("starting cleanup\n");
        CleanupAmiSSLA(NULL);
        printf("CleanupAmiSSLA() done!\n");
        DROPINTERFACE(IAmiSSL);
        CloseAmiSSL();
        printf("CloseAmiSSL() done!\n");
        AmiSSLBase = NULL;
      }
    }

    printf("About to close amisslmaster.library\n");
    DROPINTERFACE(IAmiSSLMaster);
    CloseLibrary(AmiSSLMasterBase);
    printf("done.\n");
    AmiSSLMasterBase = NULL;
  }
}
#endif

	return 0;
}
int main(void)
{
  if((IntuitionBase = (APTR)OpenLibrary("intuition.library", 38)) &&
    GETINTERFACE(IIntuition, IntuitionBase))
  if((KeymapBase = OpenLibrary("keymap.library", 37)) &&
    GETINTERFACE(IKeymap, KeymapBase))
  if((UtilityBase = (APTR)OpenLibrary("utility.library", 38)) &&
    GETINTERFACE(IUtility, UtilityBase))
  if((MUIMasterBase = OpenLibrary("muimaster.library", MUIMASTER_VMIN)) &&
    GETINTERFACE(IMUIMaster, MUIMasterBase))
  {
    struct  MUI_CustomClass  *mcc;
    Object  *app, *window, *bstring, *button;
    const char *classes[] = {"BetterString.mcc", NULL};

    mcc = MUI_CreateCustomClass(NULL, "BetterString.mcc", NULL, sizeof(struct InstData), ENTRY(_Dispatcher));
    app =  ApplicationObject,
          MUIA_Application_Author,    "Allan Odgaard",
          MUIA_Application_Base,      "HotkeyString-Demo",
          MUIA_Application_Copyright,  "®1997 Allan Odgaard",
          MUIA_Application_Description,  "HotkeyString.mcc demonstration program",
          MUIA_Application_Title,      "HotkeyString-Demo",
          MUIA_Application_Version,    "$VER: HotkeyString-Demo V1.0 (3-Sep-97)",
          MUIA_Application_UsedClasses, classes,

          MUIA_Application_Window, window = WindowObject,
            MUIA_Window_Title,    "HotkeyString-Demo",
            MUIA_Window_ID,        MAKE_ID('M','A','I','N'),
            MUIA_Window_RootObject, VGroup,
              Child, TextObject,
                MUIA_Font, MUIV_Font_Tiny,
                MUIA_Text_Contents, "\33cHotkeyString.mcc",
                End,

              Child, HGroup,
                Child, bstring = ((Object *)NewObject(mcc->mcc_Class, NULL,
                  StringFrame,
                  MUIA_CycleChain, TRUE,
                  MUIA_String_AdvanceOnCR, TRUE,
                  MUIA_HotkeyString_Snoop, FALSE,
                  End),
                Child, button = TextObject, ButtonFrame,
                  MUIA_CycleChain, TRUE,
                  MUIA_Background, MUII_ButtonBack,
                  MUIA_Text_Contents, "Sample",
                  MUIA_Text_SetMax, TRUE,
                  MUIA_InputMode, MUIV_InputMode_Toggle,
                  End,
                End,

              Child, TextObject,
                MUIA_Font, MUIV_Font_Tiny,
                MUIA_Text_Contents, "\33cConstant snoop",
                End,
              Child, NewObject(mcc->mcc_Class, NULL,
                StringFrame,
                MUIA_CycleChain, TRUE,
                End,

              End,
            End,
          End;

    if(app)
    {
        ULONG sigs;

      DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Application, 3, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
      DoMethod(button, MUIM_Notify, MUIA_Selected, TRUE, MUIV_Notify_Window, 3, MUIM_Set, MUIA_Window_ActiveObject, bstring);
      DoMethod(button, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, bstring, 3, MUIM_Set, MUIA_HotkeyString_Snoop, MUIV_TriggerValue);
      DoMethod(bstring, MUIM_Notify, MUIA_String_Contents, MUIV_EveryTime, button, 3, MUIM_Set, MUIA_Selected, FALSE);

      set(window, MUIA_Window_ActiveObject, bstring);
      set(window, MUIA_Window_Open, TRUE);

      while((LONG)DoMethod(app, MUIM_Application_NewInput, &sigs) != (LONG)MUIV_Application_ReturnID_Quit)
      {
        if(sigs)
        {
          sigs = Wait(sigs | SIGBREAKF_CTRL_C);
          if(sigs & SIGBREAKF_CTRL_C)
            break;
        }
      }

      MUI_DisposeObject(app);
      if(mcc)
        MUI_DeleteCustomClass(mcc);
    }

    DROPINTERFACE(IMUIMaster);
    CloseLibrary(MUIMasterBase);
  }

  if(UtilityBase)
  {
    DROPINTERFACE(IUtility);
    CloseLibrary((struct Library *)UtilityBase);
  }

  if(KeymapBase)
  {
    DROPINTERFACE(IKeymap);
    CloseLibrary(KeymapBase);
  }

  if(IntuitionBase)
  {
    DROPINTERFACE(IIntuition);
    CloseLibrary((struct Library *)IntuitionBase);
  }

  return 0;
}