}
/* String Reverse Function */
-void strrev( char *str ) {
+void ms_strrev( char *str ) {
int f, l;
char tmp;
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;
}
#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