Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rationalise how TCPInfoEx is set and used #4

Open
delphidabbler opened this issue Aug 25, 2022 · 2 comments
Open

Rationalise how TCPInfoEx is set and used #4

delphidabbler opened this issue Aug 25, 2022 · 2 comments

Comments

@delphidabbler
Copy link
Member

delphidabbler commented Aug 25, 2022

Creation of required TCPInfoEx record could be rationalised.

There are numerous type names created as would be required if the the structure was a public API translation, but aren't used here.

Additionally, the ANSI and Unicode versions of TCPInfoEx are so similar that we can rely on compiler to compile correct version without explicit conditional compilation.

Here's what I suggest:

type
  TCPInfoEx = packed record
      // max length in bytes of a character in the code page
      MaxCharSize: UINT;
      // default character used to translate strings to the specific code page
      DefaultChar: array[0..MAX_DEFAULTCHAR-1] of Byte;
      // fixed-length array of lead byte ranges: all elements null if none
      LeadByte: array[0..MAX_LEADBYTES-1] of Byte;
      //  unicode default char used in translations from the specific code page
      UnicodeDefaultChar: WideChar;
      // code page value
      CodePage: UINT;
      // full localised name of the code page
      // - Char is automatically set to correct AnsiChar or WideChar by compiler
      // - depending on whether UNICODE is defined, so conditional 
      // - compilation isn't necessary
      CodePageName: array[0..MAX_PATH-1] of Char;
  end;

  PCPInfoEx = ^TCPInfoEx;  // *** only define this if strictly necessary 
@delphidabbler
Copy link
Member Author

Useful Microsoft docs:

@delphidabbler
Copy link
Member Author

Given that we're dropping support for non-Unicode compilers (issue #6) do we need to care about ANSI structures anyway?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant