Used in conjunction with CONV_ESCAPEHEX to allow and escape ':'.
Needed for storing Extended Attributes in files in adouble dirs.
#define MACCHARSET "MAC_ROMAN"
-#define flag(x) x, #x
+#define flag(x) {x, #x}
struct flag_map {
int flag;
struct flag_map flag_map[] = {
flag(CONV_ESCAPEHEX),
+ flag(CONV_ALLOW_COLON),
flag(CONV_UNESCAPEHEX),
flag(CONV_ESCAPEDOTS),
flag(CONV_IGNORE),
string, strlen(string),
buffer, MAXPATHLEN,
&flags)) ) {
- fprintf( stderr, "Conversion error");
+ perror("Conversion error");
return 1;
}
/* conversion flags */
#define CONV_IGNORE (1<<0) /* return the first convertable characters. */
-#define CONV_ESCAPEHEX (1<<1) /* escape unconvertable chars with :[UCS2HEX] */
+#define CONV_ESCAPEHEX (1<<1) /* escape unconvertable chars with :[UCS2HEX], */
+ /* also escape '/'. Escape ':' if also CONV_ALLOW_COLON, */
+ /* else ':' raises EILSEQ */
#define CONV_ESCAPEDOTS (1<<2) /* escape leading dots with :2600 */
#define CONV_UNESCAPEHEX (1<<3)
#define CONV_TOUPPER (1<<4) /* convert to UPPERcase */
#define CONV_DECOMPOSE (1<<7) /* precompose */
#define CONV_FORCE (1<<8) /* force convertion */
#define CONV__EILSEQ (1<<9) /* ignore EILSEQ, replace with IGNORE_CHAR (try USC2) */
+#define CONV_ALLOW_COLON (1<<10) /* Allow ':' in name. Needed for Extended Attributes */
/* conversion return flags */
#define CONV_REQMANGLE (1<<14) /* mangling of returned name is required */
/*
* for each charset we have a function that pulls from that charset to
* a ucs2 buffer, and a function that pushes to a ucs2 buffer
- * */
+ */
struct charset_functions {
const char *name;
char* outbuf = (char*)dest;
atalk_iconv_t descriptor;
atalk_iconv_t descriptor_cap;
+ char escch;
descriptor = conv_handles[CH_UCS2][to_set];
descriptor_cap = conv_handles[CH_UCS2][cap_set];
if ((option & CONV_ESCAPEHEX)) {
for (i = 0; i < i_len; i += 2) {
ucs2_t c = SVAL(inbuf, i);
- if (c == 0x002f) { /* 0x002f = / */
+ switch (c) {
+ case 0x003a: /* 0x003a = ':' */
+ if ( ! (option & CONV_ALLOW_COLON)) {
+ errno = EILSEQ;
+ goto end;
+ }
+ escch = c;
+ j = i_len - i;
+ i_len = i;
+ break;
+ case 0x002f: /* 0x002f = '/' */
+ escch = c;
j = i_len - i;
i_len = i;
break;
- } else if (c == 0x003a) { /* 0x003a = : */
- errno = EILSEQ;
- goto end;
}
}
}
errno = E2BIG;
goto end;
}
- *outbuf++ = ':';
- *outbuf++ = '2';
- *outbuf++ = 'f';
+ switch (escch) {
+ case '/':
+ *outbuf++ = ':';
+ *outbuf++ = '2';
+ *outbuf++ = 'f';
+ break;
+ case ':':
+ *outbuf++ = ':';
+ *outbuf++ = '3';
+ *outbuf++ = 'a';
+ break;
+ default:
+ /*
+ * THIS SHOULD NEVER BE REACHED !!!
+ * As a safety net I put in a ' ' here
+ */
+ *outbuf++ = ':';
+ *outbuf++ = '2';
+ *outbuf++ = '0';
+ break;
+ }
o_len -= 3;
inbuf += 2;
i_len -= 2;
/*
- $Id: ea.c,v 1.15 2009-11-18 08:02:33 didg Exp $
+ $Id: ea.c,v 1.16 2009-11-18 10:52:00 franklahm Exp $
Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
This program is free software; you can redistribute it and/or modify
char *u;
size_t inplen;
size_t outlen;
- uint16_t flags = CONV_ESCAPEHEX | CONV_FORCE;
+ uint16_t flags = CONV_ESCAPEHEX | CONV_ALLOW_COLON;
if (!mpath)
return NULL;