version 1.10, 2004/08/08 00:23:15 |
version 1.11, 2005/07/28 17:15:11 |
|
|
|
|
void print_value(int); |
void print_value(int); |
void change_value(const struct opt_t); |
void change_value(const struct opt_t); |
void update_value(int, u_long *, u_long); |
void update_value(int, int *, int); |
|
|
void warn_unsupported(int); |
void warn_unsupported(int); |
void usage(void); |
void usage(void); |
|
|
void show_verbose(const char *, int); |
void show_verbose(const char *, int); |
void show_int_val(u_long, const char *, char *, int); |
void show_int_val(int, const char *, char *, int); |
void show_float_val(float, const char *, char *, int); |
void show_float_val(float, const char *, char *, int); |
void show_char_val(const char *, const char *, int); |
void show_char_val(const char *, const char *, int); |
int str_to_opt(const char *); |
int str_to_opt(const char *); |
u_long str_to_long(char *, int); |
u_int str_to_int(char *, int); |
|
|
/* |
/* |
* Control behavior of a FM tuner - set frequency, volume etc |
* Control behavior of a FM tuner - set frequency, volume etc |
|
|
|
|
switch (o.option) { |
switch (o.option) { |
case OPTION_VOLUME: |
case OPTION_VOLUME: |
update_value(o.sign, (u_long *)&ri.volume, o.value); |
update_value(o.sign, &ri.volume, o.value); |
break; |
break; |
case OPTION_FREQUENCY: |
case OPTION_FREQUENCY: |
update_value(o.sign, (u_long *)&ri.freq, o.value); |
update_value(o.sign, &ri.freq, o.value); |
break; |
break; |
case OPTION_REFERENCE: |
case OPTION_REFERENCE: |
if (ri.caps & RADIO_CAPS_REFERENCE_FREQ) |
if (ri.caps & RADIO_CAPS_REFERENCE_FREQ) |
update_value(o.sign, (u_long *)&ri.rfreq, o.value); |
update_value(o.sign, &ri.rfreq, o.value); |
else |
else |
unsupported++; |
unsupported++; |
break; |
break; |
|
|
break; |
break; |
case OPTION_SENSITIVITY: |
case OPTION_SENSITIVITY: |
if (ri.caps & RADIO_CAPS_LOCK_SENSITIVITY) |
if (ri.caps & RADIO_CAPS_LOCK_SENSITIVITY) |
update_value(o.sign, (u_long *)&ri.lock, o.value); |
update_value(o.sign, &ri.lock, o.value); |
else |
else |
unsupported++; |
unsupported++; |
break; |
break; |
|
|
} |
} |
|
|
void |
void |
update_value(int sign, u_long *value, u_long update) |
update_value(int sign, int *value, int update) |
{ |
{ |
switch (sign) { |
switch (sign) { |
case SIGN_NONE: |
case SIGN_NONE: |
|
|
/* |
/* |
* Convert string to unsigned integer |
* Convert string to unsigned integer |
*/ |
*/ |
u_long |
u_int |
str_to_long(char *str, int optval) |
str_to_int(char *str, int optval) |
{ |
{ |
u_long val; |
int val; |
|
|
if (str == NULL || *str == '\0') |
if (str == NULL || *str == '\0') |
return VALUE_NONE; |
return VALUE_NONE; |
|
|
if (optval == OPTION_FREQUENCY) |
if (optval == OPTION_FREQUENCY) |
val = (u_long)1000 * atof(str); |
val = (int)(1000 * atof(str)); |
else |
else |
val = (u_long)strtol(str, (char **)NULL, 10); |
val = (int)strtol(str, (char **)NULL, 10); |
|
|
return val; |
return val; |
} |
} |
|
|
case '+': |
case '+': |
case '-': |
case '-': |
o->sign = (*topt == '+') ? SIGN_PLUS : SIGN_MINUS; |
o->sign = (*topt == '+') ? SIGN_PLUS : SIGN_MINUS; |
o->value = str_to_long(&topt[1], o->option); |
o->value = str_to_int(&topt[1], o->option); |
break; |
break; |
case 'o': |
case 'o': |
if (strncmp(topt, offchar, |
if (strncmp(topt, offchar, |
|
|
break; |
break; |
default: |
default: |
if (*topt > 47 && *topt < 58) |
if (*topt > 47 && *topt < 58) |
o->value = str_to_long(topt, o->option); |
o->value = str_to_int(topt, o->option); |
break; |
break; |
} |
} |
|
|
|
|
} |
} |
|
|
void |
void |
show_int_val(u_long val, const char *nick, char *append, int silent) |
show_int_val(int val, const char *nick, char *append, int silent) |
{ |
{ |
show_verbose(nick, silent); |
show_verbose(nick, silent); |
printf("%lu%s\n", val, append); |
printf("%u%s\n", val, append); |
} |
} |
|
|
void |
void |