diff --git a/include/zinnia/cmdline.h b/include/zinnia/cmdline.h index 5fe91af..bd767d2 100644 --- a/include/zinnia/cmdline.h +++ b/include/zinnia/cmdline.h @@ -4,7 +4,7 @@ #include #include -#define _CMDLINE_OPTION(x, opt_name, opt_desc, opt_func, opt_limit) \ +#define _CMDLINE_OPTION(x, opt_name, opt_desc, opt_func) \ static const struct cmdline_option x = { \ .name = opt_name, \ .desc = opt_desc, \ @@ -16,23 +16,12 @@ void (*)(uintptr_t): CMDLINE_UINTPTR \ ), \ .func = (void*)(opt_func), \ - .limit = (void*)(opt_limit) \ }; \ - static_assert(_Generic( \ - (opt_limit), \ - const char**: true, \ - const struct cmdline_range_int*: true, \ - const struct cmdline_range_uint*: true, \ - void*: true \ - )); \ [[__used, __section(".cmdline")]] \ static const struct cmdline_option* CONCAT(x, _ptr) = &x #define CMDLINE_OPTION(opt_name, opt_desc, opt_func) \ - _CMDLINE_OPTION(UNIQUE_IDENT(cmdline_option), opt_name, opt_desc, opt_func, (void*)nullptr) - -#define CMDLINE_OPTION_RANGE(opt_name, opt_desc, opt_func, opt_values) \ - _CMDLINE_OPTION(UNIQUE_IDENT(cmdline_option), opt_name, opt_desc, opt_func, opt_values) + _CMDLINE_OPTION(UNIQUE_IDENT(cmdline_option), opt_name, opt_desc, opt_func) enum cmdline_type { CMDLINE_STRING, @@ -55,16 +44,6 @@ struct cmdline_option { void (*func_uintptr)(uintptr_t value); void* func; }; - union { - const char** str_limit; - struct cmdline_range_int { - intptr_t min, max; - }* intptr_limit; - struct cmdline_range_uint { - uintptr_t min, max; - }* uintptr_limit; - void* limit; - }; }; // Parses the command line and invokes all options. diff --git a/scripts/get_options.py b/scripts/get_options.py index 256b1c6..b48f256 100755 --- a/scripts/get_options.py +++ b/scripts/get_options.py @@ -65,44 +65,4 @@ if __name__ == "__main__": case 3: kind_str = "unsigned integer" - # Skip function pointer - - # Allowed values - limit = "" - limit_ptr = int.from_bytes(option[32:][:SIZEOF_PTR], byteorder=ENDIAN) - - if limit_ptr != 0: - elffile.seek(next(file.address_offsets(start=limit_ptr))) - match kind: - case 0: - limit = [] - i = 0 - while True: - ptr = next(file.address_offsets(start=limit_ptr + i * SIZEOF_PTR)) - elffile.seek(ptr) - str_ptr = int.from_bytes(elffile.read(SIZEOF_PTR), byteorder=ENDIAN) - if str_ptr == 0: - break - - strstr_off = next(file.address_offsets(start=str_ptr)) - val = "" - elffile.seek(strstr_off) - while True: - b = int.from_bytes(elffile.read(1)) - if b == 0: - break - val += chr(b) - i += 1 - limit.append(val) - - case 2: - min = int.from_bytes(elffile.read(SIZEOF_PTR), byteorder=ENDIAN, signed=True) - max = int.from_bytes(elffile.read(SIZEOF_PTR), byteorder=ENDIAN) - limit = f"[{min}, {max}]" - - case 3: - min = int.from_bytes(elffile.read(SIZEOF_PTR), byteorder=ENDIAN) - max = int.from_bytes(elffile.read(SIZEOF_PTR), byteorder=ENDIAN) - limit = f"[{min}, {max}]" - - print(f"- {name}:\t{desc} ({kind_str}) {limit if len(limit) != 0 else ""}") + print(f"- {name}:\t{desc} ({kind_str})")