summaryrefslogtreecommitdiff
path: root/source3/aparser/parser.c
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>2000-05-27 01:21:27 +0000
committerLuke Leighton <lkcl@samba.org>2000-05-27 01:21:27 +0000
commit5c6a7861bf4d371a16eb51e0f3a512e6b405d0b7 (patch)
tree243ddbe78a2340f018d1e907a5359dc1a006c7d3 /source3/aparser/parser.c
parenta0e1930489523b3c9682e6f90db710553cd70084 (diff)
downloadsamba-5c6a7861bf4d371a16eb51e0f3a512e6b405d0b7.tar.gz
samba-5c6a7861bf4d371a16eb51e0f3a512e6b405d0b7.tar.bz2
samba-5c6a7861bf4d371a16eb51e0f3a512e6b405d0b7.zip
cifs parser.
(This used to be commit 96fd33b8982d4d7ff1eef6f2ef836381d443b143)
Diffstat (limited to 'source3/aparser/parser.c')
-rw-r--r--source3/aparser/parser.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/source3/aparser/parser.c b/source3/aparser/parser.c
index 0e5f29b2bc..289cf95c7b 100644
--- a/source3/aparser/parser.c
+++ b/source3/aparser/parser.c
@@ -171,6 +171,8 @@ BOOL prs_align(prs_struct *ps, int align)
{
uint32 mod = ps->data_offset & (align-1);
+ return True;
+
if (align != 0 && mod != 0) {
uint32 extra_space = (align - mod);
if(!prs_grow(ps, extra_space))
@@ -320,6 +322,69 @@ BOOL io_pointer(char *desc, prs_struct *ps, int depth, void **p, unsigned flags)
return True;
}
+/*******************************************************************
+ Stream a null-terminated string.
+ ********************************************************************/
+BOOL io_fstring(char *name, prs_struct *ps, int depth, fstring *str, unsigned flags)
+{
+ char *q;
+ uint8 *start;
+ int i;
+ int len = sizeof(fstring)-1;
+
+ 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)
+ 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)) {
+ RW_CVAL(ps->io, q, (*str)[i], 0);
+ }
+
+ ps->data_offset++;
+
+ DEBUG(5,("%s %s: %s\n", tab_depth(depth), name, *str));
+ return True;
+}
+
+/******************************************************************
+ do IO on a byte array
+ ********************************************************************/
+BOOL io_uint8s(char *name, prs_struct *ps, int depth, uint8 *data8s, int len, unsigned flags)
+{
+ char *q;
+
+ if (!(flags & PARSE_SCALARS)) return True;
+
+ if (!prs_align(ps, 2)) return False;
+
+ q = prs_mem_get(ps, len * sizeof(uint8));
+ 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));
+
+ return True;
+}
+
+
/******************************************************************
do IO on a unicode array
********************************************************************/
@@ -351,3 +416,13 @@ BOOL io_alloc(char *name, prs_struct *ps, void **ptr, unsigned size)
return False;
}
+/******************************************************************
+realloc some memory for a parse structure
+ ********************************************************************/
+BOOL io_realloc(char *name, prs_struct *ps, void **ptr, unsigned size)
+{
+ (*ptr) = (void *)Realloc(*ptr, size);
+ if (*ptr) return True;
+ return False;
+}
+