1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-28 17:47:29 +03:00

r7140: removing aparser directory since it is obselete in light of pidl

(This used to be commit 38cad678b8058d5ac99b41c0be07f4c58a720cfc)
This commit is contained in:
Gerald Carter 2005-05-31 13:48:37 +00:00 committed by Gerald (Jerry) Carter
parent f24d88cf9d
commit 049d6714cb
56 changed files with 0 additions and 4009 deletions

View File

@ -1,17 +0,0 @@
CFLAGS=-Wall -g
CC=gcc
OBJ = vluke.o parser.o
AWKPROGS=dump.awk harness.awk header.awk parsefn.awk main.awk parsetree.awk template.awk util.awk
all: test.h vluke
test.h : $(AWKPROGS)
igawk -f main.awk srvsvc.struct
vluke: test.h $(OBJ)
$(CC) $(CFLAGS) -o vluke $(OBJ)
clean:
rm -f *.o test.h prs_*.[ch]

View File

@ -1,13 +0,0 @@
#!/bin/sh
file=$1
if ! igawk -f main.awk $file; then
echo parse failed;
exit 1;
fi
echo compiling vluke
gcc -Wall -g -o vluke parser.c vluke.c util.c
echo done.

File diff suppressed because it is too large Load Diff

View File

@ -1,70 +0,0 @@
# dump the current parse tree
function element_string(elnum,
LOCAL, elem)
{
elem = elements[elnum, "elem"];
if (elements[elnum, "ptr"]=="1") elem="*"elem;
if (elements[elnum, "array_len"]!="")
elem=elem"["elements[elnum, "array_len"]"]";
if (elements[elnum, "switch"]!="")
elem=elem"["elements[elnum, "switch"]"]";
return elem;
}
function dump_element(f, elnum,
LOCAL, elem, type)
{
type = elements[elnum, "type"];
case = elements[elnum, "case"];
elem = element_string(elnum);
if (case != "") {
xprintf(f,"\t\tcase %d %s %s;\n", case, type, elem);
} else {
xprintf(f,"\t%s %s;\n", type, elem);
}
}
function dump_union(f, elnum,
LOCAL, i)
{
xprintf(f,"\tunion %s {\n", element_string(elnum));
for (i=0;i<unions[elnum, "num_elems"];i++) {
dump_element(f, unions[elnum, i]);
}
xprintf(f,"\t}\n");
}
function dump_elem(f, struct_num, elem_num,
LOCAL, enum)
{
elnum = structs[struct_num, elem_num];
if (elements[elnum, "type"] == "union") {
dump_union(f, elnum);
} else {
dump_element(f, elnum);
}
}
function dump_structs(f, NIL,
LOCAL, i, j)
{
xprintf(f,"/* dump of parsed structures */\n\n\n");
for (i=0;i < num_options;i++) {
xprintf(f,"option %s %s\n", options[i, "name"], options[i, "value"]);
}
xprintf(f,"\n\n");
for (i=0;i < num_structs;i++) {
xprintf(f,"/* structure %d */\n", i);
xprintf(f,"struct %s {\n", structs[i, "name"]);
for (j=0;j<structs[i, "num_elems"];j++) {
dump_elem(f, i, j);
}
xprintf(f,"};\n\n");
}
xprintf(f,"/* end dump */\n\n");
}

View File

@ -1,17 +0,0 @@
function produce_harness(f,
LOCAL, v, struct_num, i)
{
struct_num=structs[test];
v["MODULE"]=module;
print_template(f, "harness_start.tpl", v);
for (i=0;i<num_structs;i++) {
v["TEST"] = structs[i, "name"];
print_template(f, "harness.tpl", v);
}
print_template(f, "harness_end.tpl", v);
}

View File

@ -1,80 +0,0 @@
# produce a header file for a parsed struct file
function header_elstring(elnum,
LOCAL, elem)
{
array_len = elements[elnum, "array_len"];
elem=elements[elnum, "elem"];
if (elements[elnum, "ptr"]=="1") elem="*"elem;
if (array_len!="") {
if (is_constant(array_len) == 1) {
elem=elem"["array_len"]";
} else {
elem="*"elem;
}
}
return elem;
}
function header_element(f, elnum,
LOCAL, type)
{
type=elements[elnum, "type"];
if (substr(type,1,1) == ".") return;
xprintf(f,"\t%s %s;\n", type, header_elstring(elnum));
}
function header_union(f, elnum,
LOCAL, i)
{
xprintf(f,"\tunion {\n");
for (i=0;i<unions[elnum, "num_elems"];i++) {
header_element(f, unions[elnum, i]);
}
xprintf(f,"\t} %s;\n", header_elstring(elnum));
}
function header_elem(f, elnum)
{
if (elements[elnum, "type"] == "union") {
header_union(f, elnum);
} else {
header_element(f, elnum);
}
}
function header_struct(f, struct_num,
LOCAL, i)
{
xprintf(f,"/* structure %s */\n",
structs[struct_num, "name"]);
xprintf(f,"typedef struct {\n");
for (i=0;i < structs[struct_num, "num_elems"];i++) {
header_elem(f, structs[struct_num, i]);
}
xprintf(f,"} %s;\n\n\n", structs[struct_num, "name"]);
}
function produce_headers(f, NIL,
LOCAL, i)
{
xprintf(f,"/* auto-generated headers for %s */\n\n\n", module);
xprintf(f,"#ifndef _%s_\n", module);
xprintf(f,"#define _%s_\n", module);
xprintf(f,"\n\n");
for (i=0;i < num_options;i++) {
xprintf(f,"#define OPTION_%s %s\n",
options[i, "name"], options[i, "value"]);
}
xprintf(f,"\n\n");
for (i=0;i < num_structs;i++) {
header_struct(f, i);
}
xprintf(f,"/* end auto-generated headers */\n\n");
xprintf(f,"#endif /* _%s_ */\n", module);
}

View File

@ -1,25 +0,0 @@
# the main program
@include dump.awk
@include header.awk
@include util.awk
@include template.awk
#@include parsefn.awk
@include parserel.awk
@include harness.awk
@include parsetree.awk
@include token.awk
END {
dump_structs("dump.out");
printf("Producing headers...\n");
produce_headers("prs_"module".h");
# printf("Producing parsers...\n");
# produce_parsers("prs_"module".c", "mod_"module".c");
printf("Producing relative parsers...\n");
produce_relative("prs_"module".c");
printf("Producing harness...\n");
produce_harness("test.h");
printf("Done.\n");
exit 0;
}

View File

@ -1,271 +0,0 @@
# build parse functions for a parsed struct file
function elem_name(v, elem)
{
return v["UNION"]elem;
}
function parse_array(f, v, elnum, flags,
LOCAL, type, elem, array_len)
{
type = elements[elnum, "type"];
elem = elements[elnum, "elem"];
array_len = elements[elnum, "array_len"];
v["ELEM"] = elem_name(v, elem);
v["TYPE"] = type;
v["FLAGS"] = flags;
v["ARRAY_LEN"] = array_len;
if (array_len=="+") {
print_template(f,"prs_array_optional.tpl", v);
return;
}
if (array_len=="*") {
print_template(f,"prs_array_remainder.tpl", v);
return;
}
if (type == "wchar" || type == "uint16") {
if (match(array_len,"[0-9]") == 1) {
print_template(f, "prs_wstring_fixed.tpl", v);
} else {
print_template(f, "prs_wstring.tpl", v);
}
} else if (type == "uint8") {
if (match(array_len,"[0-9]") == 1) {
print_template(f, "prs_uint8s_fixed.tpl", v);
} else {
print_template(f, "prs_uint8s.tpl", v);
}
} else {
print_template(f, "prs_array.tpl", v);
}
}
function parse_element(f, v, elnum, flags,
LOCAL, type, elem)
{
if (elements[elnum,"nowire"] != "") {
return;
}
type = elements[elnum, "type"];
if (substr(type,1,1) == ".") return;
elem = elements[elnum, "elem"];
if (elements[elnum,"ptr"] == "") {
v["PTR"] = "\\&";
} else {
v["PTR"] = " ";
}
v["ELEM"] = elem_name(v, elem);
v["TYPE"] = type;
v["FLAGS"] = flags;
print_template(f, "prs_element.tpl", v);
}
function parse_union(f, v, elnum, flags,
LOCAL, i)
{
v["UNION"] = elements[elnum, "elem"];
v["SWITCH"] = elements[elnum, "switch"];
if (elements[elnum, "ptr"] == "1") {
v["UNION"] = v["UNION"]"->";
} else {
v["UNION"] = v["UNION"]".";
}
print_template(f, "union_start.tpl", v);
for (i=0;i<unions[elnum, "num_elems"];i++) {
v["CASE"] = elements[unions[elnum, i], "case"];
print_template(f, "prs_case.tpl", v);
if (elements[elnum, "ptr"] == "1") {
parse_scalars(f, v, unions[elnum, i], "PARSE_SCALARS");
parse_buffers(f, v, unions[elnum, i], "PARSE_BUFFERS");
} else {
if (flags == "PARSE_SCALARS") {
parse_scalars(f, v, unions[elnum, i], flags);
} else {
parse_buffers(f, v, unions[elnum, i], flags);
}
}
print_template(f, "prs_break.tpl", v);
}
v["UNION"] = "";
print_template(f, "union_end.tpl", v);
}
function parse_scalar(f, v, elnum, flags)
{
if (elements[elnum, "type"] == "union") {
parse_union(f, v, elnum, flags);
} else if (elements[elnum, "array_len"]!="") {
parse_array(f, v, elnum, flags);
} else {
parse_element(f, v, elnum, flags);
}
}
function parse_align2(f, v, elnum, flags,
LOCAL, elem)
{
elem = elements[elnum, "elem"];
v["OFFSET"] = elem_name(v, elem);
print_template(f, "prs_align2.tpl", v);
}
function parse_align4(f, v, elnum, flags,
LOCAL, elem)
{
elem = elements[elnum, "elem"];
v["OFFSET"] = elem_name(v, elem);
print_template(f, "prs_align4.tpl", v);
}
function parse_pointer(f, v, elnum, flags,
LOCAL, elem)
{
elem = elements[elnum, "elem"];
v["ELEM"] = elem_name(v, elem);
v["FLAGS"] = flags;
print_template(f, "prs_pointer.tpl", v);
}
function parse_scalar_fn(m, v, elnum,
LOCAL, elem, type)
{
elem = elements[elnum, "elem"];
type = elements[elnum, "type"]
xprintf(m, "%s %s", type, elem_name(v, elem));
if (type == "union") {
} else if (elements[elnum, "array_len"]!="") {
} else {
}
}
function parse_pointer_fn(f, v, elnum, flags,
LOCAL, elem)
{
elem = elements[elnum, "elem"];
v["ELEM"] = elem_name(v, elem);
v["FLAGS"] = flags;
xprintf(m, "%s\n", v["ELEM"]);
}
function parse_scalars_fn(m, v, elnum, flags)
{
if (elements[elnum, "type"] == ".align2") {
}
else if (elements[elnum, "type"] == ".align4") {
}
else if (elements[elnum, "ptr"] == "1") {
parse_pointer_fn(m, v, elnum, flags);
} else {
parse_scalar_fn(m, v, elnum, flags);
}
}
function parse_scalars(f, v, elnum, flags)
{
if (elements[elnum, "type"] == ".align2") {
parse_align2(f, v, elnum, flags);
}
else if (elements[elnum, "type"] == ".align4") {
parse_align4(f, v, elnum, flags);
}
else if (elements[elnum, "ptr"] == "1") {
parse_pointer(f, v, elnum, flags);
} else {
parse_scalar(f, v, elnum, flags);
}
}
function parse_buffers(f, v, elnum, flags,
LOCAL, elem, type)
{
elem = elements[elnum, "elem"];
type = elements[elnum, "type"];
v["ELEM"] = elem_name(v, elem);
if (elements[elnum, "type"] == ".align2") {
}
else if (elements[elnum, "type"] == ".align4") {
} else if (elements[elnum, "ptr"] == "1") {
print_template(f, "ifptr_start.tpl", v);
parse_scalar(f, v, elnum, "PARSE_SCALARS|PARSE_BUFFERS");
print_template(f, "ifptr_end.tpl", v);
} else {
parse_scalar(f, v, elnum, flags);
}
}
function struct_parser(f, m, v, struct_num,
LOCAL, i, n1, f1, num_elems)
{
f1 = -1;
num_elems = structs[struct_num, "num_elems"];
v["STRUCTNAME"] = structs[struct_num, "name"];
v["FUNCNAME"] = "io_" v["STRUCTNAME"];
print_template(f, "fn_start.tpl", v);
for (n1=0;n1<num_elems;n1++) {
if (elements[structs[struct_num, n1], "type"] == ".trailer") {
f1 = n1;
break;
}
}
# first all the structure pointers, scalars and arrays
for (i=0;i<n1;i++) {
parse_scalars(f, v, structs[struct_num, i], "PARSE_SCALARS");
}
print_template(f, "fn_mid.tpl", v);
# now the buffers
for (i=0;i<n1;i++) {
parse_buffers(f, v, structs[struct_num, i], "PARSE_BUFFERS");
}
# and any trailers
for (i=n1;i<num_elems;i++) {
parse_scalars(f, v, structs[struct_num, i], "PARSE_SCALARS");
parse_buffers(f, v, structs[struct_num, i], "PARSE_BUFFERS");
}
if (i > 0) {
print_template(f, "fn_end.tpl", v);
}
else {
print_template(f, "fn_end0.tpl", v);
}
if (f1 == -1)
return;
xprintf(m, "void fn_%s(\n", v["STRUCTNAME"]);
for (i=f1+1;i<num_elems;i++) {
parse_scalars_fn(m, v, structs[struct_num, i]);
if (i != num_elems-1)
xprintf(m, ", \n");
}
xprintf(m, ")\n{\n}\n");
}
function produce_parsers(f, m,
LOCAL, v, i)
{
v["MODULE"]=module;
print_template(f, "module_start.tpl", v);
for (i=0;i < num_structs;i++) {
struct_parser(f, m, v, i);
}
print_template(f, "module_end.tpl", v);
}

