C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
mem.c
Go to the documentation of this file.
1/** @file mem.c
2 @brief Create and destroy main data structures for C-Menu
3 @author Bill Waller
4 Copyright (c) 2025
5 MIT License
6 billxwaller@gmail.com
7 @date 2026-02-09
8 */
9
10/** @defgroup mem Memory Management
11 * @brief Create, populate, and destroy main data structures for C-Menu
12 @verbatim
13 C-Menu main data structures
14 Init - main structure for initialization and global data
15 Menu - menu description, help, and state
16 Pick - pick description, help, and state
17 Form - form description, help, and state
18 View - view description, help, and state
19 @endverbatim
20*/
21
22#include <common.h>
23#include <errno.h>
24#include <stdlib.h>
25#include <string.h>
26#include <unistd.h>
27
28Init *new_init(int, char **);
29Menu *new_menu(Init *init, int, char **, int, int);
30Pick *new_pick(Init *init, int, char **, int, int);
31Form *new_form(Init *init, int, char **, int, int);
32View *new_view(Init *init);
33View *destroy_view(Init *init);
34Form *destroy_form(Init *init);
35Pick *destroy_pick(Init *init);
36Menu *destroy_menu(Init *init);
37Init *destroy_init(Init *init);
38bool init_menu_files(Init *, int, char **);
39bool init_pick_files(Init *, int, char **);
40bool init_form_files(Init *, int, char **);
41bool init_view_files(Init *);
42bool verify_spec_arg(char *, char *, char *, char *, int);
43int init_cnt = 0;
44
45Menu *menu;
46Pick *pick;
47Form *form;
48View *view;
49/** @brief Create and initialize Init structure
50 @ingroup mem
51 @param argc, argv - arguments
52 @details calloc initializes all fields to zero/nullptr
53 idiomatic directory usage:
54 @code
55 init->mapp_msrc description files
56 init->mapp_help help files
57 init->mapp_data in, out, data files
58 init->mapp_user executable scripts
59 init->mapp_bin binary executables
60 @endcode
61 Initialize file specifications in priority order:
62 @code
63 1 - Default values
64 2 - Configuration file
65 3 - Environment variables
66 4 - Command line positional arguments
67 5 - Command line option arguments
68 @endcode
69 */
70Init *new_init(int argc, char **argv) {
71 int i = 0;
72 Init *init = calloc(1, sizeof(Init));
73 if (init == nullptr) {
74 abend(-1, "calloc init failed");
75 return nullptr;
76 }
77 init->argv = calloc(MAXARGS + 1, sizeof(char *));
78 if (init->argv == nullptr) {
79 ssnprintf(em0, MAXLEN - 1, "%s, line: %d, errno: %d", __FILE__,
80 __LINE__ - 4, errno);
81 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
82 ssnprintf(em2, MAXLEN - 1, "view->argv = calloc(%d, %d) failed\n",
83 (MAXARGS + 1), sizeof(char *));
85 exit(EXIT_FAILURE);
86 }
87 init->argc = argc;
88 for (i = 0; i < init->argc; i++)
89 init->argv[i] = argv[i];
90 init->argv[i] = nullptr;
91
92 init->sio = (SIO *)calloc(1, sizeof(SIO));
93 if (!init->sio) {
94 Perror("calloc sio failed");
95 exit(EXIT_FAILURE);
96 }
97 init_cnt++;
98 return init;
99}
100/** @brief Destroy Init structure
101 @ingroup mem
102 @param init structure
103 @returns nullptr
104 */
105Init *destroy_init(Init *init) {
106 if (!init)
107 return nullptr;
108 if (init->sio) {
109 free(init->sio);
110 init->sio = nullptr;
111 }
112 if (init->menu) {
113 init->menu = destroy_menu(init);
114 init->menu = nullptr;
115 }
116 if (init->view) {
117 init->view = destroy_view(init);
118 init->view = nullptr;
119 }
120 if (init->form) {
121 init->form = destroy_form(init);
122 init->form = nullptr;
123 }
124 if (init->pick) {
125 init->pick = destroy_pick(init);
126 init->pick = nullptr;
127 }
128 init->argc = destroy_argv(init->argc, init->argv);
129 if (init->argv != nullptr)
130 free(init->argv);
131 if (init != nullptr) {
132 free(init);
133 init = nullptr;
134 }
135 init_cnt--;
136 return init;
137}
138/** @brief Create and initialize Menu structure
139 @ingroup mem
140 @param init structure
141 @param argc - number of arguments in argv
142 @param argv - Arguments may have been provided by command line,
143 ~/.minitrc,
144 environment variables, or
145 calling program interal to C-Menu
146 @param begy, begx - initial position of menu window
147 */
148Menu *new_menu(Init *init, int argc, char **argv, int begy, int begx) {
149 init->menu = (Menu *)calloc(1, sizeof(Menu));
150 if (!init->menu) {
151 abend(-1, "calloc menu failed");
152 return nullptr;
153 }
154 init->menu_cnt++;
155 menu = init->menu;
156 if (!init_menu_files(init, argc, argv)) {
157 abend(-1, "init_menu_files failed");
158 return nullptr;
159 }
160 menu->begy = begy;
161 menu->begx = begx;
162 return init->menu;
163}
164/** @brief Destroy Menu structure
165 @ingroup mem
166 @param init structure
167 @return nullptr
168 */
169Menu *destroy_menu(Init *init) {
170 menu = init->menu;
172 menu->line_idx++) {
182 }
183 }
184 free(init->menu);
185 init->menu = nullptr;
186 menu = nullptr;
187 init->menu_cnt--;
188 return init->menu;
189}
190/** @brief Create and initialize Pick structure
191 @ingroup mem
192 @param init structure
193 @param argc - number of arguments in argv
194 @param argv - Arguments may have been provided by command line,
195 ~/.minitrc,
196 environment variables, or
197 calling program interal to C-Menu
198 @param begy, begx - initial position of pick window
199 */
200Pick *new_pick(Init *init, int argc, char **argv, int begy, int begx) {
201 init->pick = (Pick *)calloc(1, sizeof(Pick));
202 if (!init->pick) {
203 Perror("calloc pick failed");
204 return nullptr;
205 }
206 init->pick_cnt++;
207 pick = init->pick;
208 if (!init_pick_files(init, argc, argv)) {
209 abend(-1, "init_pick_files failed");
210 return nullptr;
211 }
212 pick->m_object = calloc(OBJ_MAXCNT + 1, sizeof(char *));
213 if (pick->m_object == nullptr) {
214 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__, __LINE__ - 1);
216 "calloc pick->m_object = calloc(%d, %d) failed\n",
217 OBJ_MAXCNT + 1, sizeof(char *));
219 abend(-1, "User terminated program");
220 }
221 pick->d_object = calloc(OBJ_MAXCNT + 1, sizeof(char *));
222 if (pick->d_object == nullptr) {
223 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__, __LINE__ - 1);
225 "calloc pick->d_object = calloc(%d, %d) failed\n",
226 OBJ_MAXCNT + 1, sizeof(char *));
228 abend(-1, "User terminated program");
229 }
230 pick->begy = begy;
231 pick->begx = begx;
232 return init->pick;
233}
234/** @brief Destroy Pick structure
235 @ingroup mem
236 @param init structure
237 @return nullptr
238 */
239Pick *destroy_pick(Init *init) {
240 if (!init->pick)
241 return nullptr;
242
246 // if (pick->d_object[pick->d_idx] != nullptr)
247 // free(pick->d_object[pick->d_idx]);
248 }
249 free(pick->m_object);
250 free(pick->d_object);
251 free(pick);
252 init->pick = nullptr;
253 init->pick_cnt--;
254 return init->pick;
255}
256/** @brief Create and initialize Form structure
257 @ingroup mem
258 @param init structure
259 @param argc - number of arguments in argv
260 @param argv - Arguments may have been provided by command line,
261 ~/.minitrc,
262 environment variables, or
263 calling program interal to C-Menu
264 @param begy, begx - initial position of form window
265 */
266Form *new_form(Init *init, int argc, char **argv, int begy, int begx) {
267 init->form = (Form *)calloc(1, sizeof(Form));
268 if (!init->form) {
269 abend(-1, "calloc form failed");
270 return nullptr;
271 }
272 init->form_cnt++;
273 form = init->form;
274 if (!init_form_files(init, argc, argv)) {
275 abend(-1, "init_form_files failed");
276 return nullptr;
277 }
280 form->begy = begy;
281 form->begx = begx;
282 return init->form;
283}
284/** @brief Destroy Form structure
285 @ingroup mem
286 @param init structure
287 @return nullptr
288 */
289Form *destroy_form(Init *init) {
290 int i;
291
292 if (!init->form)
293 return nullptr;
294 for (i = 0; i < FIELD_MAXCNT; i++) {
295 if (init->form->field[i])
296 free(init->form->field[i]);
297 init->form->field[i] = nullptr;
298 }
299 for (i = 0; i < FIELD_MAXCNT; i++) {
300 if (init->form->text[i])
301 free(init->form->text[i]);
302 init->form->text[i] = nullptr;
303 }
304 free(init->form);
305 init->form = nullptr;
306 init->form_cnt--;
307 return init->form;
308}
309/** @brief Create and initialize View structure
310 @ingroup mem
311 @param init structure
312 */
313View *new_view(Init *init) {
314 init->view_cnt++;
315 init->view = (View *)calloc(1, sizeof(View));
316 if (!init->view) {
317 free(init->view);
318 ssnprintf(em0, MAXLEN - 1, "%s, line: %d, errno: %d", __FILE__,
319 __LINE__ - 1, errno);
320 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
321 ssnprintf(em2, MAXLEN - 1, "init->view = calloc(%d) failed\n",
322 sizeof(View));
324 abend(-1, "calloc init->view failed");
325 return nullptr;
326 }
327 view = init->view;
328 view->argc = init->argc;
329 if (view->argc > 0) {
330 view->argv = calloc(view->argc + 1, sizeof(char *));
331 if (view->argv == nullptr) {
332 free(view->argv);
333 ssnprintf(em0, MAXLEN - 1, "%s, line: %d, errno: %d", __FILE__,
334 __LINE__ - 1, errno);
335 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
336 ssnprintf(em2, MAXLEN - 1, "view->argv = calloc(%d, %d) failed\n",
337 view->argc, sizeof(char *));
339 abend(-1, "User terminated program");
340 return nullptr;
341 }
342 int s = 0;
343 int d = 0;
344 while (s < init->argc)
345 view->argv[d++] = strnz_dup(init->argv[s++], MAXLEN - 1);
346 view->argv[d] = nullptr;
347 }
348 if (!init_view_files(init)) {
349 abend(-1, "init_view_files failed");
350 return nullptr;
351 }
352 return view;
353}
354/** @brief Destroy View structure
355 @ingroup mem
356 @param init structure
357 @return nullptr
358 */
359View *destroy_view(Init *init) {
360 view = init->view;
361 if (!view)
362 return nullptr;
363 if (view->ln_tbl) {
364 free(view->ln_tbl);
366 }
367 if (view->ln_win) {
368 delwin(view->ln_win);
370 }
371 if (view->cmdln_win) {
372 delwin(view->cmdln_win);
374 }
375 delwin(view->cmdln_win);
376 if (view->box) {
377 delwin(view->box);
379 }
380 delwin(view->box);
381 if (view->pad) {
382 delwin(view->pad);
384 }
385 delwin(view->pad);
387 free(view->argv);
388 free(view);
389 init->view = nullptr;
390 view = nullptr;
391 init->view_cnt--;
392 return init->view;
393}
394/** @brief Verify file specification argument
395 @ingroup mem
396 @param spec - menu->spec, form->spec, etc.
397 @param org_spec - init->._spec | argv[optind]
398 @param dir - init->._. directory
399 @param alt_dir - literal, "~/menuapp/data", etc.
400 @param mode - R_OK, W_OK, X_OK, WC_OK, S_QUIET
401 @details mode is a bitwise OR of the following flags:
402 S_QUIET - suppress error messages
403 WC_OK - write create ok
404 @return bool - true if file verified
405 */
406bool verify_spec_arg(char *spec, char *org_spec, char *dir, char *alt_dir,
407 int mode) {
408 bool f_dir = false;
409 bool f_spec = false;
410 bool f_quote = true;
411 char *s1;
412 char *s2;
413 char s1_s[MAXLEN];
414 char s2_s[MAXLEN];
415 char file_name[MAXLEN];
416 char try_spec[MAXLEN];
417 char idio_spec[MAXLEN];
418
419 if (!org_spec[0])
420 return false;
421 idio_spec[0] = '\0';
422 // try the provided spec as is, with quotes stripped for file name parsing
423 strnz__cpy(try_spec, org_spec, MAXLEN - 1);
424 f_quote = stripz_quotes(try_spec);
425
426 s1 = strtok(try_spec, " \t\n");
427 strnz__cpy(s1_s, s1, MAXLEN - 1);
428
429 s2 = strtok(nullptr, "\n");
430 strnz__cpy(s2_s, s2, MAXLEN - 1);
431
432 strnz__cpy(file_name, s1, MAXLEN - 1);
433 strnz__cpy(try_spec, file_name, MAXLEN - 1);
434
436
437 if (try_spec[0]) {
438 expand_tilde(try_spec, MAXLEN - 1);
439 if (try_spec[0] == '/') {
440 // try absolute path as is, with quotes stripped for file name parsing
441 f_spec = verify_file(try_spec, mode);
442 if (f_quote)
443 /** preserve quotes */
444 strnz__cpy(spec, org_spec, MAXLEN - 1);
445 else
446 strnz__cpy(spec, try_spec, MAXLEN - 1);
447 return f_spec;
448
449 } else {
450 if (!f_dir && dir[0]) {
451 if (strcmp(dir, "$PATH") == 0) {
452 strnz__cpy(try_spec, file_name, MAXLEN - 1);
453 f_spec = locate_file_in_path(try_spec, file_name);
454 } else {
455 strnz__cpy(try_spec, dir, MAXLEN - 1);
456 expand_tilde(try_spec, MAXLEN - 1);
457 f_dir = verify_dir(try_spec, mode);
458 if (f_dir) {
459 // directory is valid, append file_name and verify file
460 strnz__cat(try_spec, "/", MAXLEN - 1);
461 strnz__cat(try_spec, file_name, MAXLEN - 1);
462 strnz__cpy(idio_spec, try_spec, MAXLEN - 1);
463 if (mode & S_WCOK)
464 f_spec = true;
465 else
466 f_spec = verify_file(idio_spec, mode | S_QUIET);
467 }
468 }
469 }
470 if (!f_spec && alt_dir && alt_dir[0] != '\0') {
471 if (strcmp(alt_dir, "$PATH") == 0) {
472 strnz__cpy(try_spec, file_name, MAXLEN - 1);
473 f_spec = locate_file_in_path(try_spec, file_name);
474 } else {
475 strnz__cpy(try_spec, alt_dir, MAXLEN - 1);
476 expand_tilde(try_spec, MAXLEN - 1);
477 f_dir = verify_dir(try_spec, mode);
478 if (f_dir) {
479 strnz__cat(try_spec, "/", MAXLEN - 1);
480 strnz__cat(try_spec, file_name, MAXLEN - 1);
481 if (mode & S_WCOK)
482 f_spec = true;
483 else
484 f_spec = verify_file(try_spec, mode | S_QUIET);
485 }
486 }
487 }
488 if (!f_spec) {
489 strnz__cpy(try_spec, ".", MAXLEN - 1);
490 strnz__cat(try_spec, "/", MAXLEN - 1);
491 strnz__cat(try_spec, file_name, MAXLEN - 1);
492 f_spec = verify_file(try_spec, mode | S_QUIET);
493 }
494 if (!f_spec && mode == W_OK) {
495 strnz__cpy(try_spec, idio_spec, MAXLEN - 1);
496 FILE *fp = fopen(try_spec, "a");
497 if (fp) {
498 fclose(fp);
499 f_spec = true;
500 }
501 }
502 if (f_quote)
503 /** preserve quotes */
504 strnz__cpy(spec, org_spec, MAXLEN - 1);
505 else if (f_spec)
506 strnz__cpy(spec, try_spec, MAXLEN - 1);
507 if (try_spec[0] == '\0' && idio_spec[0] != '\0')
508 strnz__cpy(spec, idio_spec, MAXLEN - 1);
509 else
510 strnz__cpy(spec, try_spec, MAXLEN - 1);
511 if (s2_s[0] != '\0') {
512 strnz__cat(spec, " ", MAXLEN - 1);
513 strnz__cat(spec, s2_s, MAXLEN - 1);
514 }
515 return f_spec;
516 }
517 }
518 return false;
519}
520/** @brief Initialize Menu file specifications
521 @ingroup mem
522 @param init structure
523 @param argc - number of arguments in argv
524 @param argv - Arguments may have been provided by command line,
525 ~/.minitrc, environment variables, or calling program
526 interal to C-Menu
527 @details Positional args: [menu desc], [help file] */
528bool init_menu_files(Init *init, int argc, char **argv) {
529 char tmp_str[MAXLEN];
530 int optind = 0;
531 if (optind < argc && !init->f_mapp_spec) {
534 "~/menuapp/msrc", R_OK);
536 optind++;
537 }
538 if (optind < argc && !menu->f_help_spec) {
541 "~/menuapp/help", R_OK);
543 optind++;
544 }
545 if (!menu->f_mapp_spec) {
547 menu->mapp_spec, "~/menuapp/msrc/main.m", nullptr, nullptr, R_OK);
548 if (!menu->f_mapp_spec) {
549 strnz__cpy(tmp_str, "menu cannot read description file ",
550 MAXLEN - 1);
552 abend(-1, tmp_str);
553 }
554 }
555 if (!menu->f_help_spec) {
557 verify_spec_arg(menu->help_spec, "~/menuapp/help/menu.help",
558 nullptr, nullptr, R_OK);
559 if (!menu->f_help_spec) {
560 strnz__cpy(tmp_str, "menu cannot read help file ", MAXLEN - 1);
562 abend(-1, tmp_str);
563 }
564 }
565 return true;
566}
567/** @brief Initialize Pick file specifications
568 @ingroup mem
569 @param init structure
570 @param argc - number of arguments in argv
571 @param argv - Arguments may have been provided by command line,
572 ~/.minitrc,
573 environment variables, or
574 calling program interal to C-Menu
575 @details Positional args: [pick desc], [in_file], [out_file], [help_file] */
576bool init_pick_files(Init *init, int argc, char **argv) {
577 char tmp_str[MAXLEN];
578 int optind = 1;
580 init->mapp_data, "~/menuapp/data", R_OK);
583 "~/menuapp/data", W_OK | S_QUIET);
584 if (init->provider_cmd[0] != '\0') {
587 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
588 }
589 if (init->cmd[0] != '\0') {
591 "$PATH", X_OK | S_QUIET);
592 }
593 if (init->receiver_cmd[0] != '\0') {
596 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
597 }
598 if (init->title[0])
602 "~/menuapp/help", R_OK);
603 if (optind < argc && !pick->f_in_spec) {
606 "~/menuapp/data", R_OK);
607 if (pick->f_in_spec)
608 optind++;
609 }
610 if (optind < argc && !pick->f_out_spec) {
613 "~/menuapp/data", W_OK | S_QUIET);
615 optind++;
616 }
617 if (optind < argc && !pick->f_provider_cmd) {
618 if (argv[optind][0] != '\0') {
621 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
623 base_name(tmp_str, argv[optind]);
626 }
627 }
628 optind++;
629 }
630 if (optind < argc && !pick->f_cmd) {
631 if (argv[optind][0] != '\0') {
633 verify_spec_arg(pick->cmd, argv[optind], "~/menuapp/bin",
634 nullptr, X_OK | S_QUIET);
635 if (!pick->f_cmd) {
636 base_name(tmp_str, argv[optind]);
638 }
639 }
640 optind++;
641 }
642 if (optind < argc && !pick->f_receiver_cmd) {
643 if (argv[optind][0] != '\0') {
646 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
648 base_name(tmp_str, argv[optind]);
651 }
652 }
653 optind++;
654 }
655 if (optind < argc && !pick->f_help_spec) {
658 "~/menuapp/help", R_OK);
660 optind++;
661 }
662 if (pick->provider_cmd[0] != '\0')
664 if (pick->receiver_cmd[0] != '\0')
668 return true;
669}
670/** @brief Initialize Form file specifications
671 @ingroup mem
672 @param init pointer to init structure
673 @param argc - number of arguments in argv
674 @param argv - Arguments may have been provided by command line ~/.minitrc,
675 environment variables, or calling program interal to C-Menu
676 @details Positional args: [pick desc], [in_file], [out_file], [help_file] */
677bool init_form_files(Init *init, int argc, char **argv) {
678 char tmp_str[MAXLEN];
679 int optind = 0;
682 "~/menuapp/msrc", R_OK);
684 init->mapp_data, "~/menuapp/data", R_OK);
687 "~/menuapp/data", W_OK | S_QUIET);
688 if (init->provider_cmd[0] != '\0') {
691 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
692 }
693 if (init->cmd[0] != '\0') {
695 "$PATH", X_OK | S_QUIET);
696 }
697 if (init->receiver_cmd[0] != '\0') {
700 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
701 }
704 "~/menuapp/help", R_OK);
705 if (optind < argc && !form->f_mapp_spec) {
708 "~/menuapp/msrc", R_OK);
710 optind++;
711 }
712 if (optind < argc && !form->f_in_spec) {
715 "~/menuapp/data", R_OK);
716 if (form->f_in_spec)
717 optind++;
718 }
719 if (optind < argc && !form->f_out_spec) {
722 "~/menuapp/data", W_OK | S_QUIET);
724 optind++;
725 }
726 if (optind < argc && !form->f_provider_cmd) {
727 if (argv[optind][0] != '\0') {
730 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
732 base_name(tmp_str, argv[optind]);
735 }
736 }
737 optind++;
738 }
739 if (optind < argc && !form->f_cmd) {
740 if (argv[optind][0] != '\0') {
742 verify_spec_arg(form->cmd, argv[optind], "~/menuapp/bin",
743 nullptr, X_OK | S_QUIET);
744 if (!form->f_cmd) {
745 base_name(tmp_str, argv[optind]);
747 }
748 }
749 optind++;
750 }
751 if (optind < argc && !form->f_receiver_cmd) {
752 if (argv[optind][0] != '\0') {
755 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
757 base_name(tmp_str, argv[optind]);
760 }
761 }
762 optind++;
763 }
764 if (optind < argc && !form->f_help_spec) {
767 "~/menuapp/help", R_OK);
769 optind++;
770 }
771 if (form->cmd[0] != '\0')
773 if (form->provider_cmd[0] != '\0')
775 if (form->receiver_cmd[0] != '\0')
778 if (form->title[0] == '\0' && init->title[0] != '\0') {
781 }
783 return true;
784}
785/** @brief Initialize View file specifications
786 @ingroup mem
787 @param init structure
788 @details Positional args: pick desc, in_file, out_file, help_file */
789bool init_view_files(Init *init) {
790 char *e;
791 view = init->view;
792 view->lines = init->lines;
793 view->cols = init->cols;
797 view->f_ln = init->f_ln;
798 e = getenv("VIEW_HELP_FILE");
799 if (e && e[0] != '\0') {
801 }
804 "~/menuapp/help", R_OK);
805 if (!view->f_help_spec) {
809 }
813 if (view->cmd[0] != '\0')
815 if (view->provider_cmd[0] != '\0')
817 if (view->receiver_cmd[0] != '\0')
819 if (view->title[0] == '\0') {
820 if (init->title[0] != '\0') {
822 } else {
823 if (view->provider_cmd[0] != '\0')
825 else {
826 if (view->argv != nullptr && view->argv[0] != nullptr &&
827 view->argv[0][0] != '\0') {
829 } else
830 strnz__cpy(view->title, "C-Menu View", MAXLEN - 1);
831 }
832 }
833 }
835 if (view->tab_stop == 0)
836 view->tab_stop = 4;
837 return true;
838}
Form * form
Definition mem.c:47
#define FIELD_MAXCNT
Definition form.h:19
#define VIEW_HELP_FILE
Definition common.h:37
int init_cnt
Definition mem.c:43
Pick * pick
Definition mem.c:46
#define OBJ_MAXCNT
Definition pick.h:17
#define MAXARGS
Definition cm.h:30
#define nullptr
Definition cm.h:25
#define S_QUIET
Definition cm.h:219
#define S_WCOK
Definition cm.h:218
Menu * menu
Definition mem.c:45
View * view
Definition mem.c:48
#define MAXLEN
Definition curskeys.c:15
char em1[MAXLEN]
Definition dwin.c:142
char em0[MAXLEN]
Definition dwin.c:141
char em2[MAXLEN]
Definition dwin.c:143
int Perror(char *)
Display a simple error message window or print to stderr.
Definition dwin.c:1162
int display_error(char *em0, char *em1, char *em2, char *em3)
Display an error message window or print to stderr.
Definition dwin.c:1102
void abend(int, char *)
Abnormal program termination.
Definition dwin.c:1588
bool locate_file_in_path(char *, char *)
Locates a file in the system PATH.
Definition futil.c:1148
size_t canonicalize_file_spec(char *)
Removes quotes and trims at first space.
Definition futil.c:1202
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:435
int destroy_argv(int argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:385
bool stripz_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:635
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:311
bool expand_tilde(char *, int)
Replaces "~/" in string with the user's home directory.
Definition futil.c:904
bool strip_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:620
char * strnz_dup(char *, size_t)
Allocates memory for and duplicates string s up to length l or until line feed or carriage return.
Definition futil.c:545
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:464
bool verify_file(char *, int)
Verifies that the file specified by "in_spec" exists and is accessible with the permissions specified...
Definition futil.c:1101
bool verify_dir(char *, int)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
Definition futil.c:1050
bool base_name(char *, char *)
Returns the base name of a file specification.
Definition futil.c:984
bool init_form_files(Init *, int, char **)
Initialize Form file specifications.
Definition mem.c:677
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:359
Form * new_form(Init *, int, char **, int, int)
Create and initialize Form structure.
Definition mem.c:266
bool init_menu_files(Init *, int, char **)
Initialize Menu file specifications.
Definition mem.c:528
bool verify_spec_arg(char *, char *, char *, char *, int)
Verify file specification argument.
Definition mem.c:406
Init * new_init(int, char **)
Create and initialize Init structure.
Definition mem.c:70
Menu * new_menu(Init *, int, char **, int, int)
Create and initialize Menu structure.
Definition mem.c:148
Menu * destroy_menu(Init *init)
Destroy Menu structure.
Definition mem.c:169
Form * destroy_form(Init *init)
Destroy Form structure.
Definition mem.c:289
View * new_view(Init *)
Create and initialize View structure.
Definition mem.c:313
Pick * new_pick(Init *, int, char **, int, int)
Create and initialize Pick structure.
Definition mem.c:200
Init * destroy_init(Init *init)
Destroy Init structure.
Definition mem.c:105
bool init_pick_files(Init *, int, char **)
Initialize Pick file specifications.
Definition mem.c:576
bool init_view_files(Init *)
Initialize View file specifications.
Definition mem.c:789
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:239
char title[MAXLEN]
Definition common.h:120
char mapp_data[MAXLEN]
Definition common.h:136
char mapp_help[MAXLEN]
Definition common.h:137
SIO * sio
Definition common.h:105
int pick_cnt
Definition common.h:174
Form * form
Definition common.h:171
char in_spec[MAXLEN]
Definition common.h:155
char cmd_all[MAXLEN]
Definition common.h:114
int argc
Definition common.h:121
char fill_char[2]
Definition common.h:134
char mapp_msrc[MAXLEN]
Definition common.h:138
int cols
Definition common.h:107
int menu_cnt
Definition common.h:170
bool f_erase_remainder
Definition common.h:131
char mapp_home[MAXLEN]
Definition common.h:135
bool f_squeeze
Definition common.h:127
char mapp_spec[MAXLEN]
Definition common.h:163
char receiver_cmd[MAXLEN]
Definition common.h:112
bool f_multiple_cmd_args
Definition common.h:129
int select_max
Definition common.h:166
bool f_ln
Definition common.h:132
bool f_mapp_spec
Definition common.h:143
char provider_cmd[MAXLEN]
Definition common.h:111
char out_spec[MAXLEN]
Definition common.h:156
View * view
Definition common.h:175
Menu * menu
Definition common.h:169
bool f_at_end_remove
Definition common.h:125
int view_cnt
Definition common.h:176
char brackets[3]
Definition common.h:133
bool f_ignore_case
Definition common.h:124
char ** argv
Definition common.h:122
int lines
Definition common.h:106
char cmd[MAXLEN]
Definition common.h:113
int form_cnt
Definition common.h:172
char help_spec[MAXLEN]
Definition common.h:164
Pick * pick
Definition common.h:173
Text * text[FIELD_MAXCNT]
Definition form.h:338
bool f_mapp_spec
Definition form.h:192
bool f_erase_remainder
Definition form.h:235
Field * field[FIELD_MAXCNT]
Definition form.h:351
char receiver_cmd[MAXLEN]
Definition form.h:178
int begy
Definition form.h:151
char provider_cmd[MAXLEN]
Definition form.h:170
int begx
Definition form.h:153
bool f_provider_cmd
Definition form.h:256
char fill_char[2]
Definition form.h:297
bool f_cmd
Definition form.h:271
bool f_help_spec
Definition form.h:231
char out_spec[MAXLEN]
Definition form.h:208
bool f_receiver_cmd
Definition form.h:263
bool f_multiple_cmd_args
Definition form.h:243
char in_spec[MAXLEN]
Definition form.h:201
char mapp_spec[FIELD_MAXLEN]
Definition form.h:167
char cmd[MAXLEN]
Definition form.h:185
char title[MAXLEN]
Definition form.h:157
char brackets[3]
Definition form.h:279
bool f_out_spec
Definition form.h:218
bool f_in_spec
Definition form.h:215
char help_spec[MAXLEN]
Definition form.h:194
char * choice_text
Definition menu.h:63
char * raw_text
Definition menu.h:60
char * command_str
Definition menu.h:79
char mapp_spec[MAXLEN]
Definition menu.h:124
Line * line[MAX_MENU_LINES]
Definition menu.h:203
bool f_help_spec
Definition menu.h:162
int begy
Definition menu.h:103
bool f_mapp_spec
Definition menu.h:157
int item_count
Definition menu.h:196
int line_idx
Definition menu.h:199
char help_spec[MAXLEN]
Definition menu.h:130
int begx
Definition menu.h:106
char ** m_object
Definition pick.h:66
bool f_cmd
Definition pick.h:64
bool f_provider_cmd
Definition pick.h:62
bool f_in_spec
Definition pick.h:54
int m_idx
Definition pick.h:72
char ** d_object
Definition pick.h:74
char cmd[MAXLEN]
Definition pick.h:51
bool f_help_spec
Definition pick.h:58
bool f_out_spec
Definition pick.h:55
bool f_multiple_cmd_args
Definition pick.h:59
char title[MAXLEN]
Definition pick.h:38
char help_spec[MAXLEN]
Definition pick.h:48
char receiver_cmd[MAXLEN]
Definition pick.h:50
int select_max
Definition pick.h:69
char in_spec[MAXLEN]
Definition pick.h:46
int begx
Definition pick.h:32
int begy
Definition pick.h:31
bool f_receiver_cmd
Definition pick.h:63
char provider_cmd[MAXLEN]
Definition pick.h:49
char out_spec[MAXLEN]
Definition pick.h:47
char provider_cmd[MAXLEN]
Definition view.h:52
int argc
Definition view.h:58
char ** argv
Definition view.h:59
WINDOW * pad
Definition view.h:69
char help_spec[MAXLEN]
Definition view.h:123
bool f_ignore_case
Definition view.h:61
bool f_help_spec
Definition view.h:126
char cmd[MAXLEN]
Definition view.h:54
char receiver_cmd[MAXLEN]
Definition view.h:53
WINDOW * cmdln_win
Definition view.h:68
off_t * ln_tbl
Definition view.h:159
int cols
Definition view.h:49
bool f_ln
Definition view.h:156
WINDOW * ln_win
Definition view.h:70
int lines
Definition view.h:48
bool f_at_end_remove
Definition view.h:62
bool f_squeeze
Definition view.h:63
int tab_stop
Definition view.h:77
char title[MAXLEN]
Definition view.h:57
char cmd_all[MAXLEN]
Definition view.h:55
WINDOW * box
Definition view.h:67