Exemplo n.º 1
0
BOOL PreClassInitFunc(void)
{
  if((LocaleBase = OpenLibrary("locale.library", 37L)) &&
     GETINTERFACE(ILocale, LocaleBase))
  {
    return TRUE;
  }

  return FALSE;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
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;
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
0
int
main(UNUSED int argc,char **argv)
{
    int res;

    if ((IntuitionBase = (APTR)OpenLibrary("intuition.library",39)) != NULL &&
            GETINTERFACE("main", IIntuition, IntuitionBase))
    {
        if ((MUIMasterBase = OpenLibrary("muimaster.library",19)) != NULL &&
                GETINTERFACE("main", IMUIMaster, MUIMasterBase))
        {
            Object *app, *win, *sb, *appearance, *labelPos, *borderless, *sunny, *raised, *scaled, *update;

            if ((app = ApplicationObject,
                    MUIA_Application_Title,         "TheBar Demo4",
                    MUIA_Application_Version,       "$VER: TheBarDemo4 1.0 (24.6.2003)",
                    MUIA_Application_Copyright,     "Copyright 2003 by Alfonso Ranieri",
                    MUIA_Application_Author,        "Alfonso Ranieri <*****@*****.**>",
                    MUIA_Application_Description,   "TheBar example",
                    MUIA_Application_Base,          "THEBAREXAMPLE",
                    MUIA_Application_UsedClasses,   usedClasses,

                    SubWindow, win = WindowObject,
                    MUIA_Window_ID,             MAKE_ID('M','A','I','N'),
                    MUIA_Window_Title,          "TheBar Demo4",
                    WindowContents, VGroup,
                    Child, sb = TheBarObject,
                    MUIA_Group_Horiz,             TRUE,
                    MUIA_TheBar_IgnoreAppearance, TRUE,
                    MUIA_TheBar_EnableKeys,       TRUE,
                    MUIA_TheBar_Buttons,          buttons,
                    MUIA_TheBar_StripBrush,       &cbrush,
                    MUIA_TheBar_StripCols,        16,
                    MUIA_TheBar_StripRows,        3,
                    MUIA_TheBar_StripHSpace,      0,
                    MUIA_TheBar_StripVSpace,      0,
                    End,
                    Child, VGroup,
                    GroupFrameT("Settings"),
                    Child, HGroup,
                    Child, Label2("Appearance"),
                    Child, appearance = MUI_MakeObject(MUIO_Cycle,NULL,appearances),
                    Child, Label2("Label pos"),
                    Child, labelPos = MUI_MakeObject(MUIO_Cycle,NULL,labelPoss),
                    End,
                    Child, HGroup,
                    Child, HSpace(0),
                    Child, Label1("Borderless"),
                    Child, borderless = MUI_MakeObject(MUIO_Checkmark,NULL),
                    Child, HSpace(0),
                    Child, Label1("Sunny"),
                    Child, sunny = MUI_MakeObject(MUIO_Checkmark,NULL),
                    Child, HSpace(0),
                    Child, Label1("Raised"),
                    Child, raised = MUI_MakeObject(MUIO_Checkmark,NULL),
                    Child, HSpace(0),
                    Child, Label1("Scaled"),
                    Child, scaled = MUI_MakeObject(MUIO_Checkmark,NULL),
                    Child, HSpace(0),
                    End,
                    End,
                    Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
                    End,
                    End,
                    End) != NULL)
            {
                ULONG sigs = 0;
                LONG id;

                DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
                DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);

                set(win,MUIA_Window_Open,TRUE);

                while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
                {
                    if (id==(LONG)TAG_USER)
                    {
                        IPTR appearanceV = 0,
                             labelPosV = 0,
                             borderlessV = 0,
                             sunnyV = 0,
                             raisedV = 0,
                             scaledV = 0;

                        get(appearance,MUIA_Cycle_Active,&appearanceV);
                        get(labelPos,MUIA_Cycle_Active,&labelPosV);
                        get(borderless,MUIA_Selected,&borderlessV);
                        get(sunny,MUIA_Selected,&sunnyV);
                        get(raised,MUIA_Selected,&raisedV);
                        get(scaled,MUIA_Selected,&scaledV);

                        SetAttrs(sb,MUIA_TheBar_ViewMode,   appearanceV,
                                 MUIA_TheBar_LabelPos,   labelPosV,
                                 MUIA_TheBar_Borderless, borderlessV,
                                 MUIA_TheBar_Sunny,      sunnyV,
                                 MUIA_TheBar_Raised,     raisedV,
                                 MUIA_TheBar_Scaled,     scaledV,
                                 TAG_DONE);
                    }

                    if (sigs)
                    {
                        sigs = Wait(sigs | SIGBREAKF_CTRL_C);
                        if (sigs & SIGBREAKF_CTRL_C) break;
                    }
                }

                MUI_DisposeObject(app);

                res = RETURN_OK;
            }
            else
            {
                printf("%s: can't create application\n",argv[0]);
                res = RETURN_FAIL;
            }

            CLOSELIB(MUIMasterBase, IMUIMaster);
        }
        else
        {
            printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
            res = RETURN_ERROR;
        }

        CLOSELIB(IntuitionBase, IIntuition);
    }
    else
    {
        printf("%s: Can't open intuition.library ver 39 or higher\n",argv[0]);
        res = RETURN_ERROR;
    }

    return res;
}
Exemplo n.º 6
0
int
main(UNUSED int argc,char **argv)
{
    int res;

    if ((IntuitionBase = (APTR)OpenLibrary("intuition.library",39)) != NULL &&
        GETINTERFACE("main", IIntuition, IntuitionBase))
    {
        if ((MUIMasterBase = OpenLibrary("muimaster.library",19)) != NULL &&
            GETINTERFACE("main", IMUIMaster, MUIMasterBase))
        {
            Object *app, *win, *mg, *sb, *viewMode, *buttonsPos, *labelPos, *borderless, *sunny,
                   *raised, *scaled, *keys, *bspacer, *fixed, *free, *update, *rows, *cols, *s4, *h0,
                   *rb, *rs, *ri;

            if ((app = ApplicationObject,
                    MUIA_Application_Title,        "TheBar Demo3",
                    MUIA_Application_Version,      "$VER: TheBarDemo3 1.0 (24.6.2003)",
                    MUIA_Application_Copyright,    "Copyright 2003 by Alfonso Ranieri",
                    MUIA_Application_Author,       "Alfonso Ranieri <*****@*****.**>",
                    MUIA_Application_Description,  "TheBar example",
                    MUIA_Application_Base,         "THEBAREXAMPLE",
                    MUIA_Application_UsedClasses,  usedClasses,

                    SubWindow, win = WindowObject,
                        MUIA_Window_ID,    MAKE_ID('M','A','I','N'),
                        MUIA_Window_Title, "TheBar Demo3",

                        WindowContents, mg = VGroup,

                            Child, sb = TheBarObject,
                                MUIA_Group_Horiz,             TRUE,
                                MUIA_TheBar_IgnoreAppearance, TRUE,
                                MUIA_TheBar_ViewMode,         MUIV_TheBar_ViewMode_Gfx,
                                MUIA_TheBar_Buttons,          buttons,
                                MUIA_TheBar_PicsDrawer,       "PROGDIR:Pics",
                                MUIA_TheBar_Pics,             pics,
                                MUIA_TheBar_SelPics,          spics,
                                MUIA_TheBar_DisPics,          dpics,
                            End,

                            Child, VGroup,
                                GroupFrameT("Appearance"),
                                Child, ColGroup(2),
                                    Child, Label2("Rows"),
                                    Child, HGroup,
                                        Child, rows = MUI_MakeObject(MUIO_Radio,NULL,rowss),
                                        Child, HSpace(0),
                                    End,
                                    Child, Label2("Columns"),
                                    Child, HGroup,
                                        Child, cols = MUI_MakeObject(MUIO_Radio,NULL,colss),
                                        Child, HSpace(0),
                                    End,
                                    Child, Label2("ViewMode"),
                                    Child, viewMode = MUI_MakeObject(MUIO_Cycle,NULL,viewModes),
                                    Child, Label2("Buttons position"),
                                    Child, buttonsPos = MUI_MakeObject(MUIO_Cycle,NULL,buttonsPoss),
                                    Child, Label2("Label position"),
                                    Child, labelPos = MUI_MakeObject(MUIO_Cycle,NULL,labelPoss),
                                End,
                                Child, ScrollgroupObject,
                                    MUIA_Scrollgroup_FreeHoriz, FALSE,
                                    MUIA_Scrollgroup_Contents, VirtgroupObject,
                                        MUIA_Frame, MUIV_Frame_Virtual,
                                        Child, HGroup,
                                            Child, ColGroup(2),
                                                Child, borderless = MUI_MakeObject(MUIO_Checkmark,NULL),
                                                Child, LLabel1("Borderless"),
                                                Child, sunny = MUI_MakeObject(MUIO_Checkmark,NULL),
                                                Child, LLabel1("Sunny"),
                                                Child, raised = MUI_MakeObject(MUIO_Checkmark,NULL),
                                                Child, LLabel1("Raised"),
                                                Child, scaled = MUI_MakeObject(MUIO_Checkmark,NULL),
                                                Child, LLabel1("Scaled"),
                                                Child, keys = MUI_MakeObject(MUIO_Checkmark,NULL),
                                                Child, LLabel1("Enable keys"),
                                                Child, bspacer = MUI_MakeObject(MUIO_Checkmark,NULL),
                                                Child, LLabel1("Bar spacer"),
                                                Child, fixed = MUI_MakeObject(MUIO_Checkmark,NULL),
                                                Child, LLabel("Fixed"),
                                                Child, free = MUI_MakeObject(MUIO_Checkmark,NULL),
                                                Child, LLabel("Disable 0"),
                                                Child, h0 = MUI_MakeObject(MUIO_Checkmark,NULL),
                                                Child, LLabel("Hide 0"),
                                                Child, s4 = MUI_MakeObject(MUIO_Checkmark,NULL),
                                                Child, LLabel("Sleep 4"),
                                                Child, RectangleObject, MUIA_FixHeightTxt,"a",End,
                                                Child, RectangleObject, MUIA_FixHeightTxt,"a",End,
                                                Child, rb = MUI_MakeObject(MUIO_Checkmark,NULL),
                                                Child, LLabel("Remove Bars"),
                                                Child, rs = MUI_MakeObject(MUIO_Checkmark,NULL),
                                                Child, LLabel("Remove Spaces"),
                                                Child, ri = MUI_MakeObject(MUIO_Checkmark,NULL),
                                                Child, LLabel("Remove Images"),
                                            End,
                                            Child, HSpace(0),
                                        End,
                                        Child, VSpace(0),
                                    End,
                                End,
                                Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
                            End,
                        End,
                    End,
                End) != NULL)
            {
                ULONG sigs = 0;
                LONG id;

                set(rows,MUIA_Group_Horiz,TRUE);
                set(cols,MUIA_Group_Horiz,TRUE);
                set(viewMode,MUIA_Cycle_Active,1);
                set(s4,MUIA_Selected,TRUE);
                DoMethod(sb,MUIM_TheBar_SetAttr,4,MUIA_TheBar_Attr_Sleep,TRUE);

                DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
                DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);

                set(win,MUIA_Window_Open,TRUE);

                while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
                {
                    if (id==(LONG)TAG_USER)
                    {
                        IPTR c = 0,
                             r = 0,
                             vm = 0,
                             bp = 0,
                             lp = 0,
                             br = 0,
                             su = 0,
                             ra = 0,
                             sc = 0,
                             k = 0,
                             bs = 0,
                             fi = 0,
                             fr = 0,
                             hl0 = 0,
                             sl4 = 0,
                             rbl = 0,
                             rsl = 0,
                             ril = 0,
                             rem = 0;

                        get(rows,MUIA_Radio_Active,&r);
                        if (r==4) r = 6;
                        get(cols,MUIA_Radio_Active,&c);

                        get(viewMode,MUIA_Cycle_Active,&vm);
                        get(buttonsPos,MUIA_Cycle_Active,&bp);
                        get(labelPos,MUIA_Cycle_Active,&lp);

                        get(borderless,MUIA_Selected,&br);
                        get(sunny,MUIA_Selected,&su);
                        get(raised,MUIA_Selected,&ra);
                        get(scaled,MUIA_Selected,&sc);
                        get(keys,MUIA_Selected,&k);
                        get(bspacer,MUIA_Selected,&bs);
                        get(fixed,MUIA_Selected,&fi);
                        get(free,MUIA_Selected,&fr);

                        get(h0,MUIA_Selected,&hl0);
                        get(s4,MUIA_Selected,&sl4);

                        get(rb,MUIA_Selected,&rbl);
                        get(rs,MUIA_Selected,&rsl);
                        get(ri,MUIA_Selected,&ril);
                        rem = 0;
                        if (rbl) rem |= MUIV_TheBar_RemoveSpacers_Bar;
                        if (rsl) rem |= MUIV_TheBar_RemoveSpacers_Button;
                        if (ril) rem |= MUIV_TheBar_RemoveSpacers_Image;

                        DoMethod(mg,MUIM_Group_InitChange);
                        DoMethod(sb,MUIM_Group_InitChange);

                        SetAttrs(sb,MUIA_TheBar_Columns,      c,
                                    MUIA_TheBar_Rows,         r,
                                    MUIA_TheBar_ViewMode,     vm,
                                    MUIA_TheBar_Borderless,   br,
                                    MUIA_TheBar_Sunny,        su,
                                    MUIA_TheBar_Raised,       ra,
                                    MUIA_TheBar_Scaled,       sc,
                                    MUIA_TheBar_EnableKeys,   k,
                                    MUIA_TheBar_BarSpacer,    bs,
                                    MUIA_TheBar_RemoveSpacers,rem,
                                    MUIA_TheBar_LabelPos,     lp,
                                    TAG_DONE);

                        DoMethod(sb,MUIM_TheBar_SetAttr,0,MUIA_TheBar_Attr_Hide,hl0);
                        DoMethod(sb,MUIM_TheBar_SetAttr,4,MUIA_TheBar_Attr_Sleep,sl4);

                        DoMethod(sb,MUIM_TheBar_SetAttr,6,MUIA_TheBar_Attr_Disabled,fr);

                        DoMethod(sb,MUIM_Group_ExitChange);
                        DoMethod(mg,MUIM_Group_ExitChange);
                    }

                    if (sigs)
                    {
                        sigs = Wait(sigs | SIGBREAKF_CTRL_C);
                        if (sigs & SIGBREAKF_CTRL_C) break;
                    }
                }

                MUI_DisposeObject(app);

                res = RETURN_OK;
            }
            else
            {
                printf("%s: can't create application\n",argv[0]);
                res = RETURN_FAIL;
            }

            CLOSELIB(MUIMasterBase, IMUIMaster);
        }
        else
        {
            printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
            res = RETURN_ERROR;
        }

        CLOSELIB(IntuitionBase, IIntuition);
    }
    else
    {
        printf("%s: Can't open intuition.library ver 39 or higher\n",argv[0]);
        res = RETURN_ERROR;
    }

    return res;
}
Exemplo n.º 7
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;
}
Exemplo n.º 8
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;
}
Exemplo n.º 9
0
ULONG initBase(struct LibraryHeader *lib)
{
  ENTER();

  if((DOSBase = (APTR)OpenLibrary("dos.library", 37)) != NULL &&
     GETINTERFACE(IDOS, DOSBase))
  {
    if((UtilityBase = (APTR)OpenLibrary("utility.library", 37)) != NULL &&
       GETINTERFACE(IUtility, UtilityBase))
    {
      // we have to please the internal utilitybase
      // pointers of libnix and clib2
      #if !defined(__NEWLIB__) && !defined(__AROS__)
        __UtilityBase = (APTR)UtilityBase;
        #if defined(__amigaos4__)
        __IUtility = IUtility;
        #endif
      #endif

      // setup the debugging stuff
      #if defined(DEBUG)
      SetupDebug();
      #endif

      #if defined(__amigaos4__)
      if((DiskfontBase = OpenLibrary("diskfont.library", 50)) != NULL &&
        GETINTERFACE(IDiskfont, DiskfontBase))
      {
      #endif
        #if defined(__amigaos4__)
        lib->pool = AllocSysObjectTags(ASOT_MEMPOOL, ASOPOOL_MFlags, MEMF_SHARED,
                                                     ASOPOOL_Puddle, 4096,
                                                     ASOPOOL_Threshold, 512,
                                                     ASOPOOL_Name, "codesets.library pool",
                                                     ASOPOOL_LockMem, FALSE,
                                                     TAG_DONE);
        #else
        lib->pool = CreatePool(MEMF_ANY, 4096, 512);
        #endif
        if(lib->pool != NULL)
        {
          if(codesetsInit(&lib->codesets) == TRUE)
          {
            lib->systemCodeset = (struct codeset *)GetHead((struct List *)&lib->codesets);

            if((LocaleBase = (APTR)OpenLibrary("locale.library", 37)) != NULL &&
               GETINTERFACE(ILocale, LocaleBase))
            {
              getSystemCodeset(lib);
            }

            RETURN(TRUE);
            return TRUE;
          }
        }
      #if defined(__amigaos4__)
      }
      #endif
    }
  }

  freeBase(lib);

  RETURN(FALSE);
  return FALSE;
}