/[LeafOK_CVS]/lbbs/src/menu.c
ViewVC logotype

Diff of /lbbs/src/menu.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.24 by sysadm, Sat May 3 13:41:21 2025 UTC Revision 1.30 by sysadm, Tue May 6 05:31:26 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2                                                    menu.c  -  description                                                    menu.c  -  description
3                                                           -------------------                                                           -------------------
4          begin                : Wed Mar 16 2004          Copyright            : (C) 2004-2025 by Leaflet
5          copyright            : (C) 2005 by Leaflet          Email                : leaflet@leafok.com
         email                : leaflet@leafok.com  
6   ***************************************************************************/   ***************************************************************************/
7    
8  /***************************************************************************  /***************************************************************************
9   *                                                                         *   *                                                                         *
10   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
11   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
12   *   the Free Software Foundation; either version 2 of the License, or     *   *   the Free Software Foundation; either version 3 of the License, or     *
13   *   (at your option) any later version.                                   *   *   (at your option) any later version.                                   *
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
# Line 31  Line 30 
30  #include <regex.h>  #include <regex.h>
31  #include <stdlib.h>  #include <stdlib.h>
32    
33    #define MENU_TEMP_DIR "var"
34    
35  MENU_SET bbs_menu;  MENU_SET bbs_menu;
36    
37  int load_menu(MENU_SET *p_menu_set, const char *conf_file)  int load_menu(MENU_SET *p_menu_set, const char *conf_file)
# Line 38  int load_menu(MENU_SET *p_menu_set, cons Line 39  int load_menu(MENU_SET *p_menu_set, cons
39          FILE *fin, *fout;          FILE *fin, *fout;
40          int i = 0, j;          int i = 0, j;
41          char buffer[LINE_BUFFER_LEN];          char buffer[LINE_BUFFER_LEN];
42          char screen_filename[LINE_BUFFER_LEN];          char screen_filename[FILE_PATH_LEN];
43          char temp[LINE_BUFFER_LEN];          char temp[LINE_BUFFER_LEN];
44          regmatch_t pmatch[10];          regmatch_t pmatch[10];
45    
# Line 48  int load_menu(MENU_SET *p_menu_set, cons Line 49  int load_menu(MENU_SET *p_menu_set, cons
49                  return -1;                  return -1;
50          }          }
51    
52          strcpy(p_menu_set->conf_file, conf_file);          strncpy(p_menu_set->conf_file, conf_file, sizeof(p_menu_set->conf_file) - 1);
53            p_menu_set->conf_file[sizeof(p_menu_set->conf_file) - 1] = '\0';
54    
55          while (fgets(buffer, sizeof(buffer), fin))          while (fgets(buffer, sizeof(buffer), fin))
56          {          {
# Line 60  int load_menu(MENU_SET *p_menu_set, cons Line 62  int load_menu(MENU_SET *p_menu_set, cons
62                          if (ireg("^%S_([A-Za-z0-9_]+)", buffer, 2, pmatch) == 0)                          if (ireg("^%S_([A-Za-z0-9_]+)", buffer, 2, pmatch) == 0)
63                          {                          {
64                                  strncpy(temp, buffer + pmatch[1].rm_so,                                  strncpy(temp, buffer + pmatch[1].rm_so,
65                                                  pmatch[1].rm_eo - pmatch[1].rm_so);                                                  (size_t)(pmatch[1].rm_eo - pmatch[1].rm_so));
66                                  temp[pmatch[1].rm_eo - pmatch[1].rm_so] = '\0';                                  temp[pmatch[1].rm_eo - pmatch[1].rm_so] = '\0';
67                                  sprintf(screen_filename, "%sMENU_SCR_%s", app_temp_dir, temp);                                  snprintf(screen_filename, sizeof(screen_filename), "%s/MENU_SCR_%s", MENU_TEMP_DIR, temp);
68    
69                                  if ((fout = fopen(screen_filename, "w")) == NULL)                                  if ((fout = fopen(screen_filename, "w")) == NULL)
70                                  {                                  {
# Line 90  int load_menu(MENU_SET *p_menu_set, cons Line 92  int load_menu(MENU_SET *p_menu_set, cons
92    
93                                  strncpy(p_menu_set->p_menu[i]->name,                                  strncpy(p_menu_set->p_menu[i]->name,
94                                                  buffer + pmatch[1].rm_so,                                                  buffer + pmatch[1].rm_so,
95                                                  pmatch[1].rm_eo - pmatch[1].rm_so);                                                  (size_t)(pmatch[1].rm_eo - pmatch[1].rm_so));
96                                  p_menu_set->p_menu[i]->name[pmatch[1].rm_eo - pmatch[1].rm_so] =                                  p_menu_set->p_menu[i]->name[pmatch[1].rm_eo - pmatch[1].rm_so] =
97                                          '\0';                                          '\0';
98    
# Line 120  int load_menu(MENU_SET *p_menu_set, cons Line 122  int load_menu(MENU_SET *p_menu_set, cons
122                                                  p_menu_set->p_menu[i]->items[j]->submenu = 1;                                                  p_menu_set->p_menu[i]->items[j]->submenu = 1;
123                                                  strncpy(p_menu_set->p_menu[i]->items[j]->action,                                                  strncpy(p_menu_set->p_menu[i]->items[j]->action,
124                                                                  buffer + pmatch[1].rm_so,                                                                  buffer + pmatch[1].rm_so,
125                                                                  pmatch[1].rm_eo - pmatch[1].rm_so);                                                                  (size_t)(pmatch[1].rm_eo - pmatch[1].rm_so));
126                                                  p_menu_set->p_menu[i]->items[j]->action[pmatch[1].rm_eo -                                                  p_menu_set->p_menu[i]->items[j]->action[pmatch[1].rm_eo -
127                                                                                                                                  pmatch[1].rm_so] = '\0';                                                                                                                                  pmatch[1].rm_so] = '\0';
128                                                  strncpy(temp, buffer + pmatch[2].rm_so,                                                  strncpy(temp, buffer + pmatch[2].rm_so,
129                                                                  pmatch[2].rm_eo - pmatch[2].rm_so);                                                                  (size_t)(pmatch[2].rm_eo - pmatch[2].rm_so));
130                                                  temp[pmatch[2].rm_eo - pmatch[2].rm_so] = '\0';                                                  temp[pmatch[2].rm_eo - pmatch[2].rm_so] = '\0';
131                                                  p_menu_set->p_menu[i]->items[j]->row = atoi(temp);                                                  p_menu_set->p_menu[i]->items[j]->row = atoi(temp);
132                                                  strncpy(temp,                                                  strncpy(temp,
133                                                                  buffer + pmatch[3].rm_so,                                                                  buffer + pmatch[3].rm_so,
134                                                                  pmatch[3].rm_eo - pmatch[3].rm_so);                                                                  (size_t)(pmatch[3].rm_eo - pmatch[3].rm_so));
135                                                  temp[pmatch[3].rm_eo - pmatch[3].rm_so] = '\0';                                                  temp[pmatch[3].rm_eo - pmatch[3].rm_so] = '\0';
136                                                  p_menu_set->p_menu[i]->items[j]->col = atoi(temp);                                                  p_menu_set->p_menu[i]->items[j]->col = atoi(temp);
137                                                  strncpy(temp,                                                  strncpy(temp,
138                                                                  buffer + pmatch[4].rm_so,                                                                  buffer + pmatch[4].rm_so,
139                                                                  pmatch[4].rm_eo - pmatch[4].rm_so);                                                                  (size_t)(pmatch[4].rm_eo - pmatch[4].rm_so));
140                                                  temp[pmatch[4].rm_eo - pmatch[4].rm_so] = '\0';                                                  temp[pmatch[4].rm_eo - pmatch[4].rm_so] = '\0';
141                                                  p_menu_set->p_menu[i]->items[j]->priv = atoi(temp);                                                  p_menu_set->p_menu[i]->items[j]->priv = atoi(temp);
142                                                  strncpy(temp,                                                  strncpy(temp,
143                                                                  buffer + pmatch[5].rm_so,                                                                  buffer + pmatch[5].rm_so,
144                                                                  pmatch[5].rm_eo - pmatch[5].rm_so);                                                                  (size_t)(pmatch[5].rm_eo - pmatch[5].rm_so));
145                                                  temp[pmatch[5].rm_eo - pmatch[5].rm_so] = '\0';                                                  temp[pmatch[5].rm_eo - pmatch[5].rm_so] = '\0';
146                                                  p_menu_set->p_menu[i]->items[j]->level = atoi(temp);                                                  p_menu_set->p_menu[i]->items[j]->level = atoi(temp);
147                                                  strncpy(p_menu_set->p_menu[i]->items[j]->name,                                                  strncpy(p_menu_set->p_menu[i]->items[j]->name,
148                                                                  buffer + pmatch[6].rm_so,                                                                  buffer + pmatch[6].rm_so,
149                                                                  pmatch[6].rm_eo - pmatch[6].rm_so);                                                                  (size_t)(pmatch[6].rm_eo - pmatch[6].rm_so));
150                                                  p_menu_set->p_menu[i]->items[j]->name[pmatch[6].rm_eo -                                                  p_menu_set->p_menu[i]->items[j]->name[pmatch[6].rm_eo -
151                                                                                                                            pmatch[6].rm_so] =                                                                                                                            pmatch[6].rm_so] =
152                                                          '\0';                                                          '\0';
153                                                  strncpy(p_menu_set->p_menu[i]->items[j]->text,                                                  strncpy(p_menu_set->p_menu[i]->items[j]->text,
154                                                                  buffer + pmatch[7].rm_so,                                                                  buffer + pmatch[7].rm_so,
155                                                                  pmatch[7].rm_eo - pmatch[7].rm_so);                                                                  (size_t)(pmatch[7].rm_eo - pmatch[7].rm_so));
156                                                  p_menu_set->p_menu[i]->items[j]->text[pmatch[7].rm_eo -                                                  p_menu_set->p_menu[i]->items[j]->text[pmatch[7].rm_eo -
157                                                                                                                            pmatch[7].rm_so] =                                                                                                                            pmatch[7].rm_so] =
158                                                          '\0';                                                          '\0';
# Line 168  int load_menu(MENU_SET *p_menu_set, cons Line 170  int load_menu(MENU_SET *p_menu_set, cons
170                                                  p_menu_set->p_menu[i]->items[j]->submenu = 0;                                                  p_menu_set->p_menu[i]->items[j]->submenu = 0;
171                                                  strncpy(p_menu_set->p_menu[i]->items[j]->action,                                                  strncpy(p_menu_set->p_menu[i]->items[j]->action,
172                                                                  buffer + pmatch[1].rm_so,                                                                  buffer + pmatch[1].rm_so,
173                                                                  pmatch[1].rm_eo - pmatch[1].rm_so);                                                                  (size_t)(pmatch[1].rm_eo - pmatch[1].rm_so));
174                                                  p_menu_set->p_menu[i]->items[j]->action[pmatch[1].rm_eo -                                                  p_menu_set->p_menu[i]->items[j]->action[pmatch[1].rm_eo -
175                                                                                                                                  pmatch[1].rm_so] = '\0';                                                                                                                                  pmatch[1].rm_so] = '\0';
176                                                  strncpy(temp, buffer + pmatch[2].rm_so,                                                  strncpy(temp, buffer + pmatch[2].rm_so,
177                                                                  pmatch[2].rm_eo - pmatch[2].rm_so);                                                                  (size_t)(pmatch[2].rm_eo - pmatch[2].rm_so));
178                                                  temp[pmatch[2].rm_eo - pmatch[2].rm_so] = '\0';                                                  temp[pmatch[2].rm_eo - pmatch[2].rm_so] = '\0';
179                                                  p_menu_set->p_menu[i]->items[j]->row = atoi(temp);                                                  p_menu_set->p_menu[i]->items[j]->row = atoi(temp);
180                                                  strncpy(temp,                                                  strncpy(temp,
181                                                                  buffer + pmatch[3].rm_so,                                                                  buffer + pmatch[3].rm_so,
182                                                                  pmatch[3].rm_eo - pmatch[3].rm_so);                                                                  (size_t)(pmatch[3].rm_eo - pmatch[3].rm_so));
183                                                  temp[pmatch[3].rm_eo - pmatch[3].rm_so] = '\0';                                                  temp[pmatch[3].rm_eo - pmatch[3].rm_so] = '\0';
184                                                  p_menu_set->p_menu[i]->items[j]->col = atoi(temp);                                                  p_menu_set->p_menu[i]->items[j]->col = atoi(temp);
185                                                  strncpy(temp,                                                  strncpy(temp,
186                                                                  buffer + pmatch[4].rm_so,                                                                  buffer + pmatch[4].rm_so,
187                                                                  pmatch[4].rm_eo - pmatch[4].rm_so);                                                                  (size_t)(pmatch[4].rm_eo - pmatch[4].rm_so));
188                                                  temp[pmatch[4].rm_eo - pmatch[4].rm_so] = '\0';                                                  temp[pmatch[4].rm_eo - pmatch[4].rm_so] = '\0';
189                                                  p_menu_set->p_menu[i]->items[j]->priv = atoi(temp);                                                  p_menu_set->p_menu[i]->items[j]->priv = atoi(temp);
190                                                  strncpy(temp,                                                  strncpy(temp,
191                                                                  buffer + pmatch[5].rm_so,                                                                  buffer + pmatch[5].rm_so,
192                                                                  pmatch[5].rm_eo - pmatch[5].rm_so);                                                                  (size_t)(pmatch[5].rm_eo - pmatch[5].rm_so));
193                                                  temp[pmatch[5].rm_eo - pmatch[5].rm_so] = '\0';                                                  temp[pmatch[5].rm_eo - pmatch[5].rm_so] = '\0';
194                                                  p_menu_set->p_menu[i]->items[j]->level = atoi(temp);                                                  p_menu_set->p_menu[i]->items[j]->level = atoi(temp);
195                                                  strncpy(p_menu_set->p_menu[i]->items[j]->name,                                                  strncpy(p_menu_set->p_menu[i]->items[j]->name,
196                                                                  buffer + pmatch[6].rm_so,                                                                  buffer + pmatch[6].rm_so,
197                                                                  pmatch[6].rm_eo - pmatch[6].rm_so);                                                                  (size_t)(pmatch[6].rm_eo - pmatch[6].rm_so));
198                                                  p_menu_set->p_menu[i]->items[j]->name[pmatch[6].rm_eo -                                                  p_menu_set->p_menu[i]->items[j]->name[pmatch[6].rm_eo -
199                                                                                                                            pmatch[6].rm_so] =                                                                                                                            pmatch[6].rm_so] =
200                                                          '\0';                                                          '\0';
201                                                  strncpy(p_menu_set->p_menu[i]->items[j]->text,                                                  strncpy(p_menu_set->p_menu[i]->items[j]->text,
202                                                                  buffer + pmatch[7].rm_so,                                                                  buffer + pmatch[7].rm_so,
203                                                                  pmatch[7].rm_eo - pmatch[7].rm_so);                                                                  (size_t)(pmatch[7].rm_eo - pmatch[7].rm_so));
204                                                  p_menu_set->p_menu[i]->items[j]->text[pmatch[7].rm_eo -                                                  p_menu_set->p_menu[i]->items[j]->text[pmatch[7].rm_eo -
205                                                                                                                            pmatch[7].rm_so] =                                                                                                                            pmatch[7].rm_so] =
206                                                          '\0';                                                          '\0';
# Line 212  int load_menu(MENU_SET *p_menu_set, cons Line 214  int load_menu(MENU_SET *p_menu_set, cons
214                                                  p_menu_set->p_menu[i]->title.show = 1;                                                  p_menu_set->p_menu[i]->title.show = 1;
215                                                  strncpy(temp,                                                  strncpy(temp,
216                                                                  buffer + pmatch[1].rm_so,                                                                  buffer + pmatch[1].rm_so,
217                                                                  pmatch[1].rm_eo - pmatch[1].rm_so);                                                                  (size_t)(pmatch[1].rm_eo - pmatch[1].rm_so));
218                                                  temp[pmatch[1].rm_eo - pmatch[1].rm_so] = '\0';                                                  temp[pmatch[1].rm_eo - pmatch[1].rm_so] = '\0';
219                                                  p_menu_set->p_menu[i]->title.row = atoi(temp);                                                  p_menu_set->p_menu[i]->title.row = atoi(temp);
220                                                  strncpy(temp,                                                  strncpy(temp,
221                                                                  buffer + pmatch[2].rm_so,                                                                  buffer + pmatch[2].rm_so,
222                                                                  pmatch[2].rm_eo - pmatch[2].rm_so);                                                                  (size_t)(pmatch[2].rm_eo - pmatch[2].rm_so));
223                                                  temp[pmatch[2].rm_eo - pmatch[2].rm_so] = '\0';                                                  temp[pmatch[2].rm_eo - pmatch[2].rm_so] = '\0';
224                                                  p_menu_set->p_menu[i]->title.col = atoi(temp);                                                  p_menu_set->p_menu[i]->title.col = atoi(temp);
225                                                  strncpy(p_menu_set->p_menu[i]->title.text,                                                  strncpy(p_menu_set->p_menu[i]->title.text,
226                                                                  buffer + pmatch[3].rm_so,                                                                  buffer + pmatch[3].rm_so,
227                                                                  pmatch[3].rm_eo - pmatch[3].rm_so);                                                                  (size_t)(pmatch[3].rm_eo - pmatch[3].rm_so));
228                                                  p_menu_set->p_menu[i]->title.text[pmatch[3].rm_eo -                                                  p_menu_set->p_menu[i]->title.text[pmatch[3].rm_eo -
229                                                                                                                    pmatch[3].rm_so] =                                                                                                                    pmatch[3].rm_so] =
230                                                          '\0';                                                          '\0';
# Line 235  int load_menu(MENU_SET *p_menu_set, cons Line 237  int load_menu(MENU_SET *p_menu_set, cons
237                                                  p_menu_set->p_menu[i]->screen.show = 1;                                                  p_menu_set->p_menu[i]->screen.show = 1;
238                                                  strncpy(temp,                                                  strncpy(temp,
239                                                                  buffer + pmatch[1].rm_so,                                                                  buffer + pmatch[1].rm_so,
240                                                                  pmatch[1].rm_eo - pmatch[1].rm_so);                                                                  (size_t)(pmatch[1].rm_eo - pmatch[1].rm_so));
241                                                  temp[pmatch[1].rm_eo - pmatch[1].rm_so] = '\0';                                                  temp[pmatch[1].rm_eo - pmatch[1].rm_so] = '\0';
242                                                  p_menu_set->p_menu[i]->screen.row = atoi(temp);                                                  p_menu_set->p_menu[i]->screen.row = atoi(temp);
243                                                  strncpy(temp,                                                  strncpy(temp,
244                                                                  buffer + pmatch[2].rm_so,                                                                  buffer + pmatch[2].rm_so,
245                                                                  pmatch[2].rm_eo - pmatch[2].rm_so);                                                                  (size_t)(pmatch[2].rm_eo - pmatch[2].rm_so));
246                                                  temp[pmatch[2].rm_eo - pmatch[2].rm_so] = '\0';                                                  temp[pmatch[2].rm_eo - pmatch[2].rm_so] = '\0';
247                                                  p_menu_set->p_menu[i]->screen.col = atoi(temp);                                                  p_menu_set->p_menu[i]->screen.col = atoi(temp);
248                                                  strncpy(temp,                                                  strncpy(temp,
249                                                                  buffer + pmatch[3].rm_so,                                                                  buffer + pmatch[3].rm_so,
250                                                                  pmatch[3].rm_eo - pmatch[3].rm_so);                                                                  (size_t)(pmatch[3].rm_eo - pmatch[3].rm_so));
251                                                  temp[pmatch[3].rm_eo - pmatch[3].rm_so] = '\0';                                                  temp[pmatch[3].rm_eo - pmatch[3].rm_so] = '\0';
252                                                  sprintf(p_menu_set->p_menu[i]->screen.filename,                                                  snprintf(p_menu_set->p_menu[i]->screen.filename,
253                                                                  "%sMENU_SCR_%s", app_temp_dir, temp);                                                                   sizeof(p_menu_set->p_menu[i]->screen.filename),
254                                                                     "%s/MENU_SCR_%s", MENU_TEMP_DIR, temp);
255                                                  continue;                                                  continue;
256                                          }                                          }
257                                  }                                  }
# Line 285  static void display_menu_cursor(MENU *p_ Line 288  static void display_menu_cursor(MENU *p_
288  {  {
289          moveto((p_menu->items[p_menu->item_cur_pos])->r_row,          moveto((p_menu->items[p_menu->item_cur_pos])->r_row,
290                     (p_menu->items[p_menu->item_cur_pos])->r_col - 2);                     (p_menu->items[p_menu->item_cur_pos])->r_col - 2);
291          prints(show ? ">" : " ");          outc(show ? '>' : ' ');
292          iflush();          iflush();
293  }  }
294    
295  int display_menu(MENU *p_menu)  int display_menu(MENU *p_menu)
296  {  {
297          int i, row, col, menu_selectable = 0;          int row = 0;
298            int col = 0;
299            int menu_selectable = 0;
300    
301          if (p_menu == NULL)          if (p_menu == NULL)
302            {
303                  return -1;                  return -1;
304            }
305    
306          if (p_menu->title.show)          if (p_menu->title.show)
307            {
308                  show_top(p_menu->title.text);                  show_top(p_menu->title.text);
309            }
310    
311          if (p_menu->screen.show)          if (p_menu->screen.show)
312          {          {
313                  moveto(p_menu->screen.row, p_menu->screen.col);                  moveto(p_menu->screen.row, p_menu->screen.col);
314                  if (display_file(p_menu->screen.filename) != 0)                  if (display_file(p_menu->screen.filename) != 0)
315                    {
316                          log_error("Display menu screen <%s> failed!\n",                          log_error("Display menu screen <%s> failed!\n",
317                                            p_menu->screen.filename);                                            p_menu->screen.filename);
318                    }
319          }          }
320    
321          row = p_menu->items[0]->row;          for (int i = 0; i < p_menu->item_count; i++)
         col = p_menu->items[0]->col;  
   
         for (i = 0; i < p_menu->item_count; i++)  
322          {          {
323                    if (p_menu->items[i]->row != 0)
324                    {
325                            row = p_menu->items[i]->row;
326                    }
327                    if (p_menu->items[i]->col != 0)
328                    {
329                            col = p_menu->items[i]->col;
330                    }
331    
332                  if (checkpriv(&BBS_priv, 0, p_menu->items[i]->priv) == 0 || checklevel(&BBS_priv, p_menu->items[i]->level) == 0)                  if (checkpriv(&BBS_priv, 0, p_menu->items[i]->priv) == 0 || checklevel(&BBS_priv, p_menu->items[i]->level) == 0)
333                  {                  {
334                          p_menu->items[i]->display = 0;                          p_menu->items[i]->display = 0;
335                            p_menu->items[i]->r_row = 0;
336                            p_menu->items[i]->r_col = 0;
337                  }                  }
338                  else                  else
339                  {                  {
340                          p_menu->items[i]->display = 1;                          p_menu->items[i]->display = 1;
341    
342                          menu_selectable = 1;                          if (!menu_selectable)
343                            {
344                                    p_menu->item_cur_pos = i;
345                                    menu_selectable = 1;
346                            }
347    
                         if (p_menu->items[i]->row != 0)  
                                 row = p_menu->items[i]->row;  
                         else  
                                 row++;  
348                          p_menu->items[i]->r_row = row;                          p_menu->items[i]->r_row = row;
                         if (p_menu->items[i]->col != 0)  
                                 col = p_menu->items[i]->col;  
349                          p_menu->items[i]->r_col = col;                          p_menu->items[i]->r_col = col;
350    
351                          moveto(row, col);                          moveto(row, col);
352                          prints(p_menu->items[i]->text);                          prints("%s", p_menu->items[i]->text);
353                          iflush();  
354                            row++;
355                  }                  }
356          }          }
357    
358          if (!menu_selectable)          if (!menu_selectable)
359            {
360                  return -1;                  return -1;
361            }
362    
363          display_menu_cursor(p_menu, 1);          display_menu_cursor(p_menu, 1);
364    
# Line 359  int menu_control(MENU_SET *p_menu_set, i Line 380  int menu_control(MENU_SET *p_menu_set, i
380          MENU *p_menu;          MENU *p_menu;
381    
382          if (p_menu_set->menu_count == 0)          if (p_menu_set->menu_count == 0)
383            {
384                  return 0;                  return 0;
385            }
386    
387          p_menu = p_menu_set->p_menu_select[p_menu_set->menu_select_depth];          p_menu = p_menu_set->p_menu_select[p_menu_set->menu_select_depth];
388    
# Line 371  int menu_control(MENU_SET *p_menu_set, i Line 394  int menu_control(MENU_SET *p_menu_set, i
394                  if (p_menu->items[p_menu->item_cur_pos]->submenu)                  if (p_menu->items[p_menu->item_cur_pos]->submenu)
395                  {                  {
396                          if (strcmp(p_menu->items[p_menu->item_cur_pos]->action, "..") == 0)                          if (strcmp(p_menu->items[p_menu->item_cur_pos]->action, "..") == 0)
397                            {
398                                  return menu_control(p_menu_set, KEY_LEFT);                                  return menu_control(p_menu_set, KEY_LEFT);
399                            }
400                          p_menu_set->menu_select_depth++;                          p_menu_set->menu_select_depth++;
401                          p_menu =                          p_menu = get_menu(p_menu_set, p_menu->items[p_menu->item_cur_pos]->action);
402                                  p_menu_set->p_menu_select[p_menu_set->menu_select_depth] =                          p_menu_set->p_menu_select[p_menu_set->menu_select_depth] = p_menu;
403                                          get_menu(p_menu_set,  
                                                          p_menu->items[p_menu->item_cur_pos]->action);  
404                          if (display_menu(p_menu) != 0)                          if (display_menu(p_menu) != 0)
405                            {
406                                  return menu_control(p_menu_set, KEY_LEFT);                                  return menu_control(p_menu_set, KEY_LEFT);
407                            }
408                          break;                          break;
409                  }                  }
410                  else                  else
# Line 391  int menu_control(MENU_SET *p_menu_set, i Line 417  int menu_control(MENU_SET *p_menu_set, i
417                  {                  {
418                          p_menu_set->menu_select_depth--;                          p_menu_set->menu_select_depth--;
419                          if (display_current_menu(p_menu_set) != 0)                          if (display_current_menu(p_menu_set) != 0)
420                            {
421                                  return menu_control(p_menu_set, KEY_LEFT);                                  return menu_control(p_menu_set, KEY_LEFT);
422                            }
423                          break;                          break;
424                  }                  }
425                  else                  else
426                  {                  {
427                          display_menu_cursor(p_menu, 0);                          display_menu_cursor(p_menu, 0);
428                          p_menu->item_cur_pos = p_menu->item_count - 1;                          p_menu->item_cur_pos = p_menu->item_count - 1;
429                          while (!p_menu->items[p_menu->item_cur_pos]->display || p_menu->items[p_menu->item_cur_pos]->priv != 0 || p_menu->items[p_menu->item_cur_pos]->level != 0)                          while (!p_menu->items[p_menu->item_cur_pos]->display ||
430                                       p_menu->items[p_menu->item_cur_pos]->priv != 0 ||
431                                       p_menu->items[p_menu->item_cur_pos]->level != 0)
432                            {
433                                  p_menu->item_cur_pos--;                                  p_menu->item_cur_pos--;
434                            }
435                          display_menu_cursor(p_menu, 1);                          display_menu_cursor(p_menu, 1);
436                          break;                          break;
437                  }                  }
# Line 409  int menu_control(MENU_SET *p_menu_set, i Line 441  int menu_control(MENU_SET *p_menu_set, i
441                  {                  {
442                          p_menu->item_cur_pos--;                          p_menu->item_cur_pos--;
443                          if (p_menu->item_cur_pos < 0)                          if (p_menu->item_cur_pos < 0)
444                            {
445                                  p_menu->item_cur_pos = p_menu->item_count - 1;                                  p_menu->item_cur_pos = p_menu->item_count - 1;
446                            }
447                  } while (!p_menu->items[p_menu->item_cur_pos]->display);                  } while (!p_menu->items[p_menu->item_cur_pos]->display);
448                  display_menu_cursor(p_menu, 1);                  display_menu_cursor(p_menu, 1);
449                  break;                  break;
# Line 419  int menu_control(MENU_SET *p_menu_set, i Line 453  int menu_control(MENU_SET *p_menu_set, i
453                  {                  {
454                          p_menu->item_cur_pos++;                          p_menu->item_cur_pos++;
455                          if (p_menu->item_cur_pos >= p_menu->item_count)                          if (p_menu->item_cur_pos >= p_menu->item_count)
456                            {
457                                  p_menu->item_cur_pos = 0;                                  p_menu->item_cur_pos = 0;
458                            }
459                  } while (!p_menu->items[p_menu->item_cur_pos]->display);                  } while (!p_menu->items[p_menu->item_cur_pos]->display);
460                  display_menu_cursor(p_menu, 1);                  display_menu_cursor(p_menu, 1);
461                  break;                  break;
# Line 457  int menu_control(MENU_SET *p_menu_set, i Line 493  int menu_control(MENU_SET *p_menu_set, i
493  void unload_menu(MENU_SET *p_menu_set)  void unload_menu(MENU_SET *p_menu_set)
494  {  {
495          MENU *p_menu;          MENU *p_menu;
         MENU_ITEM *p_menuitem;  
496          int i, j;          int i, j;
497    
498          for (i = 0; i < p_menu_set->menu_count; i++)          for (i = 0; i < p_menu_set->menu_count; i++)
# Line 480  int reload_menu(MENU_SET *p_menu_set) Line 515  int reload_menu(MENU_SET *p_menu_set)
515          int result;          int result;
516          char conf_file[FILE_PATH_LEN];          char conf_file[FILE_PATH_LEN];
517    
518          strncpy(conf_file, p_menu_set->conf_file, sizeof(conf_file));          strncpy(conf_file, p_menu_set->conf_file, sizeof(conf_file) - 1);
519            conf_file[sizeof(conf_file) - 1] = '\0';
520    
521          unload_menu(p_menu_set);          unload_menu(p_menu_set);
522          result = load_menu(p_menu_set, conf_file);          result = load_menu(p_menu_set, conf_file);
523    


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1