Fixed issue where the LRC of a card was the reverse of the start master
authorJeffrey Malone <ieatlint@tehinterweb.com>
Mon, 8 Nov 2010 09:02:37 +0000 (01:02 -0800)
committerJeffrey Malone <ieatlint@tehinterweb.com>
Mon, 8 Nov 2010 09:02:37 +0000 (01:02 -0800)
mslib.c
mslib.h

diff --git a/mslib.c b/mslib.c
index c45f9f5..41bc62b 100644 (file)
--- a/mslib.c
+++ b/mslib.c
@@ -275,7 +275,7 @@ void ms_decode_peaks( msData *ms ) {
 }
 
 /* String Reverse Function */
 }
 
 /* String Reverse Function */
-void strrev( char *str ) {
+void ms_strrev( char *str ) {
        int f, l;
        char tmp;
 
        int f, l;
        char tmp;
 
@@ -291,28 +291,26 @@ int ms_decode_typeDetect( msData *ms ) {
        char *bitStream;
        int loop = 2;
 
        char *bitStream;
        int loop = 2;
 
-       if( !ms || !ms->bitStream )
+       if( !ms || !ms->bitStream || strlen( ms->bitStream ) < 10 )
                return 1;
 
                return 1;
 
-
        do {
        do {
-               bitStream = strchr( ms->bitStream, '1' );
+               bitStream = strchr( ms->bitStream + 5, '1' );
                if( bitStream == NULL )
                        break;
        
                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;
                        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;
                }
 
                        ms->dataType = IATA;
                        return 0;
                }
 
-               strrev( ms->bitStream );
+               ms_strrev( ms->bitStream );
                loop--;
        } while( loop );
 
                loop--;
        } while( loop );
 
-
        ms->dataType = UNKNOWN;
        return 1;
 }
        ms->dataType = UNKNOWN;
        return 1;
 }
diff --git a/mslib.h b/mslib.h
index 096e212..262650a 100644 (file)
--- a/mslib.h
+++ b/mslib.h
@@ -33,11 +33,13 @@ extern "C" {
 #define MAX_BITSTREAM_LEN 1024
 
 #define ABA_SS         "11010"
 #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 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
 #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