// Get search data static int search_get_data( FunctionHandle *handle, SearchData *data) { NewConfigWindow new_win; struct Window *window; ObjectList *objlist; Lister *lister; short cancel=1; // Fill out new window if ((lister=function_lister_current(&handle->source_paths))) { new_win.parent=lister->window; new_win.flags=0; } else { new_win.parent=GUI->screen_pointer; new_win.flags=WINDOW_SCREEN_PARENT; } new_win.dims=&search_window; new_win.title=GetString(&locale,MSG_ENTER_SEARCH_STRING); new_win.locale=&locale; new_win.port=0; new_win.flags|=WINDOW_NO_CLOSE|WINDOW_VISITOR|WINDOW_AUTO_KEYS|WINDOW_REQ_FILL; new_win.font=0; // Open window if (!(window=OpenConfigWindow(&new_win)) || !(objlist=AddObjectList(window,search_objects))) { CloseConfigWindow(window); return 0; } // Initial settings SetGadgetValue(objlist,GAD_SEARCH_TEXT,(ULONG)data->search_text); SetGadgetValue(objlist,GAD_SEARCH_CASE,data->search_flags&SEARCH_NOCASE); SetGadgetValue(objlist,GAD_SEARCH_WILD,data->search_flags&SEARCH_WILDCARD); SetGadgetValue(objlist,GAD_SEARCH_ONLYWORD,data->search_flags&SEARCH_ONLYWORDS); SetGadgetValue(objlist,GAD_SEARCH_RESULT,data->search_result); // Activate text field ActivateStrGad(GADGET(GetObject(objlist,GAD_SEARCH_TEXT)),window); // Event loop FOREVER { struct IntuiMessage *msg; BOOL break_flag=0; // Check for abort if (function_check_abort(handle)) break; // Activate? if (handle->flags2&FUNCF_ACTIVATE_ME) { ActivateWindow(window); WindowToFront(window); handle->flags2&=~FUNCF_ACTIVATE_ME; } // Any Intuition messages? while ((msg=GetWindowMsg(window->UserPort))) { struct IntuiMessage copy_msg; // Copy message and reply copy_msg=*msg; ReplyWindowMsg(msg); // Gadget? if (copy_msg.Class==IDCMP_GADGETUP) { UWORD gadgetid; // Get gadget id gadgetid=((struct Gadget *)copy_msg.IAddress)->GadgetID; // Look at gadget ID switch (gadgetid) { // Okay case GAD_SEARCH_TEXT: case GAD_SEARCH_OKAY: // Store flags data->search_flags=0; if (GetGadgetValue(objlist,GAD_SEARCH_CASE)) data->search_flags|=SEARCH_NOCASE; if (GetGadgetValue(objlist,GAD_SEARCH_WILD)) data->search_flags|=SEARCH_WILDCARD; if (GetGadgetValue(objlist,GAD_SEARCH_ONLYWORD)) data->search_flags|=SEARCH_ONLYWORDS; data->search_result=GetGadgetValue(objlist,GAD_SEARCH_RESULT); // Get search text strcpy(data->search_text,(char *)GetGadgetValue(objlist,GAD_SEARCH_TEXT)); cancel=0; // Cancel case GAD_SEARCH_CANCEL: break_flag=1; break; } } } // Check break flag if (break_flag) break; // Wait for an event Wait(1<<window->UserPort->mp_SigBit|1<<handle->ipc->command_port->mp_SigBit); } // Close window CloseConfigWindow(window); // Return return !cancel; }
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; }