lib: Add cp_smb_filename
authorVolker Lendecke <vl@samba.org>
Thu, 11 Apr 2013 13:24:55 +0000 (15:24 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 17 Apr 2013 21:49:54 +0000 (14:49 -0700)
The interface of copy_smb_filename is just silly ;-)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/include/proto.h
source3/lib/filename_util.c

index 00a9a69d73e1d7834a4b8264a0a3c393cd836673..2ebd14b59d4742a16824bc207ac457e00a922ed4 100644 (file)
@@ -1611,6 +1611,8 @@ const char *fsp_fnum_dbg(const struct files_struct *fsp);
 NTSTATUS copy_smb_filename(TALLOC_CTX *ctx,
                           const struct smb_filename *smb_fname_in,
                           struct smb_filename **smb_fname_out);
+struct smb_filename *cp_smb_filename(TALLOC_CTX *mem_ctx,
+                                    const struct smb_filename *in);
 bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname);
 bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname);
 
index 9a6ab2b34a97da09e335167000aa393a6405c090..67fa1a98f2503ddae32e8cd2c8c91ed92f5b8ef0 100644 (file)
@@ -161,6 +161,45 @@ const char *fsp_fnum_dbg(const struct files_struct *fsp)
        return str;
 }
 
+struct smb_filename *cp_smb_filename(TALLOC_CTX *mem_ctx,
+                                    const struct smb_filename *in)
+{
+       struct smb_filename *out;
+
+       /* stream_name must always be NULL if there is no stream. */
+       if (in->stream_name) {
+               SMB_ASSERT(in->stream_name[0] != '\0');
+       }
+
+       out = talloc_zero(mem_ctx, struct smb_filename);
+       if (out == NULL) {
+               return NULL;
+       }
+       if (in->base_name != NULL) {
+               out->base_name = talloc_strdup(out, in->base_name);
+               if (out->base_name == NULL) {
+                       goto fail;
+               }
+       }
+       if (in->stream_name != NULL) {
+               out->stream_name = talloc_strdup(out, in->stream_name);
+               if (out->stream_name == NULL) {
+                       goto fail;
+               }
+       }
+       if (in->original_lcomp != NULL) {
+               out->original_lcomp = talloc_strdup(out, in->original_lcomp);
+               if (out->original_lcomp == NULL) {
+                       goto fail;
+               }
+       }
+       out->st = in->st;
+       return out;
+fail:
+       TALLOC_FREE(out);
+       return NULL;
+}
+
 NTSTATUS copy_smb_filename(TALLOC_CTX *ctx,
                           const struct smb_filename *smb_fname_in,
                           struct smb_filename **smb_fname_out)