Re: [Afpfs-ng-devel] length of volumename is wrong
Status: Alpha
Brought to you by:
alexthepuffin
From: HAT <ha...@fa...> - 2008-07-16 17:16:18
|
Alex, >Yes, that doesn't seem right and I cannot remember where I got that >data from. I probably wrote that when I started this two years, and >in looking through the 3.1 docs it looks incorrect. I may have taken >this from netatalk. netatalk's volumename length is buggy. http://www003.upp.so-net.ne.jp/hat/netatalk/cjk.html >Is the solution just to increase the length of >AFP_VOLUME_NAME_UTF8_LEN to 255? > >It looks like AFP_VOLUME_NAME_LEN should be 27. > >Are there similiar problems with server name lengths? Your sources are not clear which bare string or Pascal string. Pascal string include leading one byte. ------------------------------------------------------- Apple Filing Protocol Programming Guide Page 16 >AFPNames are encoded in conformance to the Unicode standard (UTF-8), >which uses 16-bits to encode more than 65,000 characters. >To keep character coding simple and efficient, the Unicode Standard >assigns each character a unique numeric value and name. >To help when converting from UTF-8 to other script systems, >AFPNames begin with a four-byte text encoding hint that specifies >the script that was originally used to compose the name. >The text encoding hint is followed by a two-byte length field >specifying the length of the UTF-8 encoded name that follows. ------------------------------------------------------- #define AFP_SERVER_NAME_LEN Apple Filing Protocol Programming Guide Page 11 > A string in Pascal format of up to 32 characters. A leading-octet of Pascal string is length. #define AFP_SERVER_NAME_LEN 31 ------------------------------------------------------- #define AFP_SERVER_NAME_UTF8_LEN Apple Filing Protocol Reference Page 97 >UTF-8ServerName (AFPName) >AFPName containing the UTF-8-encoded name of the server. #define AFP_SERVER_NAME_UTF8_LEN 65535 This is not realistic. If UTF-8ServerName is 255 over, this volume should be disregarded. #define AFP_SERVER_NAME_UTF8_LEN 255 ------------------------------------------------------- #define AFP_VOLUME_NAME_LEN Apple Filing Protocol Reference Page 101 >For AFP 2.x, this command returns volume names in ANSI format >with a maximum length of 27 bytes. #define AFP_VOLUME_NAME_LEN 27 Maybe, the classic client has length of 31 bytes for volumename. 4 bytes have been reserved for suffix so that the same volumename may exist. 31 - 4 = 27 ------------------------------------------------------- #define AFP_VOLUME_NAME_UTF8_LEN Apple Filing Protocol Reference Page 101 >For AFP 3.x, this command returns volume names in UTF-8 format >with a one byte length byte specifying any length up to 255. >Note that the Finder limits setting volume names to no more than >27 characters. #define AFP_VOLUME_NAME_UTF8_LEN 255 Do not confuse "character" with "byte". Generally, One Latin character is 2 bytes as UTF8. One CJK character is 3 bytes as UTF8. 27 CJK characters are 81 bytes. If character is decomposed, it is more complex. ------------------------------------------------------- #define AFP_SIGNATURE_LEN 16 ok. ------------------------------------------------------- #define AFP_MACHINETYPE_LEN Apple Filing Protocol Programming Guide Page 11 >A string in Pascal format of up to 16 characters that describes >the file server's hardware and software but has no significance to AFP. #define AFP_MACHINETYPE_LEN 15 ------------------------------------------------------- #define AFP_LOGINMESG_LEN Apple Filing Protocol Reference Page 100 >The usual size of any of these messages is 200 bytes including >the length byte (a Str199). >AFP 3.x clients can request that the server send longer attention >messages by setting the attention quantum size in the Option field >of the DSOpenSession command (described in the document Apple Filing >Protocol Client). #define AFP_LOGINMESG_LEN 199 or 200 ??? If UTF8 string is 200 over, this should be disregarded. or #define AFP_LOGINMESG_UTF8_LEN 65535 ------------------------------------------------------- #define AFP_VOLPASS_LEN 8 maybe, ok. If DHX, 255. ------------------------------------------------------- #define AFP_HOSTNAME_LEN 255 maybe, ok. ------------------------------------------------------- #define AFP_ZONE_LEN 255 I don't know it. ------------------------------------------------------- #define AFP_SERVER_ICON_LEN 256 ok. Apple Filing Protocol Programming Guide Page 11 >A optional value of 256 bytes that is used to customize >the appearance of server volumes on the Mac OS Desktop. >It consists of a 32-by-32 bit (128 bytes) icon bitmap followed >by a 32-by-32 bit (128 bytes) icon mask. >The mask usually consists of the icon's outline filled with black >(bits that are set). For more information about icons, >refer to Inside Mac OS X. mask is 128. ------------------------------------------------------- #define AFP_MAX_USERNAME_LEN Apple Filing Protocol Reference Page 116 >The name can be a string of up to 255 Macintosh Roman characters >or an AFPName of up to 255 characters. #define AFP_MAX_USERNAME_LEN 255 ------------------------------------------------------- #define AFP_MAX_PASSWORD_LEN maybe, 255 If cleartext or random number exchange, it is 8. ------------------------------------------------------- >There is a larger problem with filenames, I have a maximum filename >length of 255 bytes, but in reality the length is up to 16 bits. In >many places I preallocate the space for the filename, which is fine >for a small number, but there are many places I don't want to allocate >64k. Changing this requires a lot of rework of anything that >allocates space that references a filename. This is left for a later >release. I expect you'll hit this too. I will explain it after tomorrow. -- HAT |