void GUI::process_key(int key_id,int type) { if(m_screen_lock) return; if(m_trigger_any_key) { receive_gui_events.receive_gui_event("KEYPRESS","any"); m_trigger_any_key=false; } if(m_sleeping) return; if((key_id == KEY_HELP) && (type == KEY_RELEASED) && (!m_displaying_help)) { if(screens_layout[current_screen].help_screen != 255) show_help_screen(screens_layout[current_screen].help_screen); } if((key_id == KEY_UP) && (type == KEY_PRESSED)) { process_key_up(); m_repeating=true; m_repeat_key = KEY_UP; } if((key_id == KEY_DOWN) && (type == KEY_PRESSED)) { process_key_down(); m_repeating=true; m_repeat_key = KEY_DOWN; } if((key_id == KEY_DOWN) && (type == KEY_RELEASED)) { // if(!m_repeated) process_key_down(); m_repeating=false; m_repeated =false; } if((key_id == KEY_UP) && (type == KEY_RELEASED)) { // if(!m_repeated) process_key_up(); m_repeating=false; m_repeated =false; } if((key_id == KEY_SELECT) && (type == KEY_RELEASED)) { // if a VARNUM is selected... if(screens_layout[current_screen].items[selected_item].type == ITEM_TYPE_VARNUM) { if(selected_item != 0) { if((selected_item+1) < screens_layout[current_screen].item_count) { last_selected_item = selected_item; selected_item++; return; } } } if(screens_layout[current_screen].items[selected_item].type == ITEM_TYPE_MENU) { if(screens_layout[current_screen].items[selected_item].val1 != INVALID_SCREEN) { if(clear_next_render == false) { clear_next_render = true; first_render=true; clear_screen_screen = current_screen; clear_screen_selected = selected_item; } push_stack(current_screen,selected_item); current_screen = screens_layout[current_screen].items[selected_item].val1; last_selected_item = 1; selected_item = 1; } } else if(screens_layout[current_screen].items[selected_item].type == ITEM_TYPE_MENU_ACTION) { receive_gui_events.receive_gui_event(screens_layout[current_screen].items[selected_item].text,"select"); } } if((key_id == KEY_BACK) && (type == KEY_RELEASED)) { // if a varnum is selected if(screens_layout[current_screen].items[selected_item].type == ITEM_TYPE_VARNUM) { if(selected_item != 0) { if((selected_item-1) >= 0) { if(screens_layout[current_screen].items[selected_item-1].type == ITEM_TYPE_VARNUM) { last_selected_item = selected_item; selected_item--; receive_gui_events.receive_gui_event("varnumchange",screens_layout[current_screen].items[selected_item].text); return; } } } } if((current_screen != 0) && (!clear_next_render)) { if(selected_stack_size !=0) { clear_next_render = true; first_render=true; clear_screen_screen = current_screen; clear_screen_selected = selected_item; leave_screen_actions(current_screen); pop_stack(current_screen,selected_item); } } } if((key_id == KEY_HOME) && (type == KEY_RELEASED) && (!clear_next_render)) { if(current_screen != 0) { clear_next_render = true; first_render=true; clear_screen_screen = current_screen; clear_screen_selected = selected_item; leave_screen_actions(current_screen); clear_stack(); current_screen = 0; last_selected_item = 1; selected_item = 1; } } }
/* --------------------------------------------------- * M A I N L I N E * Check the parms are OK * Check the job database file indicated is OK * Run the report/function required --------------------------------------------------- */ int main(int argc, char **argv) { char directory_name[MAX_DIR_LEN+1]; char job_database_name[MAX_CHAR_LEN+1]; int utility_command = 0; /* 1 = report, 2 = sort */ int i, num_records; char *ptr; /* Must have the parms we need */ if (argc < 2) { show_help_screen(); exit (1); } /* This is also used by utils */ msg_log_handle = stdout; /* Get all the parms from the command line */ utility_command = 0; /* ensure it is 0 (not set) */ strcpy( job_database_name, "" ); /* ensure it is not set */ i = 1; while (i < argc) { if (memcmp(argv[i], "-d", 2) == 0) { /* directory flag */ i++; /* Get the directory, and ensure it has a trailing / on it */ strncpy( directory_name, argv[i], MAX_DIR_LEN ); ptr = (char *)&directory_name; ptr = ptr + (strlen(directory_name) - 1); if (*ptr != '/') { strcat( directory_name, "/" ); } snprintf( job_database_name, MAX_CHAR_LEN, "%sjob_details.dbs", directory_name ); i++; } else if (memcmp(argv[i], "-c", 2) == 0) { /* command flag */ i++; /* What was the command */ if (memcmp(argv[i], "execreport", 10) == 0) { /* run exectime sorted report */ utility_command = 1; } else if (memcmp(argv[i], "sortdbs", 7) == 0) { /* sort database */ utility_command = 2; } else if (memcmp(argv[i], "deletelist", 10) == 0) { /* show recs pending delete */ utility_command = 3; } else if (memcmp(argv[i], "namereport", 10) == 0) { /* run jobname sorted report */ utility_command = 4; } else if (memcmp(argv[i], "resyncdbs", 9) == 0) { /* resync times in job dbs */ utility_command = 5; } else { /* illegal cmd, show help */ show_help_screen(); exit (1); } i++; } else { /* illegal flag, show help */ show_help_screen(); exit (1); } } /* we must have a command and a job database name */ if ((utility_command == 0) || (strlen(job_database_name) == 0)) { show_help_screen(); exit (1); } /* The job file must be legal */ if ((num_records = check_job_file( job_database_name )) == 0) { exit (1); } /* Execute the required commands */ if (utility_command == 1) { produce_execorder_report( (char *)&job_database_name, num_records ); } else if (utility_command == 2) { sort_the_job_datafile( (char *)&job_database_name, num_records ); } else if (utility_command == 3) { produce_deleted_jobs_report( (char *)&job_database_name ); } else if (utility_command == 4) { produce_jobname_report( (char *)&job_database_name, num_records ); } else if (utility_command == 5) { resync_the_job_datafile( (char *)&job_database_name, num_records ); } else { show_help_screen(); } exit( 0 ); } /* end main */