Cygwin: add transform_chars_af_unix helper
This function is going to be used for transposing sun_path of abstract sockets. This also adds a transposition of the NUL character to tfx_chars since NUL-bytes in abstract socket names are perfectly valid. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
		| @@ -96,6 +96,8 @@ transform_chars (PUNICODE_STRING upath, USHORT start_idx) | |||||||
| 		   upath->Buffer + upath->Length / sizeof (WCHAR) - 1); | 		   upath->Buffer + upath->Length / sizeof (WCHAR) - 1); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | PWCHAR transform_chars_af_unix (PWCHAR, const char *, __socklen_t); | ||||||
|  |  | ||||||
| /* Memory checking */ | /* Memory checking */ | ||||||
| int __reg2 check_invalid_virtual_addr (const void *s, unsigned sz); | int __reg2 check_invalid_virtual_addr (const void *s, unsigned sz); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -22,7 +22,7 @@ details. */ | |||||||
|    is affected as well, but we can't transform it as long as we accept Win32 |    is affected as well, but we can't transform it as long as we accept Win32 | ||||||
|    paths as input. */ |    paths as input. */ | ||||||
| static const WCHAR tfx_chars[] = { | static const WCHAR tfx_chars[] = { | ||||||
| 	    0, 0xf000 |   1, 0xf000 |   2, 0xf000 |   3, |  0xf000 |   0, 0xf000 |   1, 0xf000 |   2, 0xf000 |   3, | ||||||
|  0xf000 |   4, 0xf000 |   5, 0xf000 |   6, 0xf000 |   7, |  0xf000 |   4, 0xf000 |   5, 0xf000 |   6, 0xf000 |   7, | ||||||
|  0xf000 |   8, 0xf000 |   9, 0xf000 |  10, 0xf000 |  11, |  0xf000 |   8, 0xf000 |   9, 0xf000 |  10, 0xf000 |  11, | ||||||
|  0xf000 |  12, 0xf000 |  13, 0xf000 |  14, 0xf000 |  15, |  0xf000 |  12, 0xf000 |  13, 0xf000 |  14, 0xf000 |  15, | ||||||
| @@ -61,7 +61,7 @@ static const WCHAR tfx_chars[] = { | |||||||
|    converting back space and dot on filesystems only supporting DOS |    converting back space and dot on filesystems only supporting DOS | ||||||
|    filenames. */ |    filenames. */ | ||||||
| static const WCHAR tfx_rev_chars[] = { | static const WCHAR tfx_rev_chars[] = { | ||||||
| 	    0, 0xf000 |   1, 0xf000 |   2, 0xf000 |   3, |  0xf000 |   0, 0xf000 |   1, 0xf000 |   2, 0xf000 |   3, | ||||||
|  0xf000 |   4, 0xf000 |   5, 0xf000 |   6, 0xf000 |   7, |  0xf000 |   4, 0xf000 |   5, 0xf000 |   6, 0xf000 |   7, | ||||||
|  0xf000 |   8, 0xf000 |   9, 0xf000 |  10, 0xf000 |  11, |  0xf000 |   8, 0xf000 |   9, 0xf000 |  10, 0xf000 |  11, | ||||||
|  0xf000 |  12, 0xf000 |  13, 0xf000 |  14, 0xf000 |  15, |  0xf000 |  12, 0xf000 |  13, 0xf000 |  14, 0xf000 |  15, | ||||||
| @@ -103,6 +103,15 @@ transform_chars (PWCHAR path, PWCHAR path_end) | |||||||
|       *path = tfx_chars[*path]; |       *path = tfx_chars[*path]; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | PWCHAR | ||||||
|  | transform_chars_af_unix (PWCHAR out, const char *path, __socklen_t len) | ||||||
|  | { | ||||||
|  |   len -= sizeof (__sa_family_t); | ||||||
|  |   for (const unsigned char *p = (const unsigned char *) path; len-- > 0; ++p) | ||||||
|  |     *out++ = (*p <= 0x7f) ? tfx_chars[*p] : *p; | ||||||
|  |   return out; | ||||||
|  | } | ||||||
|  |  | ||||||
| /* The SJIS, JIS and eucJP conversion in newlib does not use UTF as | /* The SJIS, JIS and eucJP conversion in newlib does not use UTF as | ||||||
|    wchar_t character representation.  That's unfortunate for us since |    wchar_t character representation.  That's unfortunate for us since | ||||||
|    we require UTF for the OS.  What we do here is to have our own |    we require UTF for the OS.  What we do here is to have our own | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user