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