summaryrefslogtreecommitdiff
path: root/source3/aparser/parser.c
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>2000-05-27 10:18:36 +0000
committerLuke Leighton <lkcl@samba.org>2000-05-27 10:18:36 +0000
commitd7d030f71e4cd17fae114488449d33afc129c380 (patch)
tree366410691d9b26b0d4f7425c16499c38cd5cc6bd /source3/aparser/parser.c
parent5f7c40f6d02df70dd3a92d5658f79b668e0ed5df (diff)
downloadsamba-d7d030f71e4cd17fae114488449d33afc129c380.tar.gz
samba-d7d030f71e4cd17fae114488449d33afc129c380.tar.bz2
samba-d7d030f71e4cd17fae114488449d33afc129c380.zip
SMBnttrans. modified io_uint8s to return address of actual data instead
of a copy, on unmarshalling. removed fstring, made it io_string, did same thing. io_string() and io_wstring() should be wrapped in a STRING typedef which is bit-switched on FLG2:Unicode. (This used to be commit 7db13bd53807f65a16442d2765a9d2f7ab792b4f)
Diffstat (limited to 'source3/aparser/parser.c')
-rw-r--r--source3/aparser/parser.c65
1 files changed, 39 insertions, 26 deletions
diff --git a/source3/aparser/parser.c b/source3/aparser/parser.c
index 289cf95c7b..098cc57540 100644
--- a/source3/aparser/parser.c
+++ b/source3/aparser/parser.c
@@ -325,40 +325,44 @@ BOOL io_pointer(char *desc, prs_struct *ps, int depth, void **p, unsigned flags)
/*******************************************************************
Stream a null-terminated string.
********************************************************************/
-BOOL io_fstring(char *name, prs_struct *ps, int depth, fstring *str, unsigned flags)
+BOOL io_string(char *name, prs_struct *ps, int depth, char **str, unsigned flags)
{
char *q;
uint8 *start;
int i;
- int len = sizeof(fstring)-1;
+ size_t len;
if (!(flags & PARSE_SCALARS)) return True;
- if (MARSHALLING(ps)) {
- len = MIN(len, strlen(*str));
- }
-
- start = (uint8*)q;
-
- for(i = 0; i < len; i++) {
- q = prs_mem_get(ps, 1);
- if (q == NULL)
+ if (UNMARSHALLING(ps)) {
+ *str = prs_mem_get(ps, 0);
+ if (*str == NULL)
return False;
-
- RW_CVAL(ps->io, q, (*str)[i],0);
- if ((*str)[i] == 0)
- break;
- ps->data_offset++;
+ len = strlen(*str);
+ ps->data_offset += len + 1;
}
+ else
+ {
+ len = strlen(*str);
+ start = (uint8*)q;
+
+ for(i = 0; i < len; i++) {
+ q = prs_mem_get(ps, 1);
+ if (q == NULL)
+ return False;
+
+ RW_CVAL(ps->io, q, (*str)[i],0);
+ if ((*str)[i] == 0)
+ break;
+ ps->data_offset++;
+ }
- /* The terminating null. */
- (*str)[i] = '\0';
-
- if (MARSHALLING(ps)) {
+ /* The terminating null. */
+ (*str)[i] = '\0';
RW_CVAL(ps->io, q, (*str)[i], 0);
- }
- ps->data_offset++;
+ ps->data_offset++;
+ }
DEBUG(5,("%s %s: %s\n", tab_depth(depth), name, *str));
return True;
@@ -367,19 +371,28 @@ BOOL io_fstring(char *name, prs_struct *ps, int depth, fstring *str, unsigned fl
/******************************************************************
do IO on a byte array
********************************************************************/
-BOOL io_uint8s(char *name, prs_struct *ps, int depth, uint8 *data8s, int len, unsigned flags)
+BOOL io_uint8s(char *name, prs_struct *ps, int depth, uint8 **data8s, int len, unsigned flags)
{
char *q;
+ size_t num_bytes = len * sizeof(uint8);
if (!(flags & PARSE_SCALARS)) return True;
if (!prs_align(ps, 2)) return False;
- q = prs_mem_get(ps, len * sizeof(uint8));
+ q = prs_mem_get(ps, num_bytes);
if (q == NULL) return False;
- DBG_RW_PCVAL(True, name, depth, ps->data_offset, ps->io, q, data8s, len)
- ps->data_offset += (len * sizeof(uint8));
+ if (MARSHALLING(ps))
+ {
+ DBG_RW_PCVAL(True, name, depth, ps->data_offset, ps->io, q, *data8s, len)
+ }
+ else
+ {
+ *data8s = q;
+ dump_data(depth+5, q, num_bytes);
+ }
+ ps->data_offset += num_bytes;
return True;
}