]> arthur.barton.de Git - netatalk.git/blobdiff - bin/uniconv/uniconv.c
New MySQL CNID backend
[netatalk.git] / bin / uniconv / uniconv.c
index 081c4493dfb630c1b3ab60f93043051a45cddfd9..93439cefa965efae35bab8255d0c97d7d1f04780 100644 (file)
 #include <sys/param.h>
 #include <pwd.h>
 #include <dirent.h>
+#include <arpa/inet.h>
+
 #include <atalk/afp.h>
 #include <atalk/unicode.h>
 #include <atalk/util.h>
 #include <atalk/logger.h>
+#include <atalk/compat.h>
 
 #include "atalk/cnid.h"
 #ifndef MAXPATHLEN
@@ -57,7 +60,7 @@ char* to_charset;
 static charset_t ch_mac;
 char* mac_charset;
 static int usedots = 0;
-static u_int16_t conv_flags = 0;
+static uint16_t conv_flags = 0;
 static int dry_run = 0;
 static int verbose=0;
 char *cnid_type;
@@ -146,11 +149,11 @@ static char *convert_name(char *name, struct stat *st, cnid_t cur_did)
        size_t outlen = 0;
        unsigned char *p,*q;
        int require_conversion = 0;
-        u_int16_t    flags = conv_flags;
+    uint16_t    flags = conv_flags;
        cnid_t id;
 
-       p = name;
-       q = buffer;
+       p = (unsigned char *)name;
+       q = (unsigned char *)buffer;
 
        /* optimize for ascii case */
        while (*p != 0) {
@@ -168,17 +171,17 @@ static char *convert_name(char *name, struct stat *st, cnid_t cur_did)
        }
 
        /* convert charsets */
-       q=buffer;
-       p=name;
+       q=(unsigned char *)buffer;
+       p=(unsigned char *)name;
 
-       outlen = convert_charset(ch_from, ch_to, ch_mac, p, strlen(p), q, sizeof(buffer) -2, &flags);
+       outlen = convert_charset(ch_from, ch_to, ch_mac, (char *)p, strlen((char *)p), (char *)q, sizeof(buffer) -2, &flags);
        if ((size_t)-1 == outlen) {
           if ( ch_to == CH_UTF8) {
                /* maybe name is already in UTF8? */
                flags = conv_flags;
-               q = (char*) buffer;
-               p = name;
-               outlen = convert_charset(ch_to, ch_to, ch_mac, p, strlen(p), q, sizeof(buffer) -2, &flags);
+               q = (unsigned char *)buffer;
+               p = (unsigned char *)name;
+               outlen = convert_charset(ch_to, ch_to, ch_mac, (char *)p, strlen((char *)p), (char *)q, sizeof(buffer) -2, &flags);
                if ((size_t)-1 == outlen) {
                        /* it's not UTF8... */
                        fprintf(stderr, "ERROR: conversion from '%s' to '%s' for '%s' in DID %u failed!!!\n", 
@@ -386,7 +389,7 @@ static int init(char* path)
 {
        DIR* startdir;
 
-        if (NULL == (cdb = cnid_open (path, 0, cnid_type, 0)) ) {
+    if (NULL == (cdb = cnid_open (path, 0, cnid_type, 0, "localhost", "4700", NULL, NULL)) ) {
                 fprintf (stderr, "ERROR: cannot open CNID database in '%s'\n", path);
                 fprintf (stderr, "ERROR: check the logs for reasons, aborting\n");
                return -1;