- while ( *m != '\0' ) {
- /* handle case conversion first */
- if (vol->v_casefold & AFPVOL_MTOUUPPER)
- *m = diatoupper( *m );
- else if (vol->v_casefold & AFPVOL_MTOULOWER)
- *m = diatolower( *m );
-
- /* we have a code page. we only use the ascii range
- * if we have map ascii specified. */
- if (vol->v_mtoupage && ((*m & 0x80) ||
- vol->v_flags & AFPVOL_MAPASCII)) {
- *u = vol->v_mtoupage->map[(unsigned char) *m].value;
- changed = 1;
- if (!*u && *m) {
- /* if conversion failed, encode in hex
- * to prevent silly truncation
- * H.P. Jansen <hpj@urpla.net> */
-#ifdef DEBUG
- LOG(log_debug, logtype_afpd, "mtoupath: hex encode: 0x%x", (unsigned char) *m);
-#endif /* DEBUG */
- *u++ = ':';
- *u++ = hexdig[ ( *m & 0xf0 ) >> 4 ];
- *u = hexdig[ *m & 0x0f ];
- }
- } else {
-#if AD_VERSION == AD_VERSION1
- if ((((vol->v_flags & AFPVOL_NOHEX) == 0) &&
- (!isascii(*m) || *m == '/')) ||
- (((vol->v_flags & AFPVOL_USEDOTS) == 0) &&
- ( i == 0 && (*m == '.' )))) {
-#else /* AD_VERSION == AD_VERSION1 */
- if ((((vol->v_flags & AFPVOL_NOHEX) == 0) &&
- (!isprint(*m) || *m == '/')) ||
- (((vol->v_flags & AFPVOL_USEDOTS) == 0) &&
- ( i == 0 && (*m == '.' )))) {
-#endif /* AD_VERSION == AD_VERSION1 */
- /* do hex conversion. */
- *u++ = ':';
- *u++ = hexdig[ ( *m & 0xf0 ) >> 4 ];
- *u = hexdig[ *m & 0x0f ];
- changed = 1;
- } else
- *u = *m;
- }
- u++;
- i++;
- m++;
+
+ inplen = strlen(m);
+ outlen = MAXPATHLEN;
+
+ if ((size_t)-1 == (outlen = convert_charset ( (utf8)?CH_UTF8_MAC:vol->v_maccharset, vol->v_volcharset, vol->v_maccharset, m, inplen, u, outlen, &flags)) ) {
+ LOG(log_error, logtype_afpd, "conversion from %s to %s for %s failed.", (utf8)?"UTF8-MAC":vol->v_maccodepage, vol->v_volcodepage, mpath);
+ return NULL;