From eccd94849869fca8752fdaf685825ad89e4e06bc Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Mon, 8 Nov 2010 01:02:37 -0800 Subject: [PATCH] Fixed issue where the LRC of a card was the reverse of the start --- mslib.c | 14 ++++++-------- mslib.h | 2 ++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mslib.c b/mslib.c index c45f9f5..41bc62b 100644 --- a/mslib.c +++ b/mslib.c @@ -275,7 +275,7 @@ void ms_decode_peaks( msData *ms ) { } /* String Reverse Function */ -void strrev( char *str ) { +void ms_strrev( char *str ) { int f, l; char tmp; @@ -291,28 +291,26 @@ int ms_decode_typeDetect( msData *ms ) { char *bitStream; int loop = 2; - if( !ms || !ms->bitStream ) + if( !ms || !ms->bitStream || strlen( ms->bitStream ) < 10 ) return 1; - do { - bitStream = strchr( ms->bitStream, '1' ); + bitStream = strchr( ms->bitStream + 5, '1' ); if( bitStream == NULL ) break; - if( !strncmp( bitStream, ABA_SS, ABA_CHAR_LEN ) ) { + if( !strncmp( bitStream, ABA_SS, ABA_CHAR_LEN ) && strncmp( bitStream, ABA_SS ABA_ES, ABA_CHAR_LEN * 2 ) ) { ms->dataType = ABA; return 0; - } else if( !strncmp( bitStream, IATA_SS, IATA_CHAR_LEN ) ) { + } else if( !strncmp( bitStream, IATA_SS, IATA_CHAR_LEN ) && strncmp( bitStream,IATA_SS IATA_ES, IATA_CHAR_LEN * 2 ) ) { ms->dataType = IATA; return 0; } - strrev( ms->bitStream ); + ms_strrev( ms->bitStream ); loop--; } while( loop ); - ms->dataType = UNKNOWN; return 1; } diff --git a/mslib.h b/mslib.h index 096e212..262650a 100644 --- a/mslib.h +++ b/mslib.h @@ -33,11 +33,13 @@ extern "C" { #define MAX_BITSTREAM_LEN 1024 #define ABA_SS "11010" +#define ABA_ES "11111" #define MAX_ABA_LEN 41 #define ABA_CHAR_LEN 5 #define ABA_ASCII_OFFSET 48 #define IATA_SS "1010001" +#define IATA_ES "1111100" #define MAX_IATA_LEN 83 // some reports say max len is 79, but AAMVA says 82 ... #define IATA_CHAR_LEN 7 #define IATA_ASCII_OFFSET 32 -- 1.7.9.5