#include "../tdkpin_command_line.h" #include #include static uint8_t g_command_segment[0x10000]; Win16FarPtr g_borland_command_line; HINSTANCE16 g_win16_instance; UINT16 GetModuleFileNameFar16( HINSTANCE16 module, Win16FarPtr buffer, UINT16 size) { assert(module == g_win16_instance && size == 0xff); static const char path[] = "C:\\TDKPIN.EXE"; for (uint16_t index = 0; index < sizeof(path); index++) { win16_write_u8(win16_far_add_offset(buffer, index), path[index]); } return (UINT16)(sizeof(path) - 1); } int main(void) { static const char command[] = " one two\tthree"; memcpy(&g_command_segment[0x100], command, sizeof(command)); win16_reset_segment_bindings(); win16_bind_segment( 0x5555, g_command_segment, sizeof(g_command_segment), true); static uint8_t result_segment[0x10000]; win16_bind_segment( 0x6666, result_segment, sizeof(result_segment), true); g_borland_command_line = win16_make_far_pointer(0x5555, 0x100); assert(borland_parameter_count() == 3); BorlandCommandToken first = borland_scan_command_token(1); assert(first.token == win16_make_far_pointer(0x5555, 0x102)); assert(first.length == 3); BorlandCommandToken second = borland_scan_command_token(2); assert(second.token == win16_make_far_pointer(0x5555, 0x106)); assert(second.length == 3); BorlandCommandToken missing = borland_scan_command_token(4); assert(missing.length == 0); Win16FarPtr result = win16_make_far_pointer(0x6666, 0x100); borland_parameter_string(1, result); assert(result_segment[0x100] == 3); assert(memcmp(&result_segment[0x101], "one", 3) == 0); borland_parameter_string(4, result); assert(result_segment[0x100] == 0); g_win16_instance = 0x1234; borland_parameter_string(0, result); assert(result_segment[0x100] == 13); assert(memcmp(&result_segment[0x101], "C:\\TDKPIN.EXE", 13) == 0); memset(&g_command_segment[0x200], 'x', 260); g_command_segment[0x304] = 0; g_borland_command_line = win16_make_far_pointer(0x5555, 0x200); borland_parameter_string(1, result); assert(result_segment[0x100] == 4); assert(memcmp(&result_segment[0x101], &g_command_segment[0x200], 260) == 0); return 0; }