Changeset tag,last-working,2 for tag/last-working/menu2.c
- Timestamp:
- 09/19/2007 11:06:52 PM (19 years ago)
- branch-nick:
- tui
- revision id:
- dsowen@fugue88.ws-20070919230652-gcf3h1qwf86lq8j7
- File:
-
- 1 edited
-
tag/last-working/menu2.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tag/last-working/menu2.c
r1 r2 12 12 char *item_names[_MAX_ITEMS]; 13 13 char *item_descriptions[_MAX_ITEMS]; 14 ITEM *item_structs[_MAX_ITEMS + 1]; 14 15 int item_count; 16 17 MENU *menu_struct; /* Only set when posted. */ 15 18 }; 16 19 … … 43 46 { 44 47 struct menu2_t *m = _menus[menu - 1]; 48 int *i; 49 45 50 if(!m) return 0; 46 51 47 if(m->item_count == _MAX_ITEMS) return 0; 52 i = &(m->item_count); 53 if(*i == _MAX_ITEMS) return 0; 48 54 49 m->item_names[m->item_count] = strdup(name); 50 m->item_descriptions[m->item_count] = 51 strdup(description ? description : name); 55 m->item_names[*i] = strdup(name); 56 m->item_descriptions[*i] = strdup(description ? description : name); 57 m->item_structs[*i] = 58 new_item(m->item_names[*i], m->item_descriptions[*i]); 52 59 53 ++ m->item_count;60 ++(*i); 54 61 55 62 return 1; … … 64 71 65 72 for(i = 0; i < m->item_count; i++) { 73 free_item(m->item_structs[i]); 74 free(m->item_descriptions[i]); 66 75 free(m->item_names[i]); 67 free(m->item_descriptions[i]);68 76 } 69 77 … … 79 87 80 88 if(!m) return 0; 89 if(m->menu_struct) return 0; 81 90 82 blah 91 m->menu_struct = new_menu(m->item_structs); 92 post_menu(m->menu_struct); 93 94 return 1; 83 95 } 84 96 85 menu2_drive(int, int); 97 int menu2_drive(menu2_h menu, int c) 98 { 99 struct menu2_t *m = _menus[menu - 1]; 100 101 if(!m) return 0; 102 if(!m->menu_struct) return 0; 103 104 menu_driver(m->menu_struct, c); 105 106 return 1; 107 } 108 109 int menu2_unpost(menu2_h menu) 110 { 111 struct menu2_t *m = _menus[menu - 1]; 112 113 if(!m) return 0; 114 if(!m->menu_struct) return 0; 115 116 unpost_menu(m->menu_struct); 117 free_menu(m->menu_struct); 118 m->menu_struct = NULL; 119 120 return 1; 121 }
Note: See TracChangeset
for help on using the changeset viewer.
