static void OpenFileAction (Widget w, XEvent *xev, String *s, Cardinal *c) { if (current_file_name[0]) strcpy (fileBuf, current_file_name); else fileBuf[0] = '\0'; MakePrompt (toplevel, "File to open:", NewFile, fileBuf); }
static void SelectPageAction (Widget widget, XEvent *event, String *params, Cardinal *num_params) { widget = widget; /* unused; suppress compiler warning */ event = event; params = params; num_params = num_params; MakePrompt (toplevel, "Page number", SelectPageNumber, ""); }
static void SetResolutionAction (Widget w, XEvent *xev, String *s, Cardinal *c) { Arg args[1]; int cur; XtSetArg (args[0], XtNscreenResolution, &cur); XtGetValues (dvi, args, 1); sprintf (resolutionBuf, "%d", cur); MakePrompt (toplevel, "Screen resolution:", NewResolution, resolutionBuf); }
static void OpenFileAction (Widget widget, XEvent *event, String *params, Cardinal *num_params) { widget = widget; /* unused; suppress compiler warning */ event = event; params = params; num_params = num_params; if (current_file_name[0]) strcpy (fileBuf, current_file_name); else fileBuf[0] = '\0'; MakePrompt (toplevel, "File to open:", NewFile, fileBuf); }
static void PrintAction (Widget widget, XEvent *event, String *params, Cardinal *num_params) { widget = widget; /* unused; suppress compiler warning */ event = event; params = params; num_params = num_params; if (current_print_command[0]) strcpy (fileBuf, current_print_command); else fileBuf[0] = '\0'; MakePrompt (toplevel, "Print command:", DoPrint, fileBuf); }
void CommandShell(void) { int tUsed, bUsed; ArgvInfo ai; char prompt[64]; char *lineRead; #if defined(WIN32) || defined(_WINDOWS) #else int sj; #endif time_t cmdStart, cmdStop; /* Execution may jump back to this point to restart the shell. */ #if defined(WIN32) || defined(_WINDOWS) #elif defined(HAVE_SIGSETJMP) sj = sigsetjmp(gBackToTopJmp, 1); #else /* HAVE_SIGSETJMP */ sj = setjmp(gBackToTopJmp); #endif /* HAVE_SIGSETJMP */ #if defined(WIN32) || defined(_WINDOWS) #else if (sj != 0) { Trace(0, "Caught signal %d, back at top.\n", gGotSig); if (gGotSig == SIGALRM) { (void) printf("\nRemote host was not responding, closing down the session."); FTPShutdownHost(&gConn); } else{ (void) printf("\nInterrupted.\n"); if (gCancelCtrl != 0) { gCancelCtrl = 0; (void) printf("Closing down the current FTP session: "); FTPShutdownHost(&gConn); (void) sleep(1); (void) printf("done.\n"); } } } gMayBackToTopJmp = 1; #endif ++gEventNumber; while (gDoneApplication == 0) { #if defined(WIN32) || defined(_WINDOWS) #else (void) NcSignal(SIGINT, BackToTop); (void) NcSignal(SIGPIPE, BackToTop); (void) NcSignal(SIGALRM, BackToTop); #endif MakePrompt(prompt, sizeof(prompt)); if (gConn.connected == 0) { SetXtermTitle("DEFAULT"); } else { SetXtermTitle("%s - NcFTP", gConn.host); } lineRead = Readline(prompt); if (lineRead == NULL) { /* EOF, Control-D */ (void) printf("\n"); break; } Trace(0, "> %s\n", lineRead); AddHistory(lineRead); for (tUsed = 0;;) { (void) memset(&ai, 0, sizeof(ai)); bUsed = MakeArgv(lineRead + tUsed, &ai.cargc, ai.cargv, (int) (sizeof(ai.cargv) / sizeof(char *)), ai.argbuf, sizeof(ai.argbuf), ai.noglobargv, 0); if (bUsed <= 0) break; tUsed += bUsed; if (ai.cargc == 0) continue; gRunningCommand = 1; (void) time(&cmdStart); if (DoCommand(&ai) < 0) { (void) time(&cmdStop); gRunningCommand = 0; break; } (void) time(&cmdStop); gRunningCommand = 0; if ((cmdStop - cmdStart) > kBeepAfterCmdTime) { /* Let the user know that a time-consuming * operation has completed. */ #if defined(WIN32) || defined(_WINDOWS) MessageBeep(MB_OK); #else (void) fprintf(stderr, "\007"); #endif } ++gEventNumber; } free(lineRead); } CloseHost(); gMayBackToTopJmp = 0; } /* Shell */