/[hurd]/hurd/boot/boot_script.c
ViewVC logotype

Diff of /hurd/boot/boot_script.c

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

revision 1.13 by roland, Fri Aug 17 10:28:22 2001 UTC revision 1.14 by roland, Wed May 29 02:42:34 2002 UTC
# Line 19  struct sym Line 19  struct sym
19    int type;    int type;
20    
21    /* Symbol value.  */    /* Symbol value.  */
22    int val;    integer_t val;
23    
24    /* For function symbols; type of value returned by function.  */    /* For function symbols; type of value returned by function.  */
25    int ret_type;    int ret_type;
# Line 46  struct arg Line 46  struct arg
46    int type;    int type;
47    
48    /* Argument value.  */    /* Argument value.  */
49    int val;    integer_t val;
50  };  };
51    
52  /* List of commands.  */  /* List of commands.  */
# Line 93  prompt_resume_task (struct cmd *cmd, int Line 93  prompt_resume_task (struct cmd *cmd, int
93  /* List of builtin symbols.  */  /* List of builtin symbols.  */
94  static struct sym builtin_symbols[] =  static struct sym builtin_symbols[] =
95  {  {
96    { "task-create", VAL_FUNC, (int) create_task, VAL_TASK, 0 },    { "task-create", VAL_FUNC, (integer_t) create_task, VAL_TASK, 0 },
97    { "task-resume", VAL_FUNC, (int) resume_task, VAL_NONE, 1 },    { "task-resume", VAL_FUNC, (integer_t) resume_task, VAL_NONE, 1 },
98    { "prompt-task-resume", VAL_FUNC, (int) prompt_resume_task, VAL_NONE, 1 },    { "prompt-task-resume",
99        VAL_FUNC, (integer_t) prompt_resume_task, VAL_NONE, 1 },
100  };  };
101  #define NUM_BUILTIN (sizeof (builtin_symbols) / sizeof (builtin_symbols[0]))  #define NUM_BUILTIN (sizeof (builtin_symbols) / sizeof (builtin_symbols[0]))
102    
# Line 296  boot_script_parse_line (void *hook, char Line 297  boot_script_parse_line (void *hook, char
297            for (p += 2;;)            for (p += 2;;)
298              {              {
299                char c;                char c;
300                int i, val, type;                int i, type;
301                  integer_t val;
302                struct sym *s;                struct sym *s;
303    
304                /* Parse symbol name.  */                /* Parse symbol name.  */
# Line 351  boot_script_parse_line (void *hook, char Line 353  boot_script_parse_line (void *hook, char
353                    if (! s->run_on_exec)                    if (! s->run_on_exec)
354                      {                      {
355                        (error                        (error
356                         = ((*((int (*) (struct cmd *, int *)) s->val))                         = ((*((int (*) (struct cmd *, integer_t *)) s->val))
357                            (cmd, &val)));                            (cmd, &val)));
358                        if (error)                        if (error)
359                          goto bad;                          goto bad;
# Line 373  boot_script_parse_line (void *hook, char Line 375  boot_script_parse_line (void *hook, char
375                else if (s->type == VAL_NONE)                else if (s->type == VAL_NONE)
376                  {                  {
377                    type = VAL_SYM;                    type = VAL_SYM;
378                    val = (int) s;                    val = (integer_t) s;
379                  }                  }
380                else                else
381                  {                  {
# Line 643  boot_script_exec () Line 645  boot_script_exec ()
645        for (i = 0; i < cmd->exec_funcs_index; i++)        for (i = 0; i < cmd->exec_funcs_index; i++)
646          {          {
647            struct sym *sym = cmd->exec_funcs[i];            struct sym *sym = cmd->exec_funcs[i];
648            int error = ((*((int (*) (struct cmd *, int *)) sym->val))            int error = ((*((int (*) (struct cmd *, integer_t *)) sym->val))
649                         (cmd, 0));                         (cmd, 0));
650            if (error)            if (error)
651              {              {
# Line 660  boot_script_exec () Line 662  boot_script_exec ()
662  /* Create an entry for the variable NAME with TYPE and value VAL,  /* Create an entry for the variable NAME with TYPE and value VAL,
663     in the symbol table.  */     in the symbol table.  */
664  int  int
665  boot_script_set_variable (const char *name, int type, int val)  boot_script_set_variable (const char *name, int type, integer_t val)
666  {  {
667    struct sym *sym = sym_enter (name);    struct sym *sym = sym_enter (name);
668    
# Line 676  boot_script_set_variable (const char *na Line 678  boot_script_set_variable (const char *na
678  /* Define the function NAME, which will return type RET_TYPE.  */  /* Define the function NAME, which will return type RET_TYPE.  */
679  int  int
680  boot_script_define_function (const char *name, int ret_type,  boot_script_define_function (const char *name, int ret_type,
681                               int (*func) (const struct cmd *cmd, int *val))                               int (*func) (const struct cmd *cmd,
682                                              integer_t *val))
683  {  {
684    struct sym *sym = sym_enter (name);    struct sym *sym = sym_enter (name);
685    
686    if (sym)    if (sym)
687      {      {
688        sym->type = VAL_FUNC;        sym->type = VAL_FUNC;
689        sym->val = (int) func;        sym->val = (integer_t) func;
690        sym->ret_type = ret_type;        sym->ret_type = ret_type;
691        sym->run_on_exec = ret_type == VAL_NONE;        sym->run_on_exec = ret_type == VAL_NONE;
692      }      }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26