libcli/smb Move attrib_string in common
authorAndrew Bartlett <abartlet@samba.org>
Fri, 29 Apr 2011 02:41:27 +0000 (12:41 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 29 Apr 2011 06:38:14 +0000 (16:38 +1000)
libcli/smb/smb_common.h
libcli/smb/smb_util.h [new file with mode: 0644]
libcli/smb/util.c [new file with mode: 0644]
libcli/smb/wscript_build
source3/Makefile.in
source3/include/proto.h
source3/lib/util.c
source3/wscript_build
source4/libcli/raw/rawfile.c

index 8fe0623..ca04eb3 100644 (file)
@@ -25,5 +25,6 @@
 #include "../libcli/smb/smb2_constants.h"
 #include "../libcli/smb/smb2_create_blob.h"
 #include "../libcli/smb/smb_constants.h"
+#include "../libcli/smb/smb_util.h"
 
 #endif
diff --git a/libcli/smb/smb_util.h b/libcli/smb/smb_util.h
new file mode 100644 (file)
index 0000000..8a67c30
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+   Unix SMB/CIFS implementation.
+   client file operations
+   Copyright (C) Andrew Tridgell 1994-1998
+   Copyright (C) Jeremy Allison 2001-2002
+   Copyright (C) James Myers 2003
+
+   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 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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, see <http://www.gnu.org/licenses/>.
+*/
+
+char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib);
diff --git a/libcli/smb/util.c b/libcli/smb/util.c
new file mode 100644 (file)
index 0000000..f8fa56f
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+   Unix SMB/CIFS implementation.
+   client file operations
+   Copyright (C) Andrew Tridgell 1994-1998
+   Copyright (C) Jeremy Allison 2001-2002
+   Copyright (C) James Myers 2003
+
+   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 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "libcli/smb/smb_common.h"
+
+/**
+ Return a string representing a CIFS attribute for a file.
+**/
+char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib)
+{
+       int i, len;
+       const struct {
+               char c;
+               uint16_t attr;
+       } attr_strs[] = {
+               {'V', FILE_ATTRIBUTE_VOLUME},
+               {'D', FILE_ATTRIBUTE_DIRECTORY},
+               {'A', FILE_ATTRIBUTE_ARCHIVE},
+               {'H', FILE_ATTRIBUTE_HIDDEN},
+               {'S', FILE_ATTRIBUTE_SYSTEM},
+               {'N', FILE_ATTRIBUTE_NORMAL},
+               {'R', FILE_ATTRIBUTE_READONLY},
+               {'d', FILE_ATTRIBUTE_DEVICE},
+               {'t', FILE_ATTRIBUTE_TEMPORARY},
+               {'s', FILE_ATTRIBUTE_SPARSE},
+               {'r', FILE_ATTRIBUTE_REPARSE_POINT},
+               {'c', FILE_ATTRIBUTE_COMPRESSED},
+               {'o', FILE_ATTRIBUTE_OFFLINE},
+               {'n', FILE_ATTRIBUTE_NONINDEXED},
+               {'e', FILE_ATTRIBUTE_ENCRYPTED}
+       };
+       char *ret;
+
+       ret = talloc_array(mem_ctx, char, ARRAY_SIZE(attr_strs)+1);
+       if (!ret) {
+               return NULL;
+       }
+
+       for (len=i=0; i<ARRAY_SIZE(attr_strs); i++) {
+               if (attrib & attr_strs[i].attr) {
+                       ret[len++] = attr_strs[i].c;
+               }
+       }
+
+       ret[len] = 0;
+
+       talloc_set_name_const(ret, ret);
+
+       return ret;
+}
index 6796b4c..36d9d10 100644 (file)
@@ -2,7 +2,7 @@
 
 
 bld.SAMBA_SUBSYSTEM('LIBCLI_SMB_COMMON',
-       source='smb2_create_blob.c',
+       source='smb2_create_blob.c util.c',
        autoproto='smb_common_proto.h',
        public_deps='talloc'
        )
index 4ec1868..7c5da09 100644 (file)
@@ -479,7 +479,8 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \
          libads/krb5_errs.o lib/system_smbd.o lib/audit.o $(LIBNDR_OBJ) \
          lib/file_id.o lib/idmap_cache.o \
          ../libcli/security/dom_sid.o ../libcli/security/security_descriptor.o \
-         ../libcli/security/security_token.o ../libcli/security/util_sid.o
+         ../libcli/security/security_token.o ../libcli/security/util_sid.o \
+         ../libcli/smb/util.o
 
 LIB_DUMMY_OBJ = lib/dummysmbd.o lib/dummyroot.o
 LIB_NONSMBD_OBJ = $(LIB_OBJ) $(LIB_DUMMY_OBJ)
