2 * CAP VFS module for Samba 3.x Version 0.3
4 * Copyright (C) Tim Potter, 1999-2000
5 * Copyright (C) Alexander Bokovoy, 2002-2003
6 * Copyright (C) Stefan (metze) Metzmacher, 2003
7 * Copyright (C) TAKAHASHI Motonobu (monyo), 2003
8 * Copyright (C) Jeremy Allison, 2007
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, see <http://www.gnu.org/licenses/>.
26 #include "smbd/smbd.h"
29 static char *capencode(TALLOC_CTX
*ctx
, const char *from
);
30 static char *capdecode(TALLOC_CTX
*ctx
, const char *from
);
32 static uint64_t cap_disk_free(vfs_handle_struct
*handle
,
33 const struct smb_filename
*smb_fname
,
38 char *capname
= capencode(talloc_tos(), smb_fname
->base_name
);
39 struct smb_filename
*cap_smb_fname
= NULL
;
45 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
51 if (cap_smb_fname
== NULL
) {
56 return SMB_VFS_NEXT_DISK_FREE(handle
, cap_smb_fname
,
60 static int cap_get_quota(vfs_handle_struct
*handle
,
61 const struct smb_filename
*smb_fname
,
62 enum SMB_QUOTA_TYPE qtype
,
66 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
67 struct smb_filename
*cap_smb_fname
= NULL
;
73 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
79 if (cap_smb_fname
== NULL
) {
84 return SMB_VFS_NEXT_GET_QUOTA(handle
, cap_smb_fname
, qtype
, id
, dq
);
87 static struct dirent
*
88 cap_readdir(vfs_handle_struct
*handle
, struct files_struct
*dirfsp
, DIR *dirp
)
90 struct dirent
*result
;
91 struct dirent
*newdirent
;
94 DEBUG(3,("cap: cap_readdir\n"));
96 result
= SMB_VFS_NEXT_READDIR(handle
, dirfsp
, dirp
);
101 newname
= capdecode(talloc_tos(), result
->d_name
);
105 DEBUG(3,("cap: cap_readdir: %s\n", newname
));
106 newnamelen
= strlen(newname
)+1;
107 newdirent
= talloc_size(
108 talloc_tos(), sizeof(struct dirent
) + newnamelen
);
112 talloc_set_name_const(newdirent
, "struct dirent");
113 memcpy(newdirent
, result
, sizeof(struct dirent
));
114 memcpy(&newdirent
->d_name
, newname
, newnamelen
);
118 static int cap_mkdirat(vfs_handle_struct
*handle
,
119 struct files_struct
*dirfsp
,
120 const struct smb_filename
*smb_fname
,
123 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
124 struct smb_filename
*cap_smb_fname
= NULL
;
131 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
137 if (cap_smb_fname
== NULL
) {
138 TALLOC_FREE(cappath
);
143 return SMB_VFS_NEXT_MKDIRAT(handle
,
149 static int cap_openat(vfs_handle_struct
*handle
,
150 const struct files_struct
*dirfsp
,
151 const struct smb_filename
*smb_fname_in
,
153 const struct vfs_open_how
*how
)
155 char *cappath
= NULL
;
156 struct smb_filename
*smb_fname
= NULL
;
160 cappath
= capencode(talloc_tos(), smb_fname_in
->base_name
);
161 if (cappath
== NULL
) {
166 smb_fname
= cp_smb_filename(talloc_tos(), smb_fname_in
);
167 if (smb_fname
== NULL
) {
168 TALLOC_FREE(cappath
);
172 smb_fname
->base_name
= cappath
;
174 DBG_DEBUG("cap_open for %s\n", smb_fname_str_dbg(smb_fname
));
175 ret
= SMB_VFS_NEXT_OPENAT(handle
,
183 TALLOC_FREE(cappath
);
184 TALLOC_FREE(smb_fname
);
185 if (saved_errno
!= 0) {
191 static int cap_renameat(vfs_handle_struct
*handle
,
192 files_struct
*srcfsp
,
193 const struct smb_filename
*smb_fname_src
,
194 files_struct
*dstfsp
,
195 const struct smb_filename
*smb_fname_dst
)
199 struct smb_filename
*smb_fname_src_tmp
= NULL
;
200 struct smb_filename
*smb_fname_dst_tmp
= NULL
;
201 struct smb_filename
*full_fname_src
= NULL
;
202 struct smb_filename
*full_fname_dst
= NULL
;
206 full_fname_src
= full_path_from_dirfsp_atname(talloc_tos(),
209 if (full_fname_src
== NULL
) {
214 full_fname_dst
= full_path_from_dirfsp_atname(talloc_tos(),
217 if (full_fname_dst
== NULL
) {
222 capold
= capencode(talloc_tos(), full_fname_src
->base_name
);
223 capnew
= capencode(talloc_tos(), full_fname_dst
->base_name
);
224 if (!capold
|| !capnew
) {
229 /* Setup temporary smb_filename structs. */
230 smb_fname_src_tmp
= cp_smb_filename(talloc_tos(), full_fname_src
);
231 if (smb_fname_src_tmp
== NULL
) {
235 smb_fname_dst_tmp
= cp_smb_filename(talloc_tos(), full_fname_dst
);
236 if (smb_fname_dst_tmp
== NULL
) {
241 smb_fname_src_tmp
->base_name
= capold
;
242 smb_fname_dst_tmp
->base_name
= capnew
;
244 ret
= SMB_VFS_NEXT_RENAMEAT(handle
,
245 srcfsp
->conn
->cwd_fsp
,
247 dstfsp
->conn
->cwd_fsp
,
256 TALLOC_FREE(full_fname_src
);
257 TALLOC_FREE(full_fname_dst
);
260 TALLOC_FREE(smb_fname_src_tmp
);
261 TALLOC_FREE(smb_fname_dst_tmp
);
270 static int cap_stat(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
)
273 char *tmp_base_name
= NULL
;
276 cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
283 tmp_base_name
= smb_fname
->base_name
;
284 smb_fname
->base_name
= cappath
;
286 ret
= SMB_VFS_NEXT_STAT(handle
, smb_fname
);
288 smb_fname
->base_name
= tmp_base_name
;
289 TALLOC_FREE(cappath
);
294 static int cap_lstat(vfs_handle_struct
*handle
, struct smb_filename
*smb_fname
)
297 char *tmp_base_name
= NULL
;
300 cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
307 tmp_base_name
= smb_fname
->base_name
;
308 smb_fname
->base_name
= cappath
;
310 ret
= SMB_VFS_NEXT_LSTAT(handle
, smb_fname
);
312 smb_fname
->base_name
= tmp_base_name
;
313 TALLOC_FREE(cappath
);
318 static int cap_unlinkat(vfs_handle_struct
*handle
,
319 struct files_struct
*dirfsp
,
320 const struct smb_filename
*smb_fname
,
323 struct smb_filename
*full_fname
= NULL
;
324 struct smb_filename
*smb_fname_tmp
= NULL
;
325 char *cappath
= NULL
;
328 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
331 if (full_fname
== NULL
) {
335 cappath
= capencode(talloc_tos(), full_fname
->base_name
);
337 TALLOC_FREE(full_fname
);
342 /* Setup temporary smb_filename structs. */
343 smb_fname_tmp
= cp_smb_filename(talloc_tos(), full_fname
);
344 TALLOC_FREE(full_fname
);
345 if (smb_fname_tmp
== NULL
) {
350 smb_fname_tmp
->base_name
= cappath
;
352 ret
= SMB_VFS_NEXT_UNLINKAT(handle
,
353 dirfsp
->conn
->cwd_fsp
,
357 TALLOC_FREE(smb_fname_tmp
);
361 static int cap_lchown(vfs_handle_struct
*handle
,
362 const struct smb_filename
*smb_fname
,
366 struct smb_filename
*cap_smb_fname
= NULL
;
367 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
376 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
382 if (cap_smb_fname
== NULL
) {
383 TALLOC_FREE(cappath
);
388 ret
= SMB_VFS_NEXT_LCHOWN(handle
, cap_smb_fname
, uid
, gid
);
390 TALLOC_FREE(cappath
);
391 TALLOC_FREE(cap_smb_fname
);
396 static int cap_chdir(vfs_handle_struct
*handle
,
397 const struct smb_filename
*smb_fname
)
399 struct smb_filename
*cap_smb_fname
= NULL
;
400 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
408 DEBUG(3,("cap: cap_chdir for %s\n", smb_fname
->base_name
));
410 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
416 if (cap_smb_fname
== NULL
) {
417 TALLOC_FREE(cappath
);
421 ret
= SMB_VFS_NEXT_CHDIR(handle
, cap_smb_fname
);
425 TALLOC_FREE(cappath
);
426 TALLOC_FREE(cap_smb_fname
);
427 if (saved_errno
!= 0) {
433 static int cap_symlinkat(vfs_handle_struct
*handle
,
434 const struct smb_filename
*link_contents
,
435 struct files_struct
*dirfsp
,
436 const struct smb_filename
*new_smb_fname
)
438 struct smb_filename
*full_fname
= NULL
;
439 char *capold
= capencode(talloc_tos(), link_contents
->base_name
);
441 struct smb_filename
*new_link_target
= NULL
;
442 struct smb_filename
*new_cap_smb_fname
= NULL
;
446 if (capold
== NULL
) {
451 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
454 if (full_fname
== NULL
) {
458 capnew
= capencode(talloc_tos(), full_fname
->base_name
);
460 TALLOC_FREE(full_fname
);
465 new_link_target
= synthetic_smb_fname(talloc_tos(),
470 new_smb_fname
->flags
);
471 if (new_link_target
== NULL
) {
472 TALLOC_FREE(full_fname
);
479 new_cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
484 new_smb_fname
->flags
);
485 if (new_cap_smb_fname
== NULL
) {
486 TALLOC_FREE(full_fname
);
489 TALLOC_FREE(new_link_target
);
493 ret
= SMB_VFS_NEXT_SYMLINKAT(handle
,
495 handle
->conn
->cwd_fsp
,
500 TALLOC_FREE(full_fname
);
503 TALLOC_FREE(new_link_target
);
504 TALLOC_FREE(new_cap_smb_fname
);
505 if (saved_errno
!= 0) {
511 static int cap_readlinkat(vfs_handle_struct
*handle
,
512 const struct files_struct
*dirfsp
,
513 const struct smb_filename
*smb_fname
,
517 struct smb_filename
*full_fname
= NULL
;
518 struct smb_filename
*cap_smb_fname
= NULL
;
519 char *cappath
= NULL
;
523 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
526 if (full_fname
== NULL
) {
530 cappath
= capencode(talloc_tos(), full_fname
->base_name
);
531 if (cappath
== NULL
) {
532 TALLOC_FREE(full_fname
);
536 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
542 if (cap_smb_fname
== NULL
) {
543 TALLOC_FREE(full_fname
);
544 TALLOC_FREE(cappath
);
548 ret
= SMB_VFS_NEXT_READLINKAT(handle
,
549 handle
->conn
->cwd_fsp
,
556 TALLOC_FREE(full_fname
);
557 TALLOC_FREE(cappath
);
558 TALLOC_FREE(cap_smb_fname
);
559 if (saved_errno
!= 0) {
565 static int cap_linkat(vfs_handle_struct
*handle
,
566 files_struct
*srcfsp
,
567 const struct smb_filename
*old_smb_fname
,
568 files_struct
*dstfsp
,
569 const struct smb_filename
*new_smb_fname
,
572 struct smb_filename
*old_full_fname
= NULL
;
573 struct smb_filename
*new_full_fname
= NULL
;
576 struct smb_filename
*old_cap_smb_fname
= NULL
;
577 struct smb_filename
*new_cap_smb_fname
= NULL
;
581 /* Process 'old' name. */
582 old_full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
585 if (old_full_fname
== NULL
) {
588 capold
= capencode(talloc_tos(), old_full_fname
->base_name
);
589 if (capold
== NULL
) {
592 TALLOC_FREE(old_full_fname
);
593 old_cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
598 old_smb_fname
->flags
);
599 if (old_cap_smb_fname
== NULL
) {
603 /* Process 'new' name. */
604 new_full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
607 if (new_full_fname
== NULL
) {
610 capnew
= capencode(talloc_tos(), new_full_fname
->base_name
);
611 if (capnew
== NULL
) {
614 TALLOC_FREE(new_full_fname
);
615 new_cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
620 new_smb_fname
->flags
);
621 if (new_cap_smb_fname
== NULL
) {
625 ret
= SMB_VFS_NEXT_LINKAT(handle
,
626 handle
->conn
->cwd_fsp
,
628 handle
->conn
->cwd_fsp
,
634 TALLOC_FREE(old_full_fname
);
635 TALLOC_FREE(old_full_fname
);
638 TALLOC_FREE(old_cap_smb_fname
);
639 TALLOC_FREE(new_cap_smb_fname
);
640 if (saved_errno
!= 0) {
647 TALLOC_FREE(old_full_fname
);
648 TALLOC_FREE(old_full_fname
);
651 TALLOC_FREE(old_cap_smb_fname
);
652 TALLOC_FREE(new_cap_smb_fname
);
657 static int cap_mknodat(vfs_handle_struct
*handle
,
658 files_struct
*dirfsp
,
659 const struct smb_filename
*smb_fname
,
663 struct smb_filename
*full_fname
= NULL
;
664 struct smb_filename
*cap_smb_fname
= NULL
;
665 char *cappath
= NULL
;
669 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
672 if (full_fname
== NULL
) {
676 cappath
= capencode(talloc_tos(), full_fname
->base_name
);
678 TALLOC_FREE(full_fname
);
682 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
688 if (cap_smb_fname
== NULL
) {
689 TALLOC_FREE(full_fname
);
690 TALLOC_FREE(cappath
);
694 ret
= SMB_VFS_NEXT_MKNODAT(handle
,
695 handle
->conn
->cwd_fsp
,
702 TALLOC_FREE(full_fname
);
703 TALLOC_FREE(cappath
);
704 TALLOC_FREE(cap_smb_fname
);
705 if (saved_errno
!= 0) {
711 static struct smb_filename
*cap_realpath(vfs_handle_struct
*handle
,
713 const struct smb_filename
*smb_fname
)
715 /* monyo need capencode'ed and capdecode'ed? */
716 struct smb_filename
*cap_smb_fname
= NULL
;
717 struct smb_filename
*return_fname
= NULL
;
718 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
725 cap_smb_fname
= synthetic_smb_fname(ctx
,
731 if (cap_smb_fname
== NULL
) {
732 TALLOC_FREE(cappath
);
736 return_fname
= SMB_VFS_NEXT_REALPATH(handle
, ctx
, cap_smb_fname
);
737 if (return_fname
== NULL
) {
740 TALLOC_FREE(cappath
);
741 TALLOC_FREE(cap_smb_fname
);
742 if (saved_errno
!= 0) {
748 static ssize_t
cap_fgetxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *path
, void *value
, size_t size
)
750 char *cappath
= capencode(talloc_tos(), path
);
756 return SMB_VFS_NEXT_FGETXATTR(handle
, fsp
, cappath
, value
, size
);
759 static int cap_fremovexattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *path
)
761 char *cappath
= capencode(talloc_tos(), path
);
767 return SMB_VFS_NEXT_FREMOVEXATTR(handle
, fsp
, cappath
);
770 static int cap_fsetxattr(vfs_handle_struct
*handle
, struct files_struct
*fsp
, const char *path
, const void *value
, size_t size
, int flags
)
772 char *cappath
= capencode(talloc_tos(), path
);
778 return SMB_VFS_NEXT_FSETXATTR(handle
, fsp
, cappath
, value
, size
, flags
);
781 static NTSTATUS
cap_create_dfs_pathat(vfs_handle_struct
*handle
,
782 files_struct
*dirfsp
,
783 const struct smb_filename
*smb_fname
,
784 const struct referral
*reflist
,
785 size_t referral_count
)
787 char *cappath
= capencode(talloc_tos(), smb_fname
->base_name
);
788 struct smb_filename
*cap_smb_fname
= NULL
;
791 if (cappath
== NULL
) {
792 return NT_STATUS_NO_MEMORY
;
794 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
800 if (cap_smb_fname
== NULL
) {
801 TALLOC_FREE(cappath
);
802 return NT_STATUS_NO_MEMORY
;
804 status
= SMB_VFS_NEXT_CREATE_DFS_PATHAT(handle
,
809 TALLOC_FREE(cappath
);
810 TALLOC_FREE(cap_smb_fname
);
814 static NTSTATUS
cap_read_dfs_pathat(struct vfs_handle_struct
*handle
,
816 struct files_struct
*dirfsp
,
817 struct smb_filename
*smb_fname
,
818 struct referral
**ppreflist
,
819 size_t *preferral_count
)
821 struct smb_filename
*full_fname
= NULL
;
822 struct smb_filename
*cap_smb_fname
= NULL
;
823 char *cappath
= NULL
;
826 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
829 if (full_fname
== NULL
) {
830 return NT_STATUS_NO_MEMORY
;
832 cappath
= capencode(talloc_tos(), full_fname
->base_name
);
833 if (cappath
== NULL
) {
834 TALLOC_FREE(full_fname
);
835 return NT_STATUS_NO_MEMORY
;
837 cap_smb_fname
= synthetic_smb_fname(talloc_tos(),
843 if (cap_smb_fname
== NULL
) {
844 TALLOC_FREE(full_fname
);
845 TALLOC_FREE(cappath
);
846 return NT_STATUS_NO_MEMORY
;
849 status
= SMB_VFS_NEXT_READ_DFS_PATHAT(handle
,
851 handle
->conn
->cwd_fsp
,
856 if (NT_STATUS_IS_OK(status
)) {
857 /* Return any stat(2) info. */
858 smb_fname
->st
= cap_smb_fname
->st
;
861 TALLOC_FREE(full_fname
);
862 TALLOC_FREE(cappath
);
863 TALLOC_FREE(cap_smb_fname
);
867 static struct vfs_fn_pointers vfs_cap_fns
= {
868 .disk_free_fn
= cap_disk_free
,
869 .get_quota_fn
= cap_get_quota
,
870 .readdir_fn
= cap_readdir
,
871 .mkdirat_fn
= cap_mkdirat
,
872 .openat_fn
= cap_openat
,
873 .renameat_fn
= cap_renameat
,
875 .lstat_fn
= cap_lstat
,
876 .unlinkat_fn
= cap_unlinkat
,
877 .lchown_fn
= cap_lchown
,
878 .chdir_fn
= cap_chdir
,
879 .symlinkat_fn
= cap_symlinkat
,
880 .readlinkat_fn
= cap_readlinkat
,
881 .linkat_fn
= cap_linkat
,
882 .mknodat_fn
= cap_mknodat
,
883 .realpath_fn
= cap_realpath
,
884 .getxattrat_send_fn
= vfs_not_implemented_getxattrat_send
,
885 .getxattrat_recv_fn
= vfs_not_implemented_getxattrat_recv
,
886 .fgetxattr_fn
= cap_fgetxattr
,
887 .fremovexattr_fn
= cap_fremovexattr
,
888 .fsetxattr_fn
= cap_fsetxattr
,
889 .create_dfs_pathat_fn
= cap_create_dfs_pathat
,
890 .read_dfs_pathat_fn
= cap_read_dfs_pathat
894 NTSTATUS
vfs_cap_init(TALLOC_CTX
*ctx
)
896 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "cap",
900 /* For CAP functions */
902 #define hex2bin(c) hex2bin_table[(unsigned char)(c)]
903 #define bin2hex(c) bin2hex_table[(unsigned char)(c)]
904 #define is_hex(s) ((s)[0] == hex_tag)
906 static unsigned char hex2bin_table
[256] = {
907 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */
908 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */
909 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */
910 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, /* 0x30 */
911 0000, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0000, /* 0x40 */
912 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
913 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 */
914 0000, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0000, /* 0x60 */
915 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
916 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 */
917 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 */
918 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 */
919 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 */
920 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 */
921 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 */
922 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 */
923 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 */
924 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0xf0 */
926 static unsigned char bin2hex_table
[256] = "0123456789abcdef";
928 /*******************************************************************
929 original code -> ":xx" - CAP format
930 ********************************************************************/
932 static char *capencode(TALLOC_CTX
*ctx
, const char *from
)
939 for (p1
= from
; *p1
; p1
++) {
940 if ((unsigned char)*p1
>= 0x80) {
948 to
= talloc_array(ctx
, char, len
);
953 for (out
= to
; *from
;) {
954 /* buffer husoku error */
955 if ((unsigned char)*from
>= 0x80) {
957 *out
++ = bin2hex (((*from
)>>4)&0x0f);
958 *out
++ = bin2hex ((*from
)&0x0f);
968 /*******************************************************************
970 ********************************************************************/
971 /* ":xx" -> a byte */
973 static char *capdecode(TALLOC_CTX
*ctx
, const char *from
)
980 for (p1
= from
; *p1
; len
++) {
989 to
= talloc_array(ctx
, char, len
);
994 for (out
= to
; *from
;) {
996 *out
++ = (hex2bin(from
[1])<<4) | (hex2bin(from
[2]));