home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume16
/
pcomm2
/
part03
/
data_log.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-09-14
|
2KB
|
82 lines
/*
* Open a window to prompt for a path name to be used for the data logging
* feature. Also turns on the data logging. A return code of 1 means we
* need to restart the input routine.
*/
#include <stdio.h>
#include <curses.h>
#include "config.h"
#include "misc.h"
#include "param.h"
#include "status.h"
int
data_logging()
{
extern int fd;
extern char *null_ptr;
int ret_code;
WINDOW *dl_win, *newwin();
char *ans, *path, *expand(), *get_str(), *strdup(), *strcpy();
void input_off(), free_ptr();
dl_win = newwin(6, 70, 5, 5);
mvwprintw(dl_win, 2, 4, "Default log file: %s", param->logfile);
mvwaddstr(dl_win, 3, 4, "New log file: ");
box(dl_win, VERT, HORZ);
mvwattrstr(dl_win, 0, 3, A_BOLD, " Start Data Logging ");
wmove(dl_win, 3, 18);
wrefresh(dl_win);
/* get the path */
ret_code = 0;
path = null_ptr;
while ((ans = get_str(dl_win, 60, "", " ")) != NULL) {
/* give 'em the default */
if (*ans == NULL)
path = strdup(param->logfile);
else
path = expand(ans);
/* test write permission */
if (can_write(path)) {
ret_code++;
break;
}
beep();
mvwattrstr(dl_win, 4, 24, A_BOLD, "No write permission");
wrefresh(dl_win);
wait_key(dl_win, 3);
/* clean up the mess */
clear_line(dl_win, 3, 18, 1);
clear_line(dl_win, 4, 24, 1);
wmove(dl_win, 3, 18);
wrefresh(dl_win);
}
if (ret_code) {
strcpy(status->log_path, path);
status->log = 1;
/*
* Without shared memory, killing and restarting the input
* routine is the only way to change the name of the file
* that the input routines uses.
*/
#ifdef SHAREDMEM
ret_code = 0;
#else /* SHAREDMEM */
input_off();
#endif /* SHAREDMEM */
}
if (fd == -1) {
werase(dl_win);
wrefresh(dl_win);
}
delwin(dl_win);
free_ptr(path);
return(ret_code);
}