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 "cm.h"
23#include <common.h>
24#include <errno.h>
25#include <stdlib.h>
26#include <string.h>
27#include <unistd.h>
28
29Init *new_init(int, char **);
30Menu *new_menu(Init *init, int, char **, int, int);
31Pick *new_pick(Init *init, int, char **, int, int);
32Form *new_form(Init *init, int, char **, int, int);
33View *new_view(Init *init);
34View *destroy_view(Init *init);
35Form *destroy_form(Init *init);
36Pick *destroy_pick(Init *init);
37Menu *destroy_menu(Init *init);
38Init *destroy_init(Init *init);
39bool init_menu_files(Init *, int, char **);
40bool init_pick_files(Init *, int, char **);
41bool init_form_files(Init *, int, char **);
42bool init_view_files(Init *);
43bool verify_spec_arg(char *, char *, char *, char *, int);
44int init_cnt = 0;
45
46Menu *menu;
47Pick *pick;
48Form *form;
49View *view;
50/** @brief Create and initialize Init structure
51 @ingroup mem
52 @param argc, argv - arguments
53 @details calloc initializes all fields to zero/nullptr
54 idiomatic directory usage:
55 @code
56 init->mapp_msrc description files
57 init->mapp_help help files
58 init->mapp_data in, out, data files
59 init->mapp_user executable scripts
60 init->mapp_bin binary executables
61 @endcode
62 Initialize file specifications in priority order:
63 @code
64 1 - Default values
65 2 - Configuration file
66 3 - Environment variables
67 4 - Command line positional arguments
68 5 - Command line option arguments
69 @endcode
70 */
71Init *new_init(int argc, char **argv) {
72 int i = 0;
73 Init *init = calloc(1, sizeof(Init));
74 if (init == nullptr) {
75 abend(-1, "calloc init failed");
76 return nullptr;
77 }
78 init->argv = calloc(MAXARGS + 1, sizeof(char *));
79 if (init->argv == nullptr) {
80 ssnprintf(em0, MAXLEN - 1, "%s, line: %d, errno: %d", __FILE__,
81 __LINE__ - 4, errno);
82 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
83 ssnprintf(em2, MAXLEN - 1, "view->argv = calloc(%d, %d) failed\n",
84 (MAXARGS + 1), sizeof(char *));
86 exit(EXIT_FAILURE);
87 }
88 init->argc = argc;
89 for (i = 0; i < init->argc; i++)
90 init->argv[i] = argv[i];
91 init->argv[i] = nullptr;
92
93 init->sio = (SIO *)calloc(1, sizeof(SIO));
94 if (!init->sio) {
95 Perror("calloc sio failed");
96 exit(EXIT_FAILURE);
97 }
98 init_cnt++;
99 return init;
100}
101/** @brief Destroy Init structure
102 @ingroup mem
103 @param init structure
104 @returns nullptr
105 */
106Init *destroy_init(Init *init) {
107 if (!init)
108 return nullptr;
109 if (init->sio) {
110 free(init->sio);
111 init->sio = nullptr;
112 }
113 if (init->menu) {
114 init->menu = destroy_menu(init);
115 init->menu = nullptr;
116 }
117 if (init->form) {
118 init->form = destroy_form(init);
119 init->form = nullptr;
120 }
121 if (init->pick) {
122 init->pick = destroy_pick(init);
123 init->pick = nullptr;
124 }
125 init->argc = destroy_argv(init->argc, init->argv);
126 if (init->argv != nullptr)
127 free(init->argv);
128 if (init != nullptr) {
129 free(init);
130 init = nullptr;
131 }
132 init_cnt--;
133 return init;
134}
135/** @brief Create and initialize Menu structure
136 @ingroup mem
137 @param init structure
138 @param argc - number of arguments in argv
139 @param argv - Arguments may have been provided by command line,
140 ~/.minitrc,
141 environment variables, or
142 calling program interal to C-Menu
143 @param begy, begx - initial position of menu window
144 */
145Menu *new_menu(Init *init, int argc, char **argv, int begy, int begx) {
146 init->menu = (Menu *)calloc(1, sizeof(Menu));
147 if (!init->menu) {
148 abend(-1, "calloc menu failed");
149 return nullptr;
150 }
151 init->menu_cnt++;
152 menu = init->menu;
153 if (!init_menu_files(init, argc, argv)) {
154 abend(-1, "init_menu_files failed");
155 return nullptr;
156 }
157 menu->begy = begy;
158 menu->begx = begx;
159 return init->menu;
160}
161/** @brief Destroy Menu structure
162 @ingroup mem
163 @param init structure
164 @return nullptr
165 */
166Menu *destroy_menu(Init *init) {
167 menu = init->menu;
169 menu->line_idx++) {
171 if (menu->line[menu->line_idx]->raw_text != nullptr)
178 menu->line[menu->line_idx] = nullptr;
179 }
180 }
181 free(init->menu);
182 init->menu = nullptr;
183 menu = nullptr;
184 init->menu_cnt--;
185 return init->menu;
186}
187/** @brief Create and initialize Pick structure
188 @ingroup mem
189 @param init structure
190 @param argc - number of arguments in argv
191 @param argv - Arguments may have been provided by command line,
192 ~/.minitrc,
193 environment variables, or
194 calling program interal to C-Menu
195 @param begy, begx - initial position of pick window
196 */
197Pick *new_pick(Init *init, int argc, char **argv, int begy, int begx) {
198 init->pick = (Pick *)calloc(1, sizeof(Pick));
199 if (!init->pick) {
200 Perror("calloc pick failed");
201 return nullptr;
202 }
203 init->pick_cnt++;
204 pick = init->pick;
205 if (!init_pick_files(init, argc, argv)) {
206 abend(-1, "init_pick_files failed");
207 return nullptr;
208 }
209 pick->m_object = calloc(OBJ_MAXCNT + 1, sizeof(char *));
210 if (pick->m_object == nullptr) {
211 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__, __LINE__ - 1);
213 "calloc pick->m_object = calloc(%d, %d) failed\n",
214 OBJ_MAXCNT + 1, sizeof(char *));
215 display_error(em0, em1, nullptr, nullptr);
216 abend(-1, "User terminated program");
217 }
218 pick->d_object = calloc(OBJ_MAXCNT + 1, sizeof(char *));
219 if (pick->d_object == nullptr) {
220 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__, __LINE__ - 1);
222 "calloc pick->d_object = calloc(%d, %d) failed\n",
223 OBJ_MAXCNT + 1, sizeof(char *));
224 display_error(em0, em1, nullptr, nullptr);
225 abend(-1, "User terminated program");
226 }
227 pick->begy = begy;
228 pick->begx = begx;
229 return init->pick;
230}
231/** @brief Destroy Pick structure
232 @ingroup mem
233 @param init structure
234 @return nullptr
235 */
236Pick *destroy_pick(Init *init) {
237 if (!init->pick)
238 return nullptr;
239
241 if (pick->m_object[pick->m_idx] != nullptr)
243 // if (pick->d_object[pick->d_idx] != nullptr)
244 // free(pick->d_object[pick->d_idx]);
245 }
246 free(pick->m_object);
247 free(pick->d_object);
248 free(pick);
249 init->pick = nullptr;
250 init->pick_cnt--;
251 return init->pick;
252}
253/** @brief Create and initialize Form structure
254 @ingroup mem
255 @param init structure
256 @param argc - number of arguments in argv
257 @param argv - Arguments may have been provided by command line,
258 ~/.minitrc,
259 environment variables, or
260 calling program interal to C-Menu
261 @param begy, begx - initial position of form window
262 */
263Form *new_form(Init *init, int argc, char **argv, int begy, int begx) {
264 init->form = (Form *)calloc(1, sizeof(Form));
265 if (!init->form) {
266 abend(-1, "calloc form failed");
267 return nullptr;
268 }
269 init->form_cnt++;
270 form = init->form;
271 if (!init_form_files(init, argc, argv)) {
272 abend(-1, "init_form_files failed");
273 return nullptr;
274 }
277 form->begy = begy;
278 form->begx = begx;
279 return init->form;
280}
281/** @brief Destroy Form structure
282 @ingroup mem
283 @param init structure
284 @return nullptr
285 */
286Form *destroy_form(Init *init) {
287 int i;
288
289 if (!init->form)
290 return nullptr;
291 for (i = 0; i < FIELD_MAXCNT; i++) {
292 if (init->form->field[i])
293 free(init->form->field[i]);
294 init->form->field[i] = nullptr;
295 }
296 for (i = 0; i < FIELD_MAXCNT; i++) {
297 if (init->form->text[i])
298 free(init->form->text[i]);
299 init->form->text[i] = nullptr;
300 }
301 free(init->form);
302 init->form = nullptr;
303 init->form_cnt--;
304 return init->form;
305}
306/** @brief Create and initialize View structure
307 @ingroup mem
308 @param init structure
309 */
310View *new_view(Init *init) {
311 init->view_cnt++;
312 init->view = (View *)calloc(1, sizeof(View));
313 if (!init->view) {
314 free(init->view);
315 ssnprintf(em0, MAXLEN - 1, "%s, line: %d, errno: %d", __FILE__,
316 __LINE__ - 1, errno);
317 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
318 ssnprintf(em2, MAXLEN - 1, "init->view = calloc(%d) failed\n",
319 sizeof(View));
321 abend(-1, "calloc init->view failed");
322 return nullptr;
323 }
324 view = init->view;
325 view->argc = init->argc;
326 if (view->argc > 0) {
327 view->argv = calloc(view->argc + 1, sizeof(char *));
328 if (view->argv == nullptr) {
329 free(view->argv);
330 ssnprintf(em0, MAXLEN - 1, "%s, line: %d, errno: %d", __FILE__,
331 __LINE__ - 1, errno);
332 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
333 ssnprintf(em2, MAXLEN - 1, "view->argv = calloc(%d, %d) failed\n",
334 view->argc, sizeof(char *));
336 abend(-1, "User terminated program");
337 return nullptr;
338 }
339 int s = 0;
340 int d = 0;
341 while (s < init->argc)
342 view->argv[d++] = strnz_dup(init->argv[s++], MAXLEN - 1);
343 view->argv[d] = nullptr;
344 }
345 if (!init_view_files(init)) {
346 abend(-1, "init_view_files failed");
347 return nullptr;
348 }
349 return view;
350}
351/** @brief Destroy View structure
352 @ingroup mem
353 @param init structure
354 @return nullptr
355 */
356View *destroy_view(Init *init) {
357 view = init->view;
358 if (!view)
359 return nullptr;
361 free(view->argv);
362 free(view);
363 init->view = nullptr;
364 view = nullptr;
365 init->view_cnt--;
366 return init->view;
367}
368/** @brief Verify file specification argument
369 @ingroup mem
370 @param spec - menu->spec, form->spec, etc.
371 @param org_spec - init->._spec | argv[optind]
372 @param dir - init->._. directory
373 @param alt_dir - literal, "~/menuapp/data", etc.
374 @param mode - R_OK, W_OK, X_OK, WC_OK, S_QUIET
375 @details mode is a bitwise OR of the following flags:
376 S_QUIET - suppress error messages
377 WC_OK - write create ok
378 @return bool - true if file verified
379 */
380bool verify_spec_arg(char *spec, char *org_spec, char *dir, char *alt_dir,
381 int mode) {
382 bool f_dir = false;
383 bool f_spec = false;
384 bool f_quote = true;
385 char *s1;
386 char *s2;
387 char s1_s[MAXLEN];
388 char s2_s[MAXLEN];
389 char file_name[MAXLEN];
390 char try_spec[MAXLEN];
391 char idio_spec[MAXLEN];
392
393 if (!org_spec[0])
394 return false;
395 idio_spec[0] = '\0';
396 // try the provided spec as is, with quotes stripped for file name parsing
397 strnz__cpy(try_spec, org_spec, MAXLEN - 1);
398 f_quote = stripz_quotes(try_spec);
399
400 s1 = strtok(try_spec, " \t\n");
401 strnz__cpy(s1_s, s1, MAXLEN - 1);
402
403 s2 = strtok(nullptr, "\n");
404 strnz__cpy(s2_s, s2, MAXLEN - 1);
405
406 strnz__cpy(file_name, s1, MAXLEN - 1);
407 strnz__cpy(try_spec, file_name, MAXLEN - 1);
408
410
411 if (try_spec[0]) {
412 expand_tilde(try_spec, MAXLEN - 1);
413 if (try_spec[0] == '/') {
414 // try absolute path as is, with quotes stripped for file name parsing
415 f_spec = verify_file(try_spec, mode);
416 if (f_quote)
417 /** preserve quotes */
418 strnz__cpy(spec, org_spec, MAXLEN - 1);
419 else
420 strnz__cpy(spec, try_spec, MAXLEN - 1);
421 return f_spec;
422
423 } else {
424 if (!f_dir && dir[0]) {
425 if (strcmp(dir, "$PATH") == 0) {
426 strnz__cpy(try_spec, file_name, MAXLEN - 1);
427 f_spec = locate_file_in_path(try_spec, file_name);
428 } else {
429 strnz__cpy(try_spec, dir, MAXLEN - 1);
430 expand_tilde(try_spec, MAXLEN - 1);
431 f_dir = verify_dir(try_spec, mode);
432 if (f_dir) {
433 // directory is valid, append file_name and verify file
434 strnz__cat(try_spec, "/", MAXLEN - 1);
435 strnz__cat(try_spec, file_name, MAXLEN - 1);
436 strnz__cpy(idio_spec, try_spec, MAXLEN - 1);
437 if (mode & S_WCOK)
438 f_spec = true;
439 else
440 f_spec = verify_file(idio_spec, mode | S_QUIET);
441 }
442 }
443 }
444 if (!f_spec && alt_dir && alt_dir[0] != '\0') {
445 if (strcmp(alt_dir, "$PATH") == 0) {
446 strnz__cpy(try_spec, file_name, MAXLEN - 1);
447 f_spec = locate_file_in_path(try_spec, file_name);
448 } else {
449 strnz__cpy(try_spec, alt_dir, MAXLEN - 1);
450 expand_tilde(try_spec, MAXLEN - 1);
451 f_dir = verify_dir(try_spec, mode);
452 if (f_dir) {
453 strnz__cat(try_spec, "/", MAXLEN - 1);
454 strnz__cat(try_spec, file_name, MAXLEN - 1);
455 if (mode & S_WCOK)
456 f_spec = true;
457 else
458 f_spec = verify_file(try_spec, mode | S_QUIET);
459 }
460 }
461 }
462 if (!f_spec) {
463 strnz__cpy(try_spec, ".", MAXLEN - 1);
464 strnz__cat(try_spec, "/", MAXLEN - 1);
465 strnz__cat(try_spec, file_name, MAXLEN - 1);
466 f_spec = verify_file(try_spec, mode | S_QUIET);
467 }
468 if (!f_spec && mode == W_OK) {
469 strnz__cpy(try_spec, idio_spec, MAXLEN - 1);
470 FILE *fp = fopen(try_spec, "a");
471 if (fp) {
472 fclose(fp);
473 f_spec = true;
474 }
475 }
476 if (f_quote)
477 /** preserve quotes */
478 strnz__cpy(spec, org_spec, MAXLEN - 1);
479 else if (f_spec)
480 strnz__cpy(spec, try_spec, MAXLEN - 1);
481 if (try_spec[0] == '\0' && idio_spec[0] != '\0')
482 strnz__cpy(spec, idio_spec, MAXLEN - 1);
483 else
484 strnz__cpy(spec, try_spec, MAXLEN - 1);
485 if (s2_s[0] != '\0') {
486 strnz__cat(spec, " ", MAXLEN - 1);
487 strnz__cat(spec, s2_s, MAXLEN - 1);
488 }
489 return f_spec;
490 }
491 }
492 return false;
493}
494/** @brief Initialize Menu file specifications
495 @ingroup mem
496 @param init structure
497 @param argc - number of arguments in argv
498 @param argv - Arguments may have been provided by command line,
499 ~/.minitrc, environment variables, or calling program
500 interal to C-Menu
501 @details Positional args: [menu desc], [help file] */
502bool init_menu_files(Init *init, int argc, char **argv) {
503 char tmp_str[MAXLEN];
504 int optind = 0;
505 if (optind < argc && !init->f_mapp_spec) {
508 "~/menuapp/msrc", R_OK);
510 optind++;
511 }
512 if (optind < argc && !menu->f_help_spec) {
515 "~/menuapp/help", R_OK);
517 optind++;
518 }
519 if (!menu->f_mapp_spec) {
521 menu->mapp_spec, "~/menuapp/msrc/main.m", nullptr, nullptr, R_OK);
522 if (!menu->f_mapp_spec) {
523 strnz__cpy(tmp_str, "menu cannot read description file ",
524 MAXLEN - 1);
526 abend(-1, tmp_str);
527 }
528 }
529 if (!menu->f_help_spec) {
531 verify_spec_arg(menu->help_spec, "~/menuapp/help/menu.help",
532 nullptr, nullptr, R_OK);
533 if (!menu->f_help_spec) {
534 strnz__cpy(tmp_str, "menu cannot read help file ", MAXLEN - 1);
536 abend(-1, tmp_str);
537 }
538 }
539 return true;
540}
541/** @brief Initialize Pick file specifications
542 @ingroup mem
543 @param init structure
544 @param argc - number of arguments in argv
545 @param argv - Arguments may have been provided by command line,
546 ~/.minitrc,
547 environment variables, or
548 calling program interal to C-Menu
549 @details Positional args: [pick desc], [in_file], [out_file], [help_file] */
550bool init_pick_files(Init *init, int argc, char **argv) {
551 char tmp_str[MAXLEN];
552 int optind = 1;
554 init->mapp_data, "~/menuapp/data", R_OK);
557 "~/menuapp/data", W_OK | S_QUIET);
558 if (init->provider_cmd[0] != '\0') {
561 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
562 }
563 if (init->cmd[0] != '\0') {
565 "$PATH", X_OK | S_QUIET);
566 }
567 if (init->receiver_cmd[0] != '\0') {
570 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
571 }
572 if (init->title[0])
576 "~/menuapp/help", R_OK);
577 if (optind < argc && !pick->f_in_spec) {
580 "~/menuapp/data", R_OK);
581 if (pick->f_in_spec)
582 optind++;
583 }
584 if (optind < argc && !pick->f_out_spec) {
587 "~/menuapp/data", W_OK | S_QUIET);
589 optind++;
590 }
591 if (optind < argc && !pick->f_provider_cmd) {
592 if (argv[optind][0] != '\0') {
595 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
597 base_name(tmp_str, argv[optind]);
600 }
601 }
602 optind++;
603 }
604 if (optind < argc && !pick->f_cmd) {
605 if (argv[optind][0] != '\0') {
607 verify_spec_arg(pick->cmd, argv[optind], "~/menuapp/bin",
608 nullptr, X_OK | S_QUIET);
609 if (!pick->f_cmd) {
610 base_name(tmp_str, argv[optind]);
612 }
613 }
614 optind++;
615 }
616 if (optind < argc && !pick->f_receiver_cmd) {
617 if (argv[optind][0] != '\0') {
620 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
622 base_name(tmp_str, argv[optind]);
625 }
626 }
627 optind++;
628 }
629 if (optind < argc && !pick->f_help_spec) {
632 "~/menuapp/help", R_OK);
634 optind++;
635 }
636 if (pick->provider_cmd[0] != '\0')
638 if (pick->receiver_cmd[0] != '\0')
644 return true;
645}
646/** @brief Initialize Form file specifications
647 @ingroup mem
648 @param init pointer to init structure
649 @param argc - number of arguments in argv
650 @param argv - Arguments may have been provided by command line ~/.minitrc,
651 environment variables, or calling program interal to C-Menu
652 @details Positional args: [pick desc], [in_file], [out_file], [help_file] */
653bool init_form_files(Init *init, int argc, char **argv) {
654 char tmp_str[MAXLEN];
655 int optind = 0;
658 "~/menuapp/msrc", R_OK);
660 init->mapp_data, "~/menuapp/data", R_OK);
663 "~/menuapp/data", W_OK | S_QUIET);
664 if (init->provider_cmd[0] != '\0') {
667 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
668 }
669 if (init->cmd[0] != '\0') {
671 "$PATH", X_OK | S_QUIET);
672 }
673 if (init->receiver_cmd[0] != '\0') {
676 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
677 }
680 "~/menuapp/help", R_OK);
681 if (optind < argc && !form->f_mapp_spec) {
684 "~/menuapp/msrc", R_OK);
686 optind++;
687 }
688 if (optind < argc && !form->f_in_spec) {
691 "~/menuapp/data", R_OK);
692 if (form->f_in_spec)
693 optind++;
694 }
695 if (optind < argc && !form->f_out_spec) {
698 "~/menuapp/data", W_OK | S_QUIET);
700 optind++;
701 }
702 if (optind < argc && !form->f_provider_cmd) {
703 if (argv[optind][0] != '\0') {
706 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
708 base_name(tmp_str, argv[optind]);
711 }
712 }
713 optind++;
714 }
715 if (optind < argc && !form->f_cmd) {
716 if (argv[optind][0] != '\0') {
718 verify_spec_arg(form->cmd, argv[optind], "~/menuapp/bin",
719 nullptr, X_OK | S_QUIET);
720 if (!form->f_cmd) {
721 base_name(tmp_str, argv[optind]);
723 }
724 }
725 optind++;
726 }
727 if (optind < argc && !form->f_receiver_cmd) {
728 if (argv[optind][0] != '\0') {
731 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
733 base_name(tmp_str, argv[optind]);
736 }
737 }
738 optind++;
739 }
740 if (optind < argc && !form->f_help_spec) {
743 "~/menuapp/help", R_OK);
745 optind++;
746 }
747 if (form->cmd[0] != '\0')
749 if (form->provider_cmd[0] != '\0')
751 if (form->receiver_cmd[0] != '\0')
754 if (form->title[0] == '\0' && init->title[0] != '\0') {
757 }
759 return true;
760}
761/** @brief Initialize View file specifications
762 @ingroup mem
763 @param init structure
764 @details Positional args: pick desc, in_file, out_file, help_file */
765bool init_view_files(Init *init) {
766 char *e;
767 view = init->view;
768 view->lines = init->lines;
769 view->cols = init->cols;
770 view->begy = init->begy;
771 view->begx = init->begx;
776 view->f_ln = init->f_ln;
778 e = getenv("VIEW_HELP_FILE");
779 if (e && e[0] != '\0') {
781 }
784 "~/menuapp/help", R_OK);
785 if (!view->f_help_spec) {
789 }
793 if (view->cmd[0] != '\0')
795 if (view->provider_cmd[0] != '\0')
797 if (view->receiver_cmd[0] != '\0')
799 if (view->title[0] == '\0') {
800 if (init->title[0] != '\0') {
802 } else {
803 if (view->provider_cmd[0] != '\0')
805 else {
806 if (view->argv != nullptr && view->argv[0] != nullptr &&
807 view->argv[0][0] != '\0') {
809 } else
810 strnz__cpy(view->title, "C-Menu View", MAXLEN - 1);
811 }
812 }
813 }
815 if (view->tab_stop == 0)
816 view->tab_stop = 4;
817 return true;
818}
#define FIELD_MAXCNT
Definition form.h:19
#define VIEW_HELP_FILE
Definition common.h:35
int init_cnt
Definition mem.c:44
#define OBJ_MAXCNT
Definition pick.h:17
char em1[MAXLEN]
Definition dwin.c:176
#define MAXARGS
Definition cm.h:48
char em0[MAXLEN]
Definition dwin.c:175
#define S_QUIET
Definition cm.h:286
#define S_WCOK
Definition cm.h:285
char em2[MAXLEN]
Definition dwin.c:177
Menu * menu
Definition mem.c:46
Pick * pick
Definition mem.c:47
Form * form
Definition mem.c:48
View * view
Definition mem.c:49
#define MAXLEN
Definition curskeys.c:15
int Perror(char *)
Display a simple error message window or print to stderr.
Definition dwin.c:1526
void abend(int, char *)
Abnormal program termination.
Definition dwin.c:2018
int display_error(char *, char *, char *, char *)
Display an error message window or print to stderr.
Definition dwin.c:1467
bool locate_file_in_path(char *, char *)
Locates a file in the system PATH.
Definition futil.c:1287
size_t canonicalize_file_spec(char *)
Removes quotes and trims at first space.
Definition futil.c:1341
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:544
int destroy_argv(int argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:494
bool stripz_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:733
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:420
bool expand_tilde(char *, int)
Replaces "~/" in string with the user's home directory.
Definition futil.c:970
bool strip_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:718
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:654
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:573
bool verify_file(char *, int)
Verifies that the file specified by "in_spec" exists and is accessible with the permissions specified...
Definition futil.c:1240
bool verify_dir(char *, int)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
Definition futil.c:1189
bool base_name(char *, char *)
Returns the base name of a file specification.
Definition futil.c:1123
bool init_form_files(Init *, int, char **)
Initialize Form file specifications.
Definition mem.c:653
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:356
Form * new_form(Init *, int, char **, int, int)
Create and initialize Form structure.
Definition mem.c:263
bool init_menu_files(Init *, int, char **)
Initialize Menu file specifications.
Definition mem.c:502
bool verify_spec_arg(char *, char *, char *, char *, int)
Verify file specification argument.
Definition mem.c:380
Init * new_init(int, char **)
Create and initialize Init structure.
Definition mem.c:71
Menu * new_menu(Init *, int, char **, int, int)
Create and initialize Menu structure.
Definition mem.c:145
Menu * destroy_menu(Init *init)
Destroy Menu structure.
Definition mem.c:166
Form * destroy_form(Init *init)
Destroy Form structure.
Definition mem.c:286
View * new_view(Init *)
Create and initialize View structure.
Definition mem.c:310
Pick * new_pick(Init *, int, char **, int, int)
Create and initialize Pick structure.
Definition mem.c:197
Init * destroy_init(Init *init)
Destroy Init structure.
Definition mem.c:106
bool init_pick_files(Init *, int, char **)
Initialize Pick file specifications.
Definition mem.c:550
bool init_view_files(Init *)
Initialize View file specifications.
Definition mem.c:765
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:236
char title[MAXLEN]
Definition common.h:129
char mapp_data[MAXLEN]
Definition common.h:147
char mapp_help[MAXLEN]
Definition common.h:148
int begx
Definition common.h:118
SIO * sio
Definition common.h:114
int pick_cnt
Definition common.h:187
Form * form
Definition common.h:184
char in_spec[MAXLEN]
Definition common.h:167
char cmd_all[MAXLEN]
Definition common.h:123
int argc
Definition common.h:130
char mapp_msrc[MAXLEN]
Definition common.h:149
int cols
Definition common.h:116
int menu_cnt
Definition common.h:183
int tab_stop
Definition common.h:180
bool f_erase_remainder
Definition common.h:141
bool f_read_theme
Definition common.h:142
char mapp_home[MAXLEN]
Definition common.h:146
char fill_char[4]
Definition common.h:145
bool f_squeeze
Definition common.h:137
int begy
Definition common.h:117
char mapp_spec[MAXLEN]
Definition common.h:175
char receiver_cmd[MAXLEN]
Definition common.h:121
int h_shift
Definition common.h:181
bool f_multiple_cmd_args
Definition common.h:139
int select_max
Definition common.h:178
bool f_ln
Definition common.h:143
bool f_mapp_spec
Definition common.h:155
char provider_cmd[MAXLEN]
Definition common.h:120
char out_spec[MAXLEN]
Definition common.h:168
View * view
Definition common.h:188
bool p_view_files
Definition common.h:134
Menu * menu
Definition common.h:182
bool f_at_end_remove
Definition common.h:135
int view_cnt
Definition common.h:189
char brackets[3]
Definition common.h:144
bool f_ignore_case
Definition common.h:133
char ** argv
Definition common.h:131
int lines
Definition common.h:115
char cmd[MAXLEN]
Definition common.h:122
int form_cnt
Definition common.h:185
char help_spec[MAXLEN]
Definition common.h:176
Pick * pick
Definition common.h:186
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[4]
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:79
char * raw_text
Definition menu.h:76
char * command_str
Definition menu.h:95
char mapp_spec[MAXLEN]
Definition menu.h:140
Line * line[MAX_MENU_LINES]
Definition menu.h:219
bool f_help_spec
Definition menu.h:178
int begy
Definition menu.h:119
bool f_mapp_spec
Definition menu.h:173
int item_count
Definition menu.h:212
int line_idx
Definition menu.h:215
char help_spec[MAXLEN]
Definition menu.h:146
int begx
Definition menu.h:122
char ** m_object
Definition pick.h:68
bool f_cmd
Definition pick.h:66
bool f_provider_cmd
Definition pick.h:64
bool p_view_files
Definition pick.h:61
bool f_in_spec
Definition pick.h:54
int m_idx
Definition pick.h:74
char ** d_object
Definition pick.h:76
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:60
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:71
bool f_read_theme
Definition pick.h:59
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:65
char provider_cmd[MAXLEN]
Definition pick.h:49
char out_spec[MAXLEN]
Definition pick.h:47
char provider_cmd[MAXLEN]
Definition view.h:57
int argc
Definition view.h:63
char ** argv
Definition view.h:64
char help_spec[MAXLEN]
Definition view.h:138
bool f_ignore_case
Definition view.h:66
bool f_help_spec
Definition view.h:141
char cmd[MAXLEN]
Definition view.h:59
char receiver_cmd[MAXLEN]
Definition view.h:58
int cols
Definition view.h:54
bool f_ln
Definition view.h:171
int lines
Definition view.h:53
bool f_at_end_remove
Definition view.h:67
bool f_squeeze
Definition view.h:68
int tab_stop
Definition view.h:91
char title[MAXLEN]
Definition view.h:62
char cmd_all[MAXLEN]
Definition view.h:60
int begy
Definition view.h:55
int h_shift
Definition view.h:92
int begx
Definition view.h:56