setterm and changing compare_string_array question
Alastor Santamaria
alastors at gmail.com
Fri Sep 1 11:51:50 UTC 2006
Hi
well, setterm.c
about a function in libbb:
may I change compare_string_array to return 0 for not found,
and start counting from 1?
keep on reading, before hiring a hitman. ;)
this is before using compare_string_array,
in setterm.c:
option = which_option(opt_act, options_list);
if (!option) <-- for me, this shouts "testing for error"
bb_show_usage();
this is now using it:
option = compare_string_array(options_list, opt_act);
if (option < 0) <-- not so much
bb_show_usage();
and some applets could benefit two.
-----------
fsck.c
// if(compare_string_array(ignored_types, fs->type))
// wanted = compare_string_array(really_wanted, fs->type);
/* Are we ignoring this type? */
if(compare_string_array(ignored_types, fs->type) >= 0)
return 1;
/* Do we really really want to check this fs? */
wanted = compare_string_array(really_wanted, fs->type) >= 0;
***
if (wanted)
bb_error_msg
--------------
devfsd.c
//changing a couple of numbers and we are done, no trouble right?
// all "default:" can be "0:" or stay like they are.
i = compare_string_array(options, when );
/*"CLEAR_CONFIG"*/
if( i == 0){
do_stuff
return;
}
***
/* "INCLUDE" & "OPTIONAL_INCLUDE" */
if( i == 1 || i == 2 ){
do_stuff
return;
}
/* "RESTORE" */
if( i == 3)
{
do_stuff
return;
}
***
i = compare_string_array(options, what );
switch(i){
case 4: /* "PERMISSIONS" */
do_stuff
break;
***
case 12: /* RMNEWCOMPAT */
do_stuff
break;
default:
msg ="WHAT in";
goto process_config_line_err;
/*esac*/
} /* switch (i) */
***
i=compare_string_array(field_names, variable);
if ( i > 6 || i < 0 || (i > 1 && gv_info == NULL))
return (NULL);
if( i >= 0 && i <= 3){
do_stuff
return(field_names[i+7]);
}
if(i == 4 )
sprintf
else if(i == 5)
sprintf
else if(i == 6)
sprintf
--------------
dpkg.c
//idem
field_num = compare_string_array(field_names, field_name);
switch(field_num) {
case 0: /* Package */
***
--------------
ipaddress.c
//idem
const int option_num = compare_string_array(option, *argv);
switch (option_num) {
case 0: /* to */
***
default:
***
***
const int option_num = compare_string_array(option, *argv);
switch (option_num) {
case 0: /* peer */
***
default:
***
***
if (*argv) {
command_num = compare_string_array(commands, *argv);
}
switch (command_num) {
case 0: /* add */
***
--------------
iproute.c
//idem
switch (compare_string_array(options, *argv)) {
case 0: /* from */
***
default:
***
***
if (*argv) {
command_num = compare_string_array(ip_route_commands, *argv);
}
switch(command_num) {
case 0: /* add*/
***
default:
***
--------------
well, what do you think?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/busybox/attachments/20060901/129673d2/attachment-0001.htm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: setterm.c
Type: text/x-csrc
Size: 2760 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20060901/129673d2/attachment-0002.c
More information about the busybox
mailing list