Ответ: Ответ: LIBBB: config_*()

Bernhard Fischer rep.dot.nop at gmail.com
Fri Jul 18 07:20:45 UTC 2008


On Thu, Jul 17, 2008 at 07:35:35PM +0200, Denys Vlasenko wrote:
>On Thursday 17 July 2008 16:24, Bernhard Fischer wrote:

>> Anyway. I've touched the parser now and converted init to use it (see
>> r22865 and before). Of course i did _not_ test it, so if init somehow
>> fails to chdir to your slash and prints a message telling you that
>> it does a countdown for self-destruction then that's somehow expected ;)
>
>        /* optional_tty:ignored_runlevel:action:command
>         * i.e. 4 tokens, minimum number of tokens is 2 ("::sysinit:echo foo")
>         * We require tokens not to be collapsed -- need exactly 4 tokens.
>         */
>        while (config_read(parser, token, -4, 2, ":", '#') >= 0) {
>
>If you need exactly four tokens, use -4, 4, not -4, 2.

consider:
::sysinit:echo "it:works"

I need a minimum of 2 tokens (0,0,"sysinit","echo \"it:works\"")
and a maximum of 4 tokens.
The order has to be preserved, before i changed that noreduce to take
seen into account, we ended up with
"sysinit","echo \"it:works\",0,0
for the case above. Perhaps i misunderstood how config_parse should
work?

Vladimir, please suggest some detailed description of config_parse
that also covers how the tokens are ment to look like. I'd like to add
that as documentation into parse_config.c -- TIA
>
>                int action = -1;
>                char *tty = token[0];
>                char *action_string = token[2];
>                char *command = token[3];
>
>                if (action_string)
>                        action = index_in_strings(actions, action_string);
>
>and then you won't need to check for NULL like you do it here.
>
>                if (action < 0 || !command || !strlen(command))
>                        goto bad_entry;
>                if (tty) {
>                        /* turn .*TTY -> /dev/TTY */
>                        if (!strncmp(tty, "/dev/", 5))
>                                tty += 5;
>                        tty = concat_path_file("/dev/", tty);
>                } else
>                        tty = ""; /* XXX: ugh. */
>
>char* = const char* doesnt compile for me.
>
>
>
>I will work on this

I pondered to change new_init_action to use varargs for the optional
tty, yes. I'll try if that's worthwile, size-wise (i saw you fixed the
gross "" hack already).

>> >> Making it all cute in one go seems to be difficult, so I propose
>> >> the following plan:
>> >>
>> >> - convert more applets to it
>> 
>> Let's build a list (perhaps in TODO) so we can check if all potential
>> users are cought.
>> 
>> + ifupdown
>> - init
>> + dumpleases ? Does that make sense?
>> + inetd
>> + bb__pgsreader()



More information about the busybox mailing list