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 delwin(view->ln_win);
351 delwin(view->win);
352 free(view->ln_tbl);
354 free(view->argv);
355 free(view);
356 init->view = nullptr;
357 view = nullptr;
358 init->view_cnt--;
359 return init->view;
360}
361/** @brief Verify file specification argument
362 @ingroup mem
363 @param spec - menu->spec, form->spec, etc.
364 @param org_spec - init->._spec | argv[optind]
365 @param dir - init->._. directory
366 @param alt_dir - literal, "~/menuapp/data", etc.
367 @param mode - R_OK, W_OK, X_OK, WC_OK, S_QUIET
368 @note mode is a bitwise OR of the following flags:
369 S_QUIET - suppress error messages
370 WC_OK - write create ok
371 @return bool - true if file verified
372 */
373bool verify_spec_arg(char *spec, char *org_spec, char *dir, char *alt_dir,
374 int mode) {
375 bool f_dir = false;
376 bool f_spec = false;
377 bool f_quote = true;
378 char *s1;
379 char *s2;
380 char s1_s[MAXLEN];
381 char s2_s[MAXLEN];
382 char file_name[MAXLEN];
383 char try_spec[MAXLEN];
384 char idio_spec[MAXLEN];
385
386 if (!org_spec[0])
387 return false;
388 idio_spec[0] = '\0';
389 strnz__cpy(try_spec, org_spec, MAXLEN - 1);
390 f_quote = stripz_quotes(try_spec);
391 s1 = strtok(try_spec, " \t\n");
392 strnz__cpy(s1_s, s1, MAXLEN - 1);
393 s2 = strtok(nullptr, "\n");
394 strnz__cpy(s2_s, s2, MAXLEN - 1);
395 strnz__cpy(file_name, s1, MAXLEN - 1);
396 strnz__cpy(try_spec, file_name, MAXLEN - 1);
398 if (try_spec[0]) {
399 expand_tilde(try_spec, MAXLEN - 1);
400 if (try_spec[0] == '/') {
401 f_spec = verify_file(try_spec, mode);
402 if (f_quote)
403 /** preserve quotes */
404 strnz__cpy(spec, org_spec, MAXLEN - 1);
405 else
406 strnz__cpy(spec, try_spec, MAXLEN - 1);
407 return f_spec;
408 } else {
409 if (!f_dir && dir[0]) {
410 if (strcmp(dir, "$PATH") == 0) {
411 strnz__cpy(try_spec, file_name, MAXLEN - 1);
412 f_spec = locate_file_in_path(try_spec, file_name);
413 } else {
414 strnz__cpy(try_spec, dir, MAXLEN - 1);
415 expand_tilde(try_spec, MAXLEN - 1);
416 f_dir = verify_dir(try_spec, mode);
417 if (f_dir) {
418 strnz__cat(try_spec, "/", MAXLEN - 1);
419 strnz__cat(try_spec, file_name, MAXLEN - 1);
420 strnz__cpy(idio_spec, try_spec, MAXLEN - 1);
421 if (mode & S_WCOK)
422 f_spec = true;
423 else
424 f_spec = verify_file(idio_spec, mode | S_QUIET);
425 }
426 }
427 }
428 if (!f_spec && alt_dir && alt_dir[0] != '\0') {
429 if (strcmp(alt_dir, "$PATH") == 0) {
430 strnz__cpy(try_spec, file_name, MAXLEN - 1);
431 f_spec = locate_file_in_path(try_spec, file_name);
432 } else {
433 strnz__cpy(try_spec, alt_dir, MAXLEN - 1);
434 expand_tilde(try_spec, MAXLEN - 1);
435 f_dir = verify_dir(try_spec, mode);
436 if (f_dir) {
437 strnz__cat(try_spec, "/", MAXLEN - 1);
438 strnz__cat(try_spec, file_name, MAXLEN - 1);
439 if (mode & S_WCOK)
440 f_spec = true;
441 else
442 f_spec = verify_file(try_spec, mode | S_QUIET);
443 }
444 }
445 }
446 if (!f_spec) {
447 strnz__cpy(try_spec, ".", MAXLEN - 1);
448 strnz__cat(try_spec, "/", MAXLEN - 1);
449 strnz__cat(try_spec, file_name, MAXLEN - 1);
450 f_spec = verify_file(try_spec, mode | S_QUIET);
451 }
452 if (!f_spec && mode == W_OK) {
453 strnz__cpy(try_spec, idio_spec, MAXLEN - 1);
454 FILE *fp = fopen(try_spec, "a");
455 if (fp) {
456 fclose(fp);
457 f_spec = true;
458 }
459 }
460 if (f_quote)
461 /** preserve quotes */
462 strnz__cpy(spec, org_spec, MAXLEN - 1);
463 else if (f_spec)
464 strnz__cpy(spec, try_spec, MAXLEN - 1);
465 if (try_spec[0] == '\0' && idio_spec[0] != '\0')
466 strnz__cpy(spec, idio_spec, MAXLEN - 1);
467 else
468 strnz__cpy(spec, try_spec, MAXLEN - 1);
469 if (s2_s[0] != '\0') {
470 strnz__cat(spec, " ", MAXLEN - 1);
471 strnz__cat(spec, s2_s, MAXLEN - 1);
472 }
473 return f_spec;
474 }
475 }
476 return false;
477}
478/** @brief Initialize Menu file specifications
479 @ingroup mem
480 @param init structure
481 @param argc - number of arguments in argv
482 @param argv - Arguments may have been provided by command line,
483 ~/.minitrc, environment variables, or calling program
484 interal to C-Menu
485 @note Positional args: [menu desc], [help file] */
486bool init_menu_files(Init *init, int argc, char **argv) {
487 char tmp_str[MAXLEN];
488 int optind = 1;
489 if (optind < argc && !init->f_mapp_spec) {
492 "~/menuapp/msrc", R_OK);
494 optind++;
495 }
496 if (optind < argc && !menu->f_help_spec) {
499 "~/menuapp/help", R_OK);
501 optind++;
502 }
503 if (!menu->f_mapp_spec) {
505 menu->mapp_spec, "~/menuapp/msrc/main.m", nullptr, nullptr, R_OK);
506 if (!menu->f_mapp_spec) {
507 strnz__cpy(tmp_str, "menu cannot read description file ",
508 MAXLEN - 1);
510 abend(-1, tmp_str);
511 }
512 }
513 if (!menu->f_help_spec) {
515 verify_spec_arg(menu->help_spec, "~/menuapp/help/menu.help",
516 nullptr, nullptr, R_OK);
517 if (!menu->f_help_spec) {
518 strnz__cpy(tmp_str, "menu cannot read help file ", MAXLEN - 1);
520 abend(-1, tmp_str);
521 }
522 }
523 return true;
524}
525/** @brief Initialize Pick file specifications
526 @ingroup mem
527 @param init structure
528 @param argc - number of arguments in argv
529 @param argv - Arguments may have been provided by command line,
530 ~/.minitrc,
531 environment variables, or
532 calling program interal to C-Menu
533 @note Positional args: [pick desc], [in_file], [out_file], [help_file] */
534bool init_pick_files(Init *init, int argc, char **argv) {
535 char tmp_str[MAXLEN];
536 int optind = 1;
538 init->mapp_data, "~/menuapp/data", R_OK);
541 "~/menuapp/data", W_OK | S_QUIET);
542 if (init->provider_cmd[0] != '\0') {
545 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
546 }
547 if (init->cmd[0] != '\0') {
549 "$PATH", X_OK | S_QUIET);
550 }
551 if (init->receiver_cmd[0] != '\0') {
554 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
555 }
556 if (init->title[0])
560 "~/menuapp/help", R_OK);
561 if (optind < argc && !pick->f_in_spec) {
564 "~/menuapp/data", R_OK);
565 if (pick->f_in_spec)
566 optind++;
567 }
568 if (optind < argc && !pick->f_out_spec) {
571 "~/menuapp/data", W_OK | S_QUIET);
573 optind++;
574 }
575 if (optind < argc && !pick->f_provider_cmd) {
576 if (argv[optind][0] != '\0') {
579 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
581 base_name(tmp_str, argv[optind]);
584 }
585 }
586 optind++;
587 }
588 if (optind < argc && !pick->f_cmd) {
589 if (argv[optind][0] != '\0') {
591 verify_spec_arg(pick->cmd, argv[optind], "~/menuapp/bin",
592 nullptr, X_OK | S_QUIET);
593 if (!pick->f_cmd) {
594 base_name(tmp_str, argv[optind]);
596 }
597 }
598 optind++;
599 }
600 if (optind < argc && !pick->f_receiver_cmd) {
601 if (argv[optind][0] != '\0') {
604 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
606 base_name(tmp_str, argv[optind]);
609 }
610 }
611 optind++;
612 }
613 if (optind < argc && !pick->f_help_spec) {
616 "~/menuapp/help", R_OK);
618 optind++;
619 }
622 return true;
623}
624/** @brief Initialize Form file specifications
625 @ingroup mem
626 @param init pointer to init structure
627 @param argc - number of arguments in argv
628 @param argv - Arguments may have been provided by command line ~/.minitrc,
629 environment variables, or calling program interal to C-Menu
630 @note Positional args: [pick desc], [in_file], [out_file], [help_file] */
631bool init_form_files(Init *init, int argc, char **argv) {
632 char tmp_str[MAXLEN];
633 int optind = 0;
636 "~/menuapp/msrc", R_OK);
638 init->mapp_data, "~/menuapp/data", R_OK);
641 "~/menuapp/data", W_OK | S_QUIET);
642 if (init->provider_cmd[0] != '\0') {
645 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
646 }
647 if (init->cmd[0] != '\0') {
649 "$PATH", X_OK | S_QUIET);
650 }
651 if (init->receiver_cmd[0] != '\0') {
654 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
655 }
658 "~/menuapp/help", R_OK);
659 if (optind < argc && !form->f_mapp_spec) {
662 "~/menuapp/msrc", R_OK);
664 optind++;
665 }
666 if (optind < argc && !form->f_in_spec) {
669 "~/menuapp/data", R_OK);
670 if (form->f_in_spec)
671 optind++;
672 }
673 if (optind < argc && !form->f_out_spec) {
676 "~/menuapp/data", W_OK | S_QUIET);
678 optind++;
679 }
680 if (optind < argc && !form->f_provider_cmd) {
681 if (argv[optind][0] != '\0') {
684 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
686 base_name(tmp_str, argv[optind]);
689 }
690 }
691 optind++;
692 }
693 if (optind < argc && !form->f_cmd) {
694 if (argv[optind][0] != '\0') {
696 verify_spec_arg(form->cmd, argv[optind], "~/menuapp/bin",
697 nullptr, X_OK | S_QUIET);
698 if (!form->f_cmd) {
699 base_name(tmp_str, argv[optind]);
701 }
702 }
703 optind++;
704 }
705 if (optind < argc && !form->f_receiver_cmd) {
706 if (argv[optind][0] != '\0') {
709 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
711 base_name(tmp_str, argv[optind]);
714 }
715 }
716 optind++;
717 }
718 if (optind < argc && !form->f_help_spec) {
721 "~/menuapp/help", R_OK);
723 optind++;
724 }
726 if (form->title[0] == '\0' && init->title[0] != '\0') {
729 }
730 return true;
731}
732/** @brief Initialize View file specifications
733 @ingroup mem
734 @param init structure
735 @note Positional args: pick desc, in_file, out_file, help_file */
736bool init_view_files(Init *init) {
737 char *e;
738 view = init->view;
739 view->lines = init->lines;
740 view->cols = init->cols;
744 view->f_ln = init->f_ln;
745 e = getenv("VIEW_HELP_FILE");
746 if (e && e[0] != '\0') {
748 }
751 "~/menuapp/help", R_OK);
752 if (!view->f_help_spec) {
756 }
760 if (view->title[0] == '\0') {
761 if (init->title[0] != '\0') {
763 } else {
764 if (view->provider_cmd[0] != '\0')
766 else {
767 if (view->argv[0] != nullptr && view->argv[0][0] != '\0')
769 else
770 strnz__cpy(view->title, "C-Menu View", MAXLEN - 1);
771 }
772 }
773 }
775 if (view->tab_stop == 0)
776 view->tab_stop = 4;
777 return true;
778}
Form * form
Definition mem.c:47
#define FIELD_MAXCNT
Definition form.h:19
#define VIEW_HELP_FILE
Definition common.h:39
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:23
#define S_QUIET
Definition cm.h:183
#define S_WCOK
Definition cm.h:182
Menu * menu
Definition mem.c:45
View * view
Definition mem.c:48
#define MAXLEN
Definition curskeys.c:15
char em1[MAXLEN]
Definition dwin.c:133
char em0[MAXLEN]
Definition dwin.c:132
char em2[MAXLEN]
Definition dwin.c:134
int Perror(char *)
Display a simple error message window or print to stderr.
Definition dwin.c:1110
int display_error(char *em0, char *em1, char *em2, char *em3)
Display an error message window or print to stderr.
Definition dwin.c:1054
void abend(int, char *)
Abnormal program termination.
Definition dwin.c:1331
bool locate_file_in_path(char *, char *)
Locates a file in the system PATH.
Definition futil.c:939
void destroy_argv(int argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:221
size_t canonicalize_file_spec(char *)
Removes quotes and trims at first space.
Definition futil.c:1216
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:269
bool stripz_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:469
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:147
bool strip_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:454
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:379
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:298
bool verify_file(char *, int)
Verifies that the file specified by "in_spec" exists and is accessible with the permissions specified...
Definition futil.c:892
bool expand_tilde(char *, int)
Replace Leading Tilde With Home Directory.
Definition futil.c:684
bool verify_dir(char *, int)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
Definition futil.c:841
bool base_name(char *, char *)
Returns the base name of a file specification.
Definition futil.c:775
bool init_form_files(Init *, int, char **)
Initialize Form file specifications.
Definition mem.c:631
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:486
bool verify_spec_arg(char *, char *, char *, char *, int)
Verify file specification argument.
Definition mem.c:373
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:534
bool init_view_files(Init *)
Initialize View file specifications.
Definition mem.c:736
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:230
char title[MAXLEN]
Definition common.h:123
char mapp_data[MAXLEN]
Definition common.h:139
char mapp_help[MAXLEN]
Definition common.h:140
SIO * sio
Definition common.h:108
int pick_cnt
Definition common.h:177
Form * form
Definition common.h:174
char in_spec[MAXLEN]
Definition common.h:158
char cmd_all[MAXLEN]
Definition common.h:117
int argc
Definition common.h:124
char fill_char[2]
Definition common.h:137
char mapp_msrc[MAXLEN]
Definition common.h:141
int cols
Definition common.h:110
int menu_cnt
Definition common.h:173
bool f_erase_remainder
Definition common.h:134
char mapp_home[MAXLEN]
Definition common.h:138
bool f_squeeze
Definition common.h:130
char mapp_spec[MAXLEN]
Definition common.h:166
char receiver_cmd[MAXLEN]
Definition common.h:115
bool f_multiple_cmd_args
Definition common.h:132
int select_max
Definition common.h:169
bool f_ln
Definition common.h:135
bool f_mapp_spec
Definition common.h:146
char provider_cmd[MAXLEN]
Definition common.h:114
char out_spec[MAXLEN]
Definition common.h:159
View * view
Definition common.h:178
Menu * menu
Definition common.h:172
bool f_at_end_remove
Definition common.h:128
int view_cnt
Definition common.h:179
char brackets[3]
Definition common.h:136
bool f_ignore_case
Definition common.h:127
char ** argv
Definition common.h:125
int lines
Definition common.h:109
char cmd[MAXLEN]
Definition common.h:116
int form_cnt
Definition common.h:175
char help_spec[MAXLEN]
Definition common.h:167
Pick * pick
Definition common.h:176
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
char help_spec[MAXLEN]
Definition view.h:121
WINDOW * win
Definition view.h:67
bool f_ignore_case
Definition view.h:61
bool f_help_spec
Definition view.h:124
char receiver_cmd[MAXLEN]
Definition view.h:53
off_t * ln_tbl
Definition view.h:158
int cols
Definition view.h:49
bool f_ln
Definition view.h:155
WINDOW * ln_win
Definition view.h:152
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:74
char title[MAXLEN]
Definition view.h:57
char cmd_all[MAXLEN]
Definition view.h:55