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 @note calloc initializes all fields to zero/nullptr
52 @param argc, argv - arguments
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 @note 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 }
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->object = calloc(OBJ_MAXCNT + 1, sizeof(char *));
213 if (pick->object == nullptr) {
214 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__, __LINE__ - 1);
216 "calloc pick->object = calloc(%d, %d) failed\n",
217 OBJ_MAXCNT + 1, sizeof(char *));
219 abend(-1, "User terminated program");
220 }
221 pick->begy = begy;
222 pick->begx = begx;
223 return init->pick;
224}
225/** @brief Destroy Pick structure
226 @ingroup mem
227 @param init structure
228 @return nullptr
229 */
230Pick *destroy_pick(Init *init) {
231 if (!init->pick)
232 return nullptr;
233
237 free(pick->object);
238 free(pick);
239 init->pick = nullptr;
240 init->pick_cnt--;
241 return init->pick;
242}
243/** @brief Create and initialize Form structure
244 @ingroup mem
245 @param init structure
246 @param argc - number of arguments in argv
247 @param argv - Arguments may have been provided by command line,
248 ~/.minitrc,
249 environment variables, or
250 calling program interal to C-Menu
251 @param begy, begx - initial position of form window
252 */
253Form *new_form(Init *init, int argc, char **argv, int begy, int begx) {
254 init->form = (Form *)calloc(1, sizeof(Form));
255 if (!init->form) {
256 abend(-1, "calloc form failed");
257 return nullptr;
258 }
259 init->form_cnt++;
260 form = init->form;
261 if (!init_form_files(init, argc, argv)) {
262 abend(-1, "init_form_files failed");
263 return nullptr;
264 }
267 form->begy = begy;
268 form->begx = begx;
269 return init->form;
270}
271/** @brief Destroy Form structure
272 @ingroup mem
273 @param init structure
274 @return nullptr
275 */
276Form *destroy_form(Init *init) {
277 int i;
278
279 if (!init->form)
280 return nullptr;
281 for (i = 0; i < FIELD_MAXCNT; i++) {
282 if (init->form->field[i])
283 free(init->form->field[i]);
284 init->form->field[i] = nullptr;
285 }
286 for (i = 0; i < FIELD_MAXCNT; i++) {
287 if (init->form->text[i])
288 free(init->form->text[i]);
289 init->form->text[i] = nullptr;
290 }
291 free(init->form);
292 init->form = nullptr;
293 init->form_cnt--;
294 return init->form;
295}
296/** @brief Create and initialize View structure
297 @ingroup mem
298 @param init structure
299 */
300View *new_view(Init *init) {
301 init->view_cnt++;
302 init->view = (View *)calloc(1, sizeof(View));
303 if (!init->view) {
304 free(init->view);
305 ssnprintf(em0, MAXLEN - 1, "%s, line: %d, errno: %d", __FILE__,
306 __LINE__ - 1, errno);
307 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
308 ssnprintf(em2, MAXLEN - 1, "init->view = calloc(%d) failed\n",
309 sizeof(View));
311 abend(-1, "calloc init->view failed");
312 return nullptr;
313 }
314 view = init->view;
315 view->argc = init->argc;
316 if (view->argc > 0) {
317 view->argv = calloc(view->argc + 1, sizeof(char *));
318 if (view->argv == nullptr) {
319 free(view->argv);
320 ssnprintf(em0, MAXLEN - 1, "%s, line: %d, errno: %d", __FILE__,
321 __LINE__ - 1, errno);
322 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
323 ssnprintf(em2, MAXLEN - 1, "view->argv = calloc(%d, %d) failed\n",
324 view->argc, sizeof(char *));
326 abend(-1, "User terminated program");
327 return nullptr;
328 }
329 int s = 0;
330 int d = 0;
331 while (s < init->argc)
332 view->argv[d++] = strnz_dup(init->argv[s++], MAXLEN - 1);
333 view->argv[d] = nullptr;
334 }
335 if (!init_view_files(init)) {
336 abend(-1, "init_view_files failed");
337 return nullptr;
338 }
339 return view;
340}
341/** @brief Destroy View structure
342 @ingroup mem
343 @param init structure
344 @return nullptr
345 */
346View *destroy_view(Init *init) {
347 view = init->view;
348 if (!view)
349 return nullptr;
350 if (view->ln_tbl) {
351 free(view->ln_tbl);
353 }
354 if (view->ln_win) {
355 delwin(view->ln_win);
357 }
358 if (view->cmdln_win) {
359 delwin(view->cmdln_win);
361 }
362 delwin(view->cmdln_win);
363 if (view->box) {
364 delwin(view->box);
366 }
367 delwin(view->box);
368 if (view->pad) {
369 delwin(view->pad);
371 }
372 delwin(view->pad);
374 free(view->argv);
375 free(view);
376 init->view = nullptr;
377 view = nullptr;
378 init->view_cnt--;
379 return init->view;
380}
381/** @brief Verify file specification argument
382 @ingroup mem
383 @param spec - menu->spec, form->spec, etc.
384 @param org_spec - init->._spec | argv[optind]
385 @param dir - init->._. directory
386 @param alt_dir - literal, "~/menuapp/data", etc.
387 @param mode - R_OK, W_OK, X_OK, WC_OK, S_QUIET
388 @note mode is a bitwise OR of the following flags:
389 S_QUIET - suppress error messages
390 WC_OK - write create ok
391 @return bool - true if file verified
392 */
393bool verify_spec_arg(char *spec, char *org_spec, char *dir, char *alt_dir,
394 int mode) {
395 bool f_dir = false;
396 bool f_spec = false;
397 bool f_quote = true;
398 char *s1;
399 char *s2;
400 char s1_s[MAXLEN];
401 char s2_s[MAXLEN];
402 char file_name[MAXLEN];
403 char try_spec[MAXLEN];
404 char idio_spec[MAXLEN];
405
406 if (!org_spec[0])
407 return false;
408 idio_spec[0] = '\0';
409 strnz__cpy(try_spec, org_spec, MAXLEN - 1);
410 f_quote = stripz_quotes(try_spec);
411 s1 = strtok(try_spec, " \t\n");
412 strnz__cpy(s1_s, s1, MAXLEN - 1);
413 s2 = strtok(nullptr, "\n");
414 strnz__cpy(s2_s, s2, MAXLEN - 1);
415 strnz__cpy(file_name, s1, MAXLEN - 1);
416 strnz__cpy(try_spec, file_name, MAXLEN - 1);
418 if (try_spec[0]) {
419 expand_tilde(try_spec, MAXLEN - 1);
420 if (try_spec[0] == '/') {
421 f_spec = verify_file(try_spec, mode);
422 if (f_quote)
423 /** preserve quotes */
424 strnz__cpy(spec, org_spec, MAXLEN - 1);
425 else
426 strnz__cpy(spec, try_spec, MAXLEN - 1);
427 return f_spec;
428 } else {
429 if (!f_dir && dir[0]) {
430 if (strcmp(dir, "$PATH") == 0) {
431 strnz__cpy(try_spec, file_name, MAXLEN - 1);
432 f_spec = locate_file_in_path(try_spec, file_name);
433 } else {
434 strnz__cpy(try_spec, dir, MAXLEN - 1);
435 expand_tilde(try_spec, MAXLEN - 1);
436 f_dir = verify_dir(try_spec, mode);
437 if (f_dir) {
438 strnz__cat(try_spec, "/", MAXLEN - 1);
439 strnz__cat(try_spec, file_name, MAXLEN - 1);
440 strnz__cpy(idio_spec, try_spec, MAXLEN - 1);
441 if (mode & S_WCOK)
442 f_spec = true;
443 else
444 f_spec = verify_file(idio_spec, mode | S_QUIET);
445 }
446 }
447 }
448 if (!f_spec && alt_dir && alt_dir[0] != '\0') {
449 if (strcmp(alt_dir, "$PATH") == 0) {
450 strnz__cpy(try_spec, file_name, MAXLEN - 1);
451 f_spec = locate_file_in_path(try_spec, file_name);
452 } else {
453 strnz__cpy(try_spec, alt_dir, MAXLEN - 1);
454 expand_tilde(try_spec, MAXLEN - 1);
455 f_dir = verify_dir(try_spec, mode);
456 if (f_dir) {
457 strnz__cat(try_spec, "/", MAXLEN - 1);
458 strnz__cat(try_spec, file_name, MAXLEN - 1);
459 if (mode & S_WCOK)
460 f_spec = true;
461 else
462 f_spec = verify_file(try_spec, mode | S_QUIET);
463 }
464 }
465 }
466 if (!f_spec) {
467 strnz__cpy(try_spec, ".", MAXLEN - 1);
468 strnz__cat(try_spec, "/", MAXLEN - 1);
469 strnz__cat(try_spec, file_name, MAXLEN - 1);
470 f_spec = verify_file(try_spec, mode | S_QUIET);
471 }
472 if (!f_spec && mode == W_OK) {
473 strnz__cpy(try_spec, idio_spec, MAXLEN - 1);
474 FILE *fp = fopen(try_spec, "a");
475 if (fp) {
476 fclose(fp);
477 f_spec = true;
478 }
479 }
480 if (f_quote)
481 /** preserve quotes */
482 strnz__cpy(spec, org_spec, MAXLEN - 1);
483 else if (f_spec)
484 strnz__cpy(spec, try_spec, MAXLEN - 1);
485 if (try_spec[0] == '\0' && idio_spec[0] != '\0')
486 strnz__cpy(spec, idio_spec, MAXLEN - 1);
487 else
488 strnz__cpy(spec, try_spec, MAXLEN - 1);
489 if (s2_s[0] != '\0') {
490 strnz__cat(spec, " ", MAXLEN - 1);
491 strnz__cat(spec, s2_s, MAXLEN - 1);
492 }
493 return f_spec;
494 }
495 }
496 return false;
497}
498/** @brief Initialize Menu file specifications
499 @ingroup mem
500 @param init structure
501 @param argc - number of arguments in argv
502 @param argv - Arguments may have been provided by command line,
503 ~/.minitrc, environment variables, or calling program
504 interal to C-Menu
505 @note Positional args: [menu desc], [help file] */
506bool init_menu_files(Init *init, int argc, char **argv) {
507 char tmp_str[MAXLEN];
508 int optind = 0;
509 if (optind < argc && !init->f_mapp_spec) {
512 "~/menuapp/msrc", R_OK);
514 optind++;
515 }
516 if (optind < argc && !menu->f_help_spec) {
519 "~/menuapp/help", R_OK);
521 optind++;
522 }
523 if (!menu->f_mapp_spec) {
525 menu->mapp_spec, "~/menuapp/msrc/main.m", nullptr, nullptr, R_OK);
526 if (!menu->f_mapp_spec) {
527 strnz__cpy(tmp_str, "menu cannot read description file ",
528 MAXLEN - 1);
530 abend(-1, tmp_str);
531 }
532 }
533 if (!menu->f_help_spec) {
535 verify_spec_arg(menu->help_spec, "~/menuapp/help/menu.help",
536 nullptr, nullptr, R_OK);
537 if (!menu->f_help_spec) {
538 strnz__cpy(tmp_str, "menu cannot read help file ", MAXLEN - 1);
540 abend(-1, tmp_str);
541 }
542 }
543 return true;
544}
545/** @brief Initialize Pick file specifications
546 @ingroup mem
547 @param init structure
548 @param argc - number of arguments in argv
549 @param argv - Arguments may have been provided by command line,
550 ~/.minitrc,
551 environment variables, or
552 calling program interal to C-Menu
553 @note Positional args: [pick desc], [in_file], [out_file], [help_file] */
554bool init_pick_files(Init *init, int argc, char **argv) {
555 char tmp_str[MAXLEN];
556 int optind = 1;
558 init->mapp_data, "~/menuapp/data", R_OK);
561 "~/menuapp/data", W_OK | S_QUIET);
562 if (init->provider_cmd[0] != '\0') {
565 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
566 }
567 if (init->cmd[0] != '\0') {
569 "$PATH", X_OK | S_QUIET);
570 }
571 if (init->receiver_cmd[0] != '\0') {
574 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
575 }
576 if (init->title[0])
580 "~/menuapp/help", R_OK);
581 if (optind < argc && !pick->f_in_spec) {
584 "~/menuapp/data", R_OK);
585 if (pick->f_in_spec)
586 optind++;
587 }
588 if (optind < argc && !pick->f_out_spec) {
591 "~/menuapp/data", W_OK | S_QUIET);
593 optind++;
594 }
595 if (optind < argc && !pick->f_provider_cmd) {
596 if (argv[optind][0] != '\0') {
599 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
601 base_name(tmp_str, argv[optind]);
604 }
605 }
606 optind++;
607 }
608 if (optind < argc && !pick->f_cmd) {
609 if (argv[optind][0] != '\0') {
611 verify_spec_arg(pick->cmd, argv[optind], "~/menuapp/bin",
612 nullptr, X_OK | S_QUIET);
613 if (!pick->f_cmd) {
614 base_name(tmp_str, argv[optind]);
616 }
617 }
618 optind++;
619 }
620 if (optind < argc && !pick->f_receiver_cmd) {
621 if (argv[optind][0] != '\0') {
624 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
626 base_name(tmp_str, argv[optind]);
629 }
630 }
631 optind++;
632 }
633 if (optind < argc && !pick->f_help_spec) {
636 "~/menuapp/help", R_OK);
638 optind++;
639 }
642 return true;
643}
644/** @brief Initialize Form file specifications
645 @ingroup mem
646 @param init pointer to init structure
647 @param argc - number of arguments in argv
648 @param argv - Arguments may have been provided by command line ~/.minitrc,
649 environment variables, or calling program interal to C-Menu
650 @note Positional args: [pick desc], [in_file], [out_file], [help_file] */
651bool init_form_files(Init *init, int argc, char **argv) {
652 char tmp_str[MAXLEN];
653 int optind = 0;
656 "~/menuapp/msrc", R_OK);
658 init->mapp_data, "~/menuapp/data", R_OK);
661 "~/menuapp/data", W_OK | S_QUIET);
662 if (init->provider_cmd[0] != '\0') {
665 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
666 }
667 if (init->cmd[0] != '\0') {
669 "$PATH", X_OK | S_QUIET);
670 }
671 if (init->receiver_cmd[0] != '\0') {
674 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
675 }
678 "~/menuapp/help", R_OK);
679 if (optind < argc && !form->f_mapp_spec) {
682 "~/menuapp/msrc", R_OK);
684 optind++;
685 }
686 if (optind < argc && !form->f_in_spec) {
689 "~/menuapp/data", R_OK);
690 if (form->f_in_spec)
691 optind++;
692 }
693 if (optind < argc && !form->f_out_spec) {
696 "~/menuapp/data", W_OK | S_QUIET);
698 optind++;
699 }
700 if (optind < argc && !form->f_provider_cmd) {
701 if (argv[optind][0] != '\0') {
704 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
706 base_name(tmp_str, argv[optind]);
709 }
710 }
711 optind++;
712 }
713 if (optind < argc && !form->f_cmd) {
714 if (argv[optind][0] != '\0') {
716 verify_spec_arg(form->cmd, argv[optind], "~/menuapp/bin",
717 nullptr, X_OK | S_QUIET);
718 if (!form->f_cmd) {
719 base_name(tmp_str, argv[optind]);
721 }
722 }
723 optind++;
724 }
725 if (optind < argc && !form->f_receiver_cmd) {
726 if (argv[optind][0] != '\0') {
729 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
731 base_name(tmp_str, argv[optind]);
734 }
735 }
736 optind++;
737 }
738 if (optind < argc && !form->f_help_spec) {
741 "~/menuapp/help", R_OK);
743 optind++;
744 }
746 if (form->title[0] == '\0' && init->title[0] != '\0') {
749 }
750 return true;
751}
752/** @brief Initialize View file specifications
753 @ingroup mem
754 @param init structure
755 @note Positional args: pick desc, in_file, out_file, help_file */
756bool init_view_files(Init *init) {
757 char *e;
758 view = init->view;
759 view->lines = init->lines;
760 view->cols = init->cols;
764 view->f_ln = init->f_ln;
765 e = getenv("VIEW_HELP_FILE");
766 if (e && e[0] != '\0') {
768 }
771 "~/menuapp/help", R_OK);
772 if (!view->f_help_spec) {
776 }
780 if (view->title[0] == '\0') {
781 if (init->title[0] != '\0') {
783 } else {
784 if (view->provider_cmd[0] != '\0')
786 else {
787 if (view->argv[0] != nullptr && view->argv[0][0] != '\0')
789 else
790 strnz__cpy(view->title, "C-Menu View", MAXLEN - 1);
791 }
792 }
793 }
795 if (view->tab_stop == 0)
796 view->tab_stop = 4;
797 return true;
798}
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:191
#define S_WCOK
Definition cm.h:190
Menu * menu
Definition mem.c:45
View * view
Definition mem.c:48
#define MAXLEN
Definition curskeys.c:15
char em1[MAXLEN]
Definition dwin.c:134
char em0[MAXLEN]
Definition dwin.c:133
char em2[MAXLEN]
Definition dwin.c:135
int Perror(char *)
Display a simple error message window or print to stderr.
Definition dwin.c:1115
int display_error(char *em0, char *em1, char *em2, char *em3)
Display an error message window or print to stderr.
Definition dwin.c:1059
void abend(int, char *)
Abnormal program termination.
Definition dwin.c:1336
bool locate_file_in_path(char *, char *)
Locates a file in the system PATH.
Definition futil.c:964
void destroy_argv(int argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:230
size_t canonicalize_file_spec(char *)
Removes quotes and trims at first space.
Definition futil.c:1315
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:278
bool stripz_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:478
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:156
bool strip_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:463
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:388
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:307
bool verify_file(char *, int)
Verifies that the file specified by "in_spec" exists and is accessible with the permissions specified...
Definition futil.c:917
bool expand_tilde(char *, int)
Replace Leading Tilde With Home Directory.
Definition futil.c:709
bool verify_dir(char *, int)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
Definition futil.c:866
bool base_name(char *, char *)
Returns the base name of a file specification.
Definition futil.c:800
bool init_form_files(Init *, int, char **)
Initialize Form file specifications.
Definition mem.c:651
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:346
Form * new_form(Init *, int, char **, int, int)
Create and initialize Form structure.
Definition mem.c:253
bool init_menu_files(Init *, int, char **)
Initialize Menu file specifications.
Definition mem.c:506
bool verify_spec_arg(char *, char *, char *, char *, int)
Verify file specification argument.
Definition mem.c:393
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:276
View * new_view(Init *)
Create and initialize View structure.
Definition mem.c:300
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:554
bool init_view_files(Init *)
Initialize View file specifications.
Definition mem.c:756
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:230
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:331
bool f_mapp_spec
Definition form.h:192
bool f_erase_remainder
Definition form.h:235
Field * field[FIELD_MAXCNT]
Definition form.h:344
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:255
char fill_char[2]
Definition form.h:290
bool f_cmd
Definition form.h:270
bool f_help_spec
Definition form.h:231
char out_spec[MAXLEN]
Definition form.h:208
bool f_receiver_cmd
Definition form.h:262
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:278
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:54
char * raw_text
Definition menu.h:51
char * command_str
Definition menu.h:70
char mapp_spec[MAXLEN]
Definition menu.h:115
Line * line[MAX_MENU_LINES]
Definition menu.h:194
bool f_help_spec
Definition menu.h:153
int begy
Definition menu.h:94
bool f_mapp_spec
Definition menu.h:148
int item_count
Definition menu.h:187
int line_idx
Definition menu.h:190
char help_spec[MAXLEN]
Definition menu.h:121
int begx
Definition menu.h:97
bool f_cmd
Definition pick.h:64
bool f_provider_cmd
Definition pick.h:62
int obj_idx
Definition pick.h:71
int obj_cnt
Definition pick.h:70
bool f_in_spec
Definition pick.h:54
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:37
char help_spec[MAXLEN]
Definition pick.h:47
char receiver_cmd[MAXLEN]
Definition pick.h:50
int select_max
Definition pick.h:69
char in_spec[MAXLEN]
Definition pick.h:45
int begx
Definition pick.h:32
int begy
Definition pick.h:31
char ** object
Definition pick.h:66
bool f_receiver_cmd
Definition pick.h:63
char provider_cmd[MAXLEN]
Definition pick.h:49
char out_spec[MAXLEN]
Definition pick.h:46
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 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