20#ifndef MENU_INDEX_FILE
38#if 0 && !(defined(FREEFORM) && defined(XVT))
50#ifndef ROWSIZE_STRUCT_DEFINED
51#define ROWSIZE_STRUCT_DEFINED
58#define ulong unsigned long
75 ulong max_buffer_size;
78 char file_index_exists;
91} MENU_INDEX, *MENU_INDEX_PTR;
103 char *additional_info;
106 ROW_SIZES_PTR help_sec;
108 char ascii_data_file;
112} MENU_SELECTION, *MENU_SELECTION_PTR;
116 MENU_INDEX_PTR mindex;
123 char dynamic_section;
125 ROW_SIZES_PTR help_sec;
128 MENU_SELECTION_PTR selection;
132} MENU_SECTION, *MENU_SECTION_PTR;
138typedef struct menu_open_struct {
139 MENU_INDEX_PTR mindex;
141 int menu_navigation_count;
148 char *menu_file_name;
149} MENU_OPEN, *MENU_OPEN_PTR;
154#define MENU_SECTION_TYPE_SELECTION 0
155#define MENU_SECTION_TYPE_HELP 1
158#define MENU_DIRECTIVE_NEW_SECTION 0
159#define MENU_DIRECTIVE_TERM_SECTION 1
160#define MENU_DIRECTIVE_NEW_MENU_FILE 2
161#define MENU_DIRECTIVE_DATA_FILE 3
164#define MENU_INDEX_FILE 0
165#define MENU_INDEX_MEM 1
168#define MENU_IN_FILE 0
172#define MENU_DIR_SEP '\\'
175#define MENU_UNTITLED "Untitled"
178#define MENU_TEXT_CONTENT "ASCII"
181#define MENU_DATA_SECTION "_DATASEC"
184#define MENU_INDEX_SECTION "*MENU INDEX"
185#define MENU_INDEX_SECTION_LEN 11
188#define MENU_TEXT_CONTENT_SEC "TEXT_CONTENT"
190#define MENU_FOPEN_R "rb"
191#define MENU_FOPEN_W "wb"
192#define MENU_FOPEN_U "r+b"
205#define MENU_ERR_PUSH(a, b, c) err_push(b, c)
209MENU_INDEX_PTR mn_index_make (
char *filename, ulong max_buf_size,
char *outfilename);
210int mn_index_remove(
char *filename,
char *outfilename);
211int mn_index_get_offset(MENU_INDEX_PTR mindex,
char *section, ROW_SIZES_PTR rowsize);
212int mn_index_free(MENU_INDEX_PTR mindex);
213int mn_index_find_title(MENU_INDEX_PTR mindex,
char *postfix, ROW_SIZES_PTR rowsize,
char **buffer);
214int mn_index_set_paths(MENU_INDEX_PTR mindex,
char *pathone,
char *pathtwo);
215char *mn_binary_fgets(
char *
string,
int n, FILE *stream,
char *file_eol_str);
216char *mn_get_file_eol_str(
char *filename);
219int mn_sec_titles_to_buf(MENU_INDEX_PTR mindex,
char *buf_to_use,
int *num_sections,
char **buf_filled);
220int mn_section_get(MENU_INDEX_PTR mindex,
char *buf_to_use, ROW_SIZES_PTR rowsize,
char **buf_filled);
221int mn_help_sec_find(MENU_INDEX_PTR mindex,
char *lookup, ROW_SIZES_PTR rowsize,
char *section_name);
222int mn_sec_process(MENU_INDEX_PTR mindex,
char *section_title, ROW_SIZES_PTR rowsize,
char *parent_menu, MENU_SECTION_PTR *menu_sec);
223int mn_help_sec_get(MENU_INDEX_PTR mindex,
char *lookup, ROW_SIZES_PTR rowsize,
char **buf_filled);
224int mn_proc_section_free(MENU_SECTION_PTR menu_sec);
225int mn_selection_free(MENU_SELECTION_PTR selection);
226int mn_datasec_len_get(MENU_INDEX_PTR mindex, ROW_SIZES_PTR rowsize,
long *length);
227int mn_section_rebuild(MENU_SECTION_PTR msection,
char **buffer);
228MENU_SELECTION_PTR mn_selection_copy(MENU_SELECTION_PTR selection);
234#define MENU_NEXT_SELECTION(a) ((a)->next_selection)
235#define MENU_PREV_SELECTION(a) ((a)->previous_selection)
236#define MENU_REWIND_SELECTION_DLL(a) {while((a)->previous_selection) (a)=(a)->previous_selection;}
239#define MENU_REMOVE_SELECTION(rmv, newptr) { \
241 if(rmv->previous_selection){ \
242 rmv->previous_selection->next_selection = rmv->next_selection; \
243 newptr = rmv->previous_selection; \
245 if(rmv->next_selection){ \
246 rmv->next_selection->previous_selection = rmv->previous_selection; \
247 newptr = rmv->next_selection; \
249 mn_selection_free(rmv); \
253#define MENU_INSERT_SELECTION(ins, list) { \
255 ins->previous_selection = list; \
256 ins->next_selection = list->next_selection; \
257 list->next_selection = ins; \
258 if(ins->next_selection) \
259 ins->next_selection->previous_selection = ins; \
268#define mAlloc(sz) mn_malloc(sz, __LINE__, ROUTINE_NAME)
269#define reAlloc(mptr, sz) mn_realloc(mptr, sz, __LINE__, ROUTINE_NAME)
270#define fRee(sz) mn_free(sz, __LINE__, ROUTINE_NAME)
272void *mn_malloc(
size_t memsize,
int linenum,
char *routine);
273void *mn_realloc(
void *memblk,
size_t memsize,
int linenum,
char *routine);
274void mn_free(
void *memblk,
int linenum,
char *routine);
276#define MEMTRAPFILE "c:\\memtrap"
280#define mAlloc(sz) memMalloc(sz, "menu")
281#define reAlloc(mptr, sz) memRealloc(mptr, sz, "menu")
282#define fRee(sz) memFree(sz, "menu")
289char *mn_strnstr(
char *pcPattern,
char *pcText,
size_t uTextLen);
290#define MN_STRNSTR(strpattern, strtext, textsize) mn_strnstr(strpattern, strtext, textsize)
295#define MN_STRNSTR(strpattern, strtext, textsize) ff_strnstr(strpattern, strtext, textsize)