int h_sh_mainmenu(request_rec* r, session* sid) { sh_start(r); sh_form_shrs(r, "The Software Hardware Request System", 96, 0, NULL, "center"); sh_formaction_submit_button(r, 1, 1, "Submit", A_NEW_REQUEST_PAGE_1); sh_formaction_submit_button(r, 2, 1, "Process", A_RECORD_REQUEST); sh_formaction_submit_button(r, 3, 1, "Summary", A_SUMMARY); sh_formaction_submit_button(r, 4, 1, "Reports", A_REPORT); sh_formaction_submit_button(r, 5, 1, "Admin", A_ADMIN); sh_formaction_submit_button(r, 6, 1, "Password", A_CHG_PWD); sh_formaction_submit_button(r, 7, 1, "Logout", A_LOGOUT); sh_row_space(r); sh_end_shrs(r, sid->key, 0, 0); return OK; }
int main(int argc, char **argv) { char name[MSG_SIZE] = ""; char msg[MSG_SIZE+100] = "", msgtmp[MSG_SIZE + 100] = ""; strcpy(name, argv[1]); /* Extract pipe descriptors and name from argv */ int readEnd = atoi(argv[2]), writeEnd = atoi(argv[3]); is_server = atoi(argv[4]); //printf("Name: %s, readend: %d, writeEnd: %d, is_server: %d\n", name,readEnd,writeEnd,is_server); /* Fork a child to read from the pipe continuously */ pid_t pid = fork(); if (pid > 0) { //Send the child's pid to the server for later cleanup strcpy(msg,CMD_CHILD_PID); sprintf(msgtmp, " %d", pid); strcat(msg,msgtmp); write(writeEnd,msg,MSG_SIZE); //Start the main shell loop sh_start(name,writeEnd); } else { // Set non-block for reading int flags = fcntl(readEnd, F_GETFL, 0); fcntl(readEnd, F_SETFL, flags | O_NONBLOCK); // Look for new data from server every 1000 usecs and print it while (1) { usleep(1000); int read_size = 0; int checked = 0; while((read_size = read(readEnd,msg,MSG_SIZE)) > 0) { fprintf(stdout, "\n%s\n", msg); fflush(stdout); checked = 1; } if (checked) { checked = 0; print_prompt(name); } } } return 0; }
int h_sh_admin(request_rec *r, session* sid) { sh_start(r); sh_form_shrs(r, "Administration", 84, 0, NULL, "right"); sh_button(r, 1, 1, "Close", "document.forms['cancel'].submit();"); sh_row_space(r); sh_fcell(r, 1); sh_formaction_submit_button(r, 0, 0 , "System", A_SYS_USERS); sh_ncell(r, 1); sh_formaction_submit_button(r, 0, 0 , "Components", A_COMP); sh_ncell(r, 1); sh_formaction_submit_button(r, 0, 0 , "Products", A_PRODUCT); sh_ncell(r, 1); sh_formaction_submit_button(r, 0, 0 , "Platforms", A_PLATFORM); sh_next_row(r); sh_fcell(r, 1); sh_formaction_submit_button(r, 0, 0 , "Users", A_USER); sh_ncell(r, 1); sh_formaction_submit_button(r, 0, 0 , "Comp Types", A_SELECT_COMP_TYPE); sh_ncell(r, 1); sh_formaction_submit_button(r, 0, 0 , "PAM Releases", A_SELECT_PAM_RELEASE); sh_ncell(r, 1); sh_formaction_submit_button(r, 0, 0 , "Request Types", A_REQUEST_TYPE); sh_ncell(r, 3); ap_rputs(" ", r); sh_next_row(r); sh_fcell(r, 1); sh_formaction_submit_button(r, 0, 0 , "Originators", A_ORIGINATOR); sh_ncell(r, 1); sh_formaction_submit_button(r, 0, 0 , "Comp Revisions", A_SELECT_COMP_REV); sh_ncell(r, 1); sh_formaction_submit_button(r, 0, 0 , "Marketing Revs", A_SELECT_MARKETING_REV); sh_ncell(r, 3); sh_formaction_submit_button(r, 0, 0 , "Resolutions", A_RESOLUTION); sh_next_row(r); sh_fcell(r, 1); ap_rputs(" ", r); sh_ncell(r, 1); ap_rputs(" ", r); sh_ncell(r, 1); ap_rputs(" ", r); sh_ncell(r, 3); sh_formaction_submit_button(r, 0, 0, "Finding Activities", A_FINDING_ACT); sh_row_div(r, ""); sh_end_shrs(r, sid->key, 0, A_MAIN); return OK; }