mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2025-04-21 12:27:27 +03:00
tools: atrf-id option -s to retrieve driver spec, with necessary infrastructure
- include/atrf.h (atrf_driver_spec), lib/atrf.c (atrf_driver_spec): new function to retrieve the local or remote/final driver spec - lib/atrf.c (struct atrf_dsc, atrf_open, atrf_close): record the local driver spec - lib/driver.h (struct atrf_driver): new driver function "driver_spec" to retrieve the driver spec - lib/atnet.c (struct atnet_dsc, atnet_open, atnet_close): maintain a cache for the driver spec - lib/atnet.c (atnet_driver_spec, atnet_driver): added support for the "driver_spec" function - atrf-proxy/PROTOCOL, atrf-proxy/atrf-proxy.c (cmd_zero): added command SPEC to retrieve the (final) driver spec - atrf-id/atrf-id.c (usage, main): added option -s to retrieve the driver spec. One -s retrieves the local spec, -s -s the remote/final.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
struct atnet_dsc {
|
||||
struct netio *netio;
|
||||
int error;
|
||||
char *spec;
|
||||
char reply[1000];
|
||||
};
|
||||
|
||||
@@ -192,6 +193,7 @@ static void *atnet_open(const char *arg)
|
||||
}
|
||||
|
||||
dsc->error = 0;
|
||||
dsc->spec = NULL;
|
||||
*dsc->reply = 0;
|
||||
|
||||
return dsc;
|
||||
@@ -203,6 +205,28 @@ static void atnet_close(void *handle)
|
||||
struct atnet_dsc *dsc = handle;
|
||||
|
||||
netio_close(dsc->netio);
|
||||
free(dsc->spec);
|
||||
}
|
||||
|
||||
|
||||
/* ----- driver specification ---------------------------------------------- */
|
||||
|
||||
|
||||
static const char *atnet_driver_spec(void *handle)
|
||||
{
|
||||
struct atnet_dsc *dsc = handle;
|
||||
|
||||
if (dialog(dsc, "SPEC") < 0) {
|
||||
dsc->error = 1;
|
||||
return NULL;
|
||||
}
|
||||
free(dsc->spec);
|
||||
dsc->spec = strdup(dsc->reply+1);
|
||||
if (!dsc->spec) {
|
||||
perror("strdup");
|
||||
exit(1);
|
||||
}
|
||||
return dsc->spec;
|
||||
}
|
||||
|
||||
|
||||
@@ -421,6 +445,7 @@ struct atrf_driver atnet_driver = {
|
||||
.name = "net",
|
||||
.open = atnet_open,
|
||||
.close = atnet_close,
|
||||
.driver_spec = atnet_driver_spec,
|
||||
.error = atnet_error,
|
||||
.clear_error = atnet_clear_error,
|
||||
.reset = atnet_reset,
|
||||
|
||||
Reference in New Issue
Block a user