2
3
4
5
6
7
8
11
12
13
47int init_form(Init *,
int,
char **,
int,
int);
53
54
55
56
57
58
59
60
61int init_form(Init *init,
int argc,
char **argv,
int begy,
int begx) {
70 rc =
Perror("Error: No form specification file given");
86 strcmp(form
->in_spec,
"/dev/stdin") == 0) {
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
127 if (form ==
nullptr) {
128 Perror("FORM: form data structure is nullptr");
162 if (form_action == 0 || form_action ==
FA_CONTINUE)
165 switch (form_action) {
194 eargv[eargc++] = strdup(
"view");
195 eargv[eargc++] = strdup(
"-Nf");
196 eargv[eargc++] = strdup(tmp_str);
197 eargv[eargc] =
nullptr;
214 if (form_action ==
FA_END)
220
221
222
223
224
231 wclrtoeol(form
->win);
250 tcflush(2, TCIFLUSH);
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
322 char earg_str[
MAXLEN + 1];
352 tcflush(2, TCIFLUSH);
366 for (i = 0; i < form
->fcnt; i++) {
373 if (pipe(pipe_fd) == -1) {
375 Perror("pipe(pipe_fd) failed in init_form");
378 if ((pid = fork()) == -1) {
380 Perror("fork() failed in init_form");
385 int dev_null = open(
"/dev/null", O_WRONLY);
386 if (dev_null == -1) {
387 Perror("open(/dev/null) failed in init_pick child "
391 dup2(dev_null, STDERR_FILENO);
394 dup2(pipe_fd[
P_WRITE], STDOUT_FILENO);
397 execvp(eargv[0], eargv);
455
456
457
458
459
460
461
462
463
510 for (
int i = 0; i < form
->fcnt; i++) {
520
521
522
523
524
531 for (n = 0; n < form
->dcnt; n++)
534 for (n = 0; n < form
->fcnt; n++)
540 for (n = 0; n < form
->fcnt; n++) {
556 immedok(form->win,
true);
557 immedok(form->box,
true);
571 for (n = 0; n < form
->dcnt; n++) {
582
583
584
585
586
587
588
589
601 for (size_t i = 0; i < fl; i++) {
632
633
634
635
636
637
638
639
655 if (form_desc_fp ==
nullptr) {
664 form
->field[i] = calloc(1,
sizeof(Field));
666 sprintf(tmp_str,
"FORM: calloc failed for fields");
671 form
->text[i] = calloc(1,
sizeof(Text));
673 sprintf(tmp_str,
"FORM: calloc failed for text");
681 while ((fgets(in_buf,
MAXLEN, form_desc_fp)) !=
nullptr) {
690 delim[1] = in_buf[1];
694 if (!(token = strtok(tmp_buf_p, delim))) {
698 switch ((
int)directive) {
711 if (!(token = strtok(
nullptr, delim))) {
713 "FORM: receiver_cmd delimiter");
719 if (!(token = strtok(
nullptr, delim))) {
721 "FORM: help_spec delimiter");
727 sprintf(tmp_str,
"FORM: calloc failed for fields");
730 if (!(token = strtok(
nullptr, delim))) {
732 "FORM: line number delimiter");
739 "FORM: invalid line number");
742 if (!(token = strtok(
nullptr, delim))) {
744 "FORM: column number delimiter");
751 "FORM: invalid column number");
754 if (!(token = strtok(
nullptr, delim))) {
765 if (!(token = strtok(
nullptr, delim))) {
767 "FORM: validation code delimiter");
774 if (!strcmp(token,
ff_tbl[i])) {
782 "FORM: invalid format code");
794 sprintf(tmp_str,
"FORM: calloc failed for text");
797 if (!(token = strtok(
nullptr, delim))) {
799 "FORM: line number delimiter");
806 "FORM: invalid line number");
809 if (!(token = strtok(
nullptr, delim))) {
811 "FORM: column number delimiter");
818 "FORM: invalid column number");
821 if (!(token = strtok(
nullptr, delim))) {
840 if ((token = strtok(
nullptr, delim))) {
849 fclose(form_desc_fp);
860
861
862
863
864
865
866
875 if ((lstat(form
->in_spec, &sb) == -1) || (sb.st_size == 0) ||
884 if (cmd_key == KEY_F(9))
905
906
907
908
909
911 char earg_str[
MAXLEN + 1];
914 for (i = 0; i < form
->fcnt; i++) {
926
927
928
929
930
931
932
933
934
935
936
941 char tmp_str[
MAXLEN] = {
'\0'};
948 bool f_append_values =
false;
966 for (i = 0; i < form
->fcnt; i++) {
968 if (tmp_str[0] !=
'\0')
973 eargv[eargc++] = strdup(tmp_str);
975 f_append_values =
false;
980 if (strstr(eargv[i],
"%%") !=
nullptr) {
982 f_append_values =
true;
989 for (i = 0; i < form
->fcnt; i++) {
992 if (f_append_values ==
true) {
993 if (tmp_str[0] !=
'\0')
1002 if (f_append_values ==
true) {
1003 if (eargv[eargx] !=
nullptr) {
1005 eargv[eargx] =
nullptr;
1008 if (out_s ==
nullptr || out_s[0] ==
'\0') {
1011 if (eargv[i] !=
nullptr)
1015 Perror("rep_substring() failed in form_exec_objects");
1019 eargv[eargx] = strdup(out_s);
1020 if (out_s !=
nullptr) {
1027 eargv[eargc] =
nullptr;
1029 if (tmp_str[0] !=
'\0' && (strcmp(tmp_str,
"view") == 0)) {
1031
1036 if (title[0] !=
'\0')
1044 if (eargv[i] !=
nullptr)
1051 if ((pid = fork()) == -1) {
1055 if (eargv[i] !=
nullptr)
1059 Perror("fork() failed in form_exec_objects");
1064 int dev_null = open(
"/dev/null", O_WRONLY);
1065 if (dev_null == -1) {
1066 Perror("open(/dev/null) failed in init_form child process");
1069 dup2(dev_null, STDERR_FILENO);
1072 execvp(eargv[0], eargv);
1074
1081 waitpid(pid,
nullptr, 0);
1091
1092
1093
1094
1095
1096
1097
1101 strcmp(form
->out_spec,
"/dev/stdout") == 0) {
1114 form
->out_fp = fdopen(STDOUT_FILENO,
"w");
1133 for (n = 0; n < form
->fcnt; n++)
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
int form_yx_to_fidx(Form *, int, int)
int popup_view(Init *, int, char **, int, int, int, int)
instantiate a view popup window
char stdio_names_str[MAXLEN]
char * stdio_fdnames(char *, char *)
void mk_filler(char *, int)
int xwgetch(WINDOW *, Chyron *, int)
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line,...
void restore_wins()
Restore all windows after a screen resize.
void win_del()
Delete the current window and its associated box window.
int box_new(int, int, int, int, char *)
Create a new window with optional box and title.
size_t str_to_cc(cchar_t *, const char *, attr_t, int, size_t)
Convert a multibyte string to an array of cchar_t complex characters.
cchar_t mkcc(int, attr_t, const char *)
Create a cchar_t with the specified color pair index.
bool waitpid_with_timeout(pid_t, int)
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.
void abend(int, char *)
Abnormal program termination.
int display_error(char *, char *, char *, char *)
Display an error message window or print to stderr.
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 *, Chyron *, int, int)
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
Chyron * new_chyron()
Create and initialize Chyron structure.
int shell(char *)
Execute a shell command.
int form_fmt_field(Form *, char *s)
Format field according to its format type.
int field_editor(Form *)
Accept input for a field.
int form_exec_receiver(Init *)
Execute a command specified by the -R option on the form command line.
int form_desc_error(Form *, int, char *, char *)
Handle errors encountered while parsing the form description file, providing detailed error messages ...
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.
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.
void sig_prog_mode()
Set up signal handlers for interrupt signals.
ChyronKey * key[CHYRON_KEYS]
char display_s[FIELD_MAXLEN]
char accept_s[FIELD_MAXLEN]
cchar_t filler_cc[FIELD_MAXLEN]
cchar_t display_cc[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]