summaryrefslogtreecommitdiffstats
path: root/libcli
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-04-29 12:41:27 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-04-29 16:38:14 +1000
commit6021af4fd38d2a712dca42a3cacf8537007fd160 (patch)
tree23673e8e5aa8f75c3b5635957dc92231f81fd2c1 /libcli
parent724915f721819705c7cf5c850a24b32f815c07e3 (diff)
downloadsamba-6021af4fd38d2a712dca42a3cacf8537007fd160.tar.gz
samba-6021af4fd38d2a712dca42a3cacf8537007fd160.tar.xz
samba-6021af4fd38d2a712dca42a3cacf8537007fd160.zip
libcli/smb Move attrib_string in common
Diffstat (limited to 'libcli')
-rw-r--r--libcli/smb/smb_common.h1
-rw-r--r--libcli/smb/smb_util.h22
-rw-r--r--libcli/smb/util.c69
-rw-r--r--libcli/smb/wscript_build2
4 files changed, 93 insertions, 1 deletions
diff --git a/libcli/smb/smb_common.h b/libcli/smb/smb_common.h
index 8fe0623727..ca04eb30c3 100644
--- a/libcli/smb/smb_common.h
+++ b/libcli/smb/smb_common.h
@@ -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
index 0000000000..8a67c30913
--- /dev/null
+++ b/libcli/smb/smb_util.h
@@ -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
index 0000000000..f8fa56ff6a
--- /dev/null
+++ b/libcli/smb/util.c
@@ -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;
+}
diff --git a/libcli/smb/wscript_build b/libcli/smb/wscript_build
index 6796b4c7fb..36d9d1033a 100644
--- a/libcli/smb/wscript_build
+++ b/libcli/smb/wscript_build
@@ -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'
)