/* s = refname:1000-2000 */ static void parse_definition( const char *s, char * name, size_t len, uint64_t *start, uint64_t *end ) { size_t n = string_size( s ); *start = 0; *end = 0; name[ 0 ] = 0; if ( n > 0 ) { size_t i, st, dst = 0; char tmp[ 4096 ]; st = RR_NAME; for ( i = 0; i < n; ++i ) { char c = s[ i ]; switch( st ) { case RR_NAME : if ( c == ':' ) { finish_txt( name, len, &dst ); st = RR_START; } else { put_c( name, len, &dst, c ); } break; case RR_START : if ( c == '-' ) { *start = finish_num( tmp, sizeof tmp, &dst ); st = RR_END; } else if ( ( c >= '0' )&&( c <= '9' ) ) { put_c( tmp, sizeof tmp, &dst, c ); } break; case RR_END : if ( ( c >= '0' )&&( c <= '9' ) ) { put_c( tmp, sizeof tmp, &dst, c ); } break; } } switch( st ) { case RR_NAME : finish_txt( name, len, &dst ); break; case RR_START : *start = finish_num( tmp, sizeof tmp, &dst ); break; case RR_END : *end = finish_num( tmp, sizeof tmp, &dst ); break; } } }
/* s = 1000-2000 */ static void parse_matepair_definition( const char *s, uint64_t *start, uint64_t *end ) { size_t n = string_size( s ); if ( n > 0 ) { size_t i, st, dst = 0; char tmp[ 32 ]; st = RR_START; for ( i = 0; i < n; ++i ) { char c = s[ i ]; switch( st ) { case RR_START : if ( c == '-' ) { *start = finish_num( tmp, sizeof tmp, &dst ); st = RR_END; } else if ( ( c >= '0' )&&( c <= '9' ) ) { put_c( tmp, sizeof tmp, &dst, c ); } break; case RR_END : if ( ( c >= '0' )&&( c <= '9' ) ) { put_c( tmp, sizeof tmp, &dst, c ); } break; } } switch( st ) { case RR_START : *start = finish_num( tmp, sizeof tmp, &dst ); break; case RR_END : *end = finish_num( tmp, sizeof tmp, &dst ); break; } } }