diff --git a/ChangeLog b/ChangeLog index 80b8ae35e..6a461305e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2003-02-08 NIIBE Yutaka + + * util/resolve.c (pupa_util_resolve_dependencies): BUG + FIX. Reverse the path_list. + + * include/pupa/normal.h: Export pupa_register_command and + pupa_unregister_command. + + * hello/hello.c (pupa_cmd_hello): New module. + * conf/i386-pc.rmk: Added hello.mod. + 2003-01-31 Yoshinori K. Okuji * kern/i386/pc/lzo1x.S: New file. diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index f8123ae46..1d49d686e 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -61,7 +61,7 @@ pupa_setup_SOURCES = util/i386/pc/pupa-setup.c util/i386/pc/biosdisk.c \ genmoddep_SOURCES = util/genmoddep.c # Modules. -pkgdata_MODULES = _chain.mod _linux.mod fat.mod normal.mod +pkgdata_MODULES = _chain.mod _linux.mod fat.mod normal.mod hello.mod # For _chain.mod. _chain_mod_SOURCES = loader/i386/pc/chainloader.c @@ -80,3 +80,7 @@ normal_mod_SOURCES = normal/cmdline.c normal/command.c normal/main.c \ normal/menu.c normal/i386/setjmp.S normal_mod_CFLAGS = $(COMMON_CFLAGS) normal_mod_ASFLAGS = $(COMMON_ASFLAGS) + +# For hello.mod. +hello_mod_SOURCES = hello/hello.c +hello_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/hello/hello.c b/hello/hello.c new file mode 100644 index 000000000..cfc0e63c7 --- /dev/null +++ b/hello/hello.c @@ -0,0 +1,46 @@ +/* hello.c - test module for dynamic loading */ +/* + * PUPA -- Preliminary Universal Programming Architecture for GRUB + * Copyright (C) 2003 NIIBE Yutaka + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include + +static int +pupa_cmd_hello (int argc, char *argv[]) +{ + (void)argc; (void)argv; /* To stop warning. */ + pupa_printf ("Hello World\n"); + return 0; +} + +PUPA_MOD_INIT +{ + (void)mod; /* To stop warning. */ + pupa_register_command ("hello", pupa_cmd_hello, PUPA_COMMAND_FLAG_BOTH, + "hello", "Say hello"); +} + +PUPA_MOD_FINI +{ + pupa_unregister_command ("hello"); +} diff --git a/include/grub/normal.h b/include/grub/normal.h index eac490460..1335859d5 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -22,6 +22,7 @@ #define PUPA_NORMAL_HEADER 1 #include +#include /* The maximum size of a command-line. */ #define PUPA_MAX_CMDLINE 1600 @@ -117,12 +118,12 @@ void pupa_menu_run (pupa_menu_t menu, int nested); void pupa_cmdline_run (int nested); int pupa_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, int echo_char, int readline); -void pupa_register_command (const char *name, +void EXPORT_FUNC(pupa_register_command) (const char *name, int (*func) (int argc, char *argv[]), unsigned flags, const char *summary, const char *description); -void pupa_unregister_command (const char *name); +void EXPORT_FUNC(pupa_unregister_command) (const char *name); pupa_command_t pupa_command_find (char *cmdline); int pupa_command_execute (char *cmdline); void pupa_command_init (void); diff --git a/util/resolve.c b/util/resolve.c index 8f985698e..9f9390416 100644 --- a/util/resolve.c +++ b/util/resolve.c @@ -234,7 +234,7 @@ pupa_util_resolve_dependencies (const char *prefix, struct dep_list *dep_list; struct mod_list *mod_list = 0; struct pupa_util_path_list *path_list = 0; - + path = pupa_util_get_path (prefix, dep_list_file); fp = fopen (path, "r"); if (! fp) @@ -253,5 +253,16 @@ pupa_util_resolve_dependencies (const char *prefix, free_dep_list (dep_list); free_mod_list (mod_list); - return path_list; + { /* Reverse the path_list */ + struct pupa_util_path_list *p, *prev, *next; + + for (p = path_list, prev = NULL; p; p = next) + { + next = p->next; + p->next = prev; + prev = p; + } + + return prev; + } }