HRESULT CBResourceFile::Open(char* Filename) { Close(); // try game first if(SUCCEEDED(OpenModule(Filename, Game->m_ResourceModule))) return S_OK; // now search plugins for(int i=0; i<Game->m_PluginMgr->m_Plugins.GetSize(); i++) { CBPlugin* Plugin = Game->m_PluginMgr->m_Plugins[i]; if(SUCCEEDED(OpenModule(Filename, Plugin->m_DllHandle))) return S_OK; } return E_FAIL; }
long DICE_CV os2exec_open_component (CORBA_Object _dice_corba_obj, const char* fname /* in */, const l4dm_dataspace_t *img_ds /* in */, unsigned long flags /* in */, unsigned long *hmod /* out */, CORBA_Server_Environment *_dice_corba_env) { char exeflag = flags & OPENFLAG_EXEC; /* Error info from ModLoadModule */ char chLoadError[CCHMAXPATH]; return OpenModule(chLoadError, sizeof(chLoadError), fname, exeflag, hmod); }
unsigned long ModLoadExeModule(char * pszName, unsigned long cbName, char const * pszModname, unsigned long * phmod) { int rc = 0; rc = OpenModule(pszName, cbName, pszModname, 1, phmod); if (rc) return rc; rc = LoadModule(pszName, cbName, phmod); return rc;
long getimp(unsigned long hmod, int *index, unsigned long *imp_hmod) { int rc; int ind = 0; IXFModule *ixf; char **mod; /* Error info from ModLoadModule */ char chLoadError[CCHMAXPATH]; unsigned long hmod2; if (!hmod) return ERROR_INVALID_PARAMETER; ixf = (IXFModule *)hmod; if (ixf->cbModules <= *index) return ERROR_MOD_NOT_FOUND; /* 126 */ for (ind = 0, mod = ixf->Modules; ind < ixf->cbModules; ind++, mod++) if (ind == *index) break; /* open a module to get its handle. If it is already opened, it just returned module handle, not opens it for the next time */ rc = OpenModule(chLoadError, sizeof(chLoadError), *mod, 0, &hmod2); if (rc) return ERROR_MOD_NOT_FOUND; /* 126 */ #if 0 ixf = (IXFModule *)hmod2; /* skip fake DL module */ if (!strcasecmp(ixf->name, "DL")) hmod2 = 0; #endif *imp_hmod = hmod2; ++ *index; return rc; }
bool CModules::GetModPathInfo(CModInfo& ModInfo, const CString& sModule, const CString& sModPath, CString& sRetMsg) { bool bVersionMismatch; ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, ModInfo, sRetMsg); if (!p) return false; ModInfo.SetName(sModule); ModInfo.SetPath(sModPath); if (bVersionMismatch) { ModInfo.SetDescription("--- Version mismatch, recompile this module. ---"); } dlclose(p); return true; }
MagickExport const MagickInfo * GetMagickInfo(const char *name,ExceptionInfo *ARGUNUSED(exception)) { const MagickInfo *magick_info=(const MagickInfo *) NULL; #if defined(SupportMagickModules) if ((name != (const char *) NULL) && (name[0] != '\0')) { LockSemaphoreInfo(module_semaphore); if (name[0] == '*') { /* If all modules are requested, then use OpenModules to load all modules. */ (void) OpenModules(exception); } else { magick_info=GetMagickInfoEntryLocked(name); if (magick_info == (const MagickInfo *) NULL) { /* Try to load a supporting module. */ (void) OpenModule(name,exception); } } UnlockSemaphoreInfo(module_semaphore); } #endif /* #if defined(SupportMagickModules) */ /* Return whatever we've got */ if (magick_info == (const MagickInfo *) NULL) magick_info=GetMagickInfoEntryLocked(name); return magick_info; }
bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg) { sRetMsg = ""; if (FindModule(sModule) != NULL) { sRetMsg = "Module [" + sModule + "] already loaded."; return false; } bool bSuccess; GLOBALMODULECALL(OnModuleLoading(sModule, sArgs, bSuccess, sRetMsg), pUser, NULL, return bSuccess); CString sModPath, sDataPath; CString sDesc; bool bVersionMismatch; bool bIsGlobal; if (!FindModPath(sModule, sModPath, sDataPath)) { sRetMsg = "Unable to find module [" + sModule + "]"; return false; } ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, bIsGlobal, sDesc, sRetMsg); if (!p) return false; if (bVersionMismatch) { dlclose(p); sRetMsg = "Version mismatch, recompile this module."; return false; } if ((pUser == NULL) != bIsGlobal) { dlclose(p); sRetMsg = "Module [" + sModule + "] is "; sRetMsg += (bIsGlobal) ? "" : "not "; sRetMsg += "a global module."; return false; } CModule* pModule = NULL; if (pUser) { typedef CModule* (*fp)(ModHandle, CUser* pUser, const CString& sModName, const CString& sDataPath); fp Load = (fp) dlsym(p, "ZNCModLoad"); if (!Load) { dlclose(p); sRetMsg = "Could not find ZNCModLoad() in module [" + sModule + "]"; return false; } pModule = Load(p, pUser, sModule, sDataPath); } else { typedef CModule* (*fp)(ModHandle, const CString& sModName, const CString& sDataPath); fp Load = (fp) dlsym(p, "ZNCModLoad"); if (!Load) { dlclose(p); sRetMsg = "Could not find ZNCModLoad() in module [" + sModule + "]"; return false; } pModule = Load(p, sModule, sDataPath); } pModule->SetDescription(sDesc); pModule->SetGlobal(bIsGlobal); pModule->SetArgs(sArgs); pModule->SetModPath(CDir::ChangeDir(CZNC::Get().GetCurPath(), sModPath)); push_back(pModule); bool bLoaded; try { bLoaded = pModule->OnLoad(sArgs, sRetMsg); } catch (CModule::EModException) { bLoaded = false; sRetMsg = "Caught an exception"; } if (!bLoaded) { UnloadModule(sModule, sModPath); if (!sRetMsg.empty()) sRetMsg = "Module [" + sModule + "] aborted: " + sRetMsg; else sRetMsg = "Module [" + sModule + "] aborted."; return false; } if (!sRetMsg.empty()) { sRetMsg = "Loaded module [" + sModule + "] [" + sRetMsg + "] [" + sModPath + "]"; } else { sRetMsg = "Loaded module [" + sModule + "] [" + sModPath + "]"; } return true; }
bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg, bool bFake) { sRetMsg = ""; if (FindModule(sModule) != NULL) { sRetMsg = "Module [" + sModule + "] already loaded."; return false; } if (bFake) { CModule* pModule = new CModule(NULL, sModule, ""); pModule->SetArgs(sArgs); pModule->SetDescription("<<Fake Module>>"); pModule->SetFake(true); push_back(pModule); sRetMsg = "Loaded fake module [" + sModule + "]"; return true; } CString sModPath, sDataPath; CString sDesc; bool bVersionMismatch; bool bIsGlobal; if (!FindModPath(sModule, sModPath, sDataPath)) { sRetMsg = "Unable to find module [" + sModule + "]"; return false; } ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, bIsGlobal, sDesc, sRetMsg); if (!p) return false; if (bVersionMismatch) { dlclose(p); return false; } if ((pUser == NULL) != bIsGlobal) { dlclose(p); sRetMsg = "Module [" + sModule + "] is "; sRetMsg += (bIsGlobal) ? "" : "not "; sRetMsg += "a global module."; return false; } CModule* pModule = NULL; if (pUser) { typedef CModule* (*fp)(ModHandle, CUser* pUser, const CString& sModName, const CString& sDataPath); fp Load = (fp) dlsym(p, "ZNCModLoad"); if (!Load) { dlclose(p); sRetMsg = "Could not find ZNCModLoad() in module [" + sModule + "]"; return false; } pModule = Load(p, pUser, sModule, sDataPath); } else { typedef CModule* (*fp)(ModHandle, const CString& sModName, const CString& sDataPath); fp Load = (fp) dlsym(p, "ZNCModLoad"); if (!Load) { dlclose(p); sRetMsg = "Could not find ZNCModLoad() in module [" + sModule + "]"; return false; } pModule = Load(p, sModule, sDataPath); } pModule->SetDescription(sDesc); pModule->SetGlobal(bIsGlobal); pModule->SetArgs(sArgs); push_back(pModule); bool bLoaded; try { bLoaded = pModule->OnLoad(sArgs, sRetMsg); } catch (CModule::EModException) { bLoaded = false; sRetMsg = "Caught an exception"; } if (!bLoaded) { UnloadModule(sModule, sModPath); if (!sRetMsg.empty()) sRetMsg = "Module [" + sModule + "] aborted: " + sRetMsg; else sRetMsg = "Module [" + sModule + "] aborted."; return false; } if (!sRetMsg.empty()) { sRetMsg = "Loaded module [" + sModule + "] [" + sRetMsg + "] [" + sModPath + "]"; } else { sRetMsg = "Loaded module [" + sModule + "] [" + sModPath + "]"; } return true; }
bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg) { sRetMsg = ""; if (FindModule(sModule) != NULL) { sRetMsg = "Module [" + sModule + "] already loaded."; return false; } bool bSuccess; GLOBALMODULECALL(OnModuleLoading(sModule, sArgs, bSuccess, sRetMsg), pUser, NULL, return bSuccess); CString sModPath, sDataPath; bool bVersionMismatch; CModInfo Info; if (!FindModPath(sModule, sModPath, sDataPath)) { sRetMsg = "Unable to find module [" + sModule + "]"; return false; } ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, Info, sRetMsg); if (!p) return false; if (bVersionMismatch) { dlclose(p); sRetMsg = "Version mismatch, recompile this module."; return false; } if ((pUser == NULL) != Info.IsGlobal()) { dlclose(p); sRetMsg = "Module [" + sModule + "] is "; sRetMsg += Info.IsGlobal() ? "" : "not "; sRetMsg += "a global module."; return false; } CModule* pModule = NULL; if (pUser) { pModule = Info.GetLoader()(p, pUser, sModule, sDataPath); } else { pModule = Info.GetGlobalLoader()(p, sModule, sDataPath); } pModule->SetDescription(Info.GetDescription()); pModule->SetGlobal(Info.IsGlobal()); pModule->SetArgs(sArgs); pModule->SetModPath(CDir::ChangeDir(CZNC::Get().GetCurPath(), sModPath)); push_back(pModule); bool bLoaded; try { bLoaded = pModule->OnLoad(sArgs, sRetMsg); } catch (CModule::EModException) { bLoaded = false; sRetMsg = "Caught an exception"; } if (!bLoaded) { UnloadModule(sModule, sModPath); if (!sRetMsg.empty()) sRetMsg = "Module [" + sModule + "] aborted: " + sRetMsg; else sRetMsg = "Module [" + sModule + "] aborted."; return false; } if (!sRetMsg.empty()) { sRetMsg += "[" + sRetMsg + "] "; } sRetMsg += "[" + sModPath + "]"; return true; }
bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CModInfo::EModuleType eType, CUser* pUser, CIRCNetwork *pNetwork, CString& sRetMsg) { sRetMsg = ""; if (FindModule(sModule) != NULL) { sRetMsg = "Module [" + sModule + "] already loaded."; return false; } bool bSuccess; _GLOBALMODULECALL(OnModuleLoading(sModule, sArgs, eType, bSuccess, sRetMsg), pUser, pNetwork, NULL, return bSuccess); CString sModPath, sDataPath; bool bVersionMismatch; CModInfo Info; if (!FindModPath(sModule, sModPath, sDataPath)) { sRetMsg = "Unable to find module [" + sModule + "]"; return false; } ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, Info, sRetMsg); if (!p) return false; if (bVersionMismatch) { dlclose(p); sRetMsg = "Version mismatch, recompile this module."; return false; } if (!Info.SupportsType(eType)) { dlclose(p); sRetMsg = "Module [" + sModule + "] does not support module type [" + CModInfo::ModuleTypeToString(eType) + "]."; return false; } if (!pUser && eType == CModInfo::UserModule) { dlclose(p); sRetMsg = "Module [" + sModule + "] requires a user."; return false; } if (!pNetwork && eType == CModInfo::NetworkModule) { dlclose(p); sRetMsg = "Module [" + sModule + "] requires a network."; return false; } CModule* pModule = Info.GetLoader()(p, pUser, pNetwork, sModule, sDataPath); pModule->SetDescription(Info.GetDescription()); pModule->SetType(eType); pModule->SetArgs(sArgs); pModule->SetModPath(CDir::ChangeDir(CZNC::Get().GetCurPath(), sModPath)); push_back(pModule); bool bLoaded; try { bLoaded = pModule->OnLoad(sArgs, sRetMsg); } catch (CModule::EModException) { bLoaded = false; sRetMsg = "Caught an exception"; } if (!bLoaded) { UnloadModule(sModule, sModPath); if (!sRetMsg.empty()) sRetMsg = "Module [" + sModule + "] aborted: " + sRetMsg; else sRetMsg = "Module [" + sModule + "] aborted."; return false; } if (!sRetMsg.empty()) { sRetMsg += "[" + sRetMsg + "] "; } sRetMsg += "[" + sModPath + "]"; return true; }
unsigned long LoadModule(char * pszName, unsigned long cbName, unsigned long * phmod) { struct module_rec * new_module_el; UCHAR chLoadError[CCHMAXPATH]; /* Error info from ModLoadModule */ unsigned long rc=NO_ERROR; IXFModule *ixfModule = *phmod; void *addr = ixfModule->addr; unsigned long size = ixfModule->size; void *ptr_mod; unsigned long module_counter; unsigned long imports_counter; unsigned long hmod; int relative_jmp; char *pszModname; char exeflag; struct module_rec *prev; pszModname = ixfModule->name; exeflag = ixfModule->exec; char *mname = get_fname(pszModname); int t; t = getrec(mname, &prev); if (!strcasecmp(mname, "SUB32")) t = getrec("EMXWRAP", &prev); LOG("%s", mname); if (!t) { if (!*phmod) return 6; /* ERROR_INVALID_HANDLE */ if (!exeflag) { LOG("already loaded, dll"); *phmod = (unsigned long)prev->module_struct; return 0; } else { /* get the last instance */ while (prev->up) prev = prev->up; LOG("already loaded, exe"); *phmod = (unsigned long)prev->module_struct; prev->load_status = DONE_LOADING; return 0; } } if ((t == 1) || (!t && prev->load_status != DONE_LOADING)); { // not loaded // Load module rc=IXFLoadModule(addr, size, ixfModule); if (rc) { strcpy(pszName, pszModname); *phmod=NULL; free(ixfModule); LOG("0"); return rc; } } // Display module entry table if (options.debugixfmgr) { unsigned long entries_counter; LOG("Module entry table"); LOG("------------------"); for (entries_counter=1; entries_counter<ixfModule->cbEntries+1; entries_counter++) { if (ixfModule->Entries[entries_counter-1].ModuleName) { LOG("%s.%d", ixfModule->Entries[entries_counter-1].ModuleName, ixfModule->Entries[entries_counter-1].Ordinal); } else { LOG("%x", ixfModule->Entries[entries_counter-1].Address); } } } if (!strcasecmp(mname, "SUB32")) mname = "EMXWRAP"; LOG("mname=%s", mname); LOG("exeflag=%d", exeflag); // Register in module list // @todo extract filename only because can be fullname with path new_module_el = ModRegister(mname, ixfModule, exeflag); new_module_el->load_status = LOADING; // Load modules which not loaded yet for (module_counter=1; module_counter<ixfModule->cbModules+1; module_counter++) { char name[1024];//=malloc(strlen(ixfModule->Modules[module_counter-1]+5)); strcpy(name, ixfModule->Modules[module_counter-1]); strcat(name, ".dll"); /* if module is not loaded, then load it */ if (t = getrec(ixfModule->Modules[module_counter-1], &prev)) { LOG("opening %s", name); rc = OpenModule(chLoadError, sizeof(chLoadError), name, 0, (unsigned long *)&hmod); if (!rc) LOG("open successful"); if (rc) { LOG("Error opening module: %s", name); return rc; } LOG("loading %s", name); rc = LoadModule(chLoadError, sizeof(chLoadError), (unsigned long *)&hmod); if (!rc) LOG("load successful"); if (rc) { LOG("Error loading module: %s", name); return rc; } } // Fixup module if (!exeflag) { #if 1 rc=IXFFixupModule(ixfModule); if (rc) { LOG("IXFFixupModule: rc=%u", rc); strcpy(pszName, pszModname); *phmod=NULL; free(ixfModule); return rc; } else { /* if (!strcmp(pszModname, "KAL")) { IXFMODULEENTRY *e; char *name; int ord; APIRET APIENTRY (*func) (); e = ixfModule->Entries; ord = e->Ordinal; name = e->FunctionName; if (!strcmp(name, "KalInit") && ord == 1) { func = e->Address; func(entry_Table); io_printf("KalInit() found and called @ 0x%x\n", func); } else { io_printf("No KalInit.1 function in KAL.dll, fatal!"); rc = ERROR_INVALID_FUNCTION; } } */ } #endif //if (t) //{ //LOG("000"); //ModLinkModule(&hmod, phmod); //} } } // Fixup module LOG("111"); if (exeflag) { LOG("222"); rc = IXFFixupModule(ixfModule); if (rc!=0/*NO_ERROR*/) { LOG("LoadModule: Error %s module fixup", pszModname); LOG("3"); return rc; } } LOG("333"); ModLinkModule(ixfModule, phmod); //@todo use handle table *phmod=(unsigned long)ixfModule; new_module_el->load_status = DONE_LOADING; LOG("4"); return rc; /*NO_ERROR;*/
function_internal_command( CommandList *command, char *args, FunctionHandle *handle, InstructionParsed *instruction) { short ret=1; Lister *lister; DirBuffer *cust_buffer=0; Lister *source_lister=0,*dest_lister=0; char custom_port[40]; PathNode *source_n=0,*dest_n=0; // Clear instruction flags if (handle) handle->instruction_flags=0; // Valid command? if (!command || !command->name) return 1; // Initialise custom port custom_port[0]=0; // Got a handle? if (handle) { // Get source and dest nodes source_n=function_path_current(&handle->source_paths); dest_n=function_path_current(&handle->dest_paths); // Get current source lister if (lister=function_lister_current(&handle->source_paths)) { // Custom handler installed? if (lister->cur_buffer->buf_CustomHandler[0]) { // If there's a NEW flag, we won't be using this lister if (instruction && !instruction->new_arg) { // Look for trap handler if (FindFunctionTrap(command->name,lister->cur_buffer->buf_CustomHandler,custom_port)) { source_lister=lister; dest_lister=function_lister_current(&handle->dest_paths); cust_buffer=lister->cur_buffer; } } } } // If no custom handler, try destination if (!cust_buffer && (command->flags&FUNCF_NEED_DEST) && (lister=function_lister_current(&handle->dest_paths))) { // Custom handler installed? if (lister->cur_buffer->buf_CustomHandler[0]) { // Look for trap handler if (FindFunctionTrap(command->name,lister->cur_buffer->buf_CustomHandler,custom_port)) { source_lister=function_lister_current(&handle->source_paths); dest_lister=lister; cust_buffer=lister->cur_buffer; } } } } // Custom handler? if (cust_buffer) { char *files=0; ULONG flags; // Need files? if (command->flags&FUNCF_NEED_ENTRIES) { // Build file string files=function_build_file_string( handle, cust_buffer->cust_flags&CUSTF_WANT_QUOTES); } // Get flags flags=RXMF_WARN; if (cust_buffer->cust_flags&CUSTF_SYNCTRAPS) flags|=RXMF_SYNC; // Send command message ret=rexx_handler_msg( custom_port, cust_buffer, flags, HA_String,0,command->name, HA_Value,1,source_lister, HA_String,2,files, HA_Value,3,dest_lister, HA_String,4,(source_n)?source_n->path:0, HA_String,5,args, HA_String,7,(dest_n)?dest_n->path:0, HA_Value,8,(flags&RXMF_SYNC)?handle:0, TAG_END); // Free file string FreeVec(files); return ret; } // External command? if (command->flags&FUNCF_EXTERNAL_FUNCTION) { struct Library *ModuleBase; char *work_buf=0,*buffer; // Need to allocate buffer? if (!handle) { work_buf=AllocVec(512,MEMF_CLEAR); buffer=work_buf; } else buffer=handle->work_buffer; // No buffer? if (!buffer || strcmp(command->stuff.module_name,"!")==0) { } // User command? else if (strnicmp(command->stuff.module_name,"dopus5:commands/",16)==0) { // Shouldn't be able to get here! } // Rexx script? else if (sufcmp(command->stuff.module_name,".dopus5")) { // Get rexx function to run lsprintf(buffer, "dopus5:modules/%s %s %s %ld %ld %s", command->stuff.module_name, GUI->rexx_port_name, command->name, (source_n)?source_n->lister:0, (dest_n)?dest_n->lister:0, args); // Run rexx thing rexx_send_command(buffer,TRUE); } // Open module else if (ModuleBase=OpenModule(command->stuff.module_name)) { // Copy arguments strcpy(buffer,args); // Add a newline if (*buffer) strcat(buffer,"\n"); // Call module ret=Module_Entry( (command->flags&FUNCF_NO_ARGS)?0:(struct List *)buffer, GUI->screen_pointer, (handle)?handle->ipc:0, &main_ipc, command->function, (ULONG)function_external_hook); // Close module CloseLibrary(ModuleBase); } // Free buffer FreeVec(work_buf); } // Valid code? else if (command->stuff.code) ret=(int)((int (*)())(command->stuff.code)(command,handle,args,instruction)); return ret; }
// 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); }