2
3
4
5
6
7
8
9
12
13
14
23#include <sys/sysmacros.h>
28
29
30
31
32
33
34
35
36
37
38
39
41 int scr_lines, scr_cols;
48 getmaxyx(stdscr, scr_lines, scr_cols);
66 immedok(view->win, true);
81 immedok(view->ln_win, true);
100 abend(-1
, "init_view_full_screen: newpad() failed");
110 immedok(view->pad, true);
115
116
117
118
119
120
121
122
124 int scr_lines, scr_cols;
131 getmaxyx(stdscr, scr_lines, scr_cols);
140 if (title !=
nullptr && title[0] !=
'\0')
166 immedok(view->win, true);
182 immedok(view->ln_win, true);
202 immedok(view->pad, true);
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
232 if (strcmp(file_name,
"-") == 0) {
233 file_name =
"/dev/stdin";
238 if (pipe(pipe_fd) == -1) {
239 Perror("pipe(pipe_fd) failed in init_view");
242 if ((pid = fork()) == -1) {
243 Perror("fork() failed in init_view");
248 dup2(pipe_fd[
P_WRITE], STDOUT_FILENO);
250 execvp(s_argv[0], s_argv);
259 dup2(pipe_fd[
P_READ], STDIN_FILENO);
260 view
->in_fd = dup(STDIN_FILENO);
264 view
->in_fd = dup(STDIN_FILENO);
269 view
->in_fd = open(file_name, O_RDONLY);
278 if (fstat(view
->in_fd, &sb) == -1) {
297 if (!S_ISREG(sb.st_mode))
303 char tmp_filename[] =
"/tmp/view_XXXXXX";
305 ssize_t bytes_read = 0;
306 ssize_t bytes_written = 0;
308 view
->in_fd = mkstemp(tmp_filename);
313 unlink(tmp_filename);
318 struct timeval timeout;
323 FD_SET(STDIN_FILENO, &read_fds);
325 timeout.tv_usec = 200000;
326 ready = select(STDIN_FILENO + 1, &read_fds,
nullptr,
nullptr, &timeout);
334 while (ready == 0 && remaining > 0 &&
cmd_key != KEY_F(9)) {
339 FD_SET(STDIN_FILENO, &read_fds);
353
362 Perror("Error waiting for view input");
365
373 Perror("Timeout waiting for view input");
376
383 if (ready == 1 && !FD_ISSET(STDIN_FILENO, &read_fds)) {
384 Perror("Unexpected error waiting for view input");
387
395 while ((bytes_read = read(STDIN_FILENO, buf,
sizeof(buf))) > 0) {
396 if (write(view
->in_fd, buf, bytes_read) != bytes_read) {
400 bytes_written += bytes_read;
402 if (bytes_written == 0) {
406 if (fstat(view
->in_fd, &sb) == -1) {
423 if (view
->buf == MAP_FAILED) {
437 for (idx = 0; idx <
NMARKS; idx++)
bool waitpid_with_timeout(pid_t pid, int timeout)
int win_new(int, int, int, int, char *, int)
Create a new window with optional box and title.
bool wait_destroy(Chyron *)
Destroy the waiting message window and chyron.
int wait_continue(WINDOW *, Chyron *, int)
Update the waiting message with remaining time and check for user input.
WINDOW * wait_mk_win(Chyron *, char *)
Display a popup waiting message.
int Perror(char *)
Display a simple error message window or print to stderr.
int display_error(char *em0, char *em1, char *em2, char *em3)
Display an error message window or print to stderr.
void abend(int, char *)
Abnormal program termination.
Chyron * wait_mk_chyron()
Create a Chyron struct for the waiting message.
void destroy_argv(int argc, char **argv)
Deallocates memory allocated for argument strings in argv.
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
bool expand_tilde(char *, int)
Replace Leading Tilde With Home Directory.
bool base_name(char *, char *)
Returns the base name of a file specification.
int str_to_args(char **, char *, int)
Converts a string into an array of argument strings.
int init_view_full_screen(Init *)
Initialize C-Menu View in full screen mode.
int init_view_boxwin(Init *, char *)
Initialize the C-Menu View in box window mode.
int view_init_input(View *, char *)
Initialize the input for a C-Menu View.
char provider_cmd[MAXLEN]
char cur_file_str[MAXLEN]