View File

@ -1,471 +0,0 @@
#include "parser.h"
/*******************************************************************
Attempt, if needed, to grow a data buffer.
Also depends on the data stream mode (io).
********************************************************************/
BOOL io_grow(io_struct *ps, uint32 extra_space)
{
uint32 new_size;
char *new_data;
ps->grow_size = MAX(ps->grow_size, ps->data_offset + extra_space);
if(ps->data_offset + extra_space <= ps->buffer_size)
return True;
/*
* We cannot grow the buffer if we're not reading
* into the io_struct, or if we don't own the memory.
*/
if(UNMARSHALLING(ps) || !ps->is_dynamic) {
DEBUG(0,("io_grow: Buffer overflow - unable to expand buffer by %u bytes.\n",
(unsigned int)extra_space));
return False;
}
/*
* Decide how much extra space we really need.
*/
extra_space -= (ps->buffer_size - ps->data_offset);
if(ps->buffer_size == 0) {
new_size = extra_space;
if((new_data = malloc(new_size)) == NULL) {
DEBUG(0,("io_grow: Malloc failure for size %u.\n", (unsigned int)new_size));
return False;
}
memset(new_data, '\0', new_size );
} else {
/*
* If the current buffer size is bigger than the space needed, just
* double it, else add extra_space.
*/
new_size = MAX(ps->buffer_size*2, ps->buffer_size + extra_space);
if ((new_data = Realloc(ps->data_p, new_size)) == NULL) {
DEBUG(0,("io_grow: Realloc failure for size %u.\n",
(unsigned int)new_size));
return False;
}
}
ps->buffer_size = new_size;
ps->data_p = new_data;
return True;
}
/*******************************************************************
Ensure we can read/write to a given offset.
********************************************************************/
char *io_mem_get(io_struct *ps, uint32 extra_size)
{
if(UNMARSHALLING(ps)) {
/*
* If reading, ensure that we can read the requested size item.
*/
if (ps->data_offset + extra_size > ps->buffer_size) {
DEBUG(0,("io_mem_get: reading data of size %u would overrun buffer.\n",
(unsigned int)extra_size ));
return NULL;
}
} else {
/*
* Writing - grow the buffer if needed.
*/
if(!io_grow(ps, extra_size))
return False;
}
return &ps->data_p[ps->data_offset];
}
/*******************************************************************
Initialise a parse structure - malloc the data if requested.
********************************************************************/
BOOL io_init(io_struct *ps, uint32 size, BOOL io)
{
ZERO_STRUCTP(ps);
ps->io = io;
ps->bigendian_data = False;
ps->is_dynamic = False;
ps->data_offset = 0;
ps->buffer_size = 0;
ps->data_p = NULL;
if (size != 0) {
ps->buffer_size = size;
if((ps->data_p = (char *)malloc((size_t)size)) == NULL) {
DEBUG(0,("io_init: malloc fail for %u bytes.\n", (unsigned int)size));
return False;
}
ps->is_dynamic = True; /* We own this memory. */
}
return True;
}
/*******************************************************************
debug output for parsing info.
XXXX side-effect of this function is to increase the debug depth XXXX
********************************************************************/
void io_debug(io_struct *ps, int depth, char *desc, char *fn_name)
{
DEBUG(5+depth, ("%s%06x %s %s\n", tab_depth(depth), ps->data_offset, fn_name, desc));
}
/*******************************************************************
Align a the data_len to a multiple of align bytes - filling with
zeros.
********************************************************************/
BOOL io_align2(io_struct *ps, int offset)
{
uint32 mod = (ps->data_offset + offset) & (2-1);
if (mod != 0) {
uint32 extra_space = (2 - mod);
if(!io_grow(ps, extra_space))
return False;
memset(&ps->data_p[ps->data_offset], '\0', (size_t)extra_space);
ps->data_offset += extra_space;
}
return True;
}
BOOL io_align4(io_struct *ps, int offset)
{
uint32 mod = (ps->data_offset + offset) & (4-1);
if (mod != 0) {
uint32 extra_space = (4 - mod);
if(!io_grow(ps, extra_space))
return False;
memset(&ps->data_p[ps->data_offset], '\0', (size_t)extra_space);
ps->data_offset += extra_space;
}
return True;
}
/*******************************************************************
Align a the data_len to a multiple of align bytes - filling with
zeros.
********************************************************************/
BOOL io_align(io_struct *ps, int align)
{
uint32 mod;
if (!ps->autoalign) return True;
mod = ps->data_offset & (align-1);
if (align != 0 && mod != 0) {
uint32 extra_space = (align - mod);
if(!io_grow(ps, extra_space))
return False;
memset(&ps->data_p[ps->data_offset], '\0', (size_t)extra_space);
ps->data_offset += extra_space;
}
return True;
}
/*******************************************************************
read from a socket into memory.
********************************************************************/
BOOL io_read(io_struct *ps, int fd, size_t len, int timeout)
{
BOOL ok;
size_t prev_size = ps->buffer_size;
if (!io_grow(ps, len))
{
return False;
}
if (timeout > 0)
{
ok = (read(fd, &ps->data_p[prev_size], len) == len);
}
else
{
ok = (read(fd, &ps->data_p[prev_size], len) == len);
}
return ok;
}
/*******************************************************************
do IO on a uint32.
********************************************************************/
BOOL io_uint32(char *name, io_struct *ps, int depth, uint32 *data32, unsigned flags)
{
char *q;
if (!(flags & PARSE_SCALARS)) return True;
if (!io_align(ps, 4)) return False;
q = io_mem_get(ps, sizeof(uint32));
if (q == NULL) return False;
DBG_RW_IVAL(name, depth, ps->data_offset, ps->io, ps->bigendian_data, q, *data32)
ps->data_offset += sizeof(uint32);
return True;
}
/*******************************************************************
do IO on a uint16.
********************************************************************/
BOOL io_uint16(char *name, io_struct *ps, int depth, uint16 *data16, unsigned flags)
{
char *q;
if (!(flags & PARSE_SCALARS)) return True;
if (!io_align(ps, 2)) return False;
q = io_mem_get(ps, sizeof(uint16));
if (q == NULL) return False;
DBG_RW_SVAL(name, depth, ps->data_offset, ps->io, ps->bigendian_data, q, *data16)
ps->data_offset += sizeof(uint16);
return True;
}
/*******************************************************************
do IO on a uint8.
********************************************************************/
BOOL io_uint8(char *name, io_struct *ps, int depth, uint8 *data8, unsigned flags)
{
char *q;
if (!(flags & PARSE_SCALARS)) return True;
q = io_mem_get(ps, sizeof(uint8));
if (q == NULL) return False;
DBG_RW_IVAL(name, depth, ps->data_offset, ps->io, ps->bigendian_data, q, *data8)
ps->data_offset += sizeof(uint8);
return True;
}
/*******************************************************************
do IO on a pointer
********************************************************************/
BOOL io_pointer(char *desc, io_struct *ps, int depth, void **p, unsigned flags)
{
uint32 v;
if (!(flags & PARSE_SCALARS)) return True;
v = (*p) ? 0xdeadbeef : 0;
if (!io_uint32(desc, ps, depth, &v, flags)) return False;
*p = (void *) (v ? 0xdeadbeef : 0);
return True;
}
/*******************************************************************
Stream a null-terminated string.
********************************************************************/
BOOL io_SMBSTR(char *name, io_struct *ps, int depth, char **str, unsigned flags)
{
char *q;
uint8 *start;
int i;
size_t len;
int start_offset = ps->data_offset;
if (!(flags & PARSE_SCALARS)) return True;
if (UNMARSHALLING(ps)) {
*str = io_mem_get(ps, 0);
if (*str == NULL)
return False;
len = strlen(*str);
ps->data_offset += len + 1;
}
else
{
len = strlen(*str)+1;
start = (uint8*)q;
for(i = 0; i < len; i++) {
q = io_mem_get(ps, 1);
if (q == NULL)
return False;
RW_CVAL(ps->io, q, (*str)[i],0);
ps->data_offset++;
}
}
DEBUG(5,("%s%04x %s: %s\n", tab_depth(depth),
start_offset, name, *str));
return True;
}
/******************************************************************
do IO on a byte array
********************************************************************/
BOOL io_uint8s(char *name, io_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;
q = io_mem_get(ps, num_bytes);
if (q == NULL) return False;
if (MARSHALLING(ps))
{
DBG_RW_PCVAL(True, name, depth, ps->data_offset, ps->io, q, *data8s, len)
}
else
{
*data8s = q;
dump_data(depth+5, *data8s, num_bytes);
}
ps->data_offset += num_bytes;
return True;
}
/******************************************************************
do IO on a fixed-size byte array
********************************************************************/
BOOL io_uint8s_fixed(char *name, io_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;
q = io_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 += num_bytes;
return True;
}
/******************************************************************
do IO on an io (eh?? :)
********************************************************************/
BOOL io_io_struct(char *name, io_struct *ps, int depth, io_struct *io, unsigned flags)
{
char *q;
uint16 len;
if (!(flags & PARSE_SCALARS)) return True;
q = io_mem_get(ps, sizeof(uint16));
if (q == NULL) return False;
/* length first */
if (MARSHALLING(ps))
{
len = io->data_offset;
}
if (!io_uint16("len", ps, depth+1, &len, flags))
{
return False;
}
if (UNMARSHALLING(ps))
{
if (!io_init(io, len, UNMARSHALL))
{
return False;
}
}
/* now data */
q = io_mem_get(ps, len * sizeof(uint8));
if (q == NULL) return False;
if (MARSHALLING(ps))
{
DBG_RW_PCVAL(False, name, depth+1, ps->data_offset, ps->io, q, io->data_p, len)
}
else
{
io->data_p = q;
dump_data(depth+5, q, len);
}
ps->data_offset += len;
return True;
}
/******************************************************************
do IO on a unicode array
********************************************************************/
BOOL io_wstring(char *name, io_struct *ps, int depth, uint16 *data16s, int len, unsigned flags)
{
char *q;
if (!(flags & PARSE_SCALARS)) return True;
if (!io_align(ps, 2)) return False;
q = io_mem_get(ps, len * sizeof(uint16));
if (q == NULL) return False;
DBG_RW_PSVAL(True, name, depth, ps->data_offset, ps->io, ps->bigendian_data, q, data16s, len)
ps->data_offset += (len * sizeof(uint16));
return True;
}
/******************************************************************
allocate some memory for a parse structure
********************************************************************/
void io_free(io_struct *ps)
{
if (ps->is_dynamic && ps->data_p)
{
free(ps->data_p);
ps->data_p = NULL;
}
}
/******************************************************************
allocate some memory for a parse structure
********************************************************************/
BOOL io_alloc(char *name, io_struct *ps, void **ptr, unsigned size)
{
(*ptr) = (void *)malloc(size);
if (*ptr) return True;
return False;
}
/******************************************************************
realloc some memory for a parse structure
********************************************************************/
BOOL io_realloc(char *name, io_struct *ps, void **ptr, unsigned size)
{
BOOL ret = True;
void *tp;
tp = (void *)Realloc(*ptr, size);
if (tp) *ptr = tp;
else ret = False;
return ret;
}

