1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-12-23 17:09:34 +02:00

atrf-gpio.c: rename anything "reg_op" to "command"

- atrf-gpio.c (bad_reg_op, reg_op): renamed "bad_reg_op" to
  "bad_command"
- atrf-gpio.c (bad_command): error message is now "invalid command"
- atrf-gpio.c (reg_op, main): renamed "reg_op" to "command"
This commit is contained in:
Werner Almesberger 2011-06-06 19:38:42 -03:00
parent 7a2e09187f
commit 533dc58824

View File

@ -56,14 +56,14 @@ static void atusb(struct atrf_dsc *dsc, const char *pattern, const char *next)
/* ----- Commands ---------------------------------------------------------- */ /* ----- Commands ---------------------------------------------------------- */
static void bad_reg_op(const char *arg) static void bad_command(const char *arg)
{ {
fprintf(stderr, "invalid operation \"%s\"\n", arg); fprintf(stderr, "invalid command \"%s\"\n", arg);
exit(1); exit(1);
} }
static int reg_op(struct atrf_dsc *dsc, const char *arg, int doit) static int command(struct atrf_dsc *dsc, const char *arg, int doit)
{ {
const char *p; const char *p;
char *end; char *end;
@ -78,7 +78,7 @@ static int reg_op(struct atrf_dsc *dsc, const char *arg, int doit)
if (!strncmp(arg, "delay=", 6)) { if (!strncmp(arg, "delay=", 6)) {
value = strtoul(arg+6, &end, 0); value = strtoul(arg+6, &end, 0);
if (!value || *end) if (!value || *end)
bad_reg_op(arg); bad_command(arg);
if (doit) if (doit)
usleep(value*1000); usleep(value*1000);
return 1; return 1;
@ -110,18 +110,18 @@ static int reg_op(struct atrf_dsc *dsc, const char *arg, int doit)
return 0; return 0;
reg = strtoul(arg, &end, 0); reg = strtoul(arg, &end, 0);
if (end != p || reg > 0xff) if (end != p || reg > 0xff)
bad_reg_op(arg); bad_command(arg);
value = strtoul(p+1, &end, 0); value = strtoul(p+1, &end, 0);
if (value > 0xff) if (value > 0xff)
bad_reg_op(arg); bad_command(arg);
if (*end) { if (*end) {
if (*p != ':') if (*p != ':')
bad_reg_op(arg); bad_command(arg);
if (*end != '/') if (*end != '/')
bad_reg_op(arg); bad_command(arg);
mask = strtoul(end+1, &end, 0); mask = strtoul(end+1, &end, 0);
if (*end || mask > 0xff) if (*end || mask > 0xff)
bad_reg_op(arg); bad_command(arg);
} }
if (!doit) if (!doit)
@ -293,7 +293,7 @@ int main(int argc, char *const *argv)
for (i = optind; i != argc; i++) { for (i = optind; i != argc; i++) {
if (*argv[i] == '#') if (*argv[i] == '#')
continue; continue;
if (reg_op(NULL, argv[i], 0)) if (command(NULL, argv[i], 0))
continue; continue;
for (s = argv[i]; *s; s++) for (s = argv[i]; *s; s++)
if (!strchr("01HLhloZzx.", *s)) if (!strchr("01HLhloZzx.", *s))
@ -322,7 +322,7 @@ int main(int argc, char *const *argv)
for (i = optind; i != argc; i++) { for (i = optind; i != argc; i++) {
if (*argv[i] == '#') if (*argv[i] == '#')
continue; continue;
if (reg_op(dsc, argv[i], 1)) if (command(dsc, argv[i], 1))
continue; continue;
if (atrf_usb_handle(dsc)) if (atrf_usb_handle(dsc))
atusb(dsc, argv[i], argv[i+1]); atusb(dsc, argv[i], argv[i+1]);