cmd_cable: restore cable-specific help output

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1944 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Mike Frysinger 14 years ago
parent 223fdef548
commit 35a70b6804

@ -2,6 +2,13 @@
* cmd/cmd_initbus.c (cmd_initbus_complete): Complete bus parameters too.
* include/urjtag/cable.h, src/tap/cable.c (urj_tap_cable_find): Add new
helper for looking up cable drivers by name.
* src/cmd/cmd_cable.c (cmd_cable_run): Use new helper to restore cable
specific help output.
* src/tap/chain.c (urj_tap_chain_connect): Replace look up code with new
urj_tap_cable_find helper.
2011-06-30 Jie Zhang <jie.zhang@analog.com>
* src/cmd/Makefile.am (generated_cmd_list.h): Depend on

@ -178,6 +178,8 @@ struct URJ_CABLE
void urj_tap_cable_free (urj_cable_t *cable);
/** @return URJ_STATUS_OK on success; URJ_STATUS_FAIL on failure */
int urj_tap_cable_init (urj_cable_t *cable);
/** @return cable named by @cname; NULL on failure */
const urj_cable_driver_t *urj_tap_cable_find (const char *cname);
void urj_tap_cable_done (urj_cable_t *cable);
void urj_tap_cable_flush (urj_cable_t *cable,
urj_cable_flush_amount_t);

@ -95,6 +95,22 @@ cmd_cable_run (urj_chain_t *chain, char *params[])
}
}
if (paramc >= 3 && strcasecmp (params[2], "help") == 0)
{
const urj_cable_driver_t *driver;
driver = urj_tap_cable_find (params[1]);
if (!driver)
{
urj_error_set (URJ_ERROR_INVALID,
"unknown cable driver '%s'", params[1]);
return URJ_STATUS_FAIL;
}
driver->help (URJ_LOG_LEVEL_NORMAL, driver->name);
return URJ_STATUS_OK;
}
return urj_tap_chain_connect (chain, params[1], &params[2]);
}

@ -51,6 +51,18 @@ const urj_cable_driver_t * const urj_tap_cable_drivers[] = {
NULL /* last must be NULL */
};
const urj_cable_driver_t *
urj_tap_cable_find (const char *cname)
{
size_t i;
for (i = 0; urj_tap_cable_drivers[i]; ++i)
if (strcasecmp (cname, urj_tap_cable_drivers[i]->name) == 0)
break;
return urj_tap_cable_drivers[i];
}
void
urj_tap_cable_free (urj_cable_t *cable)
{

@ -75,7 +75,7 @@ int
urj_tap_chain_connect (urj_chain_t *chain, const char *drivername, char *params[])
{
urj_cable_t *cable;
int i, j, paramc;
int j, paramc;
const urj_param_t **cable_params;
const urj_cable_driver_t *driver;
@ -86,12 +86,7 @@ urj_tap_chain_connect (urj_chain_t *chain, const char *drivername, char *params[
param_start = 0;
paramc = urj_cmd_params (params);
/* search cable driver list */
for (i = 0; urj_tap_cable_drivers[i]; i++)
if (strcasecmp (drivername, urj_tap_cable_drivers[i]->name) == 0)
break;
driver = urj_tap_cable_drivers[i];
driver = urj_tap_cable_find (drivername);
if (!driver)
{
urj_error_set (URJ_ERROR_INVALID,

Loading…
Cancel
Save