View File

@ -1,103 +0,0 @@
#include <ctype.h>
#include <stdio.h>
#include <malloc.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "include/byteorder.h"
#define PARSE_SCALARS (1<<0)
#define PARSE_BUFFERS (1<<1)
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#define DEBUG(lvl, str) printf str;
#define DEBUGADD(lvl, str) printf str;
#define MARSHALL 0
#define UNMARSHALL 1
#define MARSHALLING(ps) (!(ps)->io)
#define UNMARSHALLING(ps) ((ps)->io)
typedef int BOOL;
typedef unsigned char uint8;
typedef unsigned char uchar;
typedef unsigned short uint16;
typedef unsigned short wchar;
typedef unsigned uint32;
typedef char *SMBSTR;
/* a null terminated unicode string */
typedef uint16 ZUSTRING;
#ifndef _PSTRING
#define PSTRING_LEN 1024
#define FSTRING_LEN 128
typedef char pstring[PSTRING_LEN];
typedef char fstring[FSTRING_LEN];
#define _PSTRING
#endif
#define False 0
#define True 1
/* zero a structure given a pointer to the structure */
#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
#define MAX_UNISTRLEN 256
#define MAX_STRINGLEN 256
#define MAX_BUFFERLEN 512
typedef struct _io_struct
{
BOOL io; /* parsing in or out of data stream */
/*
* If the (incoming) data is big-endian. On output we are
* always little-endian.
*/
BOOL bigendian_data;
BOOL is_dynamic; /* Do we own this memory or not ? */
BOOL autoalign; /* should we auto-align all elements? */
uint32 data_offset; /* Current working offset into data. */
uint32 buffer_size; /* Current size of the buffer. */
uint32 grow_size; /* size requested via io_grow() calls */
char *data_p; /* The buffer itself. */
} io_struct;
char *io_mem_get(io_struct *ps, uint32 extra_size);
BOOL io_init(io_struct *ps, uint32 size, BOOL io);
void io_debug(io_struct *ps, int depth, char *desc, char *fn_name);
BOOL io_align(io_struct *ps, int align);
BOOL io_align4(io_struct *ps, int align);
BOOL io_align2(io_struct *ps, int align);
BOOL io_read(io_struct *ps, int fd, size_t len, int timeout);
void dump_data(int level,char *buf1,int len);
BOOL io_alloc(char *name, io_struct *ps, void **ptr, unsigned size);
BOOL io_uint32(char *name, io_struct *ps, int depth, uint32 *data32, unsigned flags);
BOOL io_uint16(char *name, io_struct *ps, int depth, uint16 *data16, unsigned flags);
BOOL io_uint8(char *name, io_struct *ps, int depth, uint8 *data8, unsigned flags);
BOOL io_pointer(char *desc, io_struct *ps, int depth, void **p, unsigned flags);
BOOL io_SMBSTR(char *name, io_struct *ps, int depth, char **str, unsigned flags);
BOOL io_io_struct(char *name, io_struct *ps, int depth, io_struct *io, unsigned flags);
BOOL io_wstring(char *name, io_struct *ps, int depth, uint16 *data16s, int len, unsigned flags);
BOOL io_uint8s_fixed(char *name, io_struct *ps, int depth, uint8 *data8s, int len, unsigned flags);
BOOL io_uint8s(char *name, io_struct *ps, int depth, uint8 **data8s, int len, unsigned flags);
char *tab_depth(int depth);
void *Realloc(void *p,size_t size);
void dump_data(int level,char *buf1,int len);
void print_asc(int level, uchar const *buf, int len);
BOOL io_ZUSTRING(char *name, io_struct *ps, int depth, uint16 **ustr, unsigned flags);
size_t strlen_w(void *src);

View File

