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 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->sio = (SIO *)calloc(1, sizeof(SIO));
83 if (!init->sio) {
84 Perror("calloc sio failed");
85 exit(EXIT_FAILURE);
86 }
87 init_cnt++;
88 return init;
89}
90/** @brief Destroy Init structure
91 @ingroup mem
92 @param init structure
93 @returns nullptr
94 */
95Init *destroy_init(Init *init) {
96 if (!init)
97 return nullptr;
98 if (init->sio) {
99 free(init->sio);
100 init->sio = nullptr;
101 }
102 if (init->menu) {
103 init->menu = destroy_menu(init);
104 init->menu = nullptr;
105 }
106 if (init->form) {
107 init->form = destroy_form(init);
108 init->form = nullptr;
109 }
110 if (init->pick) {
111 init->pick = destroy_pick(init);
112 init->pick = nullptr;
113 }
114 init->argc = destroy_argv(init->argc, init->argv);
115 if (init->argv != nullptr)
116 free(init->argv);
117 if (init != nullptr) {
118 free(init);
119 init = nullptr;
120 }
121 init_cnt--;
122 return init;
123}
124/** @brief Create and initialize Menu structure
125 @ingroup mem
126 @param init structure
127 @param argc - number of arguments in argv
128 @param argv - Arguments may have been provided by command line,
129 ~/.minitrc,
130 environment variables, or
131 calling program interal to C-Menu
132 @param begy, begx - initial position of menu window
133 */
134Menu *new_menu(Init *init, int argc, char **argv, uint begy, uint begx) {
135 init->menu = (Menu *)calloc(1, sizeof(Menu));
136 if (!init->menu) {
137 abend(-1, "calloc menu failed");
138 return nullptr;
139 }
140 init->menu_cnt++;
141 menu = init->menu;
142 if (!init_menu_files(init, argc, argv)) {
143 abend(-1, "init_menu_files failed");
144 return nullptr;
145 }
146 menu->begy = begy;
147 menu->begx = begx;
148 return init->menu;
149}
150/** @brief Destroy Menu structure
151 @ingroup mem
152 @param init structure
153 @return nullptr
154 */
155Menu *destroy_menu(Init *init) {
156 menu = init->menu;
158 menu->line_idx++) {
160 if (menu->line[menu->line_idx]->raw_text != nullptr)
167 menu->line[menu->line_idx] = nullptr;
168 }
169 }
170 free(init->menu);
171 init->menu = nullptr;
172 menu = nullptr;
173 init->menu_cnt--;
174 return init->menu;
175}
176/** @brief Create and initialize Pick structure
177 @ingroup mem
178 @param init structure
179 @param argc - number of arguments in argv
180 @param argv - Arguments may have been provided by command line,
181 ~/.minitrc,
182 environment variables, or
183 calling program interal to C-Menu
184 @param begy, begx - initial position of pick window
185 */
186Pick *new_pick(Init *init, int argc, char **argv, uint begy, uint begx) {
187 init->pick = (Pick *)calloc(1, sizeof(Pick));
188 if (!init->pick) {
189 Perror("calloc pick failed");
190 return nullptr;
191 }
192 init->pick_cnt++;
193 pick = init->pick;
194 if (!init_pick_files(init, argc, argv)) {
195 abend(-1, "init_pick_files failed");
196 return nullptr;
197 }
198 pick->m_object = calloc(OBJ_MAXCNT + 1, sizeof(char *));
199 if (pick->m_object == nullptr) {
200 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__, __LINE__ - 1);
202 "calloc pick->m_object = calloc(%d, %d) failed\n",
203 OBJ_MAXCNT + 1, sizeof(char *));
204 display_error(em0, em1, nullptr, nullptr);
205 abend(-1, "User terminated program");
206 }
207 pick->d_object = calloc(OBJ_MAXCNT + 1, sizeof(char *));
208 if (pick->d_object == nullptr) {
209 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__, __LINE__ - 1);
211 "calloc pick->d_object = calloc(%d, %d) failed\n",
212 OBJ_MAXCNT + 1, sizeof(char *));
213 display_error(em0, em1, nullptr, nullptr);
214 abend(-1, "User terminated program");
215 }
216 pick->begy = begy;
217 pick->begx = begx;
218 return init->pick;
219}
220/** @brief Destroy Pick structure
221 @ingroup mem
222 @param init structure
223 @return nullptr
224 */
225Pick *destroy_pick(Init *init) {
226 if (!init->pick)
227 return nullptr;
228
230 if (pick->m_object[pick->m_idx] != nullptr)
232 // if (pick->d_object[pick->d_idx] != nullptr)
233 // free(pick->d_object[pick->d_idx]);
234 }
235 free(pick->m_object);
236 free(pick->d_object);
237 free(pick);
238 init->pick = nullptr;
239 init->pick_cnt--;
240 return init->pick;
241}
242/** @brief Create and initialize Form structure
243 @ingroup mem
244 @param init structure
245 @param argc - number of arguments in argv
246 @param argv - Arguments may have been provided by command line,
247 ~/.minitrc,
248 environment variables, or
249 calling program interal to C-Menu
250 @param begy, begx - initial position of form window
251 */
252Form *new_form(Init *init, int argc, char **argv, uint begy, uint begx) {
253 init->form = (Form *)calloc(1, sizeof(Form));
254 if (!init->form) {
255 abend(-1, "calloc form failed");
256 return nullptr;
257 }
258 init->form_cnt++;
259 form = init->form;
260 if (!init_form_files(init, argc, argv)) {
261 abend(-1, "init_form_files failed");
262 return nullptr;
263 }
266 form->begy = begy;
267 form->begx = begx;
268 return init->form;
269}
270/** @brief Destroy Form structure
271 @ingroup mem
272 @param init structure
273 @return nullptr
274 */
275Form *destroy_form(Init *init) {
276 uint i;
277
278 if (!init->form)
279 return nullptr;
280 for (i = 0; i < FIELD_MAXCNT; i++) {
281 if (init->form->field[i])
282 free(init->form->field[i]);
283 init->form->field[i] = nullptr;
284 }
285 for (i = 0; i < FIELD_MAXCNT; i++) {
286 if (init->form->text[i])
287 free(init->form->text[i]);
288 init->form->text[i] = nullptr;
289 }
290 free(init->form);
291 init->form = nullptr;
292 init->form_cnt--;
293 return init->form;
294}
295/** @brief Create and initialize View structure
296 @ingroup mem
297 @param init structure
298 */
299View *new_view(Init *init) {
300 init->view_cnt++;
301 init->view = (View *)calloc(1, sizeof(View));
302 if (!init->view) {
303 free(init->view);
304 ssnprintf(em0, MAXLEN - 1, "%s, line: %d, errno: %d", __FILE__,
305 __LINE__ - 1, errno);
306 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
307 ssnprintf(em2, MAXLEN - 1, "init->view = calloc(%d) failed\n",
308 sizeof(View));
310 abend(-1, "calloc init->view failed");
311 return nullptr;
312 }
313 view = init->view;
314 view->argc = init->argc;
315 if (view->argc > 0) {
316 view->argv = calloc(view->argc + 1, sizeof(char *));
317 if (view->argv == nullptr) {
318 free(view->argv);
319 ssnprintf(em0, MAXLEN - 1, "%s, line: %d, errno: %d", __FILE__,
320 __LINE__ - 1, errno);
321 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
322 ssnprintf(em2, MAXLEN - 1, "view->argv = calloc(%d, %d) failed\n",
323 view->argc, sizeof(char *));
325 abend(-1, "User terminated program");
326 return nullptr;
327 }
328 int s = 0;
329 int d = 0;
330 while (s < init->argc)
331 view->argv[d++] = strnz_dup(init->argv[s++], MAXLEN - 1);
332 view->argv[d] = nullptr;
333 }
334 if (!init_view_files(init)) {
335 abend(-1, "init_view_files failed");
336 return nullptr;
337 }
338 return view;
339}
340/** @brief Destroy View structure
341 @ingroup mem
342 @param init structure
343 @return nullptr
344 */
345View *destroy_view(Init *init) {
346 view = init->view;
347 if (!view)
348 return nullptr;
350 free(view->argv);
351 free(view);
352 init->view = nullptr;
353 view = nullptr;
354 init->view_cnt--;
355 return init->view;
356}
357/** @brief Verify file specification argument
358 @ingroup mem
359 @param spec - menu->spec, form->spec, etc.
360 @param org_spec - init->._spec | argv[optind]
361 @param dir - init->._. directory
362 @param alt_dir - literal, "~/menuapp/data", etc.
363 @param mode - R_OK, W_OK, X_OK, WC_OK, S_QUIET
364 @details mode is a bitwise OR of the following flags:
365 S_QUIET - suppress error messages
366 WC_OK - write create ok
367 @return bool - true if file verified
368 */
369bool verify_spec_arg(char *spec, char *org_spec, char *dir, char *alt_dir,
370 uint mode) {
371 bool f_dir = false;
372 bool f_spec = false;
373 bool f_quote = true;
374 char *s1;
375 char *s2;
376 char s1_s[MAXLEN];
377 char s2_s[MAXLEN];
378 char file_name[MAXLEN];
379 char try_spec[MAXLEN];
380 char idio_spec[MAXLEN];
381
382 if (!org_spec[0])
383 return false;
384 idio_spec[0] = '\0';
385 // try the provided spec as is, with quotes stripped for file name parsing
386 strnz__cpy(try_spec, org_spec, MAXLEN - 1);
387 f_quote = stripz_quotes(try_spec);
388
389 s1 = strtok(try_spec, " \t\n");
390 strnz__cpy(s1_s, s1, MAXLEN - 1);
391
392 s2 = strtok(nullptr, "\n");
393 strnz__cpy(s2_s, s2, MAXLEN - 1);
394
395 strnz__cpy(file_name, s1, MAXLEN - 1);
396 strnz__cpy(try_spec, file_name, MAXLEN - 1);
397
399
400 if (try_spec[0]) {
401 expand_tilde(try_spec, MAXLEN - 1);
402 if (try_spec[0] == '/') {
403 // try absolute path as is, with quotes stripped for file name parsing
404 f_spec = verify_file(try_spec, mode);
405 if (f_quote)
406 /** preserve quotes */
407 strnz__cpy(spec, org_spec, MAXLEN - 1);
408 else
409 strnz__cpy(spec, try_spec, MAXLEN - 1);
410 return f_spec;
411
412 } else {
413 if (!f_dir && dir[0]) {
414 if (strcmp(dir, "$PATH") == 0) {
415 strnz__cpy(try_spec, file_name, MAXLEN - 1);
416 f_spec = locate_file_in_path(try_spec, file_name);
417 } else {
418 strnz__cpy(try_spec, dir, MAXLEN - 1);
419 expand_tilde(try_spec, MAXLEN - 1);
420 f_dir = verify_dir(try_spec, mode);
421 if (f_dir) {
422 // directory is valid, append file_name and verify file
423 strnz__cat(try_spec, "/", MAXLEN - 1);
424 strnz__cat(try_spec, file_name, MAXLEN - 1);
425 strnz__cpy(idio_spec, try_spec, MAXLEN - 1);
426 if (mode & S_WCOK)
427 f_spec = true;
428 else
429 f_spec = verify_file(idio_spec, mode | S_QUIET);
430 }
431 }
432 }
433 if (!f_spec && alt_dir && alt_dir[0] != '\0') {
434 if (strcmp(alt_dir, "$PATH") == 0) {
435 strnz__cpy(try_spec, file_name, MAXLEN - 1);
436 f_spec = locate_file_in_path(try_spec, file_name);
437 } else {
438 strnz__cpy(try_spec, alt_dir, MAXLEN - 1);
439 expand_tilde(try_spec, MAXLEN - 1);
440 f_dir = verify_dir(try_spec, mode);
441 if (f_dir) {
442 strnz__cat(try_spec, "/", MAXLEN - 1);
443 strnz__cat(try_spec, file_name, MAXLEN - 1);
444 if (mode & S_WCOK)
445 f_spec = true;
446 else
447 f_spec = verify_file(try_spec, mode | S_QUIET);
448 }
449 }
450 }
451 if (!f_spec) {
452 strnz__cpy(try_spec, ".", MAXLEN - 1);
453 strnz__cat(try_spec, "/", MAXLEN - 1);
454 strnz__cat(try_spec, file_name, MAXLEN - 1);
455 f_spec = verify_file(try_spec, mode | S_QUIET);
456 }
457 if (!f_spec && mode == W_OK) {
458 strnz__cpy(try_spec, idio_spec, MAXLEN - 1);
459 FILE *fp = fopen(try_spec, "a");
460 if (fp) {
461 fclose(fp);
462 f_spec = true;
463 }
464 }
465 if (f_quote)
466 /** preserve quotes */
467 strnz__cpy(spec, org_spec, MAXLEN - 1);
468 else if (f_spec)
469 strnz__cpy(spec, try_spec, MAXLEN - 1);
470 if (try_spec[0] == '\0' && idio_spec[0] != '\0')
471 strnz__cpy(spec, idio_spec, MAXLEN - 1);
472 else
473 strnz__cpy(spec, try_spec, MAXLEN - 1);
474 if (s2_s[0] != '\0') {
475 strnz__cat(spec, " ", MAXLEN - 1);
476 strnz__cat(spec, s2_s, MAXLEN - 1);
477 }
478 return f_spec;
479 }
480 }
481 return false;
482}
483/** @brief Initialize Menu file specifications
484 @ingroup mem
485 @param init structure
486 @param argc - number of arguments in argv
487 @param argv - Arguments may have been provided by command line,
488 ~/.minitrc, environment variables, or calling program
489 interal to C-Menu
490 @details Positional args: [menu desc], [help file] */
491bool init_menu_files(Init *init, int argc, char **argv) {
492 char tmp_str[MAXLEN];
493 int optind = 0;
494 if (optind < argc && !init->f_mapp_spec) {
497 "~/menuapp/msrc", R_OK);
499 optind++;
500 }
501 if (optind < argc && !menu->f_help_spec) {
504 "~/menuapp/help", R_OK);
506 optind++;
507 }
508 if (!menu->f_mapp_spec) {
510 menu->mapp_spec, "~/menuapp/msrc/main.m", nullptr, nullptr, R_OK);
511 if (!menu->f_mapp_spec) {
512 strnz__cpy(tmp_str, "menu cannot read description file ",
513 MAXLEN - 1);
515 abend(-1, tmp_str);
516 }
517 }
518 if (!menu->f_help_spec) {
520 verify_spec_arg(menu->help_spec, "~/menuapp/help/menu.help",
521 nullptr, nullptr, R_OK);
522 if (!menu->f_help_spec) {
523 strnz__cpy(tmp_str, "menu cannot read help file ", MAXLEN - 1);
525 abend(-1, tmp_str);
526 }
527 }
528 return true;
529}
530/** @brief Initialize Pick file specifications
531 @ingroup mem
532 @param init structure
533 @param argc - number of arguments in argv
534 @param argv - Arguments may have been provided by command line,
535 ~/.minitrc,
536 environment variables, or
537 calling program interal to C-Menu
538 @details Positional args: [pick desc], [in_file], [out_file], [help_file] */
539bool init_pick_files(Init *init, int argc, char **argv) {
540 char tmp_str[MAXLEN];
541 int optind = 1;
543 init->mapp_data, "~/menuapp/data", R_OK);
546 "~/menuapp/data", W_OK | S_QUIET);
547 if (init->provider_cmd[0] != '\0') {
550 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
551 }
552 if (init->cmd[0] != '\0') {
554 "$PATH", X_OK | S_QUIET);
555 }
556 if (init->receiver_cmd[0] != '\0') {
559 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
560 }
561 if (init->title[0])
565 "~/menuapp/help", R_OK);
566 if (optind < argc && !pick->f_in_spec) {
569 "~/menuapp/data", R_OK);
570 if (pick->f_in_spec)
571 optind++;
572 }
573 if (optind < argc && !pick->f_out_spec) {
576 "~/menuapp/data", W_OK | S_QUIET);
578 optind++;
579 }
580 if (optind < argc && !pick->f_provider_cmd) {
581 if (argv[optind][0] != '\0') {
584 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
586 base_name(tmp_str, argv[optind]);
589 }
590 }
591 optind++;
592 }
593 if (optind < argc && !pick->f_cmd) {
594 if (argv[optind][0] != '\0') {
596 verify_spec_arg(pick->cmd, argv[optind], "~/menuapp/bin",
597 nullptr, X_OK | S_QUIET);
598 if (!pick->f_cmd) {
599 base_name(tmp_str, argv[optind]);
601 }
602 }
603 optind++;
604 }
605 if (optind < argc && !pick->f_receiver_cmd) {
606 if (argv[optind][0] != '\0') {
609 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
611 base_name(tmp_str, argv[optind]);
614 }
615 }
616 optind++;
617 }
618 if (optind < argc && !pick->f_help_spec) {
621 "~/menuapp/help", R_OK);
623 optind++;
624 }
625 if (pick->provider_cmd[0] != '\0')
627 if (pick->receiver_cmd[0] != '\0')
633 return true;
634}
635/** @brief Initialize Form file specifications
636 @ingroup mem
637 @param init pointer to init structure
638 @param argc - number of arguments in argv
639 @param argv - Arguments may have been provided by command line ~/.minitrc,
640 environment variables, or calling program interal to C-Menu
641 @details Positional args: [pick desc], [in_file], [out_file], [help_file] */
642bool init_form_files(Init *init, int argc, char **argv) {
643 char tmp_str[MAXLEN];
644 int optind = 0;
647 "~/menuapp/msrc", R_OK);
649 init->mapp_data, "~/menuapp/data", R_OK);
652 "~/menuapp/data", W_OK | S_QUIET);
653 if (init->provider_cmd[0] != '\0') {
656 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
657 }
658 if (init->cmd[0] != '\0') {
660 "$PATH", X_OK | S_QUIET);
661 }
662 if (init->receiver_cmd[0] != '\0') {
665 "~/menuapp/bin", "$PATH", X_OK | S_QUIET);
666 }
669 "~/menuapp/help", R_OK);
670 if (optind < argc && !form->f_mapp_spec) {
673 "~/menuapp/msrc", R_OK);
675 optind++;
676 }
677 if (optind < argc && !form->f_in_spec) {
680 "~/menuapp/data", R_OK);
681 if (form->f_in_spec)
682 optind++;
683 }
684 if (optind < argc && !form->f_out_spec) {
687 "~/menuapp/data", W_OK | S_QUIET);
689 optind++;
690 }
691 if (optind < argc && !form->f_provider_cmd) {
692 if (argv[optind][0] != '\0') {
695 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
697 base_name(tmp_str, argv[optind]);
700 }
701 }
702 optind++;
703 }
704 if (optind < argc && !form->f_cmd) {
705 if (argv[optind][0] != '\0') {
707 verify_spec_arg(form->cmd, argv[optind], "~/menuapp/bin",
708 nullptr, X_OK | S_QUIET);
709 if (!form->f_cmd) {
710 base_name(tmp_str, argv[optind]);
712 }
713 }
714 optind++;
715 }
716 if (optind < argc && !form->f_receiver_cmd) {
717 if (argv[optind][0] != '\0') {
720 "~/menuapp/bin", nullptr, X_OK | S_QUIET);
722 base_name(tmp_str, argv[optind]);
725 }
726 }
727 optind++;
728 }
729 if (optind < argc && !form->f_help_spec) {
732 "~/menuapp/help", R_OK);
734 optind++;
735 }
736 if (form->cmd[0] != '\0')
738 if (form->provider_cmd[0] != '\0')
740 if (form->receiver_cmd[0] != '\0')
743 if (form->title[0] == '\0' && init->title[0] != '\0') {
746 }
748 return true;
749}
750/** @brief Initialize View file specifications
751 @ingroup mem
752 @param init structure
753 @details Positional args: pick desc, in_file, out_file, help_file */
754bool init_view_files(Init *init) {
755 char *e;
756 view = init->view;
757 view->lines = init->lines;
758 view->cols = init->cols;
759 view->begy = init->begy;
760 view->begx = init->begx;
765 view->f_ln = init->f_ln;
766 view->wrap = init->wrap;
768 e = getenv("VIEW_HELP_FILE");
769 if (e && e[0] != '\0') {
771 }
774 "~/menuapp/help", R_OK);
775 if (!view->f_help_spec) {
779 }
783 if (view->cmd[0] != '\0')
785 if (view->provider_cmd[0] != '\0')
787 if (view->receiver_cmd[0] != '\0')
789 if (view->title[0] == '\0') {
790 if (init->title[0] != '\0') {
792 } else {
793 if (view->provider_cmd[0] != '\0')
795 else {
796 if (view->argv != nullptr && view->argv[0] != nullptr &&
797 view->argv[0][0] != '\0') {
799 } else
800 strnz__cpy(view->title, "C-Menu View", MAXLEN - 1);
801 }
802 }
803 }
805 if (view->tab_stop == 0)
806 view->tab_stop = 4;
807 return true;
808}
#define FIELD_MAXCNT
Definition form.h:19
#define VIEW_HELP_FILE
Definition common.h:35
#define OBJ_MAXCNT
Definition pick.h:17
#define MAXARGS
Definition cm.h:50
#define S_QUIET
Definition cm.h:328
#define S_WCOK
Definition cm.h:327
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
char em1[MAXLEN]
Definition dwin.c:143
char em2[MAXLEN]
Definition dwin.c:144
char em0[MAXLEN]
Definition dwin.c:142
int Perror(char *emsg_str)
Display a simple error message window or print to stderr.
Definition dwin.c:841
void abend(int ec, char *s)
Abnormal program termination.
Definition dwin.c:1204
int display_error(char *msg0, char *msg1, char *msg2, char *msg3)
Display an error message window or print to stderr.
Definition dwin.c:778
bool locate_file_in_path(char *, char *)
Locates a file in the system PATH.
Definition futil.c:1270
size_t canonicalize_file_spec(char *)
Removes quotes and trims at first space.
Definition futil.c:1324
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:537
bool stripz_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:726
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:413
bool strip_quotes(char *)
removes leading and trailing double quotes if present
Definition futil.c:711
bool expand_tilde(char *, uint)
Replaces "~/" in string with the user's home directory.
Definition futil.c:963
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:647
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:566
bool verify_file(char *, uint)
Verifies that the file specified by "in_spec" exists and is accessible with the permissions specified...
Definition futil.c:1223
int destroy_argv(uint argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:487
bool base_name(char *, char *)
Returns the base name of a file specification.
Definition futil.c:1106
bool verify_dir(char *, uint)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
Definition futil.c:1172
bool verify_spec_arg(char *, char *, char *, char *, uint)
Verify file specification argument.
Definition mem.c:369
Pick * new_pick(Init *init, int argc, char **argv, uint begy, uint begx)
Create and initialize Pick structure.
Definition mem.c:186
bool init_form_files(Init *init, int argc, char **argv)
Initialize Form file specifications.
Definition mem.c:642
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:345
Menu * new_menu(Init *init, int argc, char **argv, uint begy, uint begx)
Create and initialize Menu structure.
Definition mem.c:134
bool init_menu_files(Init *init, int argc, char **argv)
Initialize Menu file specifications.
Definition mem.c:491
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:155
Form * destroy_form(Init *init)
Destroy Form structure.
Definition mem.c:275
View * new_view(Init *init)
Create and initialize View structure.
Definition mem.c:299
Init * destroy_init(Init *init)
Destroy Init structure.
Definition mem.c:95
bool init_pick_files(Init *init, int argc, char **argv)
Initialize Pick file specifications.
Definition mem.c:539
Form * new_form(Init *init, int argc, char **argv, uint begy, uint begx)
Create and initialize Form structure.
Definition mem.c:252
bool init_view_files(Init *init)
Initialize View file specifications.
Definition mem.c:754
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:225
char title[MAXLEN]
Definition common.h:129
char mapp_data[MAXLEN]
Definition common.h:148
char mapp_help[MAXLEN]
Definition common.h:149
int begx
Definition common.h:118
SIO * sio
Definition common.h:114
int pick_cnt
Definition common.h:188
Form * form
Definition common.h:185
char in_spec[MAXLEN]
Definition common.h:168
char cmd_all[MAXLEN]
Definition common.h:123
int argc
Definition common.h:130
char fill_char[2]
Definition common.h:146
char mapp_msrc[MAXLEN]
Definition common.h:150
int cols
Definition common.h:116
int menu_cnt
Definition common.h:184
int tab_stop
Definition common.h:181
bool f_erase_remainder
Definition common.h:141
bool f_read_theme
Definition common.h:142
char mapp_home[MAXLEN]
Definition common.h:147
bool f_squeeze
Definition common.h:137
int begy
Definition common.h:117
char mapp_spec[MAXLEN]
Definition common.h:176
char receiver_cmd[MAXLEN]
Definition common.h:121
int h_shift
Definition common.h:182
bool wrap
Definition common.h:144
bool f_multiple_cmd_args
Definition common.h:139
int select_max
Definition common.h:179
bool f_ln
Definition common.h:143
bool f_mapp_spec
Definition common.h:156
char provider_cmd[MAXLEN]
Definition common.h:120
char out_spec[MAXLEN]
Definition common.h:169
View * view
Definition common.h:189
bool p_view_files
Definition common.h:134
Menu * menu
Definition common.h:183
bool f_at_end_remove
Definition common.h:135
int view_cnt
Definition common.h:190
char brackets[3]
Definition common.h:145
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:186
char help_spec[MAXLEN]
Definition common.h:177
Pick * pick
Definition common.h:187
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:79
char * raw_text
Definition menu.h:76
char * command_str
Definition menu.h:94
char mapp_spec[MAXLEN]
Definition menu.h:144
Line * line[MAX_MENU_LINES]
Definition menu.h:223
bool f_help_spec
Definition menu.h:182
uint begy
Definition menu.h:118
bool f_mapp_spec
Definition menu.h:177
char help_spec[MAXLEN]
Definition menu.h:150
uint begx
Definition menu.h:121
uint line_idx
Definition menu.h:219
uint item_count
Definition menu.h:216
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:76
int argc
Definition view.h:82
char ** argv
Definition view.h:83
bool wrap
Definition view.h:201
uint lines
Definition view.h:72
uint begx
Definition view.h:75
char help_spec[MAXLEN]
Definition view.h:154
bool f_ignore_case
Definition view.h:85
bool f_help_spec
Definition view.h:157
char cmd[MAXLEN]
Definition view.h:78
char receiver_cmd[MAXLEN]
Definition view.h:77
bool f_ln
Definition view.h:193
bool f_at_end_remove
Definition view.h:86
bool f_squeeze
Definition view.h:87
int tab_stop
Definition view.h:107
char title[MAXLEN]
Definition view.h:81
uint cols
Definition view.h:73
char cmd_all[MAXLEN]
Definition view.h:79
uint begy
Definition view.h:74
int h_shift
Definition view.h:108