2
3
4
5
6
7
8
11
12
13
47int init_form(Init *,
int,
char **, uint, uint);
53
54
55
56
57
58
59
60
61int init_form(Init *init,
int argc,
char **argv, uint begy, uint begx) {
70 rc =
Perror("Error: No form specification file given");
86 strcmp(form
->in_spec,
"/dev/stdin") == 0) {
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
125 if (form ==
nullptr) {
126 Perror("FORM: form data structure is nullptr");
160 if (form_action == 0 || form_action ==
FA_CONTINUE)
163 switch (form_action) {
192 eargv[eargc++] = strdup(
"view");
193 eargv[eargc++] = strdup(
"-Nf");
194 eargv[eargc++] = strdup(tmp_str);
195 eargv[eargc] =
nullptr;
212 if (form_action ==
FA_END)
218
219
220
221
222
250 tcflush(2, TCIFLUSH);
254 if (event
.in_win == 1 && event
.y == maxy - 1)
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
320
321
325 char earg_str[
MAXLEN + 1];
356 tcflush(2, TCIFLUSH);
360 if (event
.in_win == 1 && event
.y == maxy - 1)
373 for (i = 0; i < form
->fcnt; i++) {
380 if (pipe(pipe_fd) == -1) {
382 Perror("pipe(pipe_fd) failed in init_form");
385 if ((pid = fork()) == -1) {
387 Perror("fork() failed in init_form");
392 int dev_null = open(
"/dev/null", O_WRONLY);
393 if (dev_null == -1) {
394 Perror("open(/dev/null) failed in init_pick child "
398 dup2(dev_null, STDERR_FILENO);
401 dup2(pipe_fd[
P_WRITE], STDOUT_FILENO);
404 execvp(eargv[0], eargv);
421 waitpid(pid,
nullptr, 0);
462
463
464
465
466
467
468
469
470
517 for (uint i = 0; i < form
->fcnt; i++) {
527
528
529
530
531
538 for (n = 0; n < form
->dcnt; n++)
541 for (n = 0; n < form
->fcnt; n++)
547 for (n = 0; n < form
->fcnt; n++) {
562 ui_immedok(sfc, WIN,
true);
563 ui_immedok(sfc, BOX,
true);
574 for (n = 0; n < form
->dcnt; n++) {
584
585
586
587
588
589
590
591
604 for (size_t i = 0; i < fl; i++) {
638
639
640
641
642
643
644
645
661 if (form_desc_fp ==
nullptr) {
670 form
->field[i] = calloc(1,
sizeof(Field));
672 sprintf(tmp_str,
"FORM: calloc failed for fields");
677 form
->text[i] = calloc(1,
sizeof(Text));
679 sprintf(tmp_str,
"FORM: calloc failed for text");
687 while ((fgets(in_buf,
MAXLEN, form_desc_fp)) !=
nullptr) {
696 delim[1] = in_buf[1];
700 if (!(token = strtok(tmp_buf_p, delim))) {
704 switch ((
int)directive) {
717 if (!(token = strtok(
nullptr, delim))) {
719 "FORM: receiver_cmd delimiter");
725 if (!(token = strtok(
nullptr, delim))) {
727 "FORM: help_spec delimiter");
733 sprintf(tmp_str,
"FORM: calloc failed for fields");
736 if (!(token = strtok(
nullptr, delim))) {
738 "FORM: line number delimiter");
744 "FORM: invalid line number");
747 if (!(token = strtok(
nullptr, delim))) {
749 "FORM: column number delimiter");
755 "FORM: invalid column number");
758 if (!(token = strtok(
nullptr, delim))) {
768 if (!(token = strtok(
nullptr, delim))) {
770 "FORM: validation code delimiter");
777 if (!strcmp(token,
ff_tbl[i])) {
784 "FORM: invalid format code");
796 sprintf(tmp_str,
"FORM: calloc failed for text");
799 if (!(token = strtok(
nullptr, delim))) {
801 "FORM: line number delimiter");
807 "FORM: invalid line number");
810 if (!(token = strtok(
nullptr, delim))) {
812 "FORM: column number delimiter");
818 "FORM: invalid column number");
821 if (!(token = strtok(
nullptr, delim))) {
839 if ((token = strtok(
nullptr, delim))) {
848 fclose(form_desc_fp);
859
860
861
862
863
864
865
874 if ((lstat(form
->in_spec, &sb) == -1) || (sb.st_size == 0) ||
904
905
906
907
908
910 char earg_str[
MAXLEN + 1];
913 for (i = 0; i < form
->fcnt; i++) {
925
926
927
928
929
930
931
932
933
934
935
940 char tmp_str[
MAXLEN] = {
'\0'};
947 bool f_append_values =
false;
965 for (i = 0; i < form
->fcnt; i++) {
967 if (tmp_str[0] !=
'\0')
972 eargv[eargc++] = strdup(tmp_str);
974 f_append_values =
false;
979 if (strstr(eargv[i],
"%%") !=
nullptr) {
981 f_append_values =
true;
988 for (i = 0; i < form
->fcnt; i++) {
991 if (f_append_values ==
true) {
992 if (tmp_str[0] !=
'\0')
1001 if (f_append_values ==
true) {
1002 if (eargv[eargx] !=
nullptr) {
1004 eargv[eargx] =
nullptr;
1007 if (out_s ==
nullptr || out_s[0] ==
'\0') {
1010 if (eargv[i] !=
nullptr)
1014 Perror("rep_substring() failed in form_exec_objects");
1018 eargv[eargx] = strdup(out_s);
1019 if (out_s !=
nullptr) {
1026 eargv[eargc] =
nullptr;
1028 if (tmp_str[0] !=
'\0' && (strcmp(tmp_str,
"view") == 0)) {
1030
1035 if (title[0] !=
'\0')
1043 if (eargv[i] !=
nullptr)
1050 if ((pid = fork()) == -1) {
1054 if (eargv[i] !=
nullptr)
1058 Perror("fork() failed in form_exec_objects");
1063 int dev_null = open(
"/dev/null", O_WRONLY);
1064 if (dev_null == -1) {
1065 Perror("open(/dev/null) failed in init_form child process");
1068 dup2(dev_null, STDERR_FILENO);
1071 execvp(eargv[0], eargv);
1073
1080 waitpid(pid,
nullptr, 0);
1087
1088
1089
1090
1091
1092
1093
1097 strcmp(form
->out_spec,
"/dev/stdout") == 0) {
1110 form
->out_fp = fdopen(STDOUT_FILENO,
"w");
1129 for (n = 0; n < form
->fcnt; n++)
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
int popup_view(Init *, int, char **, uint, uint, uint, uint)
instantiate a view popup window
char stdio_names_str[4096]
char * stdio_fdnames(char *, char *)
int ui_mvwadd_wchstr(UiSurface *s, uint w, uint y, uint x, const UiCell *cell)
int ui_cursor_move(UiSurface *s, uint w, uint y, uint x)
int ui_mvwaddstr(UiSurface *s, uint w, uint y, uint x, const char *text)
int ui_mvwadd_wchnstr(UiSurface *s, uint w, uint y, uint x, const UiCell *cell, uint m)
UiSurface * ui_surface[UI_SFC_MAX]
int ui_wclrtoeol(UiSurface *s, uint w)
int ui_get_event_multi(UiSurface *s, uint w, UiEvent *ev, int timeout_ms)
int ui_mvwadd_wch(UiSurface *s, uint w, uint y, uint x, const UiCell *cell)
void ui_getmaxyx(UiSurface *s, uint w, uint *lines, uint *cols)
void mk_filler(char *, uint)
uint form_yx_to_fidx(Form *, uint, uint)
int surface_box_win_new(uint wlines, uint wcols, uint wbegy, uint wbegx, char *wtitle)
int cm_surface_destroy(UiSurface *sfc)
Destroy the most recently created surface.
int Perror(char *emsg_str)
Display a simple error message window or print to stderr.
void abend(int ec, char *s)
Abnormal program termination.
int display_error(char *msg0, char *msg1, char *msg2, char *msg3)
Display an error message window or print to stderr.
void set_chyron_key_cb(Chyron *chyron, uint k, char *s, uint kc, UiCell cell_base)
Set chyron key with color pair (cp).
Chyron * destroy_chyron(Chyron *chyron)
Destroy Chyron structure.
void compile_chyron(Chyron *chyron)
construct the chyron string from the chyron structure
int get_chyron_key(Chyron *chyron, uint x)
Get keycode from chyron.
uint mbstr_to_cellstr(UiCell *cmplx_buf, const char *str, const UiCell *cell_base, uint *pos, const uint atmost)
Convert multibyte string to complex character array.
Chyron * new_chyron()
Create and initialize Chyron structure.
bool is_set_chyron_key(Chyron *chyron, uint k)
Check if function key label is set.
void display_chyron(UiSurface *sfc, uint w, Chyron *chyron, uint line, uint col)
Display chyron on the specified line and column of the surface.
void set_chyron_key(Chyron *chyron, uint k, char *s, uint kc)
Set chyron key with default color pair (cp_nt_rev).
int shell(char *)
Execute a shell command.
int form_fmt_field(Form *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 *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 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 init_form(Init *, int, char **, uint, uint)
Initialize form data structure and parse description file.
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
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.
int str_to_args(char **, char *, uint)
Converts a string into an array of argument strings.
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".
int destroy_argv(uint argc, char **argv)
Deallocates memory allocated for argument strings in argv.
bool base_name(char *, char *)
Returns the base name of a file specification.
Form * destroy_form(Init *init)
Destroy Form structure.
Form * new_form(Init *init, int argc, char **argv, uint begy, uint begx)
Create and initialize Form structure.
void sig_prog_mode()
Set up signal handlers for interrupt signals.
ChyronKey * key[CHYRON_KEYS]
char display_s[FIELD_MAXLEN]
UiCell display_cc[FIELD_MAXLEN]
char accept_s[FIELD_MAXLEN]
UiCell filler_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]