@ -1,213 +0,0 @@
# build parse functions for a parsed struct file
function elem_name(v, elem)
{
return v["UNION"]elem;
}
function parse_array(f, v, elnum, flags,
LOCAL, type, elem, array_len)
{
type = elements[elnum, "type"];
elem = elements[elnum, "elem"];
array_len = elements[elnum, "array_len"];
v["ELEM"] = elem_name(v, elem);
v["TYPE"] = type;
v["FLAGS"] = flags;
v["ARRAY_LEN"] = array_len;
if (array_len=="+") {
print_template(f,"prs_array_optional.tpl", v);
return;
}
if (array_len=="&") {
print_template(f,"prs_array_null.tpl", v);
return;
}
if (array_len=="*") {
print_template(f,"prs_array_remainder.tpl", v);
return;
}
if (type == "wchar" || type == "uint16") {
if (match(array_len,"[0-9]") == 1) {
print_template(f, "prs_wstring_fixed.tpl", v);
} else {
print_template(f, "prs_wstring.tpl", v);
}
} else if (type == "uint8") {
if (match(array_len,"[0-9]") == 1) {
print_template(f, "prs_uint8s_fixed.tpl", v);
} else {
print_template(f, "prs_uint8s.tpl", v);
}
} else {
print_template(f, "prs_array.tpl", v);
}
}
function parse_element(f, v, elnum, flags,
LOCAL, type, elem)
{
if (elements[elnum,"nowire"] != "") {
return;
}
type = elements[elnum, "type"];
if (substr(type,1,1) == ".") return;
elem = elements[elnum, "elem"];
if (elements[elnum,"ptr"] == "") {
v["PTR"] = "\\&";
} else {
v["PTR"] = " ";
}
v["ELEM"] = elem_name(v, elem);
v["TYPE"] = type;
v["FLAGS"] = flags;
print_template(f, "prs_element.tpl", v);
}
function parse_union(f, v, elnum, flags,
LOCAL, i)
{
v["UNION"] = elements[elnum, "elem"];
v["SWITCH"] = elements[elnum, "switch"];
if (elements[elnum, "ptr"] == "1") {
v["UNION"] = v["UNION"]"->";
} else {
v["UNION"] = v["UNION"]".";
}
print_template(f, "union_start.tpl", v);
for (i=0;i<unions[elnum, "num_elems"];i++) {
v["CASE"] = elements[unions[elnum, i], "case"];
print_template(f, "prs_case.tpl", v);
if (elements[elnum, "ptr"] == "1") {
parse_scalars(f, v, unions[elnum, i], "PARSE_SCALARS");
parse_buffers(f, v, unions[elnum, i], "PARSE_BUFFERS");
} else {
if (flags == "PARSE_SCALARS") {
parse_scalars(f, v, unions[elnum, i], flags);
} else {
parse_buffers(f, v, unions[elnum, i], flags);
}
}
print_template(f, "prs_break.tpl", v);
}
v["UNION"] = "";
print_template(f, "union_end.tpl", v);
}
function parse_scalar(f, v, elnum, flags)
{
if (elements[elnum, "type"] == "union") {
parse_union(f, v, elnum, flags);
} else if (elements[elnum, "array_len"]!="") {
parse_array(f, v, elnum, flags);
} else {
parse_element(f, v, elnum, flags);
}
}
function parse_pointer(f, v, elnum, flags,
LOCAL, elem)
{
elem = elements[elnum, "elem"];
v["ELEM"] = elem_name(v, elem);
v["FLAGS"] = flags;
print_template(f, "prs_pointer.tpl", v);
}
function parse_scalars(f, v, elnum, flags)
{
if (elements[elnum, "ptr"] == "1") {
parse_pointer(f, v, elnum, flags);
} else {
parse_scalar(f, v, elnum, flags);
}
}
function parse_buffers(f, v, elnum, flags,
LOCAL, elem, type)
{
elem = elements[elnum, "elem"];
type = elements[elnum, "type"];
v["ELEM"] = elem_name(v, elem);
if (elements[elnum, "ptr"] == "1") {
print_template(f, "ifptr_start.tpl", v);
parse_scalar(f, v, elnum, "PARSE_SCALARS|PARSE_BUFFERS");
print_template(f, "ifptr_end.tpl", v);
} else {
parse_scalar(f, v, elnum, flags);
}
}
function struct_immediate(f, v, struct_num,
LOCAL, i, n1, num_elems)
{
num_elems = structs[struct_num, "num_elems"];
v["STRUCTNAME"] = structs[struct_num, "name"];
v["FUNCNAME"] = "io_" v["STRUCTNAME"];
print_template(f, "fn_i_start.tpl", v);
for (i=0;i<num_elems;i++) {
parse_scalars(f, v, structs[struct_num, i], "PARSE_SCALARS");
parse_buffers(f, v, structs[struct_num, i], "PARSE_BUFFERS");
}
print_template(f, "fn_i_end.tpl", v);
}
function struct_recursive(f, v, struct_num,
LOCAL, i, n1, num_elems)
{
num_elems = structs[struct_num, "num_elems"];
v["STRUCTNAME"] = structs[struct_num, "name"];
v["FUNCNAME"] = "io_" v["STRUCTNAME"];
print_template(f, "fn_start.tpl", v);
# first all the structure pointers, scalars and arrays
for (i=0;i<num_elems;i++) {
parse_scalars(f, v, structs[struct_num, i], "PARSE_SCALARS");
}
print_template(f, "fn_mid.tpl", v);
# now the buffers
for (i=0;i<num_elems;i++) {
parse_buffers(f, v, structs[struct_num, i], "PARSE_BUFFERS");
}
print_template(f, "fn_end.tpl", v);
}
function struct_parser(f, v, struct_num,
LOCAL, i, n1, num_elems)
{
if (structs[struct_num, "recurse"] == "True") {
struct_recursive(f, v, struct_num);
} else {
struct_immediate(f, v, struct_num);
}
}
function produce_relative(f,
LOCAL, v, i)
{
v["MODULE"]=module;
print_template(f, "module_start.tpl", v);
for (i=0;i < num_structs;i++) {
struct_parser(f, v, i);
}
print_template(f, "module_end.tpl", v);
}

View File

@ -1,224 +0,0 @@
# build the parse tree for a struct file
function find_structure(name,
LOCAL, i)
{
for (i=0;i<num_structs;i++) {
if (structs[i, "name"] == name) return i;
}
return "-1";
}
function start_module(name)
{
module=name;
num_structs=0;
num_elements=0;
num_unions=0;
num_tests=0;
num_options=0;
}
function set_option(name, value)
{
options[name] = value;
options[num_options, "name"] = name;
options[num_options, "value"] = value;
num_options++;
}
function parse_define(def1, def2,
LOCAL, type, i)
{
defines[def1]=def2;
}
function start_struct(name)
{
current_struct=num_structs;
structs[name]=current_struct;
structs[current_struct, "name"]=name;
structs[current_struct, "num_elems"]=0;
structs[current_struct, "num_unions"]=0;
structs[current_struct, "recurse"] = options["recurse"];
}
function end_struct(name)
{
if (name!="") structs[num_structs, "name"]=name;
printf("struct %s with %d elements\n",
structs[num_structs, "name"],
structs[num_structs, "num_elems"]);
num_structs++;
current_struct="";
}
function add_element(type, elem, case,
LOCAL, elem_num, i, v)
{
while (defines[type]!="") {
type=defines[type];
}
elem_num=num_elements;
if (substr(elem, 1, 1) == ".") {
elem=substr(elem, 2);
elements[elem_num, "nowire"]=1;
}
if (substr(elem, 1, 1) == "*") {
elem=substr(elem, 2);
elements[elem_num, "ptr"]=1;
}
i=match(elem,"[[]");
if (i != 0) {
v = substr(elem, i+1, length(elem)-i-1);
elem=substr(elem, 1, i-1);
if (type=="union") {
elements[elem_num, "switch"] = v;
} else {
elements[elem_num, "array_len"] = v;
}
}
elements[elem_num, "type"] = type;
elements[elem_num, "elem"] = elem;
elements[elem_num, "case"] = case;
num_elements++;
return elem_num;
}
function add_struct_elem(type, elem, case,
LOCAL, elem_num)
{
elem_num=structs[current_struct, "num_elems"];
structs[current_struct, elem_num] = add_element(type, elem, case);
structs[current_struct, "num_elems"]++;
return structs[current_struct, elem_num];
}
function start_union(elem)
{
current_union = add_struct_elem("union", elem);
unions[current_union, "num_elems"] = 0;
}
function start_union_notencap(switch)
{
add_struct_elem("uint32", "switch_"switch);
start_union("UNKNOWN[switch_"switch"]");
}
function start_union_encap(struct, type, switch, union)
{
start_struct(struct);
add_struct_elem(type, switch);
add_struct_elem(type, "switch_"switch);
start_union(union"[switch_"switch"]");
encap_union="1";
}
function parse_case(case, type, elem,
LOCAL, elem_num)
{
split(case, a, "[:]");
case = a[1];
elem_num = unions[current_union, "num_elems"];
unions[current_union, elem_num] = add_element(type, elem, case);
unions[current_union, "num_elems"]++;
}
function end_union(name)
{
if (name!="") {
elements[current_union, "elem"] = name;
}
current_union="";
if (encap_union=="1") {
end_struct(name);
encap_union="0";
}
}
function delete_element(struct, elnum,
LOCAL, i)
{
for (i=elnum;i<structs[struct,"num_elems"]-1;i++) {
structs[struct, i] = structs[struct, i+1];
}
structs[struct, "num_elems"]--;
}
function copy_struct(from, to,
LOCAL, i)
{
for (i=0;i<structs[from,"num_elems"];i++) {
structs[to, i] = structs[from, i];
}
structs[to, "name"] = structs[from, "name"];
structs[to, "num_elems"] = structs[from, "num_elems"];
structs[to, "num_unions"] = structs[from, "num_unions"];
}
function add_sizeis_array(count, type, elem)
{
copy_struct(current_struct, current_struct+1);
elem=substr(elem,2);
start_struct("array_"current_struct"_"elem);
add_struct_elem("uint32", count);
add_struct_elem(type, elem"["count"]");
end_struct("");
current_struct=num_structs;
add_struct_elem("array_"current_struct-1"_"elem, "*"elem"_ptr");
}
function start_function(type, fname)
{
start_struct(fname);
structs[current_struct, "recurse"] = "False";
}
function end_function(LOCAL, i)
{
copy_struct(num_structs, num_structs+1);
structs[num_structs, "name"] = "Q_"structs[num_structs, "name"];
for (i=0;i<structs[num_structs, "num_elems"];i++) {
if (match(elements[structs[num_structs, i], "properties"], "in") == 0) {
delete_element(num_structs, i);
i--;
}
}
end_struct();
current_struct=num_structs;
structs[num_structs, "name"] = "R_"structs[num_structs, "name"];
for (i=0;i<structs[num_structs, "num_elems"];i++) {
if (match(elements[structs[num_structs, i], "properties"], "out") == 0) {
delete_element(num_structs, i);
i--;
}
}
if (return_result!="void")
add_function_param("[out]", return_result, "status");
end_struct();
}
function add_function_param(properties, type, elem,
LOCAL, elnum, len)
{
len=length(type);
if (substr(type, len) == "*") {
type=substr(type, 1, len-1);
elem="*"elem;
}
if (substr(elem,1,1) == "*" &&
(match(properties,"in") == 0 ||
find_structure(type) != "-1")) {
elem=substr(elem, 2);
}
elnum = add_struct_elem(type, elem);
elements[elnum, "properties"] = properties;
}

View File

@ -1,90 +0,0 @@
module spool
struct BUFFER5 {
uint32 buf_len;
uint16 buffer[buf_len];
};
struct BUFFERP {
uint32 buf_len;
BUFFER5 *buf;
};
struct UNISTR2 {
uint32 max_len;
uint32 undoc;
uint32 str_len;
uint16 buffer[str_len];
};
struct LPWSTR {
UNISTR2 *str;
};
struct VERSION {
uint32 version;
uint32 build;
uint32 osversion;
};
struct NTTIME {
uint32 low;
uint32 high;
};
struct DWORD {
uint32 x;
};
struct PRINTER_DRIVER_INFO_LEVEL_3 {
DWORD cversion;
LPWSTR name;
LPWSTR environment;
LPWSTR driverpath;
LPWSTR datafile;
LPWSTR configfile;
LPWSTR helpfile;
LPWSTR monitorname;
LPWSTR defaultdatatype;
BUFFERP dependentfiles;
};
struct PRINTER_DRIVER_INFO_LEVEL_6 {
DWORD dummy1;
DWORD version;
LPWSTR name;
LPWSTR environment;
LPWSTR driverpath;
LPWSTR datafile;
LPWSTR configfile;
LPWSTR helpfile;
LPWSTR monitorname;
LPWSTR defaultdatatype;
BUFFERP dependentfiles;
BUFFERP previousnames;
NTTIME driverdate;
VERSION driverversion;
LPWSTR mfgname;
LPWSTR oemurl;
LPWSTR hardwareid;
LPWSTR provider;
};
struct PRINTER_DRIVER_INFO {
uint32 level;
union *info[level] {
case 3 PRINTER_DRIVER_INFO_LEVEL_3 info_3;
case 6 PRINTER_DRIVER_INFO_LEVEL_6 info_6;
}
};
struct R_GETPRINTERDATA {
uint32 type;
uint32 size;
uint8 *data;
uint32 needed;
uint32 status;
};

