2
3
4
5
6
7
8
11
12
13
47int init_form(Init *,
int,
char **,
int,
int);
52
53
54
55
56
57
58
59
60int init_form(Init *init,
int argc,
char **argv,
int begy,
int begx) {
69 rc =
Perror("Error: No form specification file given");
92 immedok(form->win, true);
93 immedok(form->box, true);
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
128 Perror("FORM: form data structure is nullptr");
145 if (form_action == 0 || form_action ==
FA_CONTINUE)
147 switch (form_action) {
176 eargv[eargc++] = strdup(
"view");
177 eargv[eargc++] = strdup(
"-Nf");
178 eargv[eargc++] = strdup(tmp_str);
196 if (form_action ==
FA_END)
202
203
204
205
206
223 tcflush(2, TCIFLUSH);
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
295 char earg_str[
MAXLEN + 1];
323 tcflush(2, TCIFLUSH);
341 if (pipe(pipe_fd) == -1) {
343 Perror("pipe(pipe_fd) failed in init_form");
346 if ((pid = fork()) == -1) {
348 Perror("fork() failed in init_form");
353 int dev_null = open(
"/dev/null", O_WRONLY);
354 if (dev_null == -1) {
355 Perror("open(/dev/null) failed in init_pick child "
359 dup2(dev_null, STDERR_FILENO);
362 dup2(pipe_fd[
P_WRITE], STDOUT_FILENO);
364 execvp(eargv[0], eargv);
417
418
419
420
421
422
423
424
425
471 for (
int i = 0; i < form
->fcnt; i++) {
481
482
483
484
485
516 immedok(form->win, TRUE);
543
544
545
546
547
548
549
550
566 wnoutrefresh(form
->win);
571
572
573
574
575
576
577
578
603 form
->field[i] = calloc(1,
sizeof(Field));
605 sprintf(tmp_str,
"FORM: calloc failed for fields");
610 form
->text[i] = calloc(1,
sizeof(Text));
612 sprintf(tmp_str,
"FORM: calloc failed for text");
629 delim[1] = in_buf[1];
633 if (!(token = strtok(tmp_buf_p, delim))) {
637 switch ((
int)directive) {
650 if (!(token = strtok(
nullptr, delim))) {
652 "FORM: receiver_cmd delimiter");
658 if (!(token = strtok(
nullptr, delim))) {
660 "FORM: help_spec delimiter");
666 sprintf(tmp_str,
"FORM: calloc failed for fields");
669 if (!(token = strtok(
nullptr, delim))) {
671 "FORM: line number delimiter");
678 "FORM: invalid line number");
681 if (!(token = strtok(
nullptr, delim))) {
683 "FORM: column number delimiter");
690 "FORM: invalid column number");
693 if (!(token = strtok(
nullptr, delim))) {
704 if (!(token = strtok(
nullptr, delim))) {
706 "FORM: validation code delimiter");
713 if (!strcmp(token,
ff_tbl[i])) {
721 "FORM: invalid format code");
733 sprintf(tmp_str,
"FORM: calloc failed for text");
736 if (!(token = strtok(
nullptr, delim))) {
738 "FORM: line number delimiter");
745 "FORM: invalid line number");
748 if (!(token = strtok(
nullptr, delim))) {
750 "FORM: column number delimiter");
757 "FORM: invalid column number");
760 if (!(token = strtok(
nullptr, delim))) {
779 if ((token = strtok(
nullptr, delim))) {
788 fclose(form_desc_fp);
799
800
801
802
803
804
805
813 if ((lstat(form
->in_spec, &sb) == -1) || (sb.st_size == 0) ||
843
844
845
846
847
849 char earg_str[
MAXLEN + 1];
852 for (i = 0; i < form
->fcnt; i++) {
864
865
866
867
868
869
870
871
872
873
874
879 char tmp_str[
MAXLEN] = {
'\0'};
886 bool f_append_values = false;
905 if (tmp_str[0] !=
'\0')
910 eargv[eargc++] = strdup(tmp_str);
912 f_append_values = false;
917 if (strstr(eargv[i],
"%%") !=
nullptr) {
919 f_append_values = true;
929 if (f_append_values == true) {
930 if (tmp_str[0] !=
'\0')
939 if (f_append_values == true) {
945 if (out_s ==
nullptr || out_s[0] ==
'\0') {
952 Perror("rep_substring() failed in form_exec_objects");
956 eargv[eargx] = strdup(out_s);
966 if (tmp_str[0] !=
'\0' && (strcmp(tmp_str,
"view") == 0)) {
968
973 if (title[0] !=
'\0')
987 if ((pid = fork()) == -1) {
995 Perror("fork() failed in form_exec_objects");
1000 int dev_null = open(
"/dev/null", O_WRONLY);
1001 if (dev_null == -1) {
1002 Perror("open(/dev/null) failed in init_form child process");
1005 dup2(dev_null, STDERR_FILENO);
1008 execvp(eargv[0], eargv);
1010
1027
1028
1029
1030
1031
1032
1033
1037 strcmp(form
->out_spec,
"/dev/stdout") == 0) {
1050 form
->out_fp = fdopen(STDOUT_FILENO,
"w");
1069 for (n = 0; n < form
->fcnt; n++)
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
int form_yx_to_fidx(Form *, int, int)
int popup_view(Init *, int, char **, int, int, int, int)
instantiate a view popup window
int xwgetch(WINDOW *, Chyron *, int)
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line,...
int box_new(int, int, int, int, char *, bool)
Create a new window with optional box and title.
void restore_wins()
Restore all windows after a screen resize.
WINDOW * win_del()
Delete the current window and its associated box window.
bool waitpid_with_timeout(pid_t pid, int timeout)
Wait for a process to finish with a timeout and optional user cancellation.
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.
bool is_set_chyron_key(Chyron *, int)
Check if function key label is set.
void set_chyron_key(Chyron *, int, char *, int)
Set chyron key with default color pair (cp_nt_rev).
void display_chyron(WINDOW *win, Chyron *chyron, int line, int col)
Display chyron on window.
Chyron * destroy_chyron(Chyron *chyron)
Destroy Chyron structure.
void set_chyron_key_cp(Chyron *, int, char *, int, int)
Set chyron key with color pair (cp).
void compile_chyron(Chyron *)
construct the chyron string from the chyron structure
void unset_chyron_key(Chyron *, int)
Unset chyron key.
Chyron * new_chyron()
Create and initialize Chyron structure.
int shell(char *)
Execute a shell command.
int form_fmt_field(Form *, char *)
Format field according to its format type.
int field_editor(Form *)
Accept input for a field.
int form_desc_error(int, char *, char *)
Handle errors encountered while parsing the form description file, providing detailed error messages ...
int form_exec_receiver(Init *)
Execute a command specified by the -R option on the form command line.
int form_read_data(Form *)
Read initial data for form fields from a specified input source, such as a file or standard input,...
int form_parse_desc(Form *)
Parse the form description file to populate the Form data structure with field definitions,...
int form_write(Form *)
Write form field values to a specified output destination, such as a file or standard output,...
int form_process(Init *)
Handle integration with a getter program which will provide field data.
int form_exec_cmd(Form *)
Execute a command specified in the form description file, passing form field values as arguments,...
int init_form(Init *, int, char **, int, int)
Initialize form data structure and parse description file.
int form_post(Init *)
Handle post-processing after field entry, allowing user to edit data, execute a provider command,...
int form_engine(Init *)
Form main processing loop.
void form_display_fields(Form *)
Display form fields on the screen, populating field values and formatting them according to the form ...
int field_navigator(Form *)
Handle user input for field entry, allowing navigation between fields and looping until an exit actio...
unsigned int display_form(Init *)
Display the form on the screen, including text elements and fields, and set up the form window based ...
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
int destroy_argv(int argc, char **argv)
Deallocates memory allocated for argument strings in argv.
size_t trim(char *)
Trims leading and trailing spaces from string s in place.
bool str_to_lower(char *)
Converts a string to lowercase.
bool strnfill(char *, char, int)
Fills string s with character c n.
size_t strnz(char *, size_t)
terminates string at New Line, Carriage Return, or max_len
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
char * rep_substring(const char *, const char *, const char *)
Replace all occurrences of "tgt_s" in "org_s" with "rep_s".
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.
Form * new_form(Init *, int, char **, int, int)
Create and initialize Form structure.
Form * destroy_form(Init *init)
Destroy Form structure.
bool restore_curses_tioctl()
restore_curses_tioctl() - restore curses terminal settings
void sig_prog_mode()
Set up signal handlers for interrupt signals.
char display_s[FIELD_MAXLEN]
char accept_s[FIELD_MAXLEN]
char filler_s[FIELD_MAXLEN]
Text * text[FIELD_MAXCNT]
Field * field[FIELD_MAXCNT]
char receiver_cmd[MAXLEN]
char provider_cmd[MAXLEN]
char mapp_spec[FIELD_MAXLEN]