From 56f5f7750e72498ef677659a722ef2036f9b85de Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Mon, 26 Aug 2002 19:53:37 +0000 Subject: [PATCH] Added register_match(). git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@110 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- include/jtag/register.h | 3 ++- jtag/src/tap/register.c | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/jtag/register.h b/include/jtag/register.h index 96055266..13f2a743 100644 --- a/include/jtag/register.h +++ b/include/jtag/register.h @@ -32,11 +32,12 @@ typedef struct tap_register { } tap_register; tap_register *register_alloc( int len ); -tap_register *register_duplicate( tap_register *tr ); +tap_register *register_duplicate( const tap_register *tr ); void register_free( tap_register *tr ); tap_register *register_fill( tap_register *tr, int val ); const char *register_get_string( tap_register *tr ); tap_register *register_init( tap_register *tr, const char *value ); int register_compare( const tap_register *tr, const tap_register *tr2 ); +int register_match( const tap_register *tr, const char *expr ); #endif /* JTAG_REGISTER_H */ diff --git a/jtag/src/tap/register.c b/jtag/src/tap/register.c index 1abb84f9..3896a0fe 100644 --- a/jtag/src/tap/register.c +++ b/jtag/src/tap/register.c @@ -59,7 +59,7 @@ register_alloc( int len ) } tap_register * -register_duplicate( tap_register *tr ) +register_duplicate( const tap_register *tr ) { if (!tr) return NULL; @@ -144,3 +144,21 @@ register_compare( const tap_register *tr, const tap_register *tr2 ) return 0; } + +int +register_match( const tap_register *tr, const char *expr ) +{ + int i; + char *s; + + if (!tr || !expr || (tr->len != strlen( expr ))) + return 0; + + s = register_get_string( tr ); + + for (i = 0; i < tr->len; i++) + if ((expr[i] != '?') && (expr[i] != s[i])) + return 0; + + return 1; +}