304 |
PACKAGE_VERSION); |
PACKAGE_VERSION); |
305 |
} |
} |
306 |
|
|
307 |
|
/* Read the file command.lst for auto-loading. */ |
308 |
|
static void |
309 |
|
read_command_list (void) |
310 |
|
{ |
311 |
|
const char *prefix; |
312 |
|
|
313 |
|
prefix = grub_env_get ("prefix"); |
314 |
|
if (prefix) |
315 |
|
{ |
316 |
|
char *filename; |
317 |
|
|
318 |
|
filename = grub_malloc (grub_strlen (prefix) + sizeof ("/command.lst")); |
319 |
|
if (filename) |
320 |
|
{ |
321 |
|
grub_file_t file; |
322 |
|
|
323 |
|
grub_sprintf (filename, "%s/command.lst", prefix); |
324 |
|
file = grub_file_open (filename); |
325 |
|
if (file) |
326 |
|
{ |
327 |
|
char buf[80]; /* XXX arbitrary */ |
328 |
|
|
329 |
|
while (get_line (file, buf, sizeof (buf))) |
330 |
|
{ |
331 |
|
char *p; |
332 |
|
grub_command_t cmd; |
333 |
|
|
334 |
|
if (! grub_isgraph (buf[0])) |
335 |
|
continue; |
336 |
|
|
337 |
|
p = grub_strchr (buf, ':'); |
338 |
|
if (! p) |
339 |
|
continue; |
340 |
|
|
341 |
|
*p = '\0'; |
342 |
|
while (*++p == ' ') |
343 |
|
; |
344 |
|
|
345 |
|
if (! grub_isgraph (*p)) |
346 |
|
continue; |
347 |
|
|
348 |
|
cmd = grub_register_command (buf, 0, |
349 |
|
GRUB_COMMAND_FLAG_NOT_LOADED, |
350 |
|
0, 0, 0); |
351 |
|
if (! cmd) |
352 |
|
continue; |
353 |
|
|
354 |
|
cmd->module_name = grub_strdup (p); |
355 |
|
if (! cmd->module_name) |
356 |
|
grub_unregister_command (buf); |
357 |
|
} |
358 |
|
|
359 |
|
grub_file_close (file); |
360 |
|
} |
361 |
|
|
362 |
|
grub_free (filename); |
363 |
|
} |
364 |
|
} |
365 |
|
|
366 |
|
/* Ignore errors. */ |
367 |
|
grub_errno = GRUB_ERR_NONE; |
368 |
|
} |
369 |
|
|
370 |
/* Read the config file CONFIG and execute the menu interface or |
/* Read the config file CONFIG and execute the menu interface or |
371 |
the command-line interface. */ |
the command-line interface. */ |
372 |
void |
void |
382 |
grub_errno = GRUB_ERR_NONE; |
grub_errno = GRUB_ERR_NONE; |
383 |
} |
} |
384 |
|
|
385 |
|
read_command_list (); |
386 |
|
|
387 |
if (menu) |
if (menu) |
388 |
{ |
{ |
389 |
grub_menu_run (menu, nested); |
grub_menu_run (menu, nested); |