diff --git a/gen_intrange.c b/gen_intrange.c index 7006d14e6ad4804d944443f9f4ea675c6013a659..916e89127e4c1aa3bb8732f4fb9c613b7a476837 100644 --- a/gen_intrange.c +++ b/gen_intrange.c @@ -34,27 +34,37 @@ void print_charset(struct charset *cs) { } printf("\n"); } -int main(int argc, char *argv[]) { - assert(argc == 4); - uint8_t bytes = atoi(argv[1]); - uint64_t low = atoi(argv[2]); - uint64_t high = atoi(argv[3]); - printf("LOW = %llu\nHIGH=%llu\n", low, high); - struct charset *cs = (struct charset *) calloc(sizeof(struct charset), 1); - for (int i=0; i<256; i++) - { - charset_set(cs, i, 1); - } - - charset_set(cs, 255, 1); - charset_set(cs, 254, 0); - print_charset(cs); +void HCFS_ADD_CHARSET(struct charset *cs) { + print_charset(cs); +} + +void HCFS_BEGIN_CHOICE(void) { + printf("BEGIN CHOICE\n"); +} + + +void HCFS_END_CHOICE(void) { + printf("END CHOICE\n"); +} + + +void HCFS_BEGIN_SEQ(void) { + printf("BEGIN SEQ\n"); +} + +void HCFS_END_SEQ(void) { + printf("END SEQ\n"); } -/* +void HCFS_ADD_CHAR(uint8_t chr) { + struct charset *tcs = new_charset(); + charset_set(tcs, chr, 1); + print_charset(tcs); + +} void gen_int_range(uint64_t low, uint64_t high, uint8_t bytes) { // Possible FIXME: TallerThanMe @@ -63,21 +73,21 @@ void gen_int_range(uint64_t low, uint64_t high, uint8_t bytes) { for (uint64_t i=low; i<=high; ++i) { charset_set(cs, i, 1); } - HCFS_ADD_CHARSET(cs); + print_charset(cs); } else if (1 < bytes) { uint8_t low_head, hi_head; low_head = ((low >> (8*(bytes - 1))) & 0xFF); hi_head = ((high >> (8*(bytes - 1))) & 0xFF); if (low_head != hi_head) { - HCFS_BEGIN_CHOICE() { - HCFS_BEGIN_SEQ() { + HCFS_BEGIN_CHOICE(); { + HCFS_BEGIN_SEQ(); { HCFS_ADD_CHAR(low_head); - gen_int_range(mm__, stk__, low & ((1 << (8 * (bytes - 1))) - 1), ((1 << (8*(bytes-1)))-1), bytes-1); + gen_int_range(low & ((1 << (8 * (bytes - 1))) - 1), ((1 << (8*(bytes-1)))-1), bytes-1); } HCFS_END_SEQ(); - HCFS_BEGIN_SEQ() { - HCharset hd = new_charset(mm__); - HCharset rest = new_charset(mm__); + HCFS_BEGIN_SEQ(); { + struct charset * hd = new_charset(); + struct charset * rest = new_charset(); for (int i = 0; i < 256; i++) { charset_set(hd, i, (i > low_head && i < hi_head)); charset_set(rest, i, 1); @@ -86,17 +96,17 @@ void gen_int_range(uint64_t low, uint64_t high, uint8_t bytes) { for (int i = 2; i < bytes; i++) HCFS_ADD_CHARSET(rest); } HCFS_END_SEQ(); - HCFS_BEGIN_SEQ() { + HCFS_BEGIN_SEQ(); { HCFS_ADD_CHAR(hi_head); - gen_int_range(mm__, stk__, 0, high & ((1 << (8 * (bytes - 1))) - 1), bytes-1); + gen_int_range(0, high & ((1 << (8 * (bytes - 1))) - 1), bytes-1); } HCFS_END_SEQ(); } HCFS_END_CHOICE(); } else { // TODO: find a way to merge this with the higher-up SEQ - HCFS_BEGIN_CHOICE() { - HCFS_BEGIN_SEQ() { + HCFS_BEGIN_CHOICE(); { + HCFS_BEGIN_SEQ(); { HCFS_ADD_CHAR(low_head); - gen_int_range(mm__, stk__, + gen_int_range( low & ((1 << (8 * (bytes - 1))) - 1), high & ((1 << (8 * (bytes - 1))) - 1), bytes - 1); @@ -105,4 +115,16 @@ void gen_int_range(uint64_t low, uint64_t high, uint8_t bytes) { } } } -*/ + + + +int main(int argc, char *argv[]) { + assert(argc == 4); + uint8_t bytes = atoi(argv[1]); + uint64_t low = atoi(argv[2]); + uint64_t high = atoi(argv[3]); + printf("BYTES = %hhu\nLOW = %llu\nHIGH=%llu\n\n", bytes, low, high); + + gen_int_range(low, high, bytes); + +} \ No newline at end of file