r25026: Move param/param.h out of includes.h
[jelmer/samba4-debian.git] / source / ntvfs / posix / pvfs_shortname.c
index 59a3d34640724931ac0627ad14955df1352cc369..75e474a94e7cf102a4dfb101a3178cc01539e271 100644 (file)
@@ -7,7 +7,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
+#include "system/locale.h"
 #include "vfs_posix.h"
-#include "system/iconv.h"
+#include "param/param.h"
 
 /*
   this mangling scheme uses the following format
@@ -313,8 +313,8 @@ static BOOL is_8_3(struct pvfs_mangle_context *ctx,
   try to find a 8.3 name in the cache, and if found then
   return the original long name. 
 */
-static const char *check_cache(struct pvfs_mangle_context *ctx, 
-                              const char *name)
+static char *check_cache(struct pvfs_mangle_context *ctx, 
+                        TALLOC_CTX *mem_ctx, const char *name)
 {
        uint32_t hash, multiplier;
        unsigned int i;
@@ -351,10 +351,10 @@ static const char *check_cache(struct pvfs_mangle_context *ctx,
        }
 
        if (extension[0]) {
-               return talloc_asprintf(ctx, "%s.%s", prefix, extension);
+               return talloc_asprintf(mem_ctx, "%s.%s", prefix, extension);
        }
 
-       return talloc_strdup(ctx, prefix);
+       return talloc_strdup(mem_ctx, prefix);
 }
 
 
@@ -469,7 +469,7 @@ static char *name_map(struct pvfs_mangle_context *ctx,
                if (! FLAG_CHECK(lead_chars[i], FLAG_ASCII)) {
                        lead_chars[i] = '_';
                }
-               lead_chars[i] = toupper(lead_chars[i]);
+               lead_chars[i] = toupper((unsigned char)lead_chars[i]);
        }
        for (;i<ctx->mangle_prefix;i++) {
                lead_chars[i] = '_';
@@ -487,7 +487,7 @@ static char *name_map(struct pvfs_mangle_context *ctx,
        extension_length = 0;
        if (dot_p) {
                for (i=1; extension_length < 3 && dot_p[i]; i++) {
-                       char c = dot_p[i];
+                       unsigned char c = dot_p[i];
                        if (FLAG_CHECK(c, FLAG_ASCII)) {
                                extension[extension_length++] = toupper(c);
                        }
@@ -672,12 +672,7 @@ const char *pvfs_short_name(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
 char *pvfs_mangled_lookup(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx, 
                          const char *name)
 {
-       const char *ret;
-       ret = check_cache(pvfs->mangle_ctx, name);
-       if (ret) {
-               return talloc_steal(mem_ctx, ret);
-       }
-       return NULL;
+       return check_cache(pvfs->mangle_ctx, mem_ctx, name);
 }