Exemple #1
0
static int libExpunge(LIBBASETYPEPTR nh)
{
    KPRINTF(10, ("libExpunge nh: 0x%08lx\n", nh));
    CloseLibrary((struct Library *) UtilityBase);
    return(TRUE);
}
Exemple #2
0
/*************************************
*  
*  Engine for the CloseAllTVWindows()
*  function.   
*
*  Receives the each library's info.
*
*  Attempts to close window,
*  close library, and free associated
*  menu items for window.
*
**************************************/
BOOL __far __pascal CloseAllLibsWindows( FPTVLIBINFO fpTVLibInfo, LPARAM lParam )
{
  BOOL __far * bAllWndClosed;
  FPTVWNDINFO fpWndInfo;
  HTVWNDINFO hWndInfo;

  HWND hChildWnd;  
  HWND hChildsPopupWnd;  
  
  TVLIBCLOSEWINDOWPROC fpfnTVLibCloseWnd;


  /* Get LPARAM data. */
  bAllWndClosed = (BOOL __far *) lParam;
  
  /* Get library's handle to first window info. */
  hWndInfo = GetLibWndInfo( fpTVLibInfo );
  
  while( hWndInfo != 0 )
  {
    /* Lock it. */
    fpWndInfo = (FPTVWNDINFO) GlobalLock( hWndInfo ) ;
  
    /* Get the handle of the window we are closing. */
    hChildWnd = fpWndInfo->hWnd;

    /* Unlock it. */
    GlobalUnlock( hWndInfo ) ;

    /* 
    ** If we are already in the window's
    ** Wndproc() and awaiting it return,
    ** activate the last popup window.
    */
    if( GetTVEntryCount( hChildWnd ) != 0 )
    {
      /* Change focus to window. */
      MessageBeep( MB_ICONEXCLAMATION );
      hChildsPopupWnd = GetLastActivePopup( hChildWnd );
      SetActiveWindow( hChildsPopupWnd ); 

      /* Not all windows closed. */
      *bAllWndClosed = FALSE; 

      /* Stop enumerating. */
      return FALSE;
    }

    /* 
    **  Tell window to close by sending calling
    **  the TVLibWindowClose() function.
    */   
    /* Retrieve the address of the control's LibInfo() function. */
    (FARPROC) fpfnTVLibCloseWnd = GetProcAddress( fpTVLibInfo->hInstance, MAKEINTRESOURCE(TVLIB_CLOSEWINDOW_ORD) );
                                              
    /* Verify the GetProcAddress() function returned data. */
    if ( fpfnTVLibCloseWnd == NULL)
    {
      /* Not all windows closed. */
      *bAllWndClosed = FALSE; 

      /* Error message. */
      MessageBox(  NULL, (LPSTR)"GetProcAddress() failed!", (LPSTR)"Library Functions", MB_ICONHAND | MB_OK );

      /* Stop enumerating. */
      return FALSE;
    }
  
    /* 
    **  Restore the window's WndProc() to its original
    **  WndProc() so we aren't trapping for the
    **  WM_NCDESTROY message and won't therefore call
    **  PostCloseLibrary().
    */
//    RemoveChildWindowFilter( hChildWnd );

    /* Tell the library to close the window. */
    (*fpfnTVLibCloseWnd)(hChildWnd);

    /* 
    **  Window is still around. 
    */
    if( IsWindow( hChildWnd ) )
    {
      /* 
      **  Set the window's WndProc() to our special
      **  WndProc() so we can keep trapping for the
      **  WM_NCDESTROY message to call
      **  PostCloseLibrary().
      */
//      SetChildWindowFilter( hChildWnd );

      /* Not all windows closed. */
      *bAllWndClosed = FALSE; 
      
      /* Stop enumerating. */
      return FALSE;
    }
  
    /* 
    **  Window is not still around. 
    */

    /* Remove menu alias' associated with the window. */  
    DeleteMenuInfoForWnd( hChildWnd );
    
    /* Find and delete the window info. */
    DeleteWndInfo( &(fpTVLibInfo)->hTVWndInfo, hChildWnd );
  
    /* Close the library. */
    CloseLibrary( fpTVLibInfo );

    /* Get library's handle to first window info. */
    hWndInfo = GetLibWndInfo( fpTVLibInfo );
  }

  /* Keep enumerating - next library. */
  return TRUE;
}
Exemple #3
0
// Reads a coding table
BOOL ReadUnicodeTable(struct Globals *glob, STRPTR name)
{
    BPTR fh;
    struct Library *DOSBase;

    if (!(DOSBase = OpenLibrary("dos.library", 0)))
        return FALSE;

    fh = Open(name, MODE_OLDFILE);
    if (fh)
    {
        int i, n;
        char buf[512];

        while (readLine(DOSBase, fh, buf, 512 * sizeof(char)))
        {
            if (!isdigit(*buf))
                continue;
            else
            {
                char *p = buf;
                int fmt2 = 0;

                if ((*p == '=') || (fmt2 = ((*p == '0')
                    || (*(p + 1) == 'x'))))
                {
                    p++;
                    p += fmt2;

                    i = strtol((const char *)p, (char **)&p, 16);
                    if (i >= 0 && i < 256)
                    {
                        while (isspace(*p))
                            p++;

                        if (!strnicmp(p, "U+", 2))
                        {
                            p += 2;
                            n = strtol((const char *)p, (char **)&p, 16);
                        }
                        else
                        {
                            if (*p != '#')
                                n = strtol((const char *)p, (char **)&p, 0);
                            else
                                n = -1;
                        }
                        if (n >= 0 && n < 65536)
                        {
                            glob->from_unicode[n] = i;
                            glob->to_unicode[i] = n;
                        }
                    }
                }
            }
        }
        Close(fh);
    }

    CloseLibrary(DOSBase);

    return fh ? TRUE : FALSE;
}
Exemple #4
0
/* Add a bootnode using expansion.library */
BOOL ata_RegisterVolume(ULONG StartCyl, ULONG EndCyl, struct ata_Unit *unit)
{
    struct ExpansionBase *ExpansionBase;
    struct DeviceNode *devnode;
    TEXT dosdevname[4] = "HD0";
    const ULONG IdDOS = AROS_MAKE_ID('D','O','S','\001');
    const ULONG IdCDVD = AROS_MAKE_ID('C','D','V','D');

    ExpansionBase = (struct ExpansionBase *)OpenLibrary("expansion.library",
                                                        40L);

    if (ExpansionBase)
    {
        IPTR pp[24];

        /* This should be dealt with using some sort of volume manager or such. */
        switch (unit->au_DevType)
        {
            case DG_DIRECT_ACCESS:
                break;
            case DG_CDROM:
                dosdevname[0] = 'C';
                break;
            default:
                D(bug("[ATA>>]:-ata_RegisterVolume called on unknown devicetype\n"));
        }

        if (unit->au_UnitNum < 10)
            dosdevname[2] += unit->au_UnitNum % 10;
        else
            dosdevname[2] = 'A' - 10 + unit->au_UnitNum;
    
        pp[0] 		    = (IPTR)dosdevname;
        pp[1]		    = (IPTR)MOD_NAME_STRING;
        pp[2]		    = unit->au_UnitNum;
        pp[DE_TABLESIZE    + 4] = DE_BOOTBLOCKS;
        pp[DE_SIZEBLOCK    + 4] = 1 << (unit->au_SectorShift - 2);
        pp[DE_NUMHEADS     + 4] = unit->au_Heads;
        pp[DE_SECSPERBLOCK + 4] = 1;
        pp[DE_BLKSPERTRACK + 4] = unit->au_Sectors;
        pp[DE_RESERVEDBLKS + 4] = 2;
        pp[DE_LOWCYL       + 4] = StartCyl;
        pp[DE_HIGHCYL      + 4] = EndCyl;
        pp[DE_NUMBUFFERS   + 4] = 10;
        pp[DE_BUFMEMTYPE   + 4] = MEMF_PUBLIC | MEMF_31BIT;
        pp[DE_MAXTRANSFER  + 4] = 0x00200000;
        pp[DE_MASK         + 4] = 0x7FFFFFFE;
        pp[DE_BOOTPRI      + 4] = ((unit->au_DevType == DG_DIRECT_ACCESS) ? 0 : 10);
        pp[DE_DOSTYPE      + 4] = ((unit->au_DevType == DG_DIRECT_ACCESS) ? IdDOS : IdCDVD);
        pp[DE_CONTROL      + 4] = 0;
        pp[DE_BOOTBLOCKS   + 4] = 2;
    
        devnode = MakeDosNode(pp);

        if (devnode)
        {
            D(bug("[ATA>>]:-ata_RegisterVolume: '%b', type=0x%08lx with StartCyl=%d, EndCyl=%d .. ",
                  devnode->dn_Name, pp[DE_DOSTYPE + 4], StartCyl, EndCyl));

            AddBootNode(pp[DE_BOOTPRI + 4], ADNF_STARTPROC, devnode, NULL);
            D(bug("done\n"));
            
            return TRUE;
        }

        CloseLibrary((struct Library *)ExpansionBase);
    }

    return FALSE;
}
Exemple #5
0
static BOOL ClassInit(UNUSED struct Library *base)
{
  ENTER();

  if((DataTypesBase = OpenLibrary("datatypes.library",37)) &&
     GETINTERFACE(IDataTypes,struct DataTypesIFace *,DataTypesBase) &&
     (IFFParseBase = OpenLibrary("iffparse.library",37)) &&
     GETINTERFACE(IIFFParse,struct IFFParseIFace *,IFFParseBase) &&
     (LocaleBase = (APTR)OpenLibrary("locale.library",36)) &&
     GETINTERFACE(ILocale,struct LocaleIFace *,LocaleBase))
  {
    BOOL success = TRUE;

    // check for MUI 3.9+
    if(LIB_VERSION_IS_AT_LEAST(MUIMasterBase, 20, 0))
    {
      lib_flags |= BASEFLG_MUI20;

      // check for MUI 4.0+
      if(LIB_VERSION_IS_AT_LEAST(MUIMasterBase, 20, 5500))
        lib_flags |= BASEFLG_MUI4;
    }

    // on MUI 3.1 system's we do have to
    // initialize our subclasses as well
    #if defined(__amigaos3__)
    if(!(lib_flags & BASEFLG_MUI20))
    {
      if(!initColoradjust() ||
         !initPenadjust() ||
         !initBackgroundadjust() ||
         !initPoppen() ||
         !initPopbackground())
      {
        success = FALSE;
      }
    }
    #endif

    if(success == TRUE)
    {
      // open the TheBar_mcp catalog
      OpenCat();

      LocalizeArray(regs,regIDs);
      LocalizeArray(frames,frameIDs);
      LocalizeArray(precisions,precisionIDs);
      LocalizeArray(dismodes,dismodeIDs);
      LocalizeArray(spacersSizes,spacersSizeIDs);
      LocalizeArray(viewModes,viewModeIDs);
      LocalizeArray(labelPoss,labelPosIDs);

      // we open the cybgraphics.library but without failing if
      // it doesn't exist
      #if !defined(__amigaos4__)
      CyberGfxBase = OpenLibrary("cybergraphics.library", 41);
/*
      if(!GETINTERFACE(ICyberGfx, struct CyberGfxIFace *, CyberGfxBase))
      {
        CloseLibrary(CyberGfxBase);
        CyberGfxBase = NULL;
      }
*/
      #endif

      #if !defined(__MORPHOS__)
      {
        struct Library *nbitmapMcc;

        nbitmapCanHandleRawData = FALSE;

        // we need at least NBitmap.mcc V15.8 to be able to let it handle raw image data
        if((nbitmapMcc = OpenLibrary("mui/NBitmap.mcc", 0)) != NULL)
        {
          SHOWVALUE(DBF_ALWAYS, nbitmapMcc->lib_Version);
          SHOWVALUE(DBF_ALWAYS, nbitmapMcc->lib_Revision);

          if(nbitmapMcc->lib_Version > 15 || (nbitmapMcc->lib_Version == 15 && nbitmapMcc->lib_Revision >= 8))
            nbitmapCanHandleRawData = TRUE;

          CloseLibrary(nbitmapMcc);
        }

        SHOWVALUE(DBF_ALWAYS, nbitmapCanHandleRawData);
      }
      #endif

      lib_flags |= BASEFLG_Init;

      RETURN(TRUE);
      return TRUE;
    }
  }

  ClassExpunge(base);

  RETURN(FALSE);
  return FALSE;
}
// Open the button editor (called from a sub-process)
void buttons_edit(
	IPCData *my_ipc,
	buttons_edit_packet *packet)
{
	ButtonsStartup startup;
	struct Library *ConfigOpusBase;
	IPCData *ipc;
	long ret,command;
	Buttons *buttons=0;
	Cfg_Button *send_button=0;
	struct AppMessage *send_msg=0;
	short button_col=-1,button_row=-1;
	short can_start=1;

	// Get packet data
	if (packet)
	{
		buttons=packet->buttons;
		send_button=packet->edit;
		button_col=packet->col;
		button_row=packet->row;
		can_start=packet->can_start;
		send_msg=packet->appmsg;
	}

	// Lock process list
	lock_listlock(&GUI->process_list,FALSE);

	// Get edit command
	command=(button_col==-2)?BUTTONEDIT_RE_EDIT_ME:BUTTONEDIT_EDIT_ME;

	// See if button editor is running
	if (ipc=IPC_FindProc(&GUI->process_list,NAME_BUTTON_EDITOR_RUN,FALSE,0))
	{
		BOOL front=1;

		// Button bank supplied?
		if (buttons)
		{
			// Does the bank not already have the editor?
			if (!buttons->editor)
			{
				// Tell editor to edit the toolbar bank
				IPC_Command(
					ipc,
					command,
					(ULONG)buttons->bank,
					buttons->ipc,
					0,
					0);

				// Set flag for pending edit request
				buttons->flags|=BUTTONF_EDIT_REQUEST;
				front=0;
			}

			// Button to send?
			if (send_button)
			{
				Point *pos;

				// Allocate position
				if (pos=AllocVec(sizeof(Point),MEMF_CLEAR))
				{
					// Convert coordinates to window relative
					pos->x=button_col-buttons->window->LeftEdge;
					pos->y=button_row-buttons->window->TopEdge;

					// Send command
					IPC_Command(
						ipc,
						BUTTONEDIT_BUTTON_TO_BANK,
						0,
						send_button,
						pos,
						0);
					send_button=0;
				}
				front=0;
			}

			// Message to send?
			if (send_msg)
			{
				// Send it on
				IPC_Command(
					ipc,
					CFG_APPMESSAGE_PASS,
					(ULONG)buttons->bank,
					send_msg,
					0,
					0);
				send_msg=0;
			}

			// Button to edit?
			if (button_col>-1)
			{
				// Send edit command
				IPC_Command(
					ipc,
					BUTTONEDIT_EDIT_BUTTON,
					button_col,
					(APTR)button_row,
					0,
					0);
				front=0;
			}
		}

		// Bring editor to front
		if (front) IPC_Command(ipc,IPC_ACTIVATE,0,0,0,0);
	}

	// Unlock the process list
	unlock_listlock(&GUI->process_list);

	// Free button if we have one
	if (send_button) FreeButton(send_button);

	// Free message if we have one
	if (send_msg) ReplyAppMessage((DOpusAppMessage *)send_msg);

	// If editor was already running, or we can't start it if not, return
	if (ipc || !can_start) return;

	// Change our name
	my_ipc->proc->pr_Task.tc_Node.ln_Name=NAME_BUTTON_EDITOR_RUN;

	// Set flag
	GUI->flags|=GUIF_BUTTON_EDITOR;

	// Open configuration library
	if (!(ConfigOpusBase=OpenModule(config_name)))
		return;

	// Bank supplied?
	if (buttons)
	{
		// Fill out startup packet
		startup.bank=buttons->bank;
		startup.ipc=buttons->ipc;

		// Button supplied?
		if (button_col>-1)
		{
			// Set flag
			startup.flag=1;

			// Pass button
			startup.button=(button_col<<16)|button_row;
		}
		else startup.flag=0;

		// Set pending edit request
		buttons->flags|=BUTTONF_EDIT_REQUEST;
	}
	else startup.bank=0;

	// Configure buttons
	ret=Config_Buttons(
		&startup,
		my_ipc,
		&main_ipc,
		GUI->screen_pointer,
		(ULONG)&GUI->command_list.list);

	// Change our name back
	my_ipc->proc->pr_Task.tc_Node.ln_Name=NAME_BUTTON_EDITOR;

	// Clear flag
	GUI->flags&=~GUIF_BUTTON_EDITOR;

	// Permit now we've cleaned up
	Permit();

	// Close library
	CloseLibrary(ConfigOpusBase);

	// Lock buttons list
	lock_listlock(&GUI->buttons_list,FALSE);

	// Go through button banks
	for (ipc=(IPCData *)GUI->buttons_list.list.lh_Head;
		ipc->node.mln_Succ;
		ipc=(IPCData *)ipc->node.mln_Succ)
	{
		// Get buttons pointer
		Buttons *buttons=IPCDATA(ipc);

		// Toolbar buttons?
		if (buttons->flags&BUTTONF_TOOLBAR)
		{
			// Hide bank
			IPC_Command(ipc,IPC_HIDE,0,0,0,REPLY_NO_PORT);

			// Need to save?
			if (ret&CONFIG_SAVE)
				IPC_Command(ipc,BUTTONS_SAVE,0,0,0,REPLY_NO_PORT);

			// Use?
			if (ret)
			{
				// Send change
				send_main_reset_cmd(CONFIG_CHANGE_LIST_TOOLBAR,0,buttons->bank);

				// Steal bank pointer
				IPC_Command(ipc,BUTTONEDIT_NEW_BANK,1,0,0,REPLY_NO_PORT);
			}

			// Close bank
			IPC_Command(ipc,IPC_QUIT,0,0,0,0);
		}

		// Ok?
		else
		if (ret)
		{
			// Save?
			if (ret&CONFIG_SAVE)
			{
				// Buttons been changed?
				if (buttons->flags&BUTTONF_CHANGED)
				{
					// Tell bank to save itself
					IPC_Command(ipc,BUTTONS_SAVE,0,0,0,REPLY_NO_PORT);
				}
			}

			// Clear 'new' flag
			buttons->flags&=~BUTTONF_NEW_BANK;
		}
	}

	// Unlock buttons list
	unlock_listlock(&GUI->buttons_list);
}
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;
}
Exemple #8
0
static void getSystemCodeset(struct LibraryHeader *lib)
{
  struct codeset *foundCodeset = NULL;

  ENTER();

  // before we go any query the system via locale.library (which
  // might not be so accurate) we try different other means of
  // finding the codeset/charset of the system
  #if defined(__amigaos4__)
  if(foundCodeset == NULL)
  {
    LONG default_charset = GetDiskFontCtrl(DFCTRL_CHARSET);
    char *charset = (char *)ObtainCharsetInfo(DFCS_NUMBER, default_charset, DFCS_MIMENAME);

    foundCodeset = codesetsFind(&lib->codesets, charset);

    D(DBF_STARTUP, "%s system default codeset: '%s' (diskfont)", foundCodeset ? "found" : "not found", charset);
  }
  #endif

  if(foundCodeset == NULL)
  {
    char codepage[40];

    codepage[0] = '\0';
    if(GetVar("CODEPAGE", codepage, sizeof(codepage), 0) > 0)
    {
      D(DBF_STARTUP, "trying ENV:CODEPAGE '%s'", codepage);
      foundCodeset = codesetsFind(&lib->codesets, codepage);
    }

    D(DBF_STARTUP, "%s system default codeset: '%s' (ENV:CODEPAGE)", foundCodeset ? "found" : "did not find",
                                                                     foundCodeset ? foundCodeset->name : "?");
  }

  #if defined(__MORPHOS__)
  if(foundCodeset == NULL)
  {
    /* If CODEPAGE did not work (maybe user deleted it or something) we try a keymap instead. This only works
     * in MorphOS 2 and only if an old Amiga keymap is not used.
     */
    if(foundCodeset == NULL)
    {
      struct Library *KeymapBase;

      if((KeymapBase = OpenLibrary("keymap.library", 51)) != NULL)
      {
        /* Since we requested V51 it is either V51 or newer */
        if(KeymapBase->lib_Version > 51 || KeymapBase->lib_Revision >= 4)
        {
          CONST_STRPTR codepage;

          #ifndef GetKeyMapCodepage
          #define GetKeyMapCodepage(__p0) LP1(78, CONST_STRPTR , GetKeyMapCodepage, CONST struct KeyMap *, __p0, a0, , KEYMAP_BASE_NAME, 0, 0, 0, 0, 0, 0)
          #endif

          if((codepage = GetKeyMapCodepage(NULL)) != NULL)
          {
            foundCodeset = codesetsFind(&lib->codesets, codepage);

            D(DBF_STARTUP, "%s system default codeset: '%s' (keymap)", foundCodeset ? "found" : "did not find",
                                                                       foundCodeset ? foundCodeset->name : "?");
          }
        }

        CloseLibrary(KeymapBase);
      }
    }
  }
  #endif

  // if we still do not have our default charset we try to load
  // it from and environment variable ENVARC:CHARSET
  if(foundCodeset == NULL)
  {
    char charset[80];

    charset[0] = '\0';
    if(GetVar("CHARSET", charset, sizeof(charset), 0) > 0)
    {
      D(DBF_STARTUP, "trying ENV:CHARSET '%s'", charset);
      foundCodeset = codesetsFind(&lib->codesets, charset);
    }

    D(DBF_STARTUP, "%s system default codeset: '%s' (ENV:CHARSET)", foundCodeset ? "found" : "did not find",
                                                                    foundCodeset ? foundCodeset->name : "?");
  }

  // try the country code next
  if(foundCodeset == NULL)
  {
    struct Locale *defaultLocale;

    if((defaultLocale = OpenLocale(NULL)) != NULL)
    {
      int i;
      const struct loc *curLoc = NULL;
      BOOL found = FALSE;

      for(i=0;;i++)
      {
        curLoc = &locs[i];
        if(curLoc == NULL || curLoc->name == NULL)
          break;

        if(defaultLocale->loc_CountryCode == curLoc->carPlateCode || defaultLocale->loc_CountryCode == curLoc->iso3166Code)
        {
          D(DBF_STARTUP, "found country code for '%s'", curLoc->name);
          found = TRUE;
          break;
        }
      }

      if(found == TRUE)
        foundCodeset = codesetsFind(&lib->codesets, curLoc->codesetName);

      CloseLocale(defaultLocale);
    }

    D(DBF_STARTUP, "%s system default codeset: '%s' (locale/country)", foundCodeset ? "found" : "did not find",
                                                                       foundCodeset ? foundCodeset->name : "?");
  }

  // and if even the CHARSET environment variable didn't work
  // out we check the LANGUAGE env variable against our own
  // internal fallback list
  if(foundCodeset == NULL)
  {
    char language[80];

    language[0] = '\0';
    if(GetVar("LANGUAGE", language, sizeof(language), 0) > 0)
    {
      int i;
      const struct loc *curLoc = NULL;
      BOOL found = FALSE;

      for(i=0;;i++)
      {
        curLoc = &locs[i];
        if(curLoc == NULL || curLoc->name == NULL)
          break;

        if(Strnicmp(language, curLoc->name, curLoc->len) == 0)
        {
          D(DBF_STARTUP, "found language name for '%s'", curLoc->name);
          found = TRUE;
          break;
        }
      }

      if(found == TRUE)
        foundCodeset = codesetsFind(&lib->codesets, curLoc->codesetName);
    }

    D(DBF_STARTUP, "%s system default codeset: '%s' (ENV:LANGUAGE)", foundCodeset ? "found" : "did not find",
                                                                     foundCodeset ? foundCodeset->name : "?");
  }

  // and the very last check we do to find out the system's charset is
  // to use locale.library.
  if(foundCodeset == NULL)
  {
    struct Locale *locale;

    if((locale = OpenLocale(NULL)) != NULL)
    {
      int i;
      char *language = locale->loc_LanguageName;
      const struct loc *curLoc = NULL;
      BOOL found = FALSE;

      for(i=0;;i++)
      {
        curLoc = &locs[i];
        if(curLoc == NULL || curLoc->name == NULL)
          break;

        if(Strnicmp(language, curLoc->name, curLoc->len) == 0)
        {
          found = TRUE;
          break;
        }
      }

      CloseLocale(locale);

      if(found == TRUE)
        foundCodeset = codesetsFind(&lib->codesets, curLoc->codesetName);
    }

    D(DBF_STARTUP, "%s system default codeset: '%s' (locale/language)", foundCodeset ? "found" : "did not find",
                                                                        foundCodeset ? foundCodeset->name : "?");
  }

  // and if even that very last test didn't work out we
  // can just take the ISO-8859-1 charset as the fallback default
  if(foundCodeset == NULL)
    lib->systemCodeset = codesetsFind(&lib->codesets, "ISO-8859-1");
  else
    lib->systemCodeset = foundCodeset;

  D(DBF_STARTUP, "final system default codeset: '%s'", lib->systemCodeset ? lib->systemCodeset->name : "?");

  LEAVE();
}
Exemple #9
0
LONG
main(VOID)
{
  struct DosLibrary *DOSBase;

  struct RDArgs  *readargs;
  LONG            rargs[5], vargs[5];
  UBYTE          *source, *target;
  ULONG           buffersize = 0;
  UBYTE          *sourcedir, *targetdir;
  UBYTE          *textbuffer, *tmp, *tmp1, *tmp2;
  struct AnchorPath *anchorpath;
  struct FileInfoBlock *fib, *targetfib;
  struct Process *process;
  APTR            wptr;
  BPTR            dirlock, filelock;
  BOOL            checkdatestamp, all;
  LONG            date, error, rc = 0;


  /* Fail silently if < 37 */
  if (DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 37))
  {
    rargs[0] = 0L;
    rargs[1] = 0L;
    rargs[2] = 0L;
    rargs[3] = 0L;
    rargs[4] = 0L;

    if (readargs = ReadArgs("SOURCE/A,TARGET/A,DATE/S,ALL/S,BUFFER/K/N", rargs, NULL))
    {

      source = (UBYTE *) rargs[0];
      target = (UBYTE *) rargs[1];
      checkdatestamp = (BOOL) rargs[2];
      all = (BOOL) rargs[3];

      if (!(sourcedir = AllocMem(StrLen(source) + 129, MEMF_CLEAR)))
        error = ERROR_NO_FREE_STORE;
      else
      {
        /* 128 bytes to print informative text */
        textbuffer = sourcedir + StrLen(source) + 1;

        /* use user specified buffersize if indicated */
        if (rargs[4])
          buffersize = *((LONG *) rargs[4]);
        if (buffersize < BUFFERSIZE || buffersize > 4096)
          buffersize = BUFFERSIZE;

        if (!(targetdir = AllocMem(buffersize, MEMF_CLEAR)))
          error = ERROR_NO_FREE_STORE;
        else
        {
          if (!(targetfib = AllocDosObject(DOS_FIB, NULL)))
            error = ERROR_NO_FREE_STORE;
          else
          {

            /*
             * Check if source and target are valid.
             *
             * Separate source path from pattern (if any). Use the source path figure
             * out what to append to the target.
             */

            /* No requesters */
            process = (struct Process *) FindTask(NULL);
            wptr = process->pr_WindowPtr;
            process->pr_WindowPtr = (APTR) - 1L;

            if ((error = GetPath(source, sourcedir, StrLen(source) + 1) == 0))
            {
              if (!(dirlock = Lock(sourcedir, SHARED_LOCK)))
                error = IoErr();
              else
              {
                UnLock(dirlock);
                if (!(dirlock = Lock(target, SHARED_LOCK)))
                  error = IoErr();
                else
                {
                  UnLock(dirlock);

                  if (anchorpath = AllocMem(sizeof(struct AnchorPath) + buffersize,
                                            MEMF_CLEAR))
                  {
                    anchorpath->ap_Strlen = buffersize;

                    /* Allow to break on CTRL-C */
                    anchorpath->ap_BreakBits = SIGBREAKF_CTRL_C;

                    if ((error = MatchFirst(source, anchorpath)) == 0)
                    {

                      do
                      {
                        fib = &(anchorpath->ap_Info);

                        /*
                         * APF_DIDDIR indicates that we used returned from a
                         * directory. In that case we clear both APF_DIDDIR and
                         * APF_DODIR, so we can start afresh with the next one.
                         */


                        if (anchorpath->ap_Flags & APF_DIDDIR)
                          anchorpath->ap_Flags &= ~(APF_DODIR | APF_DIDDIR);
                        else
                        {

                          /*
                           * Make a filename for the target directory. First copy
                           * targetname into buffer.
                           */
                          targetdir[0] = '\0';
                          tmp = targetdir;
                          tmp1 = target;
                          while (*tmp++ = *tmp1++);

                          /* Skip sourcename in ap_Buf */
                          tmp1 = sourcedir;
                          tmp2 = anchorpath->ap_Buf;
                          while (*tmp1++ == *tmp2++);
                          /* Skip back 1 if not after a separator */
                          if (*(tmp2 - 1) != '/')
                            tmp2--;

                          /*
                           * We hit the source itself, don't compare it, but enter
                           * it.
                           */
                          if (*tmp2 == 0)
                          {
                            anchorpath->ap_Flags |= APF_DODIR;
                            continue;
                          }

                          /* Build it */
                          if (AddPart(targetdir, tmp2, buffersize - 1))
                            vargs[0] = (LONG) targetdir;
                          else
                          {
                            PrintFault(ERROR_NO_FREE_STORE, NULL);
                            break;
                          }

                          /* Lock it and check it out */
                          if (filelock = Lock(targetdir, SHARED_LOCK))
                          {
                            if ((Examine(filelock, targetfib)) == DOSTRUE)
                            {
                              textbuffer[0] = '\0';

                              /*
                               * To get nice output without work I use AddPart() to
                               * add differences to the textbuffer.
                               */
                              if (targetfib->fib_DirEntryType
                                  != fib->fib_DirEntryType)
                                AddPart(textbuffer, "of different type", 128);
                              else
                              {
                                if (targetfib->fib_Size < fib->fib_Size)
                                  AddPart(textbuffer, "smaller", 128);
                                else if (targetfib->fib_Size > fib->fib_Size)
                                  AddPart(textbuffer, "larger", 128);

                                if (checkdatestamp)
                                {
                                  date = CompareDates((struct DateStamp *)
                                        & (fib->fib_Date),
                                      (struct DateStamp *) & (targetfib->fib_Date));
                                  if (date < 0)
                                    AddPart(textbuffer, "older", 128);
                                  else if (date > 0)
                                    AddPart(textbuffer, "newer", 128);
                                }
                              }


                              if (*textbuffer != NULL)
                              {
                                vargs[1] = (LONG) textbuffer;
                                VFPrintf(Output(), "%s: object %s\n", vargs);
                              }
                            }
                            else
                              PrintFault(IoErr(), targetdir);
                            UnLock(filelock);
                          }
                          else
                          {
                            PrintFault(IoErr(), targetdir);

                            /*
                             * If and error occured on a directory name, don't enter
                             * it.
                             */
                            if (fib->fib_DirEntryType > 0)
                              continue;

                          }

                          /*
                           * If the ALL keyword has been used and this is a directory
                           * enter it by setting the APF_DODIR flag.
                           */

                          if (fib->fib_DirEntryType > 0 && all != FALSE)
                            anchorpath->ap_Flags |= APF_DODIR;

                        }

                      } while ((error = MatchNext(anchorpath)) == 0);
                    }

                    MatchEnd(anchorpath);

                    if (error == ERROR_NO_MORE_ENTRIES)
                      error = 0;

                    FreeMem(anchorpath, sizeof(struct AnchorPath) + buffersize);
                  }
                }
              }
              /* Reset windowpointer */
              process->pr_WindowPtr = wptr;
            }
            else
              PrintFault(error, NULL);
            FreeDosObject(DOS_FIB, targetfib);
          }
          FreeMem(targetdir, buffersize);
        }
        FreeMem(sourcedir, StrLen(sourcedir) + 129);
      }
      FreeArgs(readargs);
    }
    else
      error = IoErr();

    SetIoErr(error);
    if (error)
    {
      PrintFault(error, NULL);
      if (error = ERROR_BREAK)
        rc = RETURN_WARN;
      else
        error = RETURN_FAIL;
    }
    CloseLibrary((struct Library *) DOSBase);
  }
  return (rc);
}
Exemple #10
0
LONG
GetPath(UBYTE * path, UBYTE * buffer, LONG buffersize)
{
  UBYTE          *pathpart, *filepart;
  UBYTE          *tmp1, *tmp2;
  BPTR            lock;
  struct FileInfoBlock *fib;
  LONG            error = 0;

  /* Open own copy of dos.library if pragmas are used so it's standalone */
#ifdef PRAGMAS
  struct Library *DOSBase;

  if (!(DOSBase = OpenLibrary("dos.library", 36)))
    return (1);
#endif

  /*
   * If there seems to be no path, the pathpart will point to the filepart too, so we
   * need to check for that.
   */
  filepart = FilePart(path);
  pathpart = PathPart(path);

  /*
   * This also handles cases where there is only a volume/device name, only a
   * directory name or a combo of those.
   */
  if (pathpart == path)
  {

    /*
     * There seems to be only one component. Copy it if it is not wild. Caller will
     * have to check whether if it exists and if it is a file or directory.
     */
    if (!(ItsWild(pathpart)))
      pathpart = NULL;
  }

  if (pathpart != path)
  {

    /*
     * If pathpart equals filepart (pointer wise) then there is only one component
     * (possible preceeded by a volume name).
     */
    if (pathpart == filepart)
    {
      if (!(ItsWild(pathpart)))
        pathpart = NULL;
    }
    else
    {
      /* Try to lock it to determine if the last component is a directory. */
      if (lock = Lock(path, SHARED_LOCK))
      {
        if (fib = AllocMem(sizeof(struct FileInfoBlock), MEMF_CLEAR))
        {
          if ((Examine(lock, fib)) == DOSTRUE)
          {
            /* Hey it's a directory after all */
            if (fib->fib_DirEntryType > 0)
              pathpart = NULL;
          }
          FreeMem(fib, sizeof(struct FileInfoBlock));
        }
        UnLock(lock);
      }                                          /* else treat it as a filename */
    }

    /* Copy the pathpart in the buffer */
    tmp1 = buffer;
    tmp2 = path;
    while ((*tmp1++ = *tmp2++) && (tmp2 != pathpart))
    {
      if (tmp1 == (buffer + buffersize))
      {
        error = ERROR_NO_FREE_STORE;
        break;
      }
    }
    *tmp1 = '\0';                                /* NULL terminate. */
  }

#ifdef PRAGMAS
  CloseLibrary(DOSBase);
#endif
  return (error);
}
Exemple #11
0
BOOL BuildGUI(char *screenname)
{
  Object *MUISave, *MUIUse, *MUICancel;
  Object *page1,*page2;
  Object *MUITFreq,*MUITChannels,*MUITOutvol,*MUITMonvol,*MUITGain,*MUITInput,*MUITOutput,*MUITDebug,*MUITEcho,*MUITSurround,*MUITClipvol,*MUITCpu,*MUITACTime,*MUITScalemode;

  UpdateStrings();

  MUIMasterBase = (void *)OpenLibrary("muimaster.library", MUIMASTER_VLATEST);
  if(MUIMasterBase == NULL)
  {
    Printf((char *) msgTextNoOpen, (ULONG) "muimaster.library", MUIMASTER_VLATEST);
    Printf("\n");
    return FALSE;
  }

#ifdef __AMIGAOS4__
  IMUIMaster = (struct MUIMasterIFace *) GetInterface(MUIMasterBase, "main", 1, NULL);
  if(IMUIMaster == NULL)
  {
    Printf((char *) msgTextNoOpen, (ULONG) "MUIMaster main interface", 1);
    Printf("\n");
    CloseLibrary((struct Library*) MUIMasterBase);
    return FALSE;
  }
#endif
  
  
  page1 = HGroup,
    Child, VGroup,
      Child, MUIUnit = CycleObject,
        MUIA_CycleChain, 1,
        MUIA_Cycle_Entries, Units,
        MUIA_Cycle_Active, state.UnitSelected,
      End,
      Child, ListviewObject,
        MUIA_CycleChain, 1,
        MUIA_Listview_List, MUIList = ListObject,
          InputListFrame,
          MUIA_List_AutoVisible, TRUE,
        End,
      End,
      Child, HGroup,
        ReadListFrame,
        MUIA_Background, MUII_TextBack,
        Child, TextObject,
          MUIA_Text_Contents, msgProperties,
          MUIA_Text_SetMax, TRUE,
        End,
        Child, MUIInfos = TextObject,
          MUIA_Text_Contents, "\n\n\n\n\n\n",
          MUIA_Text_SetMin, FALSE,
        End,
      End,
    End,
    Child, BalanceObject,
    End,
    Child, VGroup,
      Child, HVSpace,
      Child, ColGroup(3),
        GroupFrameT(msgOptions),
        Child, MUITFreq = SpecialButton((STRPTR)msgOptFrequency),
        Child, MUIFreq = SpecialSlider(0,max(state.Frequencies-1,0),state.FreqSelected),
        Child, MUILFreq = SpecialLabel(getFreq()),
        Child, MUITChannels = SpecialButton((STRPTR)msgOptChannels),
        Child, MUIChannels = SpecialSlider(1,state.Channels,state.ChannelsSelected),
        Child, MUILChannels = SpecialLabel(getChannels()),
        Child, MUITOutvol = SpecialButton((STRPTR)msgOptVolume),
        Child, MUIOutvol = SpecialSlider(0,max(state.OutVols-1,0),state.OutVolSelected),
        Child, MUILOutvol = SpecialLabel(getOutVol()),
        Child, MUITMonvol = SpecialButton((STRPTR)msgOptMonitor),
        Child, MUIMonvol = SpecialSlider(0,max(state.MonVols-1,1),state.MonVolSelected),
        Child, MUILMonvol = SpecialLabel(getMonVol()),
        Child, MUITGain = SpecialButton((STRPTR)msgOptGain),
        Child, MUIGain = SpecialSlider(0,max(state.Gains-1,0),state.GainSelected),
        Child, MUILGain = SpecialLabel(getGain()),
        Child, MUITInput = SpecialButton((STRPTR)msgOptInput),
        Child, MUIInput = SpecialSlider(0,max(state.Inputs-1,0),state.InputSelected),
        Child, MUILInput = SpecialLabel(getInput()),
        Child, MUITOutput = SpecialButton((STRPTR)msgOptOutput),
        Child, MUIOutput = SpecialSlider(0,max(state.Outputs-1,0),state.OutputSelected),
        Child, MUILOutput = SpecialLabel(getOutput()),
      End,
      Child, MUIPlay = SimpleButton(msgButtonPlay),
      Child, HVSpace,
    End,
  End;

  page2 = VGroup,
    Child, HVSpace,
    Child, HGroup,
      Child, HVSpace,
      Child, ColGroup(2),
        GroupFrameT(msgGlobalOptions),
        Child, MUITDebug = SpecialButton((STRPTR)msgGlobOptDebugLevel),
        Child, MUIDebug = CycleObject,
          MUIA_CycleChain, 1,
          MUIA_Cycle_Entries, DebugLabels,
          MUIA_Cycle_Active, globalprefs.ahigp_DebugLevel,
        End,
        Child, MUITEcho = SpecialButton((STRPTR)msgGlobOptEcho),
        Child, MUIEcho  = CycleObject,
          MUIA_CycleChain, 1,
          MUIA_Cycle_Entries, EchoLabels,
          MUIA_Cycle_Active, (globalprefs.ahigp_DisableEcho ? 2 : 0) | (globalprefs.ahigp_FastEcho ? 1 : 0),
          MUIA_Disabled, AHIBase->lib_Version >= 5,
        End,
        Child, MUITSurround = SpecialButton((STRPTR)msgGlobOptSurround),
        Child, MUISurround = CycleObject,
          MUIA_CycleChain, 1,
          MUIA_Cycle_Entries, SurroundLabels,
          MUIA_Cycle_Active, globalprefs.ahigp_DisableSurround,
          MUIA_Disabled, AHIBase->lib_Version >= 5,
        End,
        Child, MUITClipvol = SpecialButton((STRPTR)msgGlobOptMasterVol),
        Child, MUIClipvol = CycleObject,
          MUIA_CycleChain, 1,
          MUIA_Cycle_Entries, ClipMVLabels,
          MUIA_Cycle_Active, globalprefs.ahigp_ClipMasterVolume,
          MUIA_Disabled, AHIBase->lib_Version >= 5,
        End,
        Child, MUITCpu = SpecialButton((STRPTR)msgGlobOptCPULimit),
        Child, MUICpu = SliderObject,
          MUIA_CycleChain, 1,
          MUIA_Slider_Horiz, TRUE,
          MUIA_Numeric_Min, 0,
          MUIA_Numeric_Max, 100,
          MUIA_Numeric_Value,(globalprefs.ahigp_MaxCPU * 100 + 32768) / 65536,
          MUIA_Numeric_Format,msgPercentFmt,
        End,
        Child, MUITACTime = SpecialButton((STRPTR)msgGlobOptACTime),
        Child, MUIACTime = SliderObject,
          MUIA_CycleChain, 1,
          MUIA_Slider_Horiz, TRUE,
          MUIA_Numeric_Min, 0,
          MUIA_Numeric_Max, 100,
          MUIA_Numeric_Value,(globalprefs.ahigp_AntiClickTime * 1000 + 32768) >> 16,
          MUIA_Numeric_Format,msgACTimeFmt,
          MUIA_Disabled, AHIBase->lib_Version <= 4,
        End,
        Child, MUITScalemode = SpecialButton((STRPTR)msgOptScalemode),
        Child, MUIScalemode = CycleObject,
          MUIA_CycleChain, 1,
          MUIA_Cycle_Entries, ScaleLabels,
          MUIA_Cycle_Active, globalprefs.ahigp_ScaleMode,
          MUIA_Disabled, AHIBase->lib_Version <= 4,
        End,
      End,
      Child, HVSpace,
    End,
    Child, HVSpace,
  End;

  MUIApp = ApplicationObject,
    MUIA_Application_Title, (char *) msgTextProgramName,
    MUIA_Application_Version, Version,
    MUIA_Application_Copyright, "©1996-2005 Martin Blom",
    MUIA_Application_Author, "Stéphane Barbaray/Martin Blom",
    MUIA_Application_Base, "AHI",
    MUIA_Application_HelpFile, HELPFILE,
    MUIA_Application_Menustrip, MUIMenu = MUI_MakeObject(MUIO_MenustripNM,Menus,0),
    MUIA_Application_SingleTask, TRUE,
    SubWindow, MUIWindow = WindowObject,
      MUIA_Window_Title, (char *) msgTextProgramName,
      MUIA_Window_ID   , MAKE_ID('M','A','I','N'),
      MUIA_HelpNode, "AHI",
      WindowContents, VGroup,
       Child, RegisterGroup(PageNames),
         MUIA_CycleChain, 1,
         Child, page1,
         Child, page2,
       End,
       Child, HGroup,
          Child, MUISave = SimpleButton(msgButtonSave),
          Child, MUIUse = SimpleButton(msgButtonUse),
          Child, MUICancel = SimpleButton(msgButtonCancel),
        End,
      End,
    End,
  End;
  
  if( MUIApp != NULL )
  {
    APTR item = (APTR)DoMethod(MUIMenu,MUIM_FindUData,ACTID_ICONS);
    if(item)
    {
      set(item, MUIA_Menuitem_Checked, SaveIcons);
    }
    DoMethod(MUIWindow, MUIM_MultiSet, MUIA_Text_PreParse,"\033l",MUILFreq,MUILChannels,MUILOutvol,MUILMonvol,MUILGain,MUILInput,MUILOutput,NULL);
    DoMethod(MUIWindow, MUIM_MultiSet, MUIA_CycleChain, 1, MUISave,MUIUse,MUICancel,NULL);

    DoMethod(MUITFreq, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIFreq);
    DoMethod(MUITChannels, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIChannels);
    DoMethod(MUITOutvol, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIOutvol);
    DoMethod(MUITMonvol, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIMonvol);
    DoMethod(MUITGain, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIGain);
    DoMethod(MUITInput, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIInput);
    DoMethod(MUITOutput, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIOutput);
    DoMethod(MUIPlay, MUIM_Notify, MUIA_Pressed, FALSE, MUIApp, 2, MUIM_Application_ReturnID, ACTID_PLAY);
    DoMethod(MUITDebug, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIDebug);
    DoMethod(MUITEcho, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIEcho);
    DoMethod(MUITSurround, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUISurround);
    DoMethod(MUITClipvol, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIClipvol);
    DoMethod(MUITCpu, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUICpu);
    DoMethod(MUITACTime, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIACTime);
    DoMethod(MUITScalemode, MUIM_Notify, MUIA_Pressed, TRUE, MUIWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, MUIScalemode);

    DoMethod(MUIWindow, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIApp, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
    DoMethod(MUISave, MUIM_Notify, MUIA_Pressed, FALSE, MUIApp, 2, MUIM_Application_ReturnID, ACTID_SAVE);
    DoMethod(MUIUse, MUIM_Notify, MUIA_Pressed, FALSE, MUIApp, 2, MUIM_Application_ReturnID, ACTID_USE);
    DoMethod(MUICancel, MUIM_Notify, MUIA_Pressed, FALSE, MUIApp, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
    DoMethod(MUIUnit, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID, ACTID_UNIT);
    DoMethod(MUIList, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID, ACTID_MODE);
    DoMethod(MUIDebug, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID,  ACTID_DEBUG);
    DoMethod(MUISurround, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID,  ACTID_SURROUND);
    DoMethod(MUIEcho, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID,  ACTID_ECHO);
    DoMethod(MUICpu, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID,  ACTID_CPULIMIT);
    DoMethod(MUIClipvol, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID,  ACTID_CLIPMV);
    DoMethod(MUIACTime, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID,  ACTID_ACTIME);
    DoMethod(MUIScalemode, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, MUIApp, 2, MUIM_Application_ReturnID,  ACTID_SCALEMODE);
    DoMethod(MUIFreq, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue);
    DoMethod(MUIChannels, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue);
    DoMethod(MUIOutvol, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue);
    DoMethod(MUIMonvol, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue);
    DoMethod(MUIGain, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue);
    DoMethod(MUIInput, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue);
    DoMethod(MUIOutput, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_CallHook, &hookSlider, MUIV_TriggerValue);
    set(MUIWindow, MUIA_Window_Open, TRUE);
    GUINewUnit();
    return TRUE;
  }
  return FALSE;
}
Exemple #12
0
int search_zorro(char option, BOOL testExpected, char *testValue) {
  BOOL returnCode = FALSE;
  struct ConfigDev *myCD = NULL;

  UWORD m,t;
  UBYTE p;

  char manufacturer[8] = "0";
  char product[8] = "0";
  char type[20] = "Unknown";

  if((ExpansionBase = OpenLibrary("expansion.library", 0L)) == NULL)
    return FALSE;

  while((myCD = FindConfigDev(myCD, -1L, -1L))) { /* search for all ConfigDevs */
    m = myCD->cd_Rom.er_Manufacturer;
    p = myCD->cd_Rom.er_Product;
    t = myCD->cd_Rom.er_Type;

    snprintf(manufacturer, 8, "%ld", m);
    snprintf(product, 8, "%ld", p);
    snprintf(type, 8, "%ld", t);

    if (testExpected) {
      switch ((unsigned int)option) {
        case 'v':
          if (stringTest(manufacturer, testValue)) returnCode = TRUE;
          break;
        case 'p':
          if (stringTest(product, testValue)) returnCode = TRUE;
          break;
        case 't':
          if (stringTest(type, testValue)) returnCode = TRUE;
          break;
        case '1':
        case '2':
        case '3':
          break;
        default:
          error("Invalid option");
          exit(EXIT_ERROR);
          break;
      }
    } else {
      switch ((unsigned int)option) {
        case 'v':
          printf("%s\n", manufacturer);
          break;
        case 'p':
          printf("%s\n", product);
          break;
        case 't':
          printf("%s\n", type);
          break;
        case '1':
          printf("\n");
          break;
        case '2':
          printf("\n");
          break;
        case '3':
          printf("\n");
          break;
        default:
          printf("ZORRO:%s:%s:%s:::\n", manufacturer, product, type);
          break;
      }
    }
  }
  CloseLibrary(ExpansionBase);

  return returnCode;
}