Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/multiboot/multiboot.c

    r9d58539 rc8cbd39  
    7171}
    7272
     73/** Extract arguments from the multiboot module command line.
     74 *
     75 * @param buf      Destination buffer (will be always NULL-terminated).
     76 * @param size     Size of destination buffer (in bytes).
     77 * @param cmd_line Input string (the command line).
     78 *
     79 */
     80void multiboot_extract_argument(char *buf, size_t size, const char *cmd_line)
     81{
     82        /* Start after first space. */
     83        const char *start = str_chr(cmd_line, ' ');
     84        if (start == NULL) {
     85                str_cpy(buf, size, "");
     86                return;
     87        }
     88
     89        const char *end = cmd_line + str_size(cmd_line);
     90
     91        /* Skip the space(s). */
     92        while (start != end) {
     93                if (start[0] == ' ')
     94                        start++;
     95                else
     96                        break;
     97        }
     98
     99        str_ncpy(buf, size, start, (size_t) (end - start));
     100}
     101
    73102static void multiboot_modules(uint32_t count, multiboot_module_t *mods)
    74103{
     
    84113                        multiboot_extract_command(init.tasks[init.cnt].name,
    85114                            CONFIG_TASK_NAME_BUFLEN, MULTIBOOT_PTR(mods[i].string));
    86                 } else
     115                        multiboot_extract_argument(init.tasks[init.cnt].arguments,
     116                            CONFIG_TASK_ARGUMENTS_BUFLEN, MULTIBOOT_PTR(mods[i].string));
     117                } else {
    87118                        init.tasks[init.cnt].name[0] = 0;
     119                        init.tasks[init.cnt].arguments[0] = 0;
     120                }
    88121               
    89122                init.cnt++;
Note: See TracChangeset for help on using the changeset viewer.