source: vendor/current/source3/libsmb/clistr.c@ 740

Last change on this file since 740 was 740, checked in by Silvan Scherrer, 12 years ago

Samba Server: update vendor to 3.6.0

File size: 2.6 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 client string routines
4 Copyright (C) Andrew Tridgell 2001
5 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2003
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#include "includes.h"
22#include "libsmb/libsmb.h"
23
24size_t clistr_push_fn(const char *function,
25 unsigned int line,
26 struct cli_state *cli,
27 void *dest,
28 const char *src,
29 int dest_len,
30 int flags)
31{
32 size_t buf_used = PTR_DIFF(dest, cli->outbuf);
33 if (dest_len == -1) {
34 if (((ptrdiff_t)dest < (ptrdiff_t)cli->outbuf) || (buf_used > cli->bufsize)) {
35 DEBUG(0, ("Pushing string of 'unlimited' length into non-SMB buffer!\n"));
36 return push_string_base(function, line,
37 cli->outbuf,
38 (uint16_t)(cli_ucs2(cli) ? FLAGS2_UNICODE_STRINGS : 0),
39 dest, src, -1, flags);
40 }
41 return push_string_base(function, line,
42 cli->outbuf,
43 (uint16_t)(cli_ucs2(cli) ? FLAGS2_UNICODE_STRINGS : 0),
44 dest, src, cli->bufsize - buf_used,
45 flags);
46 }
47
48 /* 'normal' push into size-specified buffer */
49 return push_string_base(function, line,
50 cli->outbuf,
51 (uint16_t)(cli_ucs2(cli) ? FLAGS2_UNICODE_STRINGS : 0),
52 dest, src, dest_len, flags);
53}
54
55size_t clistr_pull_fn(const char *function,
56 unsigned int line,
57 const char *inbuf,
58 char *dest,
59 const void *src,
60 int dest_len,
61 int src_len,
62 int flags)
63{
64 return pull_string_fn(function, line, inbuf,
65 SVAL(inbuf, smb_flg2), dest, src, dest_len,
66 src_len, flags);
67}
68
69size_t clistr_pull_talloc_fn(const char *function,
70 unsigned int line,
71 TALLOC_CTX *ctx,
72 const char *base,
73 uint16_t flags2,
74 char **pp_dest,
75 const void *src,
76 int src_len,
77 int flags)
78{
79 return pull_string_talloc_fn(function,
80 line,
81 ctx,
82 base,
83 flags2,
84 pp_dest,
85 src,
86 src_len,
87 flags);
88}
89
90size_t clistr_align_out(struct cli_state *cli, const void *p, int flags)
91{
92 return align_string(cli->outbuf, (const char *)p, flags);
93}
Note: See TracBrowser for help on using the repository browser.