View File

@ -1,184 +0,0 @@
module srvsvc
typedef uint32 LONG;
typedef uint32 *ENUM_HND;
typedef struct _UNISTR2 {
uint32 max_len;
uint32 undoc;
uint32 str_len;
wchar buffer[str_len];
} UNISTR2;
typedef UNISTR2 *LPWSTR;
/* function 8 */
struct CONN_INFO_0 {
uint32 id; /* connection id. */
};
struct CONN_INFO_1 {
uint32 id;
uint32 type;
uint32 num_opens;
uint32 num_users;
uint32 open_time;
LPWSTR usr_name;
LPWSTR net_name;
};
struct CONN_ENUM_CTR {
uint32 level;
uint32 level2;
uint32 num_entries;
uint32 num_entries2;
union *info[level] {
case 0 CONN_INFO_0 info0[num_entries];
case 1 CONN_INFO_1 info1[num_entries];
}
};
struct SRV_R_NET_CONN_ENUM {
.trailer;
CONN_ENUM_CTR ctr;
uint32 num_entries;
ENUM_HND handle;
uint32 status2;
};
struct SRV_Q_NET_CONN_ENUM {
.trailer;
LPWSTR dest_srv;
LPWSTR qual_srv;
uint32 level;
uint32 level2;
CONN_ENUM_CTR *ctr;
uint32 max_len;
ENUM_HND handle;
};
/* function 9 */
struct FILE_INFO_3 {
uint32 id; /* file index */
uint32 perms; /* file permissions. don't know what format */
uint32 num_locks; /* file locks */
LPWSTR path_name; /* file name */
LPWSTR user_name; /* file owner */
};
struct SRV_FILE_INFO_CTR {
uint32 level;
uint32 num_entries;
uint32 dummy;
union *file[level] {
case 3 FILE_INFO_3 info3[num_entries];
}
};
struct SRV_Q_NET_FILE_ENUM {
.trailer;
LPWSTR srv_name;
LPWSTR qual_name;
uint32 dummy;
uint32 level;
SRV_FILE_INFO_CTR ctr;
uint32 *status;
uint32 preferred_len;
ENUM_HND enum_hnd;
};
struct SRV_R_NET_FILE_ENUM {
.trailer;
uint32 level;
uint32 dummy;
SRV_FILE_INFO_CTR *ctr;
uint32 total_entries; /* total number of files */
ENUM_HND enum_hnd;
uint32 status; /* return status */
};
/* function 15 */
struct SRV_SHARE_INFO_1 {
LPWSTR uni_netname;
uint32 type;
LPWSTR uni_remark;
};
struct SRV_SHARE_INFO_2 {
LPWSTR uni_netname;
uint32 type;
LPWSTR uni_remark;
uint32 perms;
uint32 max_uses;
uint32 num_uses;
LPWSTR path;
LPWSTR passwd;
};
struct SRV_R_NET_SHARE_ENUM {
uint32 level;
uint32 level2;
uint32 *ret_count;
uint32 num_entries;
union *info[level] {
case 1 SRV_SHARE_INFO_1 info1[num_entries];
case 2 SRV_SHARE_INFO_2 info2[num_entries];
}
.trailer;
uint32 count;
ENUM_HND handle;
uint32 status;
};
/* function 21 */
struct SERVER_INFO_100 {
uint32 dwPlatformID;
LPWSTR pszName;
};
struct SERVER_INFO_101 {
uint32 dwPlatformID;
LPWSTR pszName;
uint32 dwVerMajor;
uint32 dwVerMinor;
uint32 dwType;
LPWSTR pszComment;
};
struct SERVER_INFO_102 {
uint32 dwPlatformID;
LPWSTR pszName;
uint32 dwVerMajor;
uint32 dwVerMinor;
uint32 dwType;
LPWSTR pszComment;
uint32 dwUsers;
uint32 lDisc;
uint32 bHidden;
uint32 dwAnnounce;
uint32 dwAnnDelta;
uint32 dwLicenses;
LPWSTR pszUserPath;
};
struct SRV_R_NET_SERVER_INFO {
.trailer;
uint32 level;
union *info[level] {
case 100 SERVER_INFO_100 sv100;
case 101 SERVER_INFO_101 sv101;
case 102 SERVER_INFO_102 sv102;
}
uint32 status;
};
struct SRV_Q_NET_SERVER_INFO {
.trailer;
LPWSTR server;
uint32 level;
};

View File

