]> arthur.barton.de Git - netatalk.git/commitdiff
renewal of charset options
authorHAT <hat@fa2.so-net.ne.jp>
Thu, 15 Mar 2012 16:36:52 +0000 (01:36 +0900)
committerHAT <hat@fa2.so-net.ne.jp>
Thu, 15 Mar 2012 16:36:52 +0000 (01:36 +0900)
unix charset = LOCALE [G]
vol charset = UTF8 [G] [V]
mac charset = MAC_ROMAN [G] [V]

BUG:  manpage has not been corrected yet.
TODO: default value of unix charset is LOCALE or UTF8 ?

include/atalk/globals.h
libatalk/util/netatalk_conf.c

index c6b8eb2862fdc56609427bc1189939f8f55e3770..345b2779b3cd71e0123e86f2bc0a8b1573498c4a 100644 (file)
@@ -89,7 +89,7 @@ struct afp_options {
     char *signatureopt;
     unsigned char signature[16];
     char *k5service, *k5realm, *k5keytab;
-    char *unixcodepage,*maccodepage;
+    char *unixcodepage, *maccodepage, *volcodepage;
     charset_t maccharset, unixcharset; 
     mode_t umask;
     mode_t save_mask;
index 1e5c64dd56f605bba2343121a021d506c6d7de43..4ae881639e1f9d3900e87103cab89acb6933d6a7 100644 (file)
@@ -599,12 +599,15 @@ static struct vol *creatvol(AFPObj *obj,
     if (val = getoption(obj->iniconfig, section, "veto", preset))
         EC_NULL( volume->v_veto = strdup(val) );
 
-    if (val = getoption(obj->iniconfig, section, "volcharset", preset))
+    /* vol charset is in [V] strictly. */
+    /* However, this can be set in both of [G] and [V] for intuitiveness */
+    if (val = getoption(obj->iniconfig, section, "vol charset", preset))
         EC_NULL( volume->v_volcodepage = strdup(val) );
     else
-        EC_NULL( volume->v_volcodepage = strdup("UTF8") );
+        EC_NULL( volume->v_volcodepage = strdup(obj->options.volcodepage) );
 
-    if (val = getoption(obj->iniconfig, section, "maccharset", preset))
+    /* mac charset is in both of [G] and [V] */
+    if (val = getoption(obj->iniconfig, section, "mac charset", preset))
         EC_NULL( volume->v_maccodepage = strdup(val) );
     else
         EC_NULL( volume->v_maccodepage = strdup(obj->options.maccodepage) );
@@ -1060,12 +1063,12 @@ void volume_free(struct vol *vol)
 int load_charset(struct vol *vol)
 {
     if ((vol->v_maccharset = add_charset(vol->v_maccodepage)) == (charset_t)-1) {
-        LOG(log_error, logtype_default, "Setting Mac codepage '%s' failed", vol->v_maccodepage);
+        LOG(log_error, logtype_default, "Setting mac charset '%s' failed", vol->v_maccodepage);
         return -1;
     }
 
     if ((vol->v_volcharset = add_charset(vol->v_volcodepage)) == (charset_t)-1) {
-        LOG(log_error, logtype_default, "Setting volume codepage '%s' failed", vol->v_volcodepage);
+        LOG(log_error, logtype_default, "Setting vol charset '%s' failed", vol->v_volcodepage);
         return -1;
     }
 
@@ -1493,27 +1496,39 @@ int afp_config_parse(AFPObj *AFPObj)
         free(q);
     }
 
-    if (!(p = iniparser_getstring(config, INISEC_GLOBAL, "unixcodepage", NULL))) {
+    /* Charset Options */
+
+    /* unix charset is in [G] only */
+    if (!(p = iniparser_getstring(config, INISEC_GLOBAL, "unix charset", NULL))) {
         options->unixcharset = CH_UNIX;
         options->unixcodepage = strdup("LOCALE");
     } else {
         if ((options->unixcharset = add_charset(p)) == (charset_t)-1) {
             options->unixcharset = CH_UNIX;
             options->unixcodepage = strdup("LOCALE");
-            LOG(log_warning, logtype_afpd, "Setting Unix codepage to '%s' failed", p);
+            LOG(log_warning, logtype_afpd, "Setting unix charset to '%s' failed", p);
         } else {
             options->unixcodepage = strdup(p);
         }
     }
+
+    /* vol charset is in [V] strictly. */
+    /* However, this can be set in both of [G] and [V] for intuitiveness */
+    if (!(p = iniparser_getstring(config, INISEC_GLOBAL, "vol charset", NULL))) {
+        options->volcodepage = strdup("UTF8");
+    } else {
+        options->volcodepage = strdup(p);
+    }
        
-    if (!(p = iniparser_getstring(config, INISEC_GLOBAL, "maccodepage", NULL))) {
+    /* mac charset is in both of [G] and [V] */
+    if (!(p = iniparser_getstring(config, INISEC_GLOBAL, "mac charset", NULL))) {
         options->maccharset = CH_MAC;
         options->maccodepage = strdup("MAC_ROMAN");
     } else {
         if ((options->maccharset = add_charset(p)) == (charset_t)-1) {
             options->maccharset = CH_MAC;
             options->maccodepage = strdup("MAC_ROMAN");
-            LOG(log_warning, logtype_afpd, "Setting Mac codepage to '%s' failed", p);
+            LOG(log_warning, logtype_afpd, "Setting mac charset to '%s' failed", p);
         } else {
             options->maccodepage = strdup(p);
         }
@@ -1522,8 +1537,8 @@ int afp_config_parse(AFPObj *AFPObj)
     /* Check for sane values */
     if (options->tickleval <= 0)
         options->tickleval = 30;
-    options->disconnected *= 3600 / options->tickleval;
-    options->sleep *= 3600 / options->tickleval;
+        options->disconnected *= 3600 / options->tickleval;
+        options->sleep *= 3600 / options->tickleval;
     if (options->timeout <= 0)
         options->timeout = 4;
     if (options->sleep <= 4)
@@ -1533,9 +1548,8 @@ int afp_config_parse(AFPObj *AFPObj)
     if (options->volnamelen < 8)
         options->volnamelen = 8; /* max mangled volname "???#FFFF" */
     if (options->volnamelen > 255)
-           options->volnamelen = 255; /* AFP3 spec */
+        options->volnamelen = 255; /* AFP3 spec */
 
 EC_CLEANUP:
     EC_EXIT;
 }
-