X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/5652b7a9aadb19380c4b99a3813ff70f611d6234..c7e6f1bd9a4bfe8db29c31fc3baafcdeb50c87d3:/clients/moira/menu.c diff --git a/clients/moira/menu.c b/clients/moira/menu.c index e171f544..4c15bb01 100644 --- a/clients/moira/menu.c +++ b/clients/moira/menu.c @@ -19,7 +19,20 @@ #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif + +#ifdef _WIN32 +#include +#include +#include +#ifdef getchar +#undef getchar +#endif +#define getchar() _getch() +#define getpid _getpid +#endif /* _WIN32 */ RCSID("$Header$"); @@ -457,11 +470,11 @@ void refresh_screen(void) /* Prompt the user for input in the input window of cur_ms */ int Prompt_input(char *prompt, char *buf, int buflen) { +#ifdef HAVE_CURSES int c; char *p; int y, x, oldx, oldy; -#ifdef HAVE_CURSES if (cur_ms != NULLMS) { more_flg = 1; @@ -641,9 +654,6 @@ void Put_message(char *msg) /* Will be truncated to COLS characters. */ void Put_line(char *msg) { - int y, x, i; - char *msg1, chr; - if (!more_flg) return; @@ -655,6 +665,9 @@ void Put_line(char *msg) #ifdef HAVE_CURSES if (cur_ms != NULLMS) { + int x, y; + char chr; + wstandout(cur_ms->ms_input); wprintw(cur_ms->ms_input, "---More---"); wstandend(cur_ms->ms_input); @@ -684,6 +697,9 @@ void Put_line(char *msg) #ifdef HAVE_CURSES if (cur_ms != NULLMS) { + int i; + char *msg1; + msg1 = calloc(COLS, 1); strncpy(msg1, msg, COLS - 1); for (i = strlen(msg1); i < COLS - 1; i++) @@ -766,13 +782,30 @@ struct menu_line *Find_command(Menu *m, char *command) return find_command_from(command, m, MAX_MENU_DEPTH); } +static char *get_tmp_dir(void) +{ +#ifdef _WIN32 + static char tmp[BUFSIZ]; + DWORD len; + if (!tmp[0]) + { + len = GetTempPath(sizeof(tmp), tmp); + if (!len || (len > sizeof(tmp))) + strcpy(tmp, "."); + } + return tmp; +#else + return "/var/tmp"; +#endif +} + int toggle_logging(int argc, char *argv[]) { char buf[BUFSIZ]; if (!log_file) { - sprintf(buf, "/var/tmp/%s-log.%ld", whoami, (long)getpid()); + sprintf(buf, "%s/%s-log.%ld", get_tmp_dir(), whoami, (long)getpid()); /* open the file */ log_file = fopen(buf, "a");