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 2 of the License, or
+ 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,
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, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "system/filesys.h"
#include "system/network.h"
#include "tdr/tdr.h"
+#include "param/param.h"
#define TDR_BASE_MARSHALL_SIZE 1024
TDR_PULL_NEED_BYTES(tdr, el_size*length);
- ret = convert_string_talloc(ctx, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v));
+ ret = convert_string_talloc(ctx, tdr->iconv_convenience, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v));
if (ret == -1) {
return NT_STATUS_INVALID_PARAMETER;
required = el_size * length;
TDR_PUSH_NEED_BYTES(tdr, required);
- ret = convert_string(CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required);
+ ret = convert_string(tdr->iconv_convenience, CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required);
if (ret == -1) {
return NT_STATUS_INVALID_PARAMETER;
return NT_STATUS_OK;
}
-/**
- pull a ipv4address
-*/
-NTSTATUS tdr_pull_ipv4address(struct tdr_pull *tdr, TALLOC_CTX *ctx,
- const char **address)
-{
- struct ipv4_addr in;
- TDR_CHECK(tdr_pull_uint32(tdr, ctx, &in.addr));
- in.addr = htonl(in.addr);
- *address = talloc_strdup(tdr, sys_inet_ntoa(in));
- NT_STATUS_HAVE_NO_MEMORY(*address);
- return NT_STATUS_OK;
-}
-
-/**
- push a ipv4address
-*/
-NTSTATUS tdr_push_ipv4address(struct tdr_push *tdr, const char **address)
-{
- uint32_t addr = htonl(interpret_addr(*address));
- TDR_CHECK(tdr_push_uint32(tdr, &addr));
- return NT_STATUS_OK;
-}
-
-/**
- print a ipv4address
-*/
-NTSTATUS tdr_print_ipv4address(struct tdr_print *tdr, const char *name,
- const char **address)
-{
- tdr->print(tdr, "%-25s: %s", name, *address);
- return NT_STATUS_OK;
-}
-
/**
parse a hyper
*/
return NT_STATUS_OK;
}
-NTSTATUS tdr_push_to_fd(int fd, tdr_push_fn_t push_fn, const void *p)
+struct tdr_push *tdr_push_init(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *ic)
+{
+ struct tdr_push *push = talloc_zero(mem_ctx, struct tdr_push);
+
+ if (push == NULL)
+ return NULL;
+
+ push->iconv_convenience = talloc_reference(push, ic);
+
+ return push;
+}
+
+struct tdr_pull *tdr_pull_init(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *ic)
+{
+ struct tdr_pull *pull = talloc_zero(mem_ctx, struct tdr_pull);
+
+ if (pull == NULL)
+ return NULL;
+
+ pull->iconv_convenience = talloc_reference(pull, ic);
+
+ return pull;
+}
+
+NTSTATUS tdr_push_to_fd(int fd, struct smb_iconv_convenience *iconv_convenience, tdr_push_fn_t push_fn, const void *p)
{
- struct tdr_push *push = talloc_zero(NULL, struct tdr_push);
+ struct tdr_push *push = tdr_push_init(NULL, iconv_convenience);
if (push == NULL)
return NT_STATUS_NO_MEMORY;
vasprintf(&s, format, ap);
va_end(ap);
- for (i=0;i<tdr->level;i++) {
- DEBUG(0,(" "));
- }
+ for (i=0;i<tdr->level;i++) { DEBUG(0,(" ")); }
DEBUG(0,("%s\n", s));
free(s);