index a697188..058356e 100644 (file)
@@ -630,7 +630,6 @@ bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf,
 bool socket_exist(const char *fname);
 uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf);
 SMB_OFF_T get_file_size(char *file_name);
-char *attrib_string(TALLOC_CTX *mem_ctx, uint16 mode);
 void show_msg(char *buf);
 void smb_set_enclen(char *buf,int len,uint16 enc_ctx_num);
 void smb_setlen(char *buf,int len);
index d908ea8..8805197 100644 (file)
@@ -294,26 +294,6 @@ SMB_OFF_T get_file_size(char *file_name)
        return get_file_size_stat(&buf);
 }
 
-/*******************************************************************
- Return a string representing an attribute for a file.
-********************************************************************/
-
-char *attrib_string(TALLOC_CTX *mem_ctx, uint16 mode)
-{
-       fstring attrstr;
-
-       attrstr[0] = 0;
-
-       if (mode & FILE_ATTRIBUTE_VOLUME) fstrcat(attrstr,"V");
-       if (mode & FILE_ATTRIBUTE_DIRECTORY) fstrcat(attrstr,"D");
-       if (mode & FILE_ATTRIBUTE_ARCHIVE) fstrcat(attrstr,"A");
-       if (mode & FILE_ATTRIBUTE_HIDDEN) fstrcat(attrstr,"H");
-       if (mode & FILE_ATTRIBUTE_SYSTEM) fstrcat(attrstr,"S");
-       if (mode & FILE_ATTRIBUTE_READONLY) fstrcat(attrstr,"R");
-
-       return talloc_strdup(mem_ctx, attrstr);
-}
-
 /*******************************************************************
  Show a smb message structure.
 ********************************************************************/
index e538463..5a79983 100755 (executable)
@@ -1066,7 +1066,8 @@ bld.SAMBA3_BINARY('client/smbclient' + bld.env.suffix3,
                  source=CLIENT_SRC,
                  deps='''talloc tdb cap POPT_SAMBA3 passdb LIBSMB LIB_NONSMBD
                  PARAM_WITHOUT_REG wbclient param KRBCLIENT LIBMSRPC_GEN
-                 msrpc3 SMBREADLINE libsmb/smbclient RPC_NDR_SRVSVC INIT_LSA''',
+                 msrpc3 SMBREADLINE libsmb/smbclient RPC_NDR_SRVSVC INIT_LSA
+                 LIBCLI_SMB_COMMON''',
                  vars=locals())
 
 bld.SAMBA3_BINARY('net',
index 5797540..626067a 100644 (file)
        if (!req) return NULL; \
 } while (0)
 
-/**
- Return a string representing a CIFS attribute for a file.
-**/
-char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib)
-{
-       int i, len;
-       const struct {
-               char c;
-               uint16_t attr;
-       } attr_strs[] = {
-               {'V', FILE_ATTRIBUTE_VOLUME},
-               {'D', FILE_ATTRIBUTE_DIRECTORY},
-               {'A', FILE_ATTRIBUTE_ARCHIVE},
-               {'H', FILE_ATTRIBUTE_HIDDEN},
-               {'S', FILE_ATTRIBUTE_SYSTEM},
-               {'N', FILE_ATTRIBUTE_NORMAL},
-               {'R', FILE_ATTRIBUTE_READONLY},
-               {'d', FILE_ATTRIBUTE_DEVICE},
-               {'t', FILE_ATTRIBUTE_TEMPORARY},
-               {'s', FILE_ATTRIBUTE_SPARSE},
-               {'r', FILE_ATTRIBUTE_REPARSE_POINT},
-               {'c', FILE_ATTRIBUTE_COMPRESSED},
-               {'o', FILE_ATTRIBUTE_OFFLINE},
-               {'n', FILE_ATTRIBUTE_NONINDEXED},
-               {'e', FILE_ATTRIBUTE_ENCRYPTED}
-       };
-       char *ret;
-
-       ret = talloc_array(mem_ctx, char, ARRAY_SIZE(attr_strs)+1);
-       if (!ret) {
-               return NULL;
-       }
-
-       for (len=i=0; i<ARRAY_SIZE(attr_strs); i++) {
-               if (attrib & attr_strs[i].attr) {
-                       ret[len++] = attr_strs[i].c;
-               }
-       }
-
-       ret[len] = 0;
-
-       talloc_set_name_const(ret, ret);
-
-       return ret;
-}
-
 /****************************************************************************
  Rename a file - async interface
 ****************************************************************************/