@ -1,655 +0,0 @@
module srvsvc
option autoalign True
option relative False
option recurse True
option foo blah
#define BOOL uint32
#define LONG uint32
#define DWORD uint32
#define STATUS uint32
typedef struct _UNISTR2 {
uint32 max_len;
uint32 undoc;
uint32 str_len;
wchar buffer[str_len];
} UNISTR2;
struct LPWSTR {
UNISTR2 *str;
};
/* -- CHARACTER DEVICE INFORMATION -- */
typedef struct _CHARDEV_INFO_0 {
LPWSTR pszName;
} CHARDEV_INFO_0;
typedef struct _CHARDEV_INFO_1 {
LPWSTR pszName;
DWORD dwStatus;
LPWSTR pszUser;
DWORD dwTime;
} CHARDEV_INFO_1;
typedef union _CHARDEV_INFO switch (DWORD dwLevel) ctr {
case 1: CHARDEV_INFO_0 *ci0;
case 2: CHARDEV_INFO_1 *ci1;
} CHARDEV_INFO;
typedef struct _CHARDEV_ENUM_0 {
DWORD dwEntries;
[size_is(dwEntries)] CHARDEV_INFO_0 *ci0;
} CHARDEV_ENUM_0;
typedef struct _CHARDEV_ENUM_1 {
DWORD dwEntries;
[size_is(dwEntries)] CHARDEV_INFO_1 *ci1;
} CHARDEV_ENUM_1;
typedef struct _CHARDEV_ENUM {
DWORD dwLevel;
[switch_is(dwLevel)] union {
[case(0)] CHARDEV_ENUM_0 *ce0;
[case(1)] CHARDEV_ENUM_1 *ce1;
} ctr;
} CHARDEV_ENUM;
STATUS NetrCharDevEnum( /* Function 0x00 */
[in,unique] LPWSTR pszServer,
[in,out] CHARDEV_ENUM* pCharDevEnum,
[in] DWORD dwMaxLen,
[out] DWORD* dwEntries,
[in,out] DWORD* hResume
);
STATUS NetrCharDevGetInfo( /* Function 0x01 */
[in,unique] LPWSTR pszServer,
[in,ref] LPWSTR pszDevice,
[in] DWORD dwLevel,
[out] CHARDEV_INFO* pCharDevInfo
);
STATUS NetrCharDevControl( /* Function 0x02 */
[in,unique] LPWSTR pszServer,
[in,ref] LPWSTR pszDevice,
[in] DWORD dwOpcode
);
/* -- CHARACTER DEVICE QUEUE INFORMATION -- */
typedef struct _CHARDEVQ_INFO_0 {
LPWSTR pszName;
} CHARDEVQ_INFO_0;
typedef struct _CHARDEVQ_INFO_1 {
LPWSTR pszName;
DWORD dwPriority;
LPWSTR pszDevices;
DWORD dwNumUsers;
DWORD dwNumAhead;
} CHARDEVQ_INFO_1;
typedef union _CHARDEVQ_INFO switch (DWORD dwLevel) ctr {
case 1: CHARDEVQ_INFO_0 *ci0;
case 2: CHARDEVQ_INFO_1 *ci1;
} CHARDEVQ_INFO;
typedef struct _CHARDEVQ_ENUM_0 {
DWORD dwEntries;
[size_is(dwEntries)] CHARDEVQ_INFO_0 *ci0;
} CHARDEVQ_ENUM_0;
typedef struct _CHARDEVQ_ENUM_1 {
DWORD dwEntries;
[size_is(dwEntries)] CHARDEVQ_INFO_1 *ci1;
} CHARDEVQ_ENUM_1;
typedef struct _CHARDEVQ_ENUM {
DWORD dwLevel;
[switch_is(dwLevel)] union {
[case(0)] CHARDEVQ_ENUM_0 *ce0;
[case(1)] CHARDEVQ_ENUM_1 *ce1;
} ctr;
} CHARDEVQ_ENUM;
STATUS NetrCharDevQEnum( /* Function 0x03 */
[in,unique] LPWSTR pszServer,
[in,unique] LPWSTR pszUser,
[in,out] CHARDEVQ_ENUM* pCharDevQEnum,
[in] DWORD dwMaxLen,
[out] DWORD* dwEntries,
[in,out] DWORD* hResume
);
STATUS NetrCharDevQGetInfo( /* Function 0x04 */
[in,unique] LPWSTR pszServer,
[in,ref] LPWSTR pszQueue,
[in,ref] LPWSTR pszUser,
[in] DWORD dwLevel,
[out] CHARDEVQ_INFO* pCharDevQInfo
);
STATUS NetrCharDevQSetInfo( /* Function 0x05 */
[in,unique] LPWSTR pszServer,
[in,ref] LPWSTR pszQueue,
[in] DWORD dwLevel,
[in] CHARDEVQ_INFO* pCharDevQInfo,
[in,out] DWORD* dwParmError
);
STATUS NetrCharDevQPurge( /* Function 0x06 */
[in,unique] LPWSTR pszServer,
[in,ref] LPWSTR pszQueue
);
STATUS NetrCharDevQPurgeSelf( /* Function 0x07 */
[in,unique] LPWSTR pszServer,
[in,ref] LPWSTR pszQueue,
[in,ref] LPWSTR pszComputer
);
/* -- CONNECTION INFORMATION -- */
typedef struct _CONNECTION_INFO_0 {
DWORD dwConnID;
} CONNECTION_INFO_0;
typedef struct _CONNECTION_INFO_1 {
DWORD dwConnID;
DWORD dwType;
DWORD dwNumOpens;
DWORD dwNumUsers;
DWORD dwTime;
LPWSTR pszUser;
LPWSTR pszShare;
} CONNECTION_INFO_1;
typedef struct _CONNECTION_ENUM_0 {
DWORD dwEntries;
[size_is(dwEntries)] CONNECTION_INFO_0 *ci0;
} CONNECTION_ENUM_0;
typedef struct _CONNECTION_ENUM_1 {
DWORD dwEntries;
[size_is(dwEntries)] CONNECTION_INFO_1 *ci1;
} CONNECTION_ENUM_1;
typedef struct _CONNECTION_ENUM {
DWORD dwLevel;
[switch_is(dwLevel)] union {
[case(0)] CONNECTION_ENUM_0 *ce0;
[case(1)] CONNECTION_ENUM_1 *ce1;
} ctr;
} CONNECTION_ENUM;
STATUS NetrConnectionEnum( /* Function 0x08 */
[in,unique] LPWSTR pszServer,
[in,unique] LPWSTR pszClient,
[in,out] CONNECTION_ENUM* pConnectionEnum,
[in] DWORD dwMaxLen,
[out] DWORD* dwEntries,
[in,out] DWORD* hResume
);
/* -- FILE INFORMATION -- */
typedef struct _FILE_INFO_2 {
DWORD dwFileID;
} FILE_INFO_2;
typedef struct _FILE_INFO_3 {
DWORD dwFileID;
DWORD dwPermissions;
DWORD dwNumLocks;
LPWSTR pszPath;
LPWSTR pszUser;
} FILE_INFO_3;
typedef union _FILE_INFO switch (DWORD dwLevel) ctr {
case 2: FILE_INFO_2 *fi2;
case 3: FILE_INFO_3 *fi3;
} FILE_INFO;
typedef struct _FILE_ENUM_2 {
DWORD dwEntries;
[size_is(dwEntries)] FILE_INFO_2 *fi2;
} FILE_ENUM_2;
typedef struct _FILE_ENUM_3 {
DWORD dwEntries;
[size_is(dwEntries)] FILE_INFO_3 *fi3;
} FILE_ENUM_3;
typedef struct _FILE_ENUM {
DWORD dwLevel;
[switch_is(dwLevel)] union {
[case(2)] FILE_ENUM_2 *fe2;
[case(3)] FILE_ENUM_3 *fe3;
} ctr;
} FILE_ENUM;
STATUS NetrFileEnum( /* Function 0x09 */
[in,unique] LPWSTR pszServer,
[in,unique] LPWSTR pszBasePath,
[in,unique] LPWSTR pszUser,
[in,out] FILE_ENUM* pFileEnum,
[in] DWORD dwMaxLen,
[out] DWORD* dwEntries,
[in,out] DWORD* hResume
);
STATUS NetrFileGetInfo( /* Function 0x0A */
[in,unique] LPWSTR pszServer,
[in] DWORD dwFileID,
[in] DWORD dwLevel,
[out] FILE_INFO* pFileInfo
);
STATUS NetrFileClose( /* Function 0x0B */
[in,unique] LPWSTR pszServer,
[in] DWORD dwFileID
);
/* -- SESSION INFORMATION -- */
typedef struct _SESSION_INFO_0 {
LPWSTR pszClient;
} SESSION_INFO_0;
typedef struct _SESSION_INFO_1 {
LPWSTR pszClient;
LPWSTR pszUser;
DWORD dwOpens;
DWORD dwTime;
DWORD dwIdleTime;
DWORD dwUserFlags;
} SESSION_INFO_1;
typedef struct _SESSION_INFO_2 {
LPWSTR pszClient;
LPWSTR pszUser;
DWORD dwOpens;
DWORD dwTime;
DWORD dwIdleTime;
DWORD dwUserFlags;
LPWSTR pszClientType;
} SESSION_INFO_2;
typedef struct _SESSION_ENUM_0 {
DWORD dwEntries;
[size_is(dwEntries)] SESSION_INFO_0 *si0;
} SESSION_ENUM_0;
typedef struct _SESSION_ENUM_1 {
DWORD dwEntries;
[size_is(dwEntries)] SESSION_INFO_1 *si1;
} SESSION_ENUM_1;
typedef struct _SESSION_ENUM_2 {
DWORD dwEntries;
[size_is(dwEntries)] SESSION_INFO_2 *si2;
} SESSION_ENUM_2;
typedef struct _SESSION_ENUM {
DWORD dwLevel;
[switch_is(dwLevel)] union {
[case(0)] SESSION_ENUM_0 *se0;
[case(1)] SESSION_ENUM_1 *se1;
[case(2)] SESSION_ENUM_2 *se2;
} ctr;
} SESSION_ENUM;
STATUS NetrSessionEnum( /* Function 0x0C */
[in,unique] LPWSTR pszServer,
[in,unique] LPWSTR pszClient,
[in,unique] LPWSTR pszUser,
[in,out] SESSION_ENUM* pFileEnum,
[in] DWORD dwMaxLen,
[out] DWORD* dwEntries,
[in,out] DWORD* hResume
);
STATUS NetrSessionDel( /* Function 0x0D */
[in,unique] LPWSTR pszServer,
[in,ref] LPWSTR pszClient,
[in,ref] LPWSTR pszUser
);
/* -- SHARE INFORMATION -- */
typedef struct _SHARE_INFO_0 {
LPWSTR pszName;
} SHARE_INFO_0;
typedef struct _SHARE_INFO_1 {
LPWSTR pszName;
DWORD dwType;
LPWSTR pszComment;
} SHARE_INFO_1;
typedef struct _SHARE_INFO_2 {
LPWSTR pszName;
DWORD dwType;
LPWSTR pszComment;
DWORD dwPermissions;
DWORD dwMaxUses;
DWORD dwCurrentUses;
LPWSTR pszPath;
LPWSTR pszPasswd;
} SHARE_INFO_2;
typedef union _SHARE_INFO switch (DWORD dwLevel) ctr {
case 0: SHARE_INFO_0 *si0;
case 1: SHARE_INFO_1 *si1;
case 2: SHARE_INFO_2 *si2;
} SHARE_INFO;
typedef struct _SHARE_ENUM_0 {
DWORD dwEntries;
[size_is(dwEntries)] SHARE_INFO_0 *si0;
} SHARE_ENUM_0;
typedef struct _SHARE_ENUM_1 {
DWORD dwEntries;
[size_is(dwEntries)] SHARE_INFO_1 *si1;
} SHARE_ENUM_1;
typedef struct _SHARE_ENUM_2 {
DWORD dwEntries;
[size_is(dwEntries)] SHARE_INFO_2 *si2;
} SHARE_ENUM_2;
typedef struct _SHARE_ENUM {
DWORD dwLevel;
[switch_is(dwLevel)] union {
[case(0)] SHARE_ENUM_0 *se0;
[case(1)] SHARE_ENUM_1 *se1;
[case(2)] SHARE_ENUM_2 *se2;
} ctr;
} SHARE_ENUM;
STATUS NetrShareAdd( /* Function 0x0E */
[in,unique] LPWSTR pszServer,
[in] DWORD dwLevel,
[out] SHARE_INFO* pShareInfo,
[in,out] DWORD* dwParmError
);
STATUS NetrShareEnum( /* Function 0x0F */
[in,unique] LPWSTR pszServer,
[in,out] SHARE_ENUM* pShareEnum,
[in] DWORD dwMaxLen,
[out] DWORD* dwEntries,
[in,out] DWORD* hResume
);
STATUS NetrShareGetInfo( /* Function 0x10 */
[in,unique] LPWSTR pszServer,
[in,ref] LPWSTR pszShare,
[in] DWORD dwLevel,
[out] SHARE_INFO* pShareInfo
);
STATUS NetrShareSetInfo( /* Function 0x11 */
[in,unique] LPWSTR pszServer,
[in,ref] LPWSTR pszShare,
[in] DWORD dwLevel,
[in] SHARE_INFO* pShareInfo,
[in] DWORD dwReserved
);
STATUS NetrShareDel( /* Function 0x12 */
[in,unique] LPWSTR pszServer,
[in,ref] LPWSTR pszShare,
[in] DWORD dwReserved
);
STATUS NetrShareDelSticky( /* Function 0x13 */
[in,unique] LPWSTR pszServer,
[in,ref] LPWSTR pszShare,
[in] DWORD dwReserved
);
STATUS NetrShareCheck( /* Function 0x14 */
[in,unique] LPWSTR pszServer,
[in,ref] LPWSTR pszDevice,
[out] DWORD* dwType
);
/* --- SERVER INFORMATION --- */
typedef struct _SERVER_INFO_100 {
DWORD dwPlatformID;
LPWSTR pszName;
} SERVER_INFO_100;
typedef struct _SERVER_INFO_101 {
DWORD dwPlatformID;
LPWSTR pszName;
DWORD dwVerMajor;
DWORD dwVerMinor;
DWORD dwType;
LPWSTR pszComment;
} SERVER_INFO_101;
typedef struct _SERVER_INFO_102 {
DWORD dwPlatformID;
LPWSTR pszName;
DWORD dwVerMajor;
DWORD dwVerMinor;
DWORD dwType;
LPWSTR pszComment;
DWORD dwUsers;
LONG lDisc;
BOOL bHidden;
DWORD dwAnnounce;
DWORD dwAnnDelta;
DWORD dwLicenses;
LPWSTR pszUserPath;
} SERVER_INFO_102;
typedef union _SERVER_INFO switch (DWORD dwLevel) ctr {
case 100: SERVER_INFO_100 *sv100;
case 101: SERVER_INFO_101 *sv101;
case 102: SERVER_INFO_102 *sv102;
} SERVER_INFO;
STATUS NetrServerGetInfo( /* Function 0x15 */
[in,unique] LPWSTR pszServerName,
[in] DWORD dwLevel,
[out] SERVER_INFO* pServerInfo
);
STATUS NetrServerSetInfo( /* Function 0x16 */
[in,unique] LPWSTR pszServerName,
[in] DWORD dwLevel,
[in] SERVER_INFO* pServerInfo,
[in] DWORD dwReserved
);
typedef struct _DISK_INFO {
LPWSTR pszName;
} DISK_INFO;
typedef struct _DISK_ENUM {
DWORD dwEntries;
[size_is(dwEntries)] DISK_INFO *di;
} DISK_ENUM;
STATUS NetrServerDiskEnum( /* Function 0x17 */
[in,unique] LPWSTR pszServer,
[in] DWORD dwLevel,
[in,out] DISK_ENUM* pDiskEnum,
[in] DWORD dwMaxLen,
[out] DWORD* dwEntries,
[in,out] DWORD* hResume
);
typedef struct _STAT_SERVER {
DWORD dwStart;
DWORD dwFOpens;
DWORD dwDevOpens;
DWORD dwJobsQueued;
DWORD dwSOpens;
DWORD dwSTimedOut;
DWORD dwSErrors;
DWORD dwPWErrors;
DWORD dwPermErrors;
DWORD dwSysErrors;
DWORD dwBytesSentLow;
DWORD dwBytesSentHigh;
DWORD dwBytesRcvdLow;
DWORD dwBytesRcvdHigh;
DWORD dwAVResponse;
DWORD dwReqBufNeed;
DWORD dwBigBufNeed;
} STAT_SERVER;
STATUS NetrServerStatisticsGet( /* Function 0x18 */
[in,unique] LPWSTR pszServer,
[in] DWORD dwLevel,
[in] DWORD dwOptions,
[out] STAT_SERVER* pStatServer
);
typedef struct _TRANSPORT_INFO_0 {
LPWSTR pszName;
} TRANSPORT_INFO_0;
typedef union _TRANSPORT_INFO switch (DWORD dwLevel) ctr {
case 0: TRANSPORT_INFO_0 *ti0;
} TRANSPORT_INFO;
typedef struct _TRANSPORT_ENUM_0 {
DWORD dwEntries;
[size_is(dwEntries)] TRANSPORT_INFO_0 *ti0;
} TRANSPORT_ENUM_0;
typedef struct _TRANSPORT_ENUM {
DWORD dwLevel;
[switch_is(dwLevel)] union {
[case(0)] TRANSPORT_ENUM_0 *te0;
} ctr;
} TRANSPORT_ENUM;
STATUS NetrServerTransportAdd( /* Function 0x19 */
[in,unique] LPWSTR pszServer,
[in] DWORD dwLevel,
[out] TRANSPORT_INFO* pTransportInfo
);
STATUS NetrServerTransportEnum( /* Function 0x1a */
[in,unique] LPWSTR pszServer,
[in,out] TRANSPORT_ENUM* pTransportEnum,
[in] DWORD dwMaxLen,
[out] DWORD* dwEntries,
[in,out] DWORD* hResume
);
STATUS NetrServerTransportDel( /* Function 0x1b */
[in,unique] LPWSTR pszServer,
[in] DWORD dwLevel,
[out] TRANSPORT_INFO* pTransportInfo
);
typedef struct _TIME_OF_DAY {
DWORD dwElapsedTime;
DWORD dwMsecs;
DWORD dwHours;
DWORD dwMins;
DWORD dwSecs;
DWORD dwHunds;
LONG lTimeZone;
DWORD dwInterval;
DWORD dwDay;
DWORD dwMonth;
DWORD dwYear;
DWORD dwWeekday;
} TIME_OF_DAY;
STATUS NetrRemoteTOD( /* Function 0x1c */
[in,unique] LPWSTR pszServer,
[out] TIME_OF_DAY* pTOD
);
STATUS NetrServerSetServiceBits( /* Function 0x1d */
[in,unique] LPWSTR pszServer,
[in] DWORD hServiceStatus, /* ?? */
[in] DWORD dwServiceBits,
[in] BOOL bSetBitsOn,
[in] BOOL bUpdateImmediately
);
/* --- PATH INFORMATION --- */
STATUS NetprPathType( /* Function 0x1e */
void /* Not known */
);
STATUS NetprPathCanonicalize( /* Function 0x1f */
void /* Not known */
);
STATUS NetprPathCompare( /* Function 0x20 */
void /* Not known */
);
STATUS NetprNameValidate( /* Function 0x21 */
void /* Not known */
);
STATUS NetprNameCanonicalize( /* Function 0x22 */
void /* Not known */
);
STATUS NetprNameCompare( /* Function 0x23 */
void /* Not known */
);
/* --- LATER ADDITIONS --- */
STATUS NetrShareEnumSticky( /* Function 0x24 */
[in,unique] LPWSTR pszServer,
[in,out] SHARE_ENUM* pShareEnum,
[in] DWORD dwMaxLen,
[out] DWORD* dwEntries,
[in,out] DWORD* hResume
);
STATUS NetrShareDelStart( /* Function 0x25 */
[in,unique] LPWSTR pszServer,
[in,ref] LPWSTR pszShare,
[in] DWORD dwReserved /* ? */
);
STATUS NetrShareDelCommit( /* Function 0x26 */
[in,unique] LPWSTR pszServer
);
STATUS NetrpGetFileSecurity( /* Function 0x27 */
void /* Not known */
);
STATUS NetrpSetFileSecurity( /* Function 0x28 */
void /* Not known */
);
STATUS NetrServerTransportAddEx( /* Function 0x29 */
[in,unique] LPWSTR pszServer,
[in] DWORD dwLevel,
[out] TRANSPORT_INFO* pTransportInfo
);
STATUS NetrServerSetServiceBitsEx( /* Function 0x30 */
[in,unique] LPWSTR pszServer,
[in] DWORD hServiceStatus, /* ?? */
[in] DWORD dwServiceBits,
[in] BOOL bSetBitsOn,
[in] BOOL bUpdateImmediately
);

View File

@ -1,18 +0,0 @@
# template file handling
function print_template(f, tplname, v,
LOCAL, i, pat, line)
{
tplname="templates/"tplname;
if (numlines(tplname) <= 0) fatal("no template "tplname);
while ((getline line < tplname) > 0) {
while ((i = match(line,"@[a-zA-Z_]*@")) != 0) {
pat=substr(line,i+1,RLENGTH-2);
if (v[pat] == "") fatal("no value for "pat" in "tplname);
gsub("@"pat"@", v[pat], line);
}
xprintf(f, "%s\n", line);
}
close(tplname);
}

View File

@ -1,13 +0,0 @@
end:
/* the parse is OK */
return True;
fail:
if (UNMARSHALLING(ps)) {
ZERO_STRUCTP(il);
}
return False;
} /* @FUNCNAME@ */

View File

@ -1,8 +0,0 @@
end:
/* the parse is OK */
return True;
} /* @FUNCNAME@ */

View File

@ -1,12 +0,0 @@
/* the parse is OK */
return True;
fail:
if (UNMARSHALLING(ps)) {
ZERO_STRUCTP(il);
}
return False;
} /* @FUNCNAME@ */

View File

@ -1,15 +0,0 @@
/*******************************************************************
parse a @STRUCTNAME@ structure
********************************************************************/
BOOL @FUNCNAME@(char *desc, io_struct *ps, int depth,
@STRUCTNAME@ *il, unsigned flags)
{
io_debug(ps, depth, desc, "@FUNCNAME@");
depth++;
#if 0
if (UNMARSHALLING(ps)) {
ZERO_STRUCTP(il);
}
#endif
/* parse the scalars */

View File

@ -1,6 +0,0 @@
buffers:
if (!(flags & PARSE_BUFFERS)) goto end;
/* now parse the buffers */

View File

@ -1,17 +0,0 @@
/*******************************************************************
parse a @STRUCTNAME@ structure
********************************************************************/
BOOL @FUNCNAME@(char *desc, io_struct *ps, int depth,
@STRUCTNAME@ *il, unsigned flags)
{
io_debug(ps, depth, desc, "@FUNCNAME@");
depth++;
if (!(flags & PARSE_SCALARS)) goto buffers;
#if 0
if (UNMARSHALLING(ps)) {
ZERO_STRUCTP(il);
}
#endif
/* parse the scalars */

View File

@ -1,5 +0,0 @@
if (strcmp(test,"@TEST@")==0) {
@TEST@ il;
ret = io_@TEST@("@TEST@", ps, 0, &il, flags);
} else

View File

@ -1,7 +0,0 @@
{
printf("structure %s not found\n", test);
ret = False;
}
return ret;
}

View File

@ -1,7 +0,0 @@
#include "prs_@MODULE@.c"
static BOOL run_test(char *test, io_struct *ps, int flags)
{
BOOL ret;

View File

@ -1 +0,0 @@
}

View File

@ -1,2 +0,0 @@
if (il->@ELEM@) {
if (!io_alloc("@ELEM@", ps, (void **)&il->@ELEM@, sizeof(*(il->@ELEM@)))) goto fail;

View File

@ -1,3 +0,0 @@
/* end auto-generated structure parsers for @MODULE@ */

View File

@ -1,5 +0,0 @@
/* auto-generated structure parsers for @MODULE@
generated by aparser
*/
#include "prs_@MODULE@.h"

View File

@ -1 +0,0 @@
if(!io_align(ps)) goto fail;

View File

@ -1 +0,0 @@
if (!io_align2(ps, @OFFSET@)) goto fail;

View File

@ -1 +0,0 @@
if (!io_align4(ps, @OFFSET@)) goto fail;

View File

@ -1,8 +0,0 @@
if ((@FLAGS@ & PARSE_SCALARS) &&
!io_alloc("@ELEM@", ps, (void **)&il->@ELEM@, sizeof(*(il->@ELEM@))*(il->@ARRAY_LEN@))) goto fail;
{
int i;
for (i=0;i<il->@ARRAY_LEN@;i++) {
if (!io_@TYPE@("@ELEM@...", ps, depth+1, &il->@ELEM@[i], @FLAGS@)) goto fail;
}
}

View File

@ -1,5 +0,0 @@
if ((MARSHALLING(ps) && il->@ELEM@) ||
ps->data_offset < ps->buffer_size) {
if (!io_alloc("@ELEM@", ps, (void **)&il->@ELEM@, sizeof(*(il->@ELEM@)))) goto fail;
if (!io_@TYPE@("@ELEM@...", ps, depth+1, il->@ELEM@, @FLAGS@)) goto fail;
}

View File

@ -1,17 +0,0 @@
if (UNMARSHALLING(ps))
{
int i;
for (i=0;ps->data_offset < ps->buffer_size;i++) {
if (!io_alloc("@ELEM@", ps, (void **)&il->@ELEM@, sizeof(*(il->@ELEM@))*(i+1))) goto fail;
if (!io_@TYPE@("@ELEM@...", ps, depth+1, &il->@ELEM@[i], @FLAGS@)) goto fail;
}
}
else
{
int i = -1;
/* HACK ALERT! */
do {
i++;
if (!io_@TYPE@("@ELEM@...", ps, depth+1, &il->@ELEM@[i], @FLAGS@)) goto fail;
} while (il->@ELEM@[i].tag2 != 0);
}

View File

@ -1 +0,0 @@
break;

View File

@ -1 +0,0 @@
case @CASE@:

View File

@ -1 +0,0 @@
break;

View File

@ -1 +0,0 @@
if (!io_@TYPE@("@ELEM@", ps, depth+1, @PTR@il->@ELEM@, @FLAGS@)) goto fail;

View File

@ -1,2 +0,0 @@
if (!io_pointer("@ELEM@_ptr", ps, depth+1,
(void **)&il->@ELEM@, @FLAGS@)) goto fail;

View File

@ -1 +0,0 @@
if (!@MODULE@_io_@TYPE@("@ELEM@", &il->@ELEM@, ps, depth+1)) goto fail;

View File

@ -1 +0,0 @@
if (!@MODULE@_io_@TYPE@_alloc("@ELEM@", &il->@ELEM@, ps, depth+1)) goto fail;

View File

@ -1 +0,0 @@
if (!io_uint16("@ELEM@", ps, depth+1, &il->@ELEM@)) goto fail;

View File

@ -1 +0,0 @@
if (!io_uint32("@ELEM@", ps, depth+1, &il->@ELEM@)) goto fail;

View File

@ -1,2 +0,0 @@
if (!io_alloc("@ELEM@", ps, (void **)&il->@ELEM@, sizeof(*(il->@ELEM@))*(il->@ARRAY_LEN@))) goto fail;
if (!io_uint8s("@ELEM@", ps, depth+1, &il->@ELEM@, il->@ARRAY_LEN@, @FLAGS@)) goto fail;

View File

@ -1 +0,0 @@
if (!io_uint8s_fixed("@ELEM@", ps, depth+1, il->@ELEM@, @ARRAY_LEN@, @FLAGS@)) goto fail;

View File

@ -1,2 +0,0 @@
if (!io_alloc("@ELEM@", ps, (void **)&il->@ELEM@, sizeof(*(il->@ELEM@))*(il->@ARRAY_LEN@))) goto fail;
if (!io_wstring("@ELEM@", ps, depth+1, il->@ELEM@, il->@ARRAY_LEN@, @FLAGS@)) goto fail;

View File

@ -1,2 +0,0 @@
if (!io_alloc("@ELEM@", ps, (void **)&il->@ELEM@, sizeof(*(il->@ELEM@))*(@ARRAY_LEN@))) goto fail;
if (!io_wstring("@ELEM@", ps, depth+1, il->@ELEM@, @ARRAY_LEN@, @FLAGS@)) goto fail;

View File

@ -1,5 +0,0 @@
default:
DEBUG(5,("No handler for case %d in @FUNCNAME@\n",
(int)il->@SWITCH@));
goto fail;
}

View File

@ -1 +0,0 @@
switch (il->@SWITCH@) {

View File

@ -1,180 +0,0 @@
# tokenise the input file
function parse_error(msg) {
printf("PARSE ERROR: %s\nLine "NR" : "$0"\n", msg);
exit 1;
}
# ignore multi-line C comments.
{
if (t = index($0, "/*")) {
if (t > 1)
tmp = substr($0, 1, t - 1)
else
tmp = ""
u = index(substr($0, t + 2), "*/")
while (u == 0) {
getline
t = -1
u = index($0, "*/")
}
if (u <= length($0) - 2)
$0 = tmp substr($0, t + u + 3)
else
$0 = tmp
}
}
# ignore blank lines
/^[ \t]*$/ {
next;
}
/^\#define.*/ {
split($0,a,"[ \t;]*");
parse_define(a[2], a[3]);
next;
}
# ignore comments
/^[ \t]*\#/ {
next;
}
/^[ \t]*module/ {
{if (module!="") parse_error("you can only specify one module name");}
start_module($2);
next;
}
{if (module=="") parse_error("you must specify the module name first");}
/^[ \t]*option/ {
set_option($2, $3);
next;
}
/^[ \t]*typedef struct.*\{/ {
{if (current_struct!="") parse_error("you cannot have nested structures");}
start_struct($3);
next;
}
/^[ \t]*struct.*\{/ {
{if (current_struct!="") parse_error("you cannot have nested structures");}
start_struct($2);
next;
}
/^[ \t]*typedef union.*\{/ {
{if (current_struct!="") parse_error("this cannot appear inside a structure");}
split($0,a,"[ \t;()]*");
start_union_encap(a[4], a[6], a[7], a[8]);
next;
}
/^[ \t]*void.*\(/ {
{if (current_struct!="") parse_error("you cannot have nested structures");}
split($0,a,"[ \t;()]*");
start_function(a[2], a[3]);
return_result="void";
next;
}
/^[ \t]*STATUS.*\(|^[ \t]*void.*\(/ {
{if (current_struct!="") parse_error("you cannot have nested structures");}
split($0,a,"[ \t;()]*");
start_function(a[2], a[3]);
return_result="STATUS";
next;
}
{if (current_struct=="") parse_error("this must appear inside a structure");}
/^[ \t]*union.*\{/ {
{if (current_union!="") parse_error("you cannot have nested unions");}
start_union($2);
next;
}
/^[ \t]*\[switch_is.*union.*\{/ {
{if (current_union!="") parse_error("you cannot have nested unions");}
split($0,a,"[ \t;()]*");
start_union_notencap(a[3]);
next;
}
/^[ \t]*case.*;/ {
{if (current_union=="") parse_error("this must appear inide a union");}
split($0,a,"[ \t;]*");
parse_case(a[3],a[4],a[5]);
next;
}
/^[ \t]*\[case(.*)\].*;/ {
{if (current_union=="") parse_error("this must appear inide a union");}
split($0,a,"[ \t;()[\]]*");
parse_case(a[6],a[8],a[9]);
next;
}
/^[ \t]*\}$/ {
{if (current_union=="") parse_error("this must appear inside a union");}
end_union("");
next;
}
/^[ \t]*\} .*;/ {
if (current_union!="") {
split($2,a,"[ \t;]*");
end_union(a[1]);
next;
}
}
{if (current_union!="") parse_error("this cannot appear inside a union");}
/^[ \t]*\};/ {
end_struct("");
next;
}
/^[ \t]*\} .*;/ {
split($2,a,"[ \t;]*");
end_struct(a[1]);
next;
}
/^[ \t]*\);/ {
end_function();
return_result="";
next;
}
/^.*size_is.*\*.*;/ {
split($0,a,"[ \t;()]*");
add_sizeis_array(a[3], a[5], a[6]);
next;
}
/^.*;/ {
split($0,a,"[ \t;]*");
add_struct_elem(a[2], a[3]);
next;
}
/^[\t ]*void/ {
next;
}
/^[ \t]*\[.*\].*/ {
split($0,a,"[ \t;]*");
split(a[4], b, "[,]");
add_function_param(a[2], a[3], b[1]);
next;
}
{
parse_error("Unknown construct.");
}

View File

@ -1,39 +0,0 @@
function isaptr(elem)
{
if (substr(elem, 1, 1) == "*") {
return 1;
}
return 0;
}
function noptr(elem)
{
if (!isaptr(elem)) return elem;
return substr(elem, 2);
}
function xprintf(f, fmt, v1, v2, v3, v4, v5, v6, v7)
{
printf(fmt, v1, v2, v3, v4, v5, v6) > f;
}
function fatal(why)
{
printf("FATAL: %s\n", why);
exit 1;
}
function numlines(fname,
LOCAL, line, count)
{
count=0;
while ((getline line < fname) > 0) count++;
close(fname);
return count;
}
# return 1 if the string is a constant
function is_constant(s)
{
return match(s,"^[0-9]+$");
}

View File

@ -1,112 +0,0 @@
#include "parser.h"
/*******************************************************************
Count the number of characters (not bytes) in a unicode string.
********************************************************************/
size_t strlen_w(void *src)
{
size_t len;
for (len = 0; SVAL(src, len*2); len++) ;
return len;
}
/****************************************************************************
expand a pointer to be a particular size
****************************************************************************/
void *Realloc(void *p,size_t size)
{
void *ret=NULL;
if (size == 0) {
if (p) free(p);
DEBUG(5,("Realloc asked for 0 bytes\n"));
return NULL;
}
if (!p)
ret = (void *)malloc(size);
else
ret = (void *)realloc(p,size);
if (!ret)
DEBUG(0,("Memory allocation error: failed to expand to %d bytes\n",(int)size));
return(ret);
}
char *tab_depth(int depth)
{
static pstring spaces;
memset(spaces, ' ', depth * 4);
spaces[depth * 4] = 0;
return spaces;
}
void print_asc(int level, uchar const *buf, int len)
{
int i;
for (i = 0; i < len; i++)
{
DEBUGADD(level, ("%c", isprint(buf[i]) ? buf[i] : '.'));
}
}
void dump_data(int level, char *buf1, int len)
{
uchar const *buf = (uchar const *)buf1;
int i = 0;
if (buf == NULL)
{
DEBUG(level, ("dump_data: NULL, len=%d\n", len));
return;
}
if (len < 0)
return;
if (len == 0)
{
DEBUG(level, ("\n"));
return;
}
DEBUG(level, ("[%03X] ", i));
for (i = 0; i < len;)
{
DEBUGADD(level, ("%02X ", (int)buf[i]));
i++;
if (i % 8 == 0)
DEBUGADD(level, (" "));
if (i % 16 == 0)
{
print_asc(level, &buf[i - 16], 8);
DEBUGADD(level, (" "));
print_asc(level, &buf[i - 8], 8);
DEBUGADD(level, ("\n"));
if (i < len)
DEBUGADD(level, ("[%03X] ", i));
}
}
if (i % 16 != 0) /* finish off a non-16-char-length row */
{
int n;
n = 16 - (i % 16);
DEBUGADD(level, (" "));
if (n > 8)
DEBUGADD(level, (" "));
while (n--)
DEBUGADD(level, (" "));
n = MIN(8, i % 16);
print_asc(level, &buf[i - (i % 16)], n);
DEBUGADD(level, (" "));
n = (i % 16) - n;
if (n > 0)
print_asc(level, &buf[i - n], n);
DEBUGADD(level, ("\n"));
}
}

View File

@ -1,41 +0,0 @@
#include "parser.h"
#include "test.h"
int main(int argc, char *argv[])
{
BOOL ret;
char *fname, *test;
int fd;
struct stat st;
io_struct ps;
if (argc < 3) {
printf("usage: vluke <structure> <file>\n");
exit(1);
}
test = argv[1];
fname = argv[2];
fd = open(fname,O_RDONLY);
if (fd == -1) {
perror(fname);
exit(1);
}
fstat(fd, &st);
io_init(&ps, 0, MARSHALL);
ps.is_dynamic=True;
io_read(&ps, fd, st.st_size, 0);
ps.data_offset = 0;
ps.buffer_size = ps.grow_size;
ps.io = UNMARSHALL;
ps.autoalign = OPTION_autoalign;
ret = run_test(test, &ps, PARSE_SCALARS|PARSE_BUFFERS);
printf("\nret=%s\n", ret?"OK":"Bad");
printf("Trailer is %d bytes\n\n", ps.grow_size - ps.data_offset);
if (ps.grow_size - ps.data_offset > 0) {
dump_data(0, ps.data_p + ps.data_offset, ps.grow_size - ps.data_offset);
}
return !ret;
}