Duplicate widl tool to widl_new

svn path=/trunk/; revision=28872
This commit is contained in:
Hervé Poussineau
2007-09-05 11:11:31 +00:00
parent 05e11ee73f
commit 72e2ba5445
29 changed files with 23171 additions and 0 deletions
+298
View File
@@ -0,0 +1,298 @@
ChangeLog
2007-05-17 ekohl
tools/widl/lex.yy.c
tools/widl/parser.l
tools/widl/typelib.c
- Update wpp and fix the wpp_find_include issue!
2006-07-30 ekohl
- Synchronized with WINE widl 20060729.
The only difference is one call to wpp_find_include in parser.l.
We'll need to fix this issue!
2006-02-27 ekohl
tools/widl/client.c
tools/widl/server.c
- Dereference type declarations properly.
2006-02-27 ekohl
tools/widl/client.c
tools/widl/server.c
- Move proc string offset calculation to a separate function.
- Replace all __FUNCTION__ by __FILE__.
2006-01-01 ekohl
tools/widl/client.c
tools/widl/server.c
- Generate static MIDL_PROC_FORMAT_STRING, MIDL_TYPE_FORMAT_STRING and
MIDL_STUB_DESC variables.
2005-12-05 ekohl
tools/widl/widl.c
tools/widl/widl.man
- Change oldnames option from '-o' to '--oldnames'.
2005-11-26 ekohl
tools/widl/client.c
tools/widl/server.c
- Allocate another 4 bytes for unique pointers to simple types.
2005-10-16 ekohl
tools/widl/client.c
tools/widl/server.c
- Fix [out, size_is, unique] parameter issues.
2005-10-09 ekohl
tools/widl/client.c
tools/widl/server.c
- Support [out, unique] base type parameters.
2005-08-07 ekohl
tools/widl/server.c
- Support size_is(*Length) attributes for strings.
2005-07-30 ekohl
tools/widl/client.c
tools/widl/server.c
- Support conformant arrays as in and out parameters.
- Fix message buffer size calculation for client and server.
2005-07-25 ekohl
tools/widl/client.c
tools/widl/lex.yy.c
tools/widl/parser.y
tools/widl/proxy.c
tools/widl/server.c
tools/widl/y.tab.c
tools/widl/y.tab.h
- Fix grammar of the size_is attribute so that size_is(*Length) gets accepted.
2005-07-23 ekohl
tools/widl/client.c
tools/widl/server.c
- Fix offset calculation bug in the ProcFormatString.
- Fix offset calculation bug in the marshalling and unmarshalling code.
- Fix typos in the TypeFormatString.
This makes the [string, out, size_is()] parameters work properly.
2005-07-17 ekohl
tools/widl/client.c
tools/widl/server.c
Fix bugs for in-string parameters.
Implement out-string parameters (untested).
2005-05-08 weiden
tools/widl/server.c
Don't generate lvalue assignment code.
2005-05-08 weiden
tools/widl/client.c
tools/widl/proxy.c
tools/widl/server.c
Generate code GCC4.x accepts.
2005-04-18 navaraf
tools/widl/parser.y
Don't use pointer to freed memory.
2005-04-17 ekohl
tools/widl/server.c
Support out-pointers to structs.
2005-04-15 ekohl
tools/widl/client.c
tools/widl/parser.y
tools/widl/server.c
Support in-pointers to structs.
2005-04-03 ekohl
tools/widl/client.c
tools/widl/parser.l
tools/widl/parser.y
tools/widl/server.c
tools/widl/widltypes.h
Support 'ref' and 'unique' attributes for pointers.
2005-03-27 Jacek Caban (from WINE)
tools/widl/parser.y
tools/widl/y.tab.c
Added handling of unsigned type
2005-03-25 ekohl
tools/widl/client.c
tools/widl/server.c
Generate code without L-value casts. Fix remaining issues.
2005-03-21 navaraf
tools/widl/client.c
Fix a typo in write_function_stubs.
2005-03-20 navaraf
tools/widl/client.c
tools/widl/server.c
Generate code without L-value casts.
2005-03-20 ekohl
tools/widl/client.c
tools/widl/server.c
Improve error messages.
Don't start counting the type_offset for each new fuction. It is a global offset.
Use only basic types in type- and proc-strings (e.g. unsigned long -> long).
2005-03-13 ekohl
tools/widl/server.c
Remove debug printf().
2005-03-13 jimtabor
tools/widl/write_msft.c
Fixup *nix port, added include fcntl.h and unistd.h.
2005-03-13 royce3
tools/widl/hash.c
tools/widl/Makefile
tools/widl/write_msft.c
-Wall -Werror and fix warnings
2005-03-13 ekohl
tools/widl/client.c
tools/widl/server.c
Implement [string] attribute for pointers to char and wchar_t.
2005-03-12 ekohl
tools/widl/client.c
tools/widl/server.c
Implement [in], [out] and [in, out] support for pointers to basic types.
2005-03-10 ekohl
tools/widl/client.c
tools/widl/header.c
tools/widl/server.c
tools/widl/widl.c
tools/widl/widl.h
Implement '-o' option. This is equivalent to MIDLs '/oldnames' option.
2005-03-06 ekohl
tools/widl/client.c
tools/widl/header.c
tools/widl/header.h
tools/widl/server.c
Support pointers to simple types as input arguments.
2005-02-27 sedwards
tools/widl/y.tab.c
tools/widl/parser.y
tools/widl/widl.c
tools/widl/widl.h
tools/widl/server.c
tools/widl/typelib.c
Merge in Winehq changes to reduce noise.
tools/widl/server.h
tools/widl/client.h
tools/widl/proxy.h
Deleted unneeded headers.
2005-02-26 ekohl
tools/widl/server.c
Server stubs are void functions.
Fix a warning in the server stub descriptor.
2005-02-25 ekohl
tools/widl/client.c
tools/widl/header.c
tools/widl/header.h
tools/widl/server.c
Support multiple interfaces per idl file.
Support explicit binding handles.
2005-02-24 ekohl
include/wine/rpcfc.h
tools/widl/client.c
tools/widl/header.c
tools/widl/parser.l
tools/widl/parser.y
tools/widl/server.c
Support remaining basic types (float, double, small, wchar_t and handle_t).
+53
View File
@@ -0,0 +1,53 @@
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
EXEEXT = @EXEEXT@
PROGRAMS = widl$(EXEEXT)
MANPAGES = widl.man
MODULE = none
C_SRCS = \
client.c \
hash.c \
header.c \
proxy.c \
server.c \
typegen.c \
typelib.c \
utils.c \
widl.c \
write_msft.c
EXTRA_SRCS = parser.y parser.l
EXTRA_OBJS = parser.tab.o @[email protected]
all: $(PROGRAMS) $(MANPAGES)
@MAKE_RULES@
widl$(EXEEXT): $(OBJS) $(LIBWPP)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBWPP) $(LIBPORT) $(LEXLIB) $(LDFLAGS)
parser.tab.c parser.tab.h: parser.y
$(BISON) -d -t $(SRCDIR)/parser.y -o parser.tab.c
# hack to allow parallel make
parser.tab.h: parser.tab.c
parser.tab.o: parser.tab.h
@[email protected]: parser.l
$(LEX) $(SRCDIR)/parser.l
@[email protected]: parser.tab.h
install:: $(PROGRAMS) $(MANPAGES)
$(MKINSTALLDIRS) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man$(prog_manext)
$(INSTALL_PROGRAM) widl$(EXEEXT) $(DESTDIR)$(bindir)/widl$(EXEEXT)
$(INSTALL_DATA) widl.man $(DESTDIR)$(mandir)/man$(prog_manext)/widl.$(prog_manext)
uninstall::
$(RM) $(DESTDIR)$(bindir)/widl$(EXEEXT) $(DESTDIR)$(mandir)/man$(prog_manext)/widl.$(prog_manext)
### Dependencies:
+524
View File
@@ -0,0 +1,524 @@
/*
* IDL Compiler
*
* Copyright 2005-2006 Eric Kohl
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <signal.h>
#include "windef.h"
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "header.h"
#include "widltypes.h"
#include "typelib.h"
#include "typelib_struct.h"
#include "typegen.h"
static FILE* client;
static int indent = 0;
static int print_client( const char *format, ... )
{
va_list va;
int i, r;
va_start(va, format);
for (i = 0; i < indent; i++)
fprintf(client, " ");
r = vfprintf(client, format, va);
va_end(va);
return r;
}
static void print_message_buffer_size(const func_t *func)
{
unsigned int total_size = 0;
if (func->args)
{
const var_t *var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
{
unsigned int alignment;
total_size += get_required_buffer_size(var, &alignment, PASS_IN);
total_size += alignment;
var = PREV_LINK(var);
}
}
fprintf(client, " %u", total_size);
}
static void check_pointers(const func_t *func)
{
var_t *var;
int pointer_type;
if (!func->args)
return;
var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
{
pointer_type = get_attrv(var->attrs, ATTR_POINTERTYPE);
if (!pointer_type)
pointer_type = RPC_FC_RP;
if (pointer_type == RPC_FC_RP)
{
if (var->ptr_level >= 1)
{
print_client("if (!%s)\n", var->name);
print_client("{\n");
indent++;
print_client("RpcRaiseException(RPC_X_NULL_REF_POINTER);\n");
indent--;
print_client("}\n\n");
}
}
var = PREV_LINK(var);
}
}
static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsigned int *type_offset)
{
const func_t *func = iface->funcs;
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE);
var_t *var;
int method_count = 0;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
{
const var_t *def = func->def;
const var_t* explicit_handle_var;
unsigned int type_offset_func;
/* check for a defined binding handle */
explicit_handle_var = get_explicit_handle_var(func);
if (explicit_handle)
{
if (!explicit_handle_var)
{
error("%s() does not define an explicit binding handle!\n", def->name);
return;
}
}
else if (implicit_handle)
{
if (explicit_handle_var)
{
error("%s() must not define a binding handle!\n", def->name);
return;
}
}
write_type(client, def->type, def, def->tname);
fprintf(client, " ");
write_name(client, def);
fprintf(client, "(\n");
indent++;
if (func->args)
write_args(client, func->args, iface->name, 0, TRUE);
else
print_client("void");
fprintf(client, ")\n");
indent--;
/* write the functions body */
fprintf(client, "{\n");
indent++;
/* declare return value '_RetVal' */
if (!is_void(def->type, NULL))
{
print_client("");
write_type(client, def->type, def, def->tname);
fprintf(client, " _RetVal;\n");
}
if (implicit_handle || explicit_handle_var)
print_client("RPC_BINDING_HANDLE _Handle = 0;\n");
print_client("RPC_MESSAGE _RpcMessage;\n");
print_client("MIDL_STUB_MESSAGE _StubMsg;\n");
fprintf(client, "\n");
/* check pointers */
check_pointers(func);
print_client("RpcTryFinally\n");
print_client("{\n");
indent++;
print_client("NdrClientInitializeNew(\n");
indent++;
print_client("(PRPC_MESSAGE)&_RpcMessage,\n");
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
print_client("(PMIDL_STUB_DESC)&%s_StubDesc,\n", iface->name);
print_client("%d);\n", method_count);
indent--;
fprintf(client, "\n");
if (implicit_handle)
{
print_client("_Handle = %s;\n", implicit_handle);
fprintf(client, "\n");
}
else if (explicit_handle_var)
{
print_client("_Handle = %s;\n", explicit_handle_var->name);
fprintf(client, "\n");
}
/* emit the message buffer size */
print_client("_StubMsg.BufferLength =");
print_message_buffer_size(func);
fprintf(client, ";\n");
type_offset_func = *type_offset;
write_remoting_arguments(client, indent, func, &type_offset_func, PASS_IN, PHASE_BUFFERSIZE);
print_client("NdrGetBuffer(\n");
indent++;
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
print_client("_StubMsg.BufferLength,\n");
if (implicit_handle || explicit_handle_var)
print_client("_Handle);\n");
else
print_client("%s__MIDL_AutoBindHandle);\n", iface->name);
indent--;
fprintf(client, "\n");
/* make a copy so we don't increment the type offset twice */
type_offset_func = *type_offset;
/* marshal arguments */
write_remoting_arguments(client, indent, func, &type_offset_func, PASS_IN, PHASE_MARSHAL);
/* send/receive message */
/* print_client("NdrNsSendReceive(\n"); */
/* print_client("(unsigned char *)_StubMsg.Buffer,\n"); */
/* print_client("(RPC_BINDING_HANDLE *) &%s__MIDL_AutoBindHandle);\n", iface->name); */
print_client("NdrSendReceive(\n");
indent++;
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
print_client("(unsigned char *)_StubMsg.Buffer);\n\n");
indent--;
print_client("_StubMsg.BufferStart = (unsigned char *)_RpcMessage.Buffer;\n");
print_client("_StubMsg.BufferEnd = _StubMsg.BufferStart + _RpcMessage.BufferLength;\n");
if (has_out_arg_or_return(func))
{
fprintf(client, "\n");
print_client("if ((_RpcMessage.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
indent++;
print_client("NdrConvert(\n");
indent++;
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
print_client("(PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n", *proc_offset);
indent -= 2;
}
/* unmarshall arguments */
fprintf(client, "\n");
write_remoting_arguments(client, indent, func, type_offset, PASS_OUT, PHASE_UNMARSHAL);
/* unmarshal return value */
if (!is_void(def->type, NULL))
print_phase_basetype(client, indent, PHASE_UNMARSHAL, PASS_RETURN, def, "_RetVal");
/* update proc_offset */
if (func->args)
{
var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
{
*proc_offset += get_size_procformatstring_var(var);
var = PREV_LINK(var);
}
}
if (!is_void(def->type, NULL))
*proc_offset += get_size_procformatstring_var(def);
else
*proc_offset += 2; /* FC_END and FC_PAD */
indent--;
print_client("}\n");
print_client("RpcFinally\n");
print_client("{\n");
indent++;
/* FIXME: emit client finally code */
print_client("NdrFreeBuffer((PMIDL_STUB_MESSAGE)&_StubMsg);\n");
indent--;
print_client("}\n");
print_client("RpcEndFinally\n");
/* emit return code */
if (!is_void(def->type, NULL))
{
fprintf(client, "\n");
print_client("return _RetVal;\n");
}
indent--;
fprintf(client, "}\n");
fprintf(client, "\n");
method_count++;
func = PREV_LINK(func);
}
}
static void write_bindinghandledecl(type_t *iface)
{
print_client("static RPC_BINDING_HANDLE %s__MIDL_AutoBindHandle;\n", iface->name);
fprintf(client, "\n");
}
static void write_stubdescdecl(type_t *iface)
{
print_client("static const MIDL_STUB_DESC %s_StubDesc;\n", iface->name);
fprintf(client, "\n");
}
static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
{
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
print_client("static const MIDL_STUB_DESC %s_StubDesc =\n", iface->name);
print_client("{\n");
indent++;
print_client("(void *)& %s___RpcClientInterface,\n", iface->name);
print_client("MIDL_user_allocate,\n");
print_client("MIDL_user_free,\n");
print_client("{\n");
indent++;
if (implicit_handle)
print_client("&%s,\n", implicit_handle);
else
print_client("&%s__MIDL_AutoBindHandle,\n", iface->name);
indent--;
print_client("},\n");
print_client("0,\n");
print_client("0,\n");
if (expr_eval_routines)
print_client("ExprEvalRoutines,\n");
else
print_client("0,\n");
print_client("0,\n");
print_client("__MIDL_TypeFormatString.Format,\n");
print_client("1, /* -error bounds_check flag */\n");
print_client("0x10001, /* Ndr library version */\n");
print_client("0,\n");
print_client("0x50100a4, /* MIDL Version 5.1.164 */\n");
print_client("0,\n");
print_client("0,\n");
print_client("0, /* notify & notify_flag routine table */\n");
print_client("1, /* Flags */\n");
print_client("0, /* Reserved3 */\n");
print_client("0, /* Reserved4 */\n");
print_client("0 /* Reserved5 */\n");
indent--;
print_client("};\n");
fprintf(client, "\n");
}
static void write_clientinterfacedecl(type_t *iface)
{
unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION);
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
print_client("static const RPC_CLIENT_INTERFACE %s___RpcClientInterface =\n", iface->name );
print_client("{\n");
indent++;
print_client("sizeof(RPC_CLIENT_INTERFACE),\n");
print_client("{{0x%08lx,0x%04x,0x%04x,{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x}},{%d,%d}},\n",
uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1],
uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6],
uuid->Data4[7], LOWORD(ver), HIWORD(ver));
print_client("{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},\n"); /* FIXME */
print_client("0,\n");
print_client("0,\n");
print_client("0,\n");
print_client("0,\n");
print_client("0,\n");
print_client("0,\n");
indent--;
print_client("};\n");
if (old_names)
print_client("RPC_IF_HANDLE %s_ClientIfHandle = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n",
iface->name, iface->name);
else
print_client("RPC_IF_HANDLE %s_v%d_%d_c_ifspec = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n",
iface->name, LOWORD(ver), HIWORD(ver), iface->name);
fprintf(client, "\n");
}
static void write_formatdesc( const char *str )
{
print_client("typedef struct _MIDL_%s_FORMAT_STRING\n", str );
print_client("{\n");
indent++;
print_client("short Pad;\n");
print_client("unsigned char Format[%s_FORMAT_STRING_SIZE];\n", str);
indent--;
print_client("} MIDL_%s_FORMAT_STRING;\n", str);
print_client("\n");
}
static void write_formatstringsdecl(ifref_t *ifaces)
{
print_client("#define TYPE_FORMAT_STRING_SIZE %d\n",
get_size_typeformatstring(ifaces));
print_client("#define PROC_FORMAT_STRING_SIZE %d\n",
get_size_procformatstring(ifaces));
fprintf(client, "\n");
write_formatdesc("TYPE");
write_formatdesc("PROC");
fprintf(client, "\n");
print_client("static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;\n");
print_client("static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;\n");
print_client("\n");
}
static void write_implicithandledecl(type_t *iface)
{
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
if (implicit_handle)
{
fprintf(client, "handle_t %s;\n", implicit_handle);
fprintf(client, "\n");
}
}
static void init_client(void)
{
if (client) return;
if (!(client = fopen(client_name, "w")))
error("Could not open %s for output\n", client_name);
print_client("/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", WIDL_FULLVERSION, input_name);
print_client("#include <string.h>\n");
print_client("#ifdef _ALPHA_\n");
print_client("#include <stdarg.h>\n");
print_client("#endif\n");
fprintf(client, "\n");
print_client("#include \"%s\"\n", header_name);
fprintf(client, "\n");
}
void write_client(ifref_t *ifaces)
{
unsigned int proc_offset = 0;
unsigned int type_offset = 2;
ifref_t *iface = ifaces;
if (!do_client)
return;
if (!iface)
return;
END_OF_LIST(iface);
init_client();
if (!client)
return;
write_formatstringsdecl(ifaces);
for (; iface; iface = PREV_LINK(iface))
{
if (is_object(iface->iface->attrs) || is_local(iface->iface->attrs))
continue;
fprintf(client, "/*****************************************************************************\n");
fprintf(client, " * %s interface\n", iface->iface->name);
fprintf(client, " */\n");
fprintf(client, "\n");
if (iface->iface->funcs)
{
int expr_eval_routines;
write_implicithandledecl(iface->iface);
write_clientinterfacedecl(iface->iface);
write_stubdescdecl(iface->iface);
write_bindinghandledecl(iface->iface);
write_function_stubs(iface->iface, &proc_offset, &type_offset);
print_client("#if !defined(__RPC_WIN32__)\n");
print_client("#error Invalid build platform for this stub.\n");
print_client("#endif\n");
fprintf(client, "\n");
expr_eval_routines = write_expr_eval_routines(client, iface->iface->name);
if (expr_eval_routines)
write_expr_eval_routine_list(client, iface->iface->name);
write_stubdescriptor(iface->iface, expr_eval_routines);
}
}
fprintf(client, "\n");
write_procformatstring(client, ifaces);
write_typeformatstring(client, ifaces);
fclose(client);
}
+621
View File
@@ -0,0 +1,621 @@
/*
* Oleaut32 hash functions
*
* Copyright 1999 Corel Corporation
* Copyright 2001-2003 Jon Griffiths
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdio.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "hash.h"
static const unsigned char Lookup_16[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x55, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x56, 0x58, 0x55, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x7F, 0x7F, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x7F, 0x89, 0x53, 0x8B, 0x8C,
0x7F, 0x7F, 0x7F, 0x7F, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x96, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x7F, 0x7F, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x96, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x4F, 0x55, 0x55,
0x55, 0x55, 0x55, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43,
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0x4F, 0xF7, 0x4F, 0x55, 0x55, 0x55, 0x55, 0x55, 0xDE, 0x55,
/* Mac */
0x41, 0x41, 0x43, 0x45, 0x4E, 0x4F, 0x55, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0x4F, 0x55, 0x55, 0x55, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0x41, 0x4F, 0xB0, 0xB1, 0xB2, 0xB3,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0x41, 0x4F, 0xBD, 0x41, 0x4F, 0xC0,
0xC1, 0xC2, 0xC3, 0x46, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0x41, 0x41, 0x4F,
0xCE, 0xCE, 0xD0, 0xD0, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0x55, 0x55, 0xDA,
0xDB, 0xDC, 0xDD, 0x3F, 0x3F, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0x41, 0x45, 0x41,
0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4F, 0x4F, 0x3F, 0x4F, 0x55, 0x55, 0x55,
0x49, 0x7F, 0xF7, 0x7F, 0xF9, 0xFA, 0xFB, 0x3F, 0xFD, 0xFE, 0x7F
};
static const unsigned char Lookup_32[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x7F, 0x7F, 0x82, 0x7F, 0x84, 0x85, 0x86, 0x87, 0x7F, 0x89, 0x53, 0x8B, 0x53,
0x54, 0x5A, 0x5A, 0x7F, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x96, 0x7F, 0x99,
0x53, 0x9B, 0x53, 0x54, 0x5A, 0x5A, 0xA0, 0x7F, 0xA2, 0x4C, 0xA4, 0x41, 0xA6,
0xA7, 0xA8, 0xA9, 0x53, 0xAB, 0xAC, 0x96, 0xAE, 0x5A, 0xB0, 0xB1, 0xB2, 0x4C,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x41, 0x53, 0xBB, 0x4C, 0xBD, 0x4C, 0x5A, 0x52,
0x41, 0x41, 0x41, 0x41, 0x4C, 0x43, 0x43, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49,
0x49, 0x44, 0xD0, 0x4E, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x52, 0x55, 0x55,
0x55, 0x55, 0x59, 0x54, 0xDF, 0x52, 0x41, 0x41, 0x41, 0x41, 0x4C, 0x43, 0x43,
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x44, 0xD0, 0x4E, 0x4E, 0x4F, 0x4F,
0x4F, 0x4F, 0xF7, 0x52, 0x55, 0x55, 0x55, 0x55, 0x59, 0x54, 0xFF,
/* Mac */
0x41, 0x41, 0x41, 0x45, 0x41, 0x4F, 0x55, 0x41, 0x41, 0x43, 0x41, 0x43, 0x43,
0x43, 0x45, 0x5A, 0x5A, 0x44, 0x49, 0x44, 0x45, 0x45, 0x45, 0x4F, 0x45, 0x4F,
0x4F, 0x4F, 0x55, 0x45, 0x45, 0x55, 0xA0, 0xA1, 0x45, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0x45, 0xAC, 0xAD, 0x47, 0x49, 0x49, 0x49, 0xB2, 0xB3,
0x49, 0x4B, 0xB6, 0xB7, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4E, 0x4E,
0x4E, 0xC2, 0xC3, 0x4E, 0x4E, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0x4E, 0x4F, 0x4F,
0x4F, 0x4F, 0xD0, 0xD0, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0x4F, 0x52, 0x52,
0x52, 0xDC, 0xDD, 0x52, 0x52, 0x52, 0x53, 0xE2, 0xE3, 0x53, 0x53, 0x53, 0x41,
0x54, 0x54, 0x49, 0x5A, 0x5A, 0x55, 0x4F, 0x4F, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x59, 0x59, 0x4B, 0x5A, 0x4C, 0x4C, 0x47, 0xFF
};
static const unsigned char Lookup_48[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x7F, 0x7F, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x7F, 0x89, 0x53, 0x8B, 0x8C,
0x7F, 0x7F, 0x7F, 0x7F, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x96, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x7F, 0x7F, 0x59, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x96, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x4F, 0x55, 0x55,
0x55, 0x55, 0x59, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43,
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0x4F, 0xF7, 0x4F, 0x55, 0x55, 0x55, 0x55, 0x59, 0xDE, 0x59,
/* Mac */
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C,
0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAB, 0xAD, 0xAE, 0xAE, 0xB0, 0xB1, 0xB2, 0xB3,
0xA7, 0xB5, 0xB6, 0xB7, 0xB8, 0xB8, 0xBA, 0xBA, 0xBC, 0xBC, 0xBE, 0xBE, 0xB7,
0xC1, 0xC2, 0xC3, 0x46, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCB, 0xCD,
0xCD, 0xC1, 0xD0, 0xD0, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD8, 0xDA,
0xDA, 0xDC, 0xDD, 0xDD, 0x9F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F
};
static const unsigned char Lookup_64[128 * 3] = {
/* Common */
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x55, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x56, 0x58, 0x55, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x96, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x4F, 0x55, 0x55,
0x55, 0x55, 0x55, 0xDE, 0xDF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* Mac */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x96, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0xD7, 0x4F, 0x55, 0x55,
0x55, 0x55, 0x55, 0xDE, 0xDF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char Lookup_80[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x55, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x56, 0x58, 0x55, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
/* Mac */
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
};
static const unsigned char Lookup_112[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x00, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x56, 0x58, 0x55, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x56, 0x58, 0x55, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
/* Mac */
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
};
static const unsigned char Lookup_128[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x00,
/* Windows */
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x00, 0x8B, 0x00,
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x00, 0x99,
0x00, 0x9B, 0x00, 0x00, 0x00, 0x00, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x00, 0xAB, 0xAC, 0x2D, 0xAE, 0x2D, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xBA,
0xA2, 0xC2, 0xC3, 0xC4, 0xB8, 0xC6, 0xB9, 0xC8, 0xBA, 0xCA, 0xCB, 0xCC, 0xCD,
0xCE, 0xBC, 0xD0, 0xD1, 0x00, 0xD3, 0xD4, 0xBE, 0xD6, 0xD7, 0xD8, 0xBF, 0xBA,
0xBE, 0xA2, 0xB8, 0xB9, 0xBA, 0xBE, 0xA2, 0xC2, 0xC3, 0xC4, 0xB8, 0xC6, 0xB9,
0xC8, 0xBA, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xBC, 0xD0, 0xD1, 0xD3, 0xD3, 0xD4,
0xBE, 0xD6, 0xD7, 0xD8, 0xBF, 0xBA, 0xBE, 0xBC, 0xBE, 0xBF, 0x00,
/* Mac */
0x41, 0x31, 0x32, 0x45, 0x33, 0x4F, 0x55, 0x87, 0x41, 0x41, 0x41, 0x00, 0x8C,
0x43, 0x45, 0x45, 0x45, 0x45, 0x92, 0x93, 0x49, 0x49, 0x96, 0x97, 0x98, 0x4F,
0x4F, 0x9B, 0x3F, 0x55, 0x55, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xAB, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xB0,
0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0x09, 0xBD, 0xCC, 0xB0,
0xB6, 0xCF, 0x2D, 0x2D, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xB8, 0xAB, 0xC3, 0xBD,
0xB6, 0xB8, 0xAB, 0xC3, 0xBF, 0xBD, 0xB0, 0xB5, 0xBE, 0xA2, 0xB6, 0xBC, 0xA1,
0xB8, 0xAB, 0xA5, 0xBA, 0xA4, 0xBB, 0xC1, 0xC3, 0xA6, 0xBF, 0xC4, 0xAA, 0xC6,
0xA3, 0xBF, 0xAA, 0xCC, 0xBD, 0xB7, 0xAB, 0xBD, 0xAB, 0xBD, 0x3F,
};
static const unsigned char Lookup_144[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x00,
/* Windows */
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0xC1, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43, 0x45, 0xC9, 0x45, 0x45, 0x49, 0xCD,
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0xD3, 0x4F, 0x4F, 0xD6, 0xD7, 0xD6, 0x55, 0xDA,
0x55, 0x55, 0xDD, 0xDE, 0xDF, 0x41, 0xC1, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43,
0x45, 0xC9, 0x45, 0x45, 0x49, 0xCD, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0xD3, 0x4F,
0x4F, 0xD6, 0xF7, 0xD6, 0x55, 0xDA, 0x55, 0x55, 0xDD, 0xDE, 0x59,
/* Mac */
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0xC1, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43, 0x45, 0xC9, 0x45, 0x45, 0x49, 0xCD,
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0xD3, 0x4F, 0x4F, 0xD6, 0xD7, 0xD6, 0x55, 0xDA,
0x55, 0x55, 0xDD, 0xDE, 0xDF, 0x41, 0xC1, 0x41, 0x41, 0x41, 0x41, 0xC6, 0x43,
0x45, 0xC9, 0x45, 0x45, 0x49, 0xCD, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0xD3, 0x4F,
0x4F, 0xD6, 0xF7, 0xD6, 0x55, 0xDA, 0x55, 0x55, 0xDD, 0xDE, 0x59,
};
static const unsigned char Lookup_160[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x00,
/* Windows */
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0xC7, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0xD6, 0xD7, 0x4F, 0x55, 0x55,
0x55, 0xDC, 0xDD, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0xC7,
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0xD6, 0xF7, 0x4F, 0x55, 0x55, 0x55, 0xDC, 0xDD, 0xDE, 0x59,
/* Mac */
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0xC7, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0xD6, 0xD7, 0x4F, 0x55, 0x55,
0x55, 0xDC, 0xDD, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0xC6, 0xC7,
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0xD0, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0xD6, 0xF7, 0x4F, 0x55, 0x55, 0x55, 0xDC, 0xDD, 0xDE, 0x59,
};
static const unsigned char Lookup_176[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x00,
/* Windows */
0x00, 0x00, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x00, 0x89, 0x53, 0x8B, 0x8C,
0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93, 0x94, 0x95, 0x2D, 0x2D, 0x98, 0x99,
0x53, 0x9B, 0x8C, 0x00, 0x00, 0x59, 0x09, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0x41, 0xAB, 0xAC, 0x2D, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0x4F, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x41,
0x41, 0x41, 0x41, 0xC4, 0xC5, 0xC4, 0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49,
0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0xD6, 0xD7, 0xD6, 0x55, 0x55,
0x55, 0x59, 0x59, 0xDE, 0xDF, 0x41, 0x41, 0x41, 0x41, 0xC4, 0xC5, 0xC4, 0x43,
0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0xD6, 0xF7, 0xD6, 0x55, 0x55, 0x55, 0x59, 0x59, 0xDE, 0x59,
/* Mac */
0x80, 0x81, 0x43, 0x45, 0x4E, 0x85, 0x59, 0x41, 0x41, 0x41, 0x80, 0x41, 0x81,
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4E, 0x4F, 0x4F, 0x4F,
0x85, 0x4F, 0x55, 0x55, 0x55, 0x59, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0x80, 0x85, 0xB0, 0xB1, 0xB2, 0xB3,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0x41, 0x4F, 0xBD, 0x80, 0x85, 0xC0,
0xC1, 0xC2, 0xC3, 0x46, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0x09, 0x41, 0x41, 0x4F,
0xCE, 0xCE, 0x2D, 0x2D, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0x59, 0x59, 0xDA,
0xDB, 0xDC, 0xDD, 0x3F, 0x3F, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0x41, 0x45, 0x41,
0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4F, 0x4F, 0x3F, 0x4F, 0x55, 0x55, 0x55,
0x49, 0x00, 0xF7, 0x00, 0xF9, 0xFA, 0xFB, 0x3F, 0xFD, 0xFE, 0x00
};
static const unsigned char Lookup_208[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x80, 0x81, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x5E, 0x89, 0x8A, 0x8B, 0x8C,
0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
0x9A, 0x9B, 0x8C, 0x9D, 0x00, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0,
0xC1, 0xC2, 0xC1, 0xC1, 0xC1, 0xC1, 0xC7, 0xC8, 0xC9, 0xC9, 0xCB, 0xCC, 0xCD,
0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
0xDB, 0x00, 0xDD, 0xDE, 0xDF, 0x41, 0xE1, 0x41, 0xE3, 0xE4, 0xE5, 0xE6, 0x43,
0x45, 0x45, 0x45, 0x45, 0xEC, 0xEC, 0x49, 0x49, 0xF0, 0xF1, 0xF2, 0xF3, 0x4F,
0xF5, 0xF6, 0xF7, 0xF8, 0x55, 0xFA, 0x55, 0x55, 0x00, 0x00, 0xFF,
/* Mac */
0x41, 0x81, 0x43, 0x45, 0x4E, 0x4F, 0x55, 0x41, 0x41, 0x41, 0x41, 0x8B, 0x8C,
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x93, 0x49, 0x49, 0x4E, 0x4F, 0x98, 0x4F,
0x4F, 0x9B, 0x55, 0x55, 0x55, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0,
0xC1, 0xC2, 0xC1, 0xC1, 0xC1, 0xC1, 0xC7, 0xC8, 0xC9, 0xC9, 0xCB, 0xCC, 0xCD,
0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0x00, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
0xE8, 0xE9, 0xE9, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4,
0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
};
static const unsigned char Lookup_224[128 * 3] = {
/* Common */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
/* Windows */
0x80, 0x81, 0x82, 0x46, 0x84, 0x85, 0x86, 0x87, 0x5E, 0x89, 0x8A, 0x8B, 0x8C,
0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0x32, 0x33,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x31, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0,
0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD,
0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
0xE8, 0xE9, 0xEA, 0xEA, 0xEC, 0xED, 0xED, 0xEF, 0xEF, 0xF1, 0xF2, 0xF3, 0xF3,
0xF5, 0xF5, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0x00, 0x00, 0xFF,
/* Mac */
0x41, 0x41, 0x43, 0x45, 0x4E, 0x4F, 0x55, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
0x43, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49, 0x4E, 0x4F, 0x4F, 0x4F,
0x4F, 0x4F, 0x55, 0x55, 0x55, 0x55, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0,
0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD,
0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
0xE8, 0xE9, 0xEA, 0xEA, 0xEC, 0xED, 0xED, 0xEF, 0xEF, 0xF1, 0xF2, 0xF3, 0xF3,
0xF5, 0xF5, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
};
/***********************************************************************
* lhash_val_of_name_sys
*
* Copy of oleaut32.LHashValOfNameSysA
* Produce a string hash value.
*
* PARAMS
* skind [I] Type of the system.
* lcid [I] Locale id for the hash.
* lpStr [I] String to hash.
*
* RETURNS
* Success: The hash value of the string.
* Failure: 0, if lpStr is NULL.
*
* NOTES
* This function produces a two part hash: The high word is based on
* skind and lcid, while the low word is based on a repeated string
* hash of skind/str.
*/
unsigned long lhash_val_of_name_sys( syskind_t skind, LCID lcid, LPCSTR lpStr)
{
ULONG nOffset, nMask = skind == SYS_MAC ? 1 : 0;
ULONG nHiWord, nLoWord = 0x0deadbee;
const unsigned char *str = (const unsigned char *)lpStr, *pnLookup = NULL;
if (!str)
return 0;
switch (PRIMARYLANGID(LANGIDFROMLCID(lcid)))
{
default:
fprintf(stderr, "Unknown lcid %lx, treating as latin-based, please report\n", lcid);
/* .. Fall Through .. */
case LANG_AFRIKAANS: case LANG_ALBANIAN: case LANG_ARMENIAN:
case LANG_ASSAMESE: case LANG_AZERI: case LANG_BASQUE:
case LANG_BELARUSIAN: case LANG_BENGALI: case LANG_BULGARIAN:
case LANG_CATALAN: case LANG_DANISH: case LANG_DIVEHI:
case LANG_DUTCH: case LANG_ENGLISH: case LANG_ESTONIAN:
case LANG_FAEROESE: case LANG_FINNISH: case LANG_FRENCH:
case LANG_GALICIAN: case LANG_GEORGIAN: case LANG_GERMAN:
case LANG_GUJARATI: case LANG_HINDI: case LANG_INDONESIAN:
case LANG_ITALIAN: case LANG_KANNADA: case LANG_KASHMIRI:
case LANG_KAZAK: case LANG_KONKANI: case LANG_KYRGYZ:
case LANG_LATVIAN: case LANG_LITHUANIAN: case LANG_MACEDONIAN:
case LANG_MALAY: case LANG_MALAYALAM: case LANG_MANIPURI:
case LANG_MARATHI: case LANG_MONGOLIAN: case LANG_NEPALI:
case LANG_ORIYA: case LANG_PORTUGUESE: case LANG_PUNJABI:
case LANG_ROMANIAN: case LANG_SANSKRIT: case LANG_SERBIAN:
case LANG_SINDHI: case LANG_SLOVENIAN: case LANG_SWAHILI:
case LANG_SWEDISH: case LANG_SYRIAC: case LANG_TAMIL:
case LANG_TATAR: case LANG_TELUGU: case LANG_THAI:
case LANG_UKRAINIAN: case LANG_URDU: case LANG_UZBEK:
case LANG_VIETNAMESE: case LANG_GAELIC: case LANG_MALTESE:
case LANG_TAJIK: case LANG_ROMANSH: case LANG_IRISH:
case LANG_SAMI: case LANG_UPPER_SORBIAN: case LANG_SUTU:
case LANG_TSONGA: case LANG_TSWANA: case LANG_VENDA:
case LANG_XHOSA: case LANG_ZULU: case LANG_ESPERANTO:
case LANG_WALON: case LANG_CORNISH: case LANG_WELSH:
case LANG_BRETON:
nOffset = 16;
pnLookup = Lookup_16;
break;
case LANG_CZECH: case LANG_HUNGARIAN: case LANG_POLISH:
case LANG_SLOVAK: case LANG_SPANISH:
nOffset = 32;
pnLookup = Lookup_32;
break;
case LANG_HEBREW:
nOffset = 48;
pnLookup = Lookup_48;
break;
case LANG_JAPANESE:
nOffset = 64;
pnLookup = Lookup_64;
break;
case LANG_KOREAN:
nOffset = 80;
pnLookup = Lookup_80;
break;
case LANG_CHINESE:
nOffset = 112;
pnLookup = Lookup_112;
break;
case LANG_GREEK:
nOffset = 128;
pnLookup = Lookup_128;
break;
case LANG_ICELANDIC:
nOffset = 144;
pnLookup = Lookup_144;
break;
case LANG_TURKISH:
nOffset = 160;
pnLookup = Lookup_160;
break;
case LANG_NORWEGIAN:
if (SUBLANGID(LANGIDFROMLCID(lcid)) == SUBLANG_NORWEGIAN_NYNORSK)
{
nOffset = 176;
pnLookup = Lookup_176;
}
else
{
nOffset = 16;
pnLookup = Lookup_16;
}
break;
case LANG_ARABIC:
case LANG_FARSI:
nOffset = 208;
pnLookup = Lookup_208;
break;
case LANG_RUSSIAN:
nOffset = 224;
pnLookup = Lookup_224;
break;
}
nHiWord = (nOffset | nMask) << 16;
while (*str)
{
ULONG newLoWord = 0, i;
/* Cumulative prime multiplication (*37) with modulo 2^32 wrap-around */
for (i = 0; i < 37; i++)
newLoWord += nLoWord;
nLoWord = newLoWord + pnLookup[*str > 0x7f && nMask ? *str + 0x80 : *str];
str++;
}
/* Constrain to a prime modulo and sizeof(WORD) */
nLoWord = (nLoWord % 65599) & 0xffff;
return nHiWord | nLoWord;
}
+33
View File
@@ -0,0 +1,33 @@
/*
* Hash definitions
*
* Copyright 2005 Huw Davies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#ifndef __WIDL_HASH_H
#define __WIDL_HASH_H
typedef enum tag_syskind_t {
SYS_WIN16 = 0,
SYS_WIN32,
SYS_MAC
} syskind_t;
extern unsigned long lhash_val_of_name_sys( syskind_t skind, LCID lcid, LPCSTR lpStr);
#endif
File diff suppressed because it is too large Load Diff
+62
View File
@@ -0,0 +1,62 @@
/*
* IDL Compiler
*
* Copyright 2002 Ove Kaaven
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WIDL_HEADER_H
#define __WIDL_HEADER_H
extern int is_attr(const attr_t *a, enum attr_type t);
extern void *get_attrp(const attr_t *a, enum attr_type t);
extern unsigned long get_attrv(const attr_t *a, enum attr_type t);
extern int is_void(const type_t *t, const var_t *v);
extern void write_name(FILE *h, const var_t *v);
extern const char* get_name(const var_t *v);
extern void write_type(FILE *h, type_t *t, const var_t *v, const char *n);
extern int is_object(const attr_t *a);
extern int is_local(const attr_t *a);
extern const var_t *is_callas(const attr_t *a);
extern void write_args(FILE *h, var_t *arg, const char *name, int obj, int do_indent);
extern void write_array(FILE *h, const expr_t *v, int field);
extern void write_forward(type_t *iface);
extern void write_interface(type_t *iface);
extern void write_dispinterface(type_t *iface);
extern void write_coclass(type_t *cocl);
extern void write_coclass_forward(type_t *cocl);
extern void write_typedef(type_t *type, const var_t *names);
extern void write_expr(FILE *h, const expr_t *e, int brackets);
extern void write_constdef(const var_t *v);
extern void write_externdef(const var_t *v);
extern void write_library(const char *name, const attr_t *attr);
extern void write_user_types(void);
extern const var_t* get_explicit_handle_var(const func_t* func);
extern int has_out_arg_or_return(const func_t *func);
static inline int is_string_type(const attr_t *attrs, int ptr_level, const expr_t *array)
{
return (is_attr(attrs, ATTR_STRING) &&
((ptr_level == 1 && !array) || (ptr_level == 0 && array)));
}
static inline int is_array_type(const attr_t *attrs, int ptr_level, const expr_t *array)
{
return ((ptr_level == 1 && !array && is_attr(attrs, ATTR_SIZEIS)) ||
(ptr_level == 0 && array));
}
#endif
File diff suppressed because it is too large Load Diff
+41
View File
@@ -0,0 +1,41 @@
/*
* IDL Compiler
*
* Copyright 2002 Ove Kaaven
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WIDL_PARSER_H
#define __WIDL_PARSER_H
int yyparse(void);
extern FILE *yyin;
extern char *yytext;
extern int yydebug;
extern int yy_flex_debug;
int yylex(void);
extern int import_stack_ptr;
int do_import(char *fname);
void abort_import(void);
#define parse_only import_stack_ptr
int is_type(const char *name);
#endif
+443
View File
@@ -0,0 +1,443 @@
/* -*-C-*-
* IDL Compiler
*
* Copyright 2002 Ove Kaaven
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
%option stack
%option nounput noyy_top_state
%option 8bit never-interactive
nl \r?\n
ws [ \f\t\r]
cident [a-zA-Z_][0-9a-zA-Z_]*
int [0-9]+
hexd [0-9a-fA-F]
hex 0x{hexd}+
uuid {hexd}{8}-{hexd}{4}-{hexd}{4}-{hexd}{4}-{hexd}{12}
%x QUOTE
%x pp_line
%{
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "wine/wpp.h"
#include "parser.tab.h"
extern char *temp_name;
static void addcchar(char c);
static char *get_buffered_cstring(void);
static char *cbuffer;
static int cbufidx;
static int cbufalloc = 0;
static int kw_token(const char *kw);
#define MAX_IMPORT_DEPTH 10
struct {
YY_BUFFER_STATE state;
char *input_name;
int line_number;
char *temp_name;
} import_stack[MAX_IMPORT_DEPTH];
int import_stack_ptr = 0;
static void pop_import(void);
static UUID* parse_uuid(const char*u)
{
UUID* uuid = xmalloc(sizeof(UUID));
char b[3];
/* it would be nice to use UuidFromStringA */
uuid->Data1 = strtoul(u, NULL, 16);
uuid->Data2 = strtoul(u+9, NULL, 16);
uuid->Data3 = strtoul(u+14, NULL, 16);
b[2] = 0;
memcpy(b, u+19, 2); uuid->Data4[0] = strtoul(b, NULL, 16);
memcpy(b, u+21, 2); uuid->Data4[1] = strtoul(b, NULL, 16);
memcpy(b, u+24, 2); uuid->Data4[2] = strtoul(b, NULL, 16);
memcpy(b, u+26, 2); uuid->Data4[3] = strtoul(b, NULL, 16);
memcpy(b, u+28, 2); uuid->Data4[4] = strtoul(b, NULL, 16);
memcpy(b, u+30, 2); uuid->Data4[5] = strtoul(b, NULL, 16);
memcpy(b, u+32, 2); uuid->Data4[6] = strtoul(b, NULL, 16);
memcpy(b, u+34, 2); uuid->Data4[7] = strtoul(b, NULL, 16);
return uuid;
}
%}
/*
**************************************************************************
* The flexer starts here
**************************************************************************
*/
%%
<INITIAL>^{ws}*\#{ws}* yy_push_state(pp_line);
<pp_line>[^\n]* {
int lineno;
char *cptr, *fname;
yy_pop_state();
lineno = (int)strtol(yytext, &cptr, 10);
if(!lineno)
yyerror("Malformed '#...' line-directive; invalid linenumber");
fname = strchr(cptr, '"');
if(!fname)
yyerror("Malformed '#...' line-directive; missing filename");
fname++;
cptr = strchr(fname, '"');
if(!cptr)
yyerror("Malformed '#...' line-directive; missing terminating \"");
*cptr = '\0';
line_number = lineno - 1; /* We didn't read the newline */
free( input_name );
input_name = xstrdup(fname);
}
\" yy_push_state(QUOTE); cbufidx = 0;
<QUOTE>\" {
yy_pop_state();
yylval.str = get_buffered_cstring();
return aSTRING;
}
<QUOTE>\\\\ |
<QUOTE>\\\" addcchar(yytext[1]);
<QUOTE>\\. addcchar('\\'); addcchar(yytext[1]);
<QUOTE>. addcchar(yytext[0]);
{uuid} {
yylval.uuid = parse_uuid(yytext);
return aUUID;
}
{hex} {
yylval.num = strtoul(yytext, NULL, 0);
return aHEXNUM;
}
{int} {
yylval.num = strtoul(yytext, NULL, 0);
return aNUM;
}
SAFEARRAY{ws}*/\( return tSAFEARRAY;
{cident} return kw_token(yytext);
\n line_number++;
{ws}
\<\< return SHL;
\>\> return SHR;
. return yytext[0];
<<EOF>> {
if (import_stack_ptr) {
pop_import();
return aEOF;
}
else yyterminate();
}
%%
#ifndef yywrap
int yywrap(void)
{
return 1;
}
#endif
static struct keyword {
const char *kw;
int token;
int val;
} keywords[] = {
{"FALSE", tFALSE},
{"TRUE", tTRUE},
{"__cdecl", tCDECL},
{"__int64", tINT64},
{"__stdcall", tSTDCALL},
{"_stdcall", tSTDCALL},
{"aggregatable", tAGGREGATABLE},
{"allocate", tALLOCATE},
{"appobject", tAPPOBJECT},
{"async", tASYNC},
{"async_uuid", tASYNCUUID},
{"auto_handle", tAUTOHANDLE},
{"bindable", tBINDABLE},
{"boolean", tBOOLEAN},
{"broadcast", tBROADCAST},
{"byte", tBYTE},
{"byte_count", tBYTECOUNT},
{"call_as", tCALLAS},
{"callback", tCALLBACK},
{"case", tCASE},
{"char", tCHAR},
{"coclass", tCOCLASS},
{"code", tCODE},
{"comm_status", tCOMMSTATUS},
{"const", tCONST},
{"context_handle", tCONTEXTHANDLE},
{"context_handle_noserialize", tCONTEXTHANDLENOSERIALIZE},
{"context_handle_serialize", tCONTEXTHANDLENOSERIALIZE},
{"control", tCONTROL},
{"cpp_quote", tCPPQUOTE},
/* ... */
{"default", tDEFAULT},
{"defaultcollelem", tDEFAULTCOLLELEM},
{"defaultvalue", tDEFAULTVALUE},
{"defaultvtable", tDEFAULTVTABLE},
{"dispinterface", tDISPINTERFACE},
{"displaybind", tDISPLAYBIND},
{"dllname", tDLLNAME},
{"double", tDOUBLE},
{"dual", tDUAL},
{"endpoint", tENDPOINT},
{"entry", tENTRY},
{"enum", tENUM},
{"error_status_t", tERRORSTATUST},
{"explicit_handle", tEXPLICITHANDLE},
{"extern", tEXTERN},
{"float", tFLOAT},
{"handle", tHANDLE},
{"handle_t", tHANDLET},
{"helpcontext", tHELPCONTEXT},
{"helpfile", tHELPFILE},
{"helpstring", tHELPSTRING},
{"helpstringcontext", tHELPSTRINGCONTEXT},
{"helpstringdll", tHELPSTRINGDLL},
{"hidden", tHIDDEN},
{"hyper", tHYPER},
{"id", tID},
{"idempotent", tIDEMPOTENT},
/* ... */
{"iid_is", tIIDIS},
{"immediatebind", tIMMEDIATEBIND},
{"implicit_handle", tIMPLICITHANDLE},
{"import", tIMPORT},
{"importlib", tIMPORTLIB},
{"in", tIN},
{"in_line", tINLINE},
{"input_sync", tINPUTSYNC},
{"int", tINT},
/* ... */
{"interface", tINTERFACE},
{"lcid", tLCID},
{"length_is", tLENGTHIS},
{"library", tLIBRARY},
/* ... */
{"local", tLOCAL},
{"long", tLONG},
/* ... */
{"methods", tMETHODS},
/* ... */
{"module", tMODULE},
/* ... */
{"nonbrowsable", tNONBROWSABLE},
{"noncreatable", tNONCREATABLE},
{"nonextensible", tNONEXTENSIBLE},
{"object", tOBJECT},
{"odl", tODL},
{"oleautomation", tOLEAUTOMATION},
/* ... */
{"optional", tOPTIONAL},
{"out", tOUT},
/* ... */
{"pointer_default", tPOINTERDEFAULT},
/* ... */
{"properties", tPROPERTIES},
{"propget", tPROPGET},
{"propput", tPROPPUT},
{"propputref", tPROPPUTREF},
{"ptr", tPTR},
/* ... */
{"public", tPUBLIC},
{"range", tRANGE},
/* ... */
{"readonly", tREADONLY},
{"ref", tREF},
{"requestedit", tREQUESTEDIT},
{"restricted", tRESTRICTED},
{"retval", tRETVAL},
/* ... */
{"short", tSHORT},
{"signed", tSIGNED},
{"single", tSINGLE},
{"size_is", tSIZEIS},
{"sizeof", tSIZEOF},
{"small", tSMALL},
/* ... */
{"source", tSOURCE},
/* ... */
{"string", tSTRING},
{"struct", tSTRUCT},
{"switch", tSWITCH},
{"switch_is", tSWITCHIS},
{"switch_type", tSWITCHTYPE},
/* ... */
{"transmit_as", tTRANSMITAS},
{"typedef", tTYPEDEF},
{"union", tUNION},
/* ... */
{"unique", tUNIQUE},
{"unsigned", tUNSIGNED},
/* ... */
{"uuid", tUUID},
{"v1_enum", tV1ENUM},
/* ... */
{"vararg", tVARARG},
{"version", tVERSION},
{"void", tVOID},
{"wchar_t", tWCHAR},
{"wire_marshal", tWIREMARSHAL},
};
#define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
#define KWP(p) ((const struct keyword *)(p))
static int kw_cmp_func(const void *s1, const void *s2)
{
return strcmp(KWP(s1)->kw, KWP(s2)->kw);
}
#define KW_BSEARCH
static int kw_token(const char *kw)
{
struct keyword key, *kwp;
key.kw = kw;
#ifdef KW_BSEARCH
kwp = bsearch(&key, keywords, NKEYWORDS, sizeof(keywords[0]), kw_cmp_func);
#else
{
int i;
for (kwp=NULL, i=0; i < NKEYWORDS; i++)
if (!kw_cmp_func(&key, &keywords[i])) {
kwp = &keywords[i];
break;
}
}
#endif
if (kwp) {
yylval.str = (char*)kwp->kw;
return kwp->token;
}
yylval.str = xstrdup(kw);
return is_type(kw) ? aKNOWNTYPE : aIDENTIFIER;
}
static void addcchar(char c)
{
if(cbufidx >= cbufalloc)
{
cbufalloc += 1024;
cbuffer = xrealloc(cbuffer, cbufalloc * sizeof(cbuffer[0]));
if(cbufalloc > 65536)
yywarning("Reallocating string buffer larger than 64kB");
}
cbuffer[cbufidx++] = c;
}
static char *get_buffered_cstring(void)
{
addcchar(0);
return xstrdup(cbuffer);
}
static void pop_import(void)
{
int ptr = import_stack_ptr-1;
fclose(yyin);
yy_delete_buffer( YY_CURRENT_BUFFER );
yy_switch_to_buffer( import_stack[ptr].state );
if (temp_name) {
unlink(temp_name);
free(temp_name);
}
temp_name = import_stack[ptr].temp_name;
free( input_name );
input_name = import_stack[ptr].input_name;
line_number = import_stack[ptr].line_number;
import_stack_ptr--;
}
struct imports {
char *name;
struct imports *next;
} *first_import;
int do_import(char *fname)
{
FILE *f;
char *hname, *path, *p;
struct imports *import;
int ptr = import_stack_ptr;
int ret;
if (!parse_only && do_header) {
hname = dup_basename(fname, ".idl");
p = hname + strlen(hname) - 2;
if (p <= hname || strcmp( p, ".h" )) strcat(hname, ".h");
fprintf(header, "#include <%s>\n", hname);
free(hname);
}
import = first_import;
while (import && strcmp(import->name, fname))
import = import->next;
if (import) return 0; /* already imported */
import = xmalloc(sizeof(struct imports));
import->name = xstrdup(fname);
import->next = first_import;
first_import = import;
if (!(path = wpp_find_include( fname, input_name )))
yyerror("Unable to open include file %s", fname);
import_stack[ptr].temp_name = temp_name;
import_stack[ptr].input_name = input_name;
import_stack[ptr].line_number = line_number;
import_stack_ptr++;
input_name = path;
line_number = 1;
ret = wpp_parse_temp( path, NULL, &temp_name );
if (ret) exit(1);
if((f = fopen(temp_name, "r")) == NULL)
yyerror("Unable to open %s", temp_name);
import_stack[ptr].state = YY_CURRENT_BUFFER;
yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));
return 1;
}
void abort_import(void)
{
int ptr;
for (ptr=0; ptr<import_stack_ptr; ptr++)
unlink(import_stack[ptr].temp_name);
}
File diff suppressed because it is too large Load Diff
+324
View File
@@ -0,0 +1,324 @@
/* A Bison parser, made by GNU Bison 1.875. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
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, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
aIDENTIFIER = 258,
aKNOWNTYPE = 259,
aNUM = 260,
aHEXNUM = 261,
aSTRING = 262,
aUUID = 263,
aEOF = 264,
SHL = 265,
SHR = 266,
tAGGREGATABLE = 267,
tALLOCATE = 268,
tAPPOBJECT = 269,
tASYNC = 270,
tASYNCUUID = 271,
tAUTOHANDLE = 272,
tBINDABLE = 273,
tBOOLEAN = 274,
tBROADCAST = 275,
tBYTE = 276,
tBYTECOUNT = 277,
tCALLAS = 278,
tCALLBACK = 279,
tCASE = 280,
tCDECL = 281,
tCHAR = 282,
tCOCLASS = 283,
tCODE = 284,
tCOMMSTATUS = 285,
tCONST = 286,
tCONTEXTHANDLE = 287,
tCONTEXTHANDLENOSERIALIZE = 288,
tCONTEXTHANDLESERIALIZE = 289,
tCONTROL = 290,
tCPPQUOTE = 291,
tDEFAULT = 292,
tDEFAULTCOLLELEM = 293,
tDEFAULTVALUE = 294,
tDEFAULTVTABLE = 295,
tDISPLAYBIND = 296,
tDISPINTERFACE = 297,
tDLLNAME = 298,
tDOUBLE = 299,
tDUAL = 300,
tENDPOINT = 301,
tENTRY = 302,
tENUM = 303,
tERRORSTATUST = 304,
tEXPLICITHANDLE = 305,
tEXTERN = 306,
tFALSE = 307,
tFLOAT = 308,
tHANDLE = 309,
tHANDLET = 310,
tHELPCONTEXT = 311,
tHELPFILE = 312,
tHELPSTRING = 313,
tHELPSTRINGCONTEXT = 314,
tHELPSTRINGDLL = 315,
tHIDDEN = 316,
tHYPER = 317,
tID = 318,
tIDEMPOTENT = 319,
tIIDIS = 320,
tIMMEDIATEBIND = 321,
tIMPLICITHANDLE = 322,
tIMPORT = 323,
tIMPORTLIB = 324,
tIN = 325,
tINLINE = 326,
tINPUTSYNC = 327,
tINT = 328,
tINT64 = 329,
tINTERFACE = 330,
tLCID = 331,
tLENGTHIS = 332,
tLIBRARY = 333,
tLOCAL = 334,
tLONG = 335,
tMETHODS = 336,
tMODULE = 337,
tNONBROWSABLE = 338,
tNONCREATABLE = 339,
tNONEXTENSIBLE = 340,
tOBJECT = 341,
tODL = 342,
tOLEAUTOMATION = 343,
tOPTIONAL = 344,
tOUT = 345,
tPOINTERDEFAULT = 346,
tPROPERTIES = 347,
tPROPGET = 348,
tPROPPUT = 349,
tPROPPUTREF = 350,
tPTR = 351,
tPUBLIC = 352,
tRANGE = 353,
tREADONLY = 354,
tREF = 355,
tREQUESTEDIT = 356,
tRESTRICTED = 357,
tRETVAL = 358,
tSAFEARRAY = 359,
tSHORT = 360,
tSIGNED = 361,
tSINGLE = 362,
tSIZEIS = 363,
tSIZEOF = 364,
tSMALL = 365,
tSOURCE = 366,
tSTDCALL = 367,
tSTRING = 368,
tSTRUCT = 369,
tSWITCH = 370,
tSWITCHIS = 371,
tSWITCHTYPE = 372,
tTRANSMITAS = 373,
tTRUE = 374,
tTYPEDEF = 375,
tUNION = 376,
tUNIQUE = 377,
tUNSIGNED = 378,
tUUID = 379,
tV1ENUM = 380,
tVARARG = 381,
tVERSION = 382,
tVOID = 383,
tWCHAR = 384,
tWIREMARSHAL = 385,
CAST = 386,
PPTR = 387,
NEG = 388
};
#endif
#define aIDENTIFIER 258
#define aKNOWNTYPE 259
#define aNUM 260
#define aHEXNUM 261
#define aSTRING 262
#define aUUID 263
#define aEOF 264
#define SHL 265
#define SHR 266
#define tAGGREGATABLE 267
#define tALLOCATE 268
#define tAPPOBJECT 269
#define tASYNC 270
#define tASYNCUUID 271
#define tAUTOHANDLE 272
#define tBINDABLE 273
#define tBOOLEAN 274
#define tBROADCAST 275
#define tBYTE 276
#define tBYTECOUNT 277
#define tCALLAS 278
#define tCALLBACK 279
#define tCASE 280
#define tCDECL 281
#define tCHAR 282
#define tCOCLASS 283
#define tCODE 284
#define tCOMMSTATUS 285
#define tCONST 286
#define tCONTEXTHANDLE 287
#define tCONTEXTHANDLENOSERIALIZE 288
#define tCONTEXTHANDLESERIALIZE 289
#define tCONTROL 290
#define tCPPQUOTE 291
#define tDEFAULT 292
#define tDEFAULTCOLLELEM 293
#define tDEFAULTVALUE 294
#define tDEFAULTVTABLE 295
#define tDISPLAYBIND 296
#define tDISPINTERFACE 297
#define tDLLNAME 298
#define tDOUBLE 299
#define tDUAL 300
#define tENDPOINT 301
#define tENTRY 302
#define tENUM 303
#define tERRORSTATUST 304
#define tEXPLICITHANDLE 305
#define tEXTERN 306
#define tFALSE 307
#define tFLOAT 308
#define tHANDLE 309
#define tHANDLET 310
#define tHELPCONTEXT 311
#define tHELPFILE 312
#define tHELPSTRING 313
#define tHELPSTRINGCONTEXT 314
#define tHELPSTRINGDLL 315
#define tHIDDEN 316
#define tHYPER 317
#define tID 318
#define tIDEMPOTENT 319
#define tIIDIS 320
#define tIMMEDIATEBIND 321
#define tIMPLICITHANDLE 322
#define tIMPORT 323
#define tIMPORTLIB 324
#define tIN 325
#define tINLINE 326
#define tINPUTSYNC 327
#define tINT 328
#define tINT64 329
#define tINTERFACE 330
#define tLCID 331
#define tLENGTHIS 332
#define tLIBRARY 333
#define tLOCAL 334
#define tLONG 335
#define tMETHODS 336
#define tMODULE 337
#define tNONBROWSABLE 338
#define tNONCREATABLE 339
#define tNONEXTENSIBLE 340
#define tOBJECT 341
#define tODL 342
#define tOLEAUTOMATION 343
#define tOPTIONAL 344
#define tOUT 345
#define tPOINTERDEFAULT 346
#define tPROPERTIES 347
#define tPROPGET 348
#define tPROPPUT 349
#define tPROPPUTREF 350
#define tPTR 351
#define tPUBLIC 352
#define tRANGE 353
#define tREADONLY 354
#define tREF 355
#define tREQUESTEDIT 356
#define tRESTRICTED 357
#define tRETVAL 358
#define tSAFEARRAY 359
#define tSHORT 360
#define tSIGNED 361
#define tSINGLE 362
#define tSIZEIS 363
#define tSIZEOF 364
#define tSMALL 365
#define tSOURCE 366
#define tSTDCALL 367
#define tSTRING 368
#define tSTRUCT 369
#define tSWITCH 370
#define tSWITCHIS 371
#define tSWITCHTYPE 372
#define tTRANSMITAS 373
#define tTRUE 374
#define tTYPEDEF 375
#define tUNION 376
#define tUNIQUE 377
#define tUNSIGNED 378
#define tUUID 379
#define tV1ENUM 380
#define tVARARG 381
#define tVERSION 382
#define tVOID 383
#define tWCHAR 384
#define tWIREMARSHAL 385
#define CAST 386
#define PPTR 387
#define NEG 388
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 109 "parser.y"
typedef union YYSTYPE {
attr_t *attr;
expr_t *expr;
type_t *type;
typeref_t *tref;
var_t *var;
func_t *func;
ifref_t *ifref;
char *str;
UUID *uuid;
unsigned int num;
} YYSTYPE;
/* Line 1248 of yacc.c. */
#line 315 "parser.tab.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;
File diff suppressed because it is too large Load Diff
+138
View File
@@ -0,0 +1,138 @@
/* Copyright (C) 1991, 1992, 1996, 1998 Free Software Foundation, Inc.
This file is derived from mkstemp.c from the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "config.h"
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_PROCESS_H
#include <process.h>
#endif
/* We need to provide a type for gcc_uint64_t. */
#ifdef __GNUC__
__extension__ typedef unsigned long long gcc_uint64_t;
#else
typedef unsigned long gcc_uint64_t;
#endif
#ifndef TMP_MAX
#define TMP_MAX 16384
#endif
/*
@deftypefn Replacement int mkstemps (char *@var{template}, int @var{suffix_len})
Generate a unique temporary file name from @var{template}.
@var{template} has the form:
@example
@var{path}/ccXXXXXX@var{suffix}
@end example
@var{suffix_len} tells us how long @var{suffix} is (it can be zero
length). The last six characters of @var{template} before @var{suffix}
must be @samp{XXXXXX}; they are replaced with a string that makes the
filename unique. Returns a file descriptor open on the file for
reading and writing.
@end deftypefn
*/
int
mkstemps (
char *template,
int suffix_len)
{
static const char letters[]
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
static gcc_uint64_t value;
#ifdef HAVE_GETTIMEOFDAY
struct timeval tv;
#endif
char *XXXXXX;
size_t len;
int count;
len = strlen (template);
if ((int) len < 6 + suffix_len
|| strncmp (&template[len - 6 - suffix_len], "XXXXXX", 6))
{
return -1;
}
XXXXXX = &template[len - 6 - suffix_len];
#ifdef HAVE_GETTIMEOFDAY
/* Get some more or less random data. */
gettimeofday (&tv, NULL);
value += ((gcc_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
#else
value += getpid ();
#endif
for (count = 0; count < TMP_MAX; ++count)
{
gcc_uint64_t v = value;
int fd;
/* Fill in the random bits. */
XXXXXX[0] = letters[v % 62];
v /= 62;
XXXXXX[1] = letters[v % 62];
v /= 62;
XXXXXX[2] = letters[v % 62];
v /= 62;
XXXXXX[3] = letters[v % 62];
v /= 62;
XXXXXX[4] = letters[v % 62];
v /= 62;
XXXXXX[5] = letters[v % 62];
#ifdef VMS
fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600, "fop=tmd");
#else
fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
#endif
if (fd >= 0)
/* The file does not exist. */
return fd;
/* This is a random value. It is only necessary that the next
TMP_MAX values generated by adding 7777 to VALUE are different
with (module 2^32). */
value += 7777;
}
/* We return the null string if we can't find a unique file name. */
template[0] = '\0';
return -1;
}
File diff suppressed because it is too large Load Diff
+656
View File
@@ -0,0 +1,656 @@
/*
* IDL Compiler
*
* Copyright 2005-2006 Eric Kohl
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <signal.h>
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "header.h"
#include "windef.h"
#include "widl.h"
#include "typelib.h"
#include "typelib_struct.h"
#include "typegen.h"
static FILE* server;
static int indent = 0;
static int print_server(const char *format, ...)
{
va_list va;
int i, r;
va_start(va, format);
for (i = 0; i < indent; i++)
fprintf(server, " ");
r = vfprintf(server, format, va);
va_end(va);
return r;
}
static void write_parameters_init(const func_t *func)
{
const var_t *var;
if (!func->args)
return;
var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
{
if (var->type->type != RPC_FC_BIND_PRIMITIVE)
print_server("%s = 0;\n", var->name);
var = PREV_LINK(var);
}
fprintf(server, "\n");
}
static void declare_args(const func_t *func)
{
int in_attr, out_attr;
int i = 0;
var_t *var;
if (!func->args)
return;
var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
{
const expr_t *size_is = get_attrp(var->attrs, ATTR_SIZEIS);
int has_size = size_is && (size_is->type != EXPR_VOID);
int is_string = is_attr(var->attrs, ATTR_STRING);
in_attr = is_attr(var->attrs, ATTR_IN);
out_attr = is_attr(var->attrs, ATTR_OUT);
if (!out_attr && !in_attr)
in_attr = 1;
if (!in_attr && !has_size && !is_string)
{
int indirection;
print_server("");
write_type(server, var->type, NULL, var->tname);
for (indirection = 0; indirection < var->ptr_level - 1; indirection++)
fprintf(server, "*");
fprintf(server, " _W%u;\n", i++);
}
print_server("");
write_type(server, var->type, var, var->tname);
fprintf(server, " ");
write_name(server, var);
write_array(server, var->array, 0);
fprintf(server, ";\n");
var = PREV_LINK(var);
}
}
static void assign_out_args(const func_t *func)
{
int in_attr, out_attr;
int i = 0, sep = 0;
var_t *var;
const expr_t *size_is;
int has_size;
if (!func->args)
return;
var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
{
int is_string = is_attr(var->attrs, ATTR_STRING);
size_is = get_attrp(var->attrs, ATTR_SIZEIS);
has_size = size_is && (size_is->type != EXPR_VOID);
in_attr = is_attr(var->attrs, ATTR_IN);
out_attr = is_attr(var->attrs, ATTR_OUT);
if (!out_attr && !in_attr)
in_attr = 1;
if (!in_attr)
{
print_server("");
write_name(server, var);
if (has_size)
{
unsigned int size;
type_t *type = var->type;
while (type->type == 0 && type->ref)
type = type->ref;
fprintf(server, " = NdrAllocate(&_StubMsg, ");
write_expr(server, size_is, 1);
size = get_type_memsize(type);
fprintf(server, " * %u);\n", size);
}
else if (!is_string)
{
fprintf(server, " = &_W%u;\n", i);
if (var->ptr_level > 1)
print_server("_W%u = 0;\n", i);
i++;
}
sep = 1;
}
var = PREV_LINK(var);
}
if (sep)
fprintf(server, "\n");
}
static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsigned int *type_offset)
{
char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE);
const func_t *func = iface->funcs;
const var_t *var;
const var_t* explicit_handle_var;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
{
const var_t *def = func->def;
unsigned long buffer_size = 0;
unsigned int type_offset_func;
/* check for a defined binding handle */
explicit_handle_var = get_explicit_handle_var(func);
if (explicit_handle)
{
if (!explicit_handle_var)
{
error("%s() does not define an explicit binding handle!\n", def->name);
return;
}
}
else if (implicit_handle)
{
if (explicit_handle_var)
{
error("%s() must not define a binding handle!\n", def->name);
return;
}
}
fprintf(server, "void __RPC_STUB\n");
fprintf(server, "%s_", iface->name);
write_name(server, def);
fprintf(server, "(\n");
indent++;
print_server("PRPC_MESSAGE _pRpcMessage)\n");
indent--;
/* write the functions body */
fprintf(server, "{\n");
indent++;
/* declare return value '_RetVal' */
if (!is_void(def->type, NULL))
{
print_server("");
write_type(server, def->type, def, def->tname);
fprintf(server, " _RetVal;\n");
}
/* Declare arguments */
declare_args(func);
print_server("MIDL_STUB_MESSAGE _StubMsg;\n");
print_server("RPC_STATUS _Status;\n");
fprintf(server, "\n");
print_server("((void)(_Status));\n");
print_server("NdrServerInitializeNew(\n");
indent++;
print_server("_pRpcMessage,\n");
print_server("&_StubMsg,\n");
print_server("&%s_StubDesc);\n", iface->name);
indent--;
fprintf(server, "\n");
write_parameters_init(func);
if (explicit_handle_var)
{
print_server("%s = _pRpcMessage->Handle;\n", explicit_handle_var->name);
fprintf(server, "\n");
}
print_server("RpcTryFinally\n");
print_server("{\n");
indent++;
print_server("RpcTryExcept\n");
print_server("{\n");
indent++;
if (func->args)
{
print_server("if ((_pRpcMessage->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
indent++;
print_server("NdrConvert(\n");
indent++;
print_server("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
print_server("(PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n", *proc_offset);
indent -= 2;
fprintf(server, "\n");
/* make a copy so we don't increment the type offset twice */
type_offset_func = *type_offset;
/* unmarshall arguments */
write_remoting_arguments(server, indent, func, &type_offset_func, PASS_IN, PHASE_UNMARSHAL);
}
print_server("if (_StubMsg.Buffer > _StubMsg.BufferEnd)\n");
print_server("{\n");
indent++;
print_server("RpcRaiseException(RPC_X_BAD_STUB_DATA);\n");
indent--;
print_server("}\n");
indent--;
print_server("}\n");
print_server("RpcExcept(RPC_BAD_STUB_DATA_EXCEPTION_FILTER)\n");
print_server("{\n");
indent++;
print_server("RpcRaiseException(RPC_X_BAD_STUB_DATA);\n");
indent--;
print_server("}\n");
print_server("RpcEndExcept\n");
fprintf(server, "\n");
/* Assign 'out' arguments */
assign_out_args(func);
/* Call the real server function */
if (!is_void(def->type, NULL))
print_server("_RetVal = ");
else
print_server("");
write_name(server, def);
if (func->args)
{
int first_arg = 1;
fprintf(server, "(\n");
indent++;
var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
{
if (first_arg)
first_arg = 0;
else
fprintf(server, ",\n");
print_server("");
write_name(server, var);
var = PREV_LINK(var);
}
fprintf(server, ");\n");
indent--;
}
else
{
fprintf(server, "();\n");
}
if (func->args)
{
const var_t *var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
{
if (is_attr(var->attrs, ATTR_OUT))
{
unsigned int alignment;
buffer_size += get_required_buffer_size(var, &alignment, PASS_OUT);
buffer_size += alignment;
}
var = PREV_LINK(var);
}
}
if (!is_void(def->type, NULL))
{
unsigned int alignment;
buffer_size += get_required_buffer_size(def, &alignment, PASS_RETURN);
buffer_size += alignment;
}
if (has_out_arg_or_return(func))
{
fprintf(server, "\n");
print_server("_StubMsg.BufferLength = %u;\n", buffer_size);
type_offset_func = *type_offset;
write_remoting_arguments(server, indent, func, &type_offset_func, PASS_OUT, PHASE_BUFFERSIZE);
print_server("_pRpcMessage->BufferLength = _StubMsg.BufferLength;\n");
fprintf(server, "\n");
print_server("_Status = I_RpcGetBuffer(_pRpcMessage);\n");
print_server("if (_Status)\n");
indent++;
print_server("RpcRaiseException(_Status);\n");
indent--;
fprintf(server, "\n");
print_server("_StubMsg.Buffer = (unsigned char *)_pRpcMessage->Buffer;\n");
fprintf(server, "\n");
}
type_offset_func = *type_offset;
/* marshall arguments */
write_remoting_arguments(server, indent, func, type_offset, PASS_OUT, PHASE_MARSHAL);
/* marshall the return value */
if (!is_void(def->type, NULL))
print_phase_basetype(server, indent, PHASE_MARSHAL, PASS_RETURN, def, "_RetVal");
indent--;
print_server("}\n");
print_server("RpcFinally\n");
print_server("{\n");
indent++;
write_remoting_arguments(server, indent, func, &type_offset_func, PASS_OUT, PHASE_FREE);
indent--;
print_server("}\n");
print_server("RpcEndFinally\n");
/* calculate buffer length */
fprintf(server, "\n");
print_server("_pRpcMessage->BufferLength =\n");
indent++;
print_server("(unsigned int)(_StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer);\n");
indent--;
indent--;
fprintf(server, "}\n");
fprintf(server, "\n");
/* update proc_offset */
if (func->args)
{
var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
{
*proc_offset += get_size_procformatstring_var(var);
var = PREV_LINK(var);
}
}
if (!is_void(def->type, NULL))
*proc_offset += get_size_procformatstring_var(def);
else
*proc_offset += 2; /* FC_END and FC_PAD */
func = PREV_LINK(func);
}
}
static void write_dispatchtable(type_t *iface)
{
unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION);
unsigned long method_count = 0;
func_t *func = iface->funcs;
print_server("static RPC_DISPATCH_FUNCTION %s_table[] =\n", iface->name);
print_server("{\n");
indent++;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
{
var_t *def = func->def;
print_server("%s_", iface->name);
write_name(server, def);
fprintf(server, ",\n");
method_count++;
func = PREV_LINK(func);
}
print_server("0\n");
indent--;
print_server("};\n");
print_server("RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable =\n", iface->name, LOWORD(ver), HIWORD(ver));
print_server("{\n");
indent++;
print_server("%u,\n", method_count);
print_server("%s_table\n", iface->name);
indent--;
print_server("};\n");
fprintf(server, "\n");
}
static void write_stubdescdecl(type_t *iface)
{
print_server("static const MIDL_STUB_DESC %s_StubDesc;\n", iface->name);
fprintf(server, "\n");
}
static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
{
print_server("static const MIDL_STUB_DESC %s_StubDesc =\n", iface->name);
print_server("{\n");
indent++;
print_server("(void *)& %s___RpcServerInterface,\n", iface->name);
print_server("MIDL_user_allocate,\n");
print_server("MIDL_user_free,\n");
print_server("{\n");
indent++;
print_server("0,\n");
indent--;
print_server("},\n");
print_server("0,\n");
print_server("0,\n");
if (expr_eval_routines)
print_server("ExprEvalRoutines,\n");
else
print_server("0,\n");
print_server("0,\n");
print_server("__MIDL_TypeFormatString.Format,\n");
print_server("1, /* -error bounds_check flag */\n");
print_server("0x10001, /* Ndr library version */\n");
print_server("0,\n");
print_server("0x50100a4, /* MIDL Version 5.1.164 */\n");
print_server("0,\n");
print_server("0,\n");
print_server("0, /* notify & notify_flag routine table */\n");
print_server("1, /* Flags */\n");
print_server("0, /* Reserved3 */\n");
print_server("0, /* Reserved4 */\n");
print_server("0 /* Reserved5 */\n");
indent--;
print_server("};\n");
fprintf(server, "\n");
}
static void write_serverinterfacedecl(type_t *iface)
{
unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION);
UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
print_server("extern RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable;\n", iface->name, LOWORD(ver), HIWORD(ver));
fprintf(server, "\n");
print_server("static const RPC_SERVER_INTERFACE %s___RpcServerInterface =\n", iface->name );
print_server("{\n");
indent++;
print_server("sizeof(RPC_SERVER_INTERFACE),\n");
print_server("{{0x%08lx,0x%04x,0x%04x,{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x}},{%d,%d}},\n",
uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1],
uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6],
uuid->Data4[7], LOWORD(ver), HIWORD(ver));
print_server("{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},\n"); /* FIXME */
print_server("&%s_v%d_%d_DispatchTable,\n", iface->name, LOWORD(ver), HIWORD(ver));
print_server("0,\n");
print_server("0,\n");
print_server("0,\n");
print_server("0,\n");
print_server("0,\n");
indent--;
print_server("};\n");
if (old_names)
print_server("RPC_IF_HANDLE %s_ServerIfHandle = (RPC_IF_HANDLE)& %s___RpcServerInterface;\n",
iface->name, iface->name);
else
print_server("RPC_IF_HANDLE %s_v%d_%d_s_ifspec = (RPC_IF_HANDLE)& %s___RpcServerInterface;\n",
iface->name, LOWORD(ver), HIWORD(ver), iface->name);
fprintf(server, "\n");
}
static void write_formatdesc( const char *str )
{
print_server("typedef struct _MIDL_%s_FORMAT_STRING\n", str );
print_server("{\n");
indent++;
print_server("short Pad;\n");
print_server("unsigned char Format[%s_FORMAT_STRING_SIZE];\n", str);
indent--;
print_server("} MIDL_%s_FORMAT_STRING;\n", str);
print_server("\n");
}
static void write_formatstringsdecl(ifref_t *ifaces)
{
print_server("#define TYPE_FORMAT_STRING_SIZE %d\n",
get_size_typeformatstring(ifaces));
print_server("#define PROC_FORMAT_STRING_SIZE %d\n",
get_size_procformatstring(ifaces));
fprintf(server, "\n");
write_formatdesc("TYPE");
write_formatdesc("PROC");
fprintf(server, "\n");
print_server("static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;\n");
print_server("static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;\n");
print_server("\n");
}
static void init_server(void)
{
if (server)
return;
if (!(server = fopen(server_name, "w")))
error("Could not open %s for output\n", server_name);
print_server("/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", WIDL_FULLVERSION, input_name);
print_server("#include <string.h>\n");
fprintf(server, "\n");
print_server("#include \"%s\"\n", header_name);
fprintf(server, "\n");
}
void write_server(ifref_t *ifaces)
{
unsigned int proc_offset = 0;
unsigned int type_offset = 2;
ifref_t *iface = ifaces;
if (!do_server)
return;
if (!ifaces)
return;
END_OF_LIST(iface);
init_server();
if (!server)
return;
write_formatstringsdecl(ifaces);
for (; iface; iface = PREV_LINK(iface))
{
if (is_object(iface->iface->attrs) || is_local(iface->iface->attrs))
continue;
fprintf(server, "/*****************************************************************************\n");
fprintf(server, " * %s interface\n", iface->iface->name);
fprintf(server, " */\n");
fprintf(server, "\n");
if (iface->iface->funcs)
{
int expr_eval_routines;
write_serverinterfacedecl(iface->iface);
write_stubdescdecl(iface->iface);
write_function_stubs(iface->iface, &proc_offset, &type_offset);
print_server("#if !defined(__RPC_WIN32__)\n");
print_server("#error Invalid build platform for this stub.\n");
print_server("#endif\n");
fprintf(server, "\n");
expr_eval_routines = write_expr_eval_routines(server, iface->iface->name);
if (expr_eval_routines)
write_expr_eval_routine_list(server, iface->iface->name);
write_stubdescriptor(iface->iface, expr_eval_routines);
write_dispatchtable(iface->iface);
}
}
fprintf(server, "\n");
write_procformatstring(server, ifaces);
write_typeformatstring(server, ifaces);
fclose(server);
}
File diff suppressed because it is too large Load Diff
+49
View File
@@ -0,0 +1,49 @@
/*
* Format String Generator for IDL Compiler
*
* Copyright 2005-2006 Eric Kohl
* Copyright 2005 Robert Shearman
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
enum pass
{
PASS_IN,
PASS_OUT,
PASS_RETURN
};
enum remoting_phase
{
PHASE_BUFFERSIZE,
PHASE_MARSHAL,
PHASE_UNMARSHAL,
PHASE_FREE
};
void write_procformatstring(FILE *file, const ifref_t *ifaces);
void write_typeformatstring(FILE *file, const ifref_t *ifaces);
size_t get_type_memsize(const type_t *type);
unsigned int get_required_buffer_size(const var_t *var, unsigned int *alignment, enum pass pass);
void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, enum pass pass, const var_t *var, const char *varname);
void write_remoting_arguments(FILE *file, int indent, const func_t *func, unsigned int *type_offset, enum pass pass, enum remoting_phase phase);
size_t get_size_procformatstring_var(const var_t *var);
size_t get_size_typeformatstring_var(const var_t *var);
size_t get_size_procformatstring(const ifref_t *ifaces);
size_t get_size_typeformatstring(const ifref_t *ifaces);
int write_expr_eval_routines(FILE *file, const char *iface);
void write_expr_eval_routine_list(FILE *file, const char *iface);
+417
View File
@@ -0,0 +1,417 @@
/*
* IDL Compiler
*
* Copyright 2004 Ove Kaaven
* Copyright 2006 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include "wine/wpp.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <signal.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "header.h"
#include "typelib.h"
#include "widltypes.h"
#include "typelib_struct.h"
int in_typelib = 0;
static typelib_t *typelib;
/* List of oleauto types that should be recognized by name.
* (most of) these seem to be intrinsic types in mktyplib. */
static struct oatype {
const char *kw;
unsigned short vt;
} oatypes[] = {
{"BSTR", VT_BSTR},
{"CURRENCY", VT_CY},
{"DATE", VT_DATE},
{"DECIMAL", VT_DECIMAL},
{"HRESULT", VT_HRESULT},
{"LPSTR", VT_LPSTR},
{"LPWSTR", VT_LPWSTR},
{"SCODE", VT_ERROR},
{"VARIANT", VT_VARIANT},
{"VARIANT_BOOL", VT_BOOL}
};
#define NTYPES (sizeof(oatypes)/sizeof(oatypes[0]))
#define KWP(p) ((const struct oatype *)(p))
static int kw_cmp_func(const void *s1, const void *s2)
{
return strcmp(KWP(s1)->kw, KWP(s2)->kw);
}
static unsigned short builtin_vt(const char *kw)
{
struct oatype key, *kwp;
key.kw = kw;
#ifdef KW_BSEARCH
kwp = bsearch(&key, oatypes, NTYPES, sizeof(oatypes[0]), kw_cmp_func);
#else
{
unsigned int i;
for (kwp=NULL, i=0; i < NTYPES; i++)
if (!kw_cmp_func(&key, &oatypes[i])) {
kwp = &oatypes[i];
break;
}
}
#endif
if (kwp) {
return kwp->vt;
}
return 0;
}
static int match(const char*n, const char*m)
{
if (!n) return 0;
return !strcmp(n, m);
}
unsigned short get_type_vt(type_t *t)
{
unsigned short vt;
chat("get_type_vt: %p type->name %s\n", t, t->name);
if (t->name) {
vt = builtin_vt(t->name);
if (vt) return vt;
}
switch (t->type) {
case RPC_FC_BYTE:
case RPC_FC_USMALL:
return VT_UI1;
case RPC_FC_CHAR:
case RPC_FC_SMALL:
return VT_I1;
case RPC_FC_WCHAR:
return VT_I2; /* mktyplib seems to parse wchar_t as short */
case RPC_FC_SHORT:
return VT_I2;
case RPC_FC_USHORT:
return VT_UI2;
case RPC_FC_LONG:
if (t->ref && match(t->ref->name, "int")) return VT_INT;
return VT_I4;
case RPC_FC_ULONG:
if (t->ref && match(t->ref->name, "int")) return VT_UINT;
return VT_UI4;
case RPC_FC_HYPER:
if (t->sign < 0) return VT_UI8;
if (t->ref && match(t->ref->name, "MIDL_uhyper")) return VT_UI8;
return VT_I8;
case RPC_FC_FLOAT:
return VT_R4;
case RPC_FC_DOUBLE:
return VT_R8;
case RPC_FC_RP:
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
if(t->ref)
return VT_PTR;
error("get_type_vt: unknown-deref-type: %d\n", t->ref->type);
break;
case RPC_FC_IP:
if(match(t->name, "IUnknown"))
return VT_UNKNOWN;
if(match(t->name, "IDispatch"))
return VT_DISPATCH;
return VT_USERDEFINED;
case RPC_FC_ENUM16:
case RPC_FC_STRUCT:
case RPC_FC_PSTRUCT:
case RPC_FC_CSTRUCT:
case RPC_FC_CPSTRUCT:
case RPC_FC_CVSTRUCT:
case RPC_FC_BOGUS_STRUCT:
return VT_USERDEFINED;
case 0:
if(t->attrs)
return VT_USERDEFINED;
return 0;
default:
error("get_type_vt: unknown type: 0x%02x\n", t->type);
}
return 0;
}
unsigned short get_var_vt(var_t *v)
{
unsigned short vt;
chat("get_var_vt: %p tname %s\n", v, v->tname);
if (v->tname) {
vt = builtin_vt(v->tname);
if (vt) return vt;
}
return get_type_vt(v->type);
}
void start_typelib(char *name, attr_t *attrs)
{
in_typelib++;
if (!do_typelib) return;
typelib = xmalloc(sizeof(*typelib));
typelib->name = xstrdup(name);
typelib->filename = xstrdup(typelib_name);
typelib->attrs = attrs;
}
void end_typelib(void)
{
in_typelib--;
if (!typelib) return;
create_msft_typelib(typelib);
return;
}
void add_interface(type_t *iface)
{
typelib_entry_t *entry;
if (!typelib) return;
chat("add interface: %s\n", iface->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_INTERFACE;
entry->u.interface = iface;
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_coclass(type_t *cls)
{
typelib_entry_t *entry;
if (!typelib) return;
chat("add coclass: %s\n", cls->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_COCLASS;
entry->u.class = cls;
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_module(type_t *module)
{
typelib_entry_t *entry;
if (!typelib) return;
chat("add module: %s\n", module->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_MODULE;
entry->u.module = module;
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_struct(type_t *structure)
{
typelib_entry_t *entry;
if (!typelib) return;
chat("add struct: %s\n", structure->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_RECORD;
entry->u.structure = structure;
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_enum(type_t *enumeration)
{
typelib_entry_t *entry;
if (!typelib) return;
chat("add enum: %s\n", enumeration->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_ENUM;
entry->u.enumeration = enumeration;
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_typedef(type_t *tdef, var_t *name)
{
typelib_entry_t *entry;
if (!typelib) return;
chat("add typedef: %s\n", name->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_ALIAS;
entry->u.tdef = xmalloc(sizeof(*entry->u.tdef));
memcpy(entry->u.tdef, name, sizeof(*name));
entry->u.tdef->type = tdef;
entry->u.tdef->name = xstrdup(name->name);
LINK(entry, typelib->entry);
typelib->entry = entry;
}
static void tlb_read(int fd, void *buf, size_t count)
{
if(read(fd, buf, count) < count)
error("error while reading importlib.\n");
}
static void tlb_lseek(int fd, off_t offset)
{
if(lseek(fd, offset, SEEK_SET) == -1)
error("lseek failed\n");
}
static void msft_read_guid(int fd, MSFT_SegDir *segdir, int offset, GUID *guid)
{
tlb_lseek(fd, segdir->pGuidTab.offset+offset);
tlb_read(fd, guid, sizeof(GUID));
}
static void read_msft_importlib(importlib_t *importlib, int fd)
{
MSFT_Header header;
MSFT_SegDir segdir;
int *typeinfo_offs;
int i;
importlib->allocated = 0;
tlb_lseek(fd, 0);
tlb_read(fd, &header, sizeof(header));
importlib->version = header.version;
typeinfo_offs = xmalloc(header.nrtypeinfos*sizeof(INT));
tlb_read(fd, typeinfo_offs, header.nrtypeinfos*sizeof(INT));
tlb_read(fd, &segdir, sizeof(segdir));
msft_read_guid(fd, &segdir, header.posguid, &importlib->guid);
importlib->ntypeinfos = header.nrtypeinfos;
importlib->importinfos = xmalloc(importlib->ntypeinfos*sizeof(importinfo_t));
for(i=0; i < importlib->ntypeinfos; i++) {
MSFT_TypeInfoBase base;
MSFT_NameIntro nameintro;
int len;
tlb_lseek(fd, sizeof(MSFT_Header) + header.nrtypeinfos*sizeof(INT) + sizeof(MSFT_SegDir)
+ typeinfo_offs[i]);
tlb_read(fd, &base, sizeof(base));
importlib->importinfos[i].importlib = importlib;
importlib->importinfos[i].flags = (base.typekind&0xf)<<24;
importlib->importinfos[i].offset = -1;
importlib->importinfos[i].id = i;
if(base.posguid != -1) {
importlib->importinfos[i].flags |= MSFT_IMPINFO_OFFSET_IS_GUID;
msft_read_guid(fd, &segdir, base.posguid, &importlib->importinfos[i].guid);
}
tlb_lseek(fd, segdir.pNametab.offset + base.NameOffset);
tlb_read(fd, &nameintro, sizeof(nameintro));
len = nameintro.namelen & 0xff;
importlib->importinfos[i].name = xmalloc(len+1);
tlb_read(fd, importlib->importinfos[i].name, len);
importlib->importinfos[i].name[len] = 0;
}
free(typeinfo_offs);
}
static void read_importlib(importlib_t *importlib)
{
int fd;
INT magic;
char *file_name;
file_name = wpp_find_include(importlib->name, NULL);
if(file_name) {
fd = open(file_name, O_RDONLY);
free(file_name);
}else {
fd = open(importlib->name, O_RDONLY);
}
if(fd < 0)
error("Could not open importlib %s.\n", importlib->name);
tlb_read(fd, &magic, sizeof(magic));
switch(magic) {
case MSFT_MAGIC:
read_msft_importlib(importlib, fd);
break;
default:
error("Wrong or unsupported typelib magic %x\n", magic);
};
close(fd);
}
void add_importlib(const char *name)
{
importlib_t *importlib;
if(!typelib) return;
for(importlib = typelib->importlibs; importlib; importlib = NEXT_LINK(importlib)) {
if(!strcmp(name, importlib->name))
return;
}
chat("add_importlib: %s\n", name);
importlib = xmalloc(sizeof(*importlib));
importlib->name = xstrdup(name);
read_importlib(importlib);
LINK(importlib, typelib->importlibs);
typelib->importlibs = importlib;
}
+93
View File
@@ -0,0 +1,93 @@
/*
* IDL Compiler
*
* Copyright 2004 Ove Kaaven
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WIDL_TYPELIB_H
#define __WIDL_TYPELIB_H
extern int in_typelib;
extern void start_typelib(char *name, attr_t *attrs);
extern void end_typelib(void);
extern void add_interface(type_t *iface);
extern void add_coclass(type_t *cls);
extern void add_module(type_t *module);
extern void add_struct(type_t *structure);
extern void add_enum(type_t *enumeration);
extern void add_typedef(type_t *tdef, var_t *name);
extern void add_importlib(const char *name);
/* Copied from wtypes.h. Not included directly because that would create a
* circular dependency (after all, wtypes.h is generated by widl...) */
enum VARENUM {
VT_EMPTY = 0,
VT_NULL = 1,
VT_I2 = 2,
VT_I4 = 3,
VT_R4 = 4,
VT_R8 = 5,
VT_CY = 6,
VT_DATE = 7,
VT_BSTR = 8,
VT_DISPATCH = 9,
VT_ERROR = 10,
VT_BOOL = 11,
VT_VARIANT = 12,
VT_UNKNOWN = 13,
VT_DECIMAL = 14,
VT_I1 = 16,
VT_UI1 = 17,
VT_UI2 = 18,
VT_UI4 = 19,
VT_I8 = 20,
VT_UI8 = 21,
VT_INT = 22,
VT_UINT = 23,
VT_VOID = 24,
VT_HRESULT = 25,
VT_PTR = 26,
VT_SAFEARRAY = 27,
VT_CARRAY = 28,
VT_USERDEFINED = 29,
VT_LPSTR = 30,
VT_LPWSTR = 31,
VT_RECORD = 36,
VT_FILETIME = 64,
VT_BLOB = 65,
VT_STREAM = 66,
VT_STORAGE = 67,
VT_STREAMED_OBJECT = 68,
VT_STORED_OBJECT = 69,
VT_BLOB_OBJECT = 70,
VT_CF = 71,
VT_CLSID = 72,
VT_BSTR_BLOB = 0xfff,
VT_VECTOR = 0x1000,
VT_ARRAY = 0x2000,
VT_BYREF = 0x4000,
VT_RESERVED = 0x8000,
VT_ILLEGAL = 0xffff,
VT_ILLEGALMASKED = 0xfff,
VT_TYPEMASK = 0xfff
};
extern unsigned short get_type_vt(type_t *t);
extern unsigned short get_var_vt(var_t *v);
extern int create_msft_typelib(typelib_t *typelib);
#endif
+605
View File
@@ -0,0 +1,605 @@
/*
* typelib_struct.h internal wine data structures
* used to decode typelib's
*
* Copyright 1999 Rein KLazes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _WIDL_TYPELIB_STRUCT_H
#define _WIDL_TYPELIB_STRUCT_H
#define HELPDLLFLAG (0x0100)
#define DO_NOT_SEEK (-1)
#define MSFT_HREFTYPE_INTHISFILE(href) (!((href) & 3))
#define MSFT_HREFTYPE_INDEX(href) ((href) /sizeof(MSFT_TypeInfoBase))
/*-------------------------FILE STRUCTURES-----------------------------------*/
/* There are two known file formats, those created with ICreateTypeLib
* have the signature "SLTG" as their first four bytes, while those created
* with ICreateTypeLib2 have "MSFT".
*/
#define MSFT_MAGIC 0x5446534d
/*****************************************************
* MSFT typelibs
*
* These are TypeLibs created with ICreateTypeLib2
*
*/
/*
* structure of the typelib type2 header
* it is at the beginning of a type lib file
*
*/
typedef struct tagMSFT_Header {
/*0x00*/INT magic1; /* 0x5446534D "MSFT" */
INT magic2; /* 0x00010002 version nr? */
INT posguid; /* position of libid in guid table */
/* (should be, else -1) */
INT lcid; /* locale id */
/*0x10*/INT lcid2;
INT varflags; /* (largely) unknown flags */
/* the lower nibble is syskind */
/* 0x40 always seems to be set */
/* 0x10 set with a helpfile defined */
/* 0x100 set with a helpstringdll defined - in this
case the offset to the name in the stringtable
appears right after this struct, before the
typeinfo offsets */
INT version; /* set with SetVersion() */
INT flags; /* set with SetFlags() */
/*0x20*/INT nrtypeinfos; /* number of typeinfo's (till so far) */
INT helpstring; /* position of help string in stringtable */
INT helpstringcontext;
INT helpcontext;
/*0x30*/INT nametablecount; /* number of names in name table */
INT nametablechars; /* nr of characters in name table */
INT NameOffset; /* offset of name in name table */
INT helpfile; /* position of helpfile in stringtable */
/*0x40*/INT CustomDataOffset; /* if -1 no custom data, else it is offset */
/* in customer data/guid offset table */
INT res44; /* unknown always: 0x20 (guid hash size?) */
INT res48; /* unknown always: 0x80 (name hash size?) */
INT dispatchpos; /* HREFTYPE to IDispatch, or -1 if no IDispatch */
/*0x50*/INT nimpinfos; /* number of impinfos */
} MSFT_Header;
/* segments in the type lib file have a structure like this: */
typedef struct tagMSFT_pSeg {
INT offset; /* absolute offset in file */
INT length; /* length of segment */
INT res08; /* unknown always -1 */
INT res0c; /* unknown always 0x0f in the header */
/* 0x03 in the typeinfo_data */
} MSFT_pSeg;
/* layout of the main segment directory */
typedef struct tagMSFT_SegDir {
/*1*/MSFT_pSeg pTypeInfoTab; /* each type info get an entry of 0x64 bytes */
/* (25 ints) */
/*2*/MSFT_pSeg pImpInfo; /* table with info for imported types */
/*3*/MSFT_pSeg pImpFiles; /* import libaries */
/*4*/MSFT_pSeg pRefTab; /* References table */
/*5*/MSFT_pSeg pLibtab; /* always exists, alway same size (0x80) */
/* hash table w offsets to guid????? */
/*6*/MSFT_pSeg pGuidTab; /* all guids are stored here together with */
/* offset in some table???? */
/*7*/MSFT_pSeg res07; /* always created, alway same size (0x200) */
/* purpose largely unknown */
/*8*/MSFT_pSeg pNametab; /* name tables */
/*9*/MSFT_pSeg pStringtab; /* string table */
/*A*/MSFT_pSeg pTypdescTab; /* table with type descriptors */
/*B*/MSFT_pSeg pArrayDescriptions;
/*C*/MSFT_pSeg pCustData; /* data table, used for custom data and default */
/* parameter values */
/*D*/MSFT_pSeg pCDGuids; /* table with offsets for the guids and into */
/* the customer data table */
/*E*/MSFT_pSeg res0e; /* unknown */
/*F*/MSFT_pSeg res0f; /* unknown */
} MSFT_SegDir;
/* base type info data */
typedef struct tagMSFT_TypeInfoBase {
/*000*/ INT typekind; /* it is the TKIND_xxx */
/* some byte alignment stuf */
INT memoffset; /* points past the file, if no elements */
INT res2; /* zero if no element, N*0x40 */
INT res3; /* -1 if no lement, (N-1)*0x38 */
/*010*/ INT res4; /* always? 3 */
INT res5; /* always? zero */
INT cElement; /* counts elements, HI=cVars, LO=cFuncs */
INT res7; /* always? zero */
/*020*/ INT res8; /* always? zero */
INT res9; /* always? zero */
INT resA; /* always? zero */
INT posguid; /* position in guid table */
/*030*/ INT flags; /* Typeflags */
INT NameOffset; /* offset in name table */
INT version; /* element version */
INT docstringoffs; /* offset of docstring in string tab */
/*040*/ INT helpstringcontext; /* */
INT helpcontext; /* */
INT oCustData; /* offset in customer data table */
#ifdef WORDS_BIGENDIAN
INT16 cbSizeVft; /* virtual table size, including inherits */
INT16 cImplTypes; /* nr of implemented interfaces */
#else
INT16 cImplTypes; /* nr of implemented interfaces */
INT16 cbSizeVft; /* virtual table size, including inherits */
#endif
/*050*/ INT size; /* size in bytes, at least for structures */
/* FIXME: name of this field */
INT datatype1; /* position in type description table */
/* or in base intefaces */
/* if coclass: offset in reftable */
/* if interface: reference to inherited if */
INT datatype2; /* for interfaces: hiword is num of inherited funcs */
/* loword is num of inherited interfaces */
INT res18; /* always? 0 */
/*060*/ INT res19; /* always? -1 */
} MSFT_TypeInfoBase;
/* layout of an entry with information on imported types */
typedef struct tagMSFT_ImpInfo {
INT flags; /* bits 0 - 15: count */
/* bit 16: if set oGuid is an offset to Guid */
/* if clear oGuid is a typeinfo index in the specified typelib */
/* bits 24 - 31: TKIND of reference */
INT oImpFile; /* offset in the Import File table */
INT oGuid; /* offset in Guid table or typeinfo index (see bit 16 of flags) */
} MSFT_ImpInfo;
#define MSFT_IMPINFO_OFFSET_IS_GUID 0x00010000
/* function description data */
typedef struct {
/* INT recsize; record size including some xtra stuff */
INT DataType; /* data type of the member, eg return of function */
INT Flags; /* something to do with attribute flags (LOWORD) */
#ifdef WORDS_BIGENDIAN
INT16 funcdescsize; /* size of reconstituted FUNCDESC and related structs */
INT16 VtableOffset; /* offset in vtable */
#else
INT16 VtableOffset; /* offset in vtable */
INT16 funcdescsize; /* size of reconstituted FUNCDESC and related structs */
#endif
INT FKCCIC; /* bit string with the following */
/* meaning (bit 0 is the lsb): */
/* bits 0 - 2: FUNCKIND */
/* bits 3 - 6: INVOKEKIND */
/* bit 7: custom data present */
/* bits 8 - 11: CALLCONV */
/* bit 12: parameters have default values */
/* bit 13: oEntry is numeric */
/* bit 14: has retval param */
/* bits 16 - 31: index of next function with same id */
#ifdef WORDS_BIGENDIAN
INT16 nroargs; /* nr of optional arguments */
INT16 nrargs; /* number of arguments (including optional ????) */
#else
INT16 nrargs; /* number of arguments (including optional ????) */
INT16 nroargs; /* nr of optional arguments */
#endif
/* optional attribute fields, the number of them is variable */
INT OptAttr[1];
/*
0* INT helpcontext;
1* INT oHelpString;
2* INT oEntry; // either offset in string table or numeric as it is (see bit 13 of FKCCIC) //
3* INT res9; // unknown (-1) //
4* INT resA; // unknown (-1) //
5* INT HelpStringContext;
// these are controlled by a bit set in the FKCCIC field //
6* INT oCustData; // custom data for function //
7* INT oArgCustData[1]; // custom data per argument //
*/
} MSFT_FuncRecord;
/* after this may follow an array with default value pointers if the
* appropriate bit in the FKCCIC field has been set:
* INT oDefautlValue[nrargs];
*/
/* Parameter info one per argument*/
typedef struct {
INT DataType;
INT oName;
INT Flags;
} MSFT_ParameterInfo;
/* Variable description data */
typedef struct {
/* INT recsize; // record size including some xtra stuff */
INT DataType; /* data type of the variable */
INT Flags; /* VarFlags (LOWORD) */
#ifdef WORDS_BIGENDIAN
INT16 vardescsize; /* size of reconstituted VARDESC and related structs */
INT16 VarKind; /* VarKind */
#else
INT16 VarKind; /* VarKind */
INT16 vardescsize; /* size of reconstituted VARDESC and related structs */
#endif
INT OffsValue; /* value of the variable or the offset */
/* in the data structure */
/* optional attribute fields, the number of them is variable */
/* controlled by record length */
INT HelpContext;
INT oHelpString;
INT res9; /* unknown (-1) */
INT oCustData; /* custom data for variable */
INT HelpStringContext;
} MSFT_VarRecord;
/* Structure of the reference data */
typedef struct {
INT reftype; /* either offset in type info table, then it's */
/* a multiple of 64 */
/* or offset in the external reference table */
/* with an offset of 1 */
INT flags;
INT oCustData; /* custom data */
INT onext; /* next offset, -1 if last */
} MSFT_RefRecord;
/* this is how a guid is stored */
typedef struct {
GUID guid;
INT hreftype; /* -2 for the typelib guid, typeinfo offset
for typeinfo guid, low two bits are 01 if
this is an imported typeinfo, low two bits
are 10 if this is an imported typelib (used
by imported typeinfos) */
INT next_hash; /* offset to next guid in the hash bucket */
} MSFT_GuidEntry;
/* some data preceding entries in the name table */
typedef struct {
INT hreftype; /* is -1 if name is for neither a typeinfo,
a variable, or a function (that is, name
is for a typelib or a function parameter).
otherwise is the offset of the first
typeinfo that this name refers to (either
to the typeinfo itself or to a member of
the typeinfo */
INT next_hash; /* offset to next name in the hash bucket */
INT namelen; /* only lower 8 bits are valid */
/* 0x1000 if name is only used once as a variable name */
/* 0x2000 if name is a variable in an enumeration */
/* 0x3800 if name is typeinfo name */
/* upper 16 bits are hash code */
} MSFT_NameIntro;
/* the custom data table directory has enties like this */
typedef struct {
INT GuidOffset;
INT DataOffset;
INT next; /* next offset in the table, -1 if it's the last */
} MSFT_CDGuid;
/***********************************************************
*
* SLTG typelibs.
*
* These are created with ICreateTypeLib
*
*/
#include "pshpack1.h"
typedef struct {
/*00*/ DWORD SLTG_magic; /* 0x47544c53 == "SLTG" */
/*04*/ WORD nrOfFileBlks; /* no of SLTG_BlkEntry's + 1 */
/*06*/ WORD res06; /* ?? always 9 */
/*08*/ WORD res08; /* some kind of len/offset ?? */
/*0a*/ WORD first_blk; /* 1 based index into blk entries that
corresponds to first block in file */
/*0c*/ DWORD res0c; /* always 0x000204ff */
/*10*/ DWORD res10; /* always 0x00000000 */
/*14*/ DWORD res14; /* always 0x000000c0 */
/*18*/ DWORD res18; /* always 0x46000000 */
/*1c*/ DWORD res1c; /* always 0x00000044 */
/*20*/ DWORD res20; /* always 0xffff0000 */
} SLTG_Header;
/* This gets followed by a list of block entries */
typedef struct {
/*00*/ DWORD len;
/*04*/ WORD index_string; /* offs from start of SLTG_Magic to index string */
/*06*/ WORD next;
} SLTG_BlkEntry;
/* The order of the blocks in the file is given by starting at Block
entry firt_blk and stepping through using the next pointer */
/* These then get followed by this magic */
typedef struct {
/*00*/ BYTE res00; /* always 0x01 */
/*01*/ CHAR CompObj_magic[8]; /* always "CompObj" */
/*09*/ CHAR dir_magic[4]; /* always "dir" */
} SLTG_Magic;
#define SLTG_COMPOBJ_MAGIC "CompObj"
#define SLTG_DIR_MAGIC "dir"
/* Next we have SLTG_Header.nrOfFileBlks - 2 of Index strings. These
are presumably unique to within the file and look something like
"AAAAAAAAAA" with the first character incremented from 'A' to ensure
uniqueness. I guess successive chars increment when we need to wrap
the first one. */
typedef struct {
/*00*/ CHAR string[11];
} SLTG_Index;
/* This is followed by SLTG_pad9 */
typedef struct {
/*00*/ CHAR pad[9]; /* 9 '\0's */
} SLTG_Pad9;
/* Now we have the noOfFileBlks - 1 worth of blocks. The length of
each block is given by its entry in SLTG_BlkEntry. */
/* type SLTG_NAME in rather like a BSTR except that the length in
bytes is given by the first WORD and the string contains 8bit chars */
typedef WORD SLTG_Name;
/* The main library block looks like this. This one seems to come last */
typedef struct {
/*00*/ WORD magic; /* 0x51cc */
/*02*/ WORD res02; /* 0x0003, 0x0004 */
/*04*/ WORD name; /* offset to name in name table */
/*06*/ SLTG_Name res06; /* maybe this is just WORD == 0xffff */
SLTG_Name helpstring;
SLTG_Name helpfile;
DWORD helpcontext;
WORD syskind; /* == 1 for win32, 0 for win16 */
WORD lcid; /* == 0x409, 0x809 etc */
DWORD res12; /* == 0 */
WORD libflags; /* LIBFLAG_* */
WORD maj_vers;
WORD min_vers;
GUID uuid;
} SLTG_LibBlk;
#define SLTG_LIBBLK_MAGIC 0x51cc
/* we then get 0x40 bytes worth of 0xffff or small numbers followed by
nrOfFileBlks - 2 of these */
typedef struct {
WORD small_no;
SLTG_Name index_name; /* This refers to a name in the directory */
SLTG_Name other_name; /* Another one of these weird names */
WORD res1a; /* 0xffff */
WORD name_offs; /* offset to name in name table */
WORD more_bytes; /* if this is non-zero we get this many
bytes before the next element, which seem
to reference the docstring of the type ? */
WORD res20; /* 0xffff */
DWORD helpcontext;
WORD res26; /* 0xffff */
GUID uuid;
} SLTG_OtherTypeInfo;
/* Next we get WORD 0x0003 followed by a DWORD which if we add to
0x216 gives the offset to the name table from the start of the LibBlk
struct */
typedef struct {
/*00*/ WORD magic; /* 0x0501 */
/*02*/ DWORD href_table; /* if not 0xffffffff, then byte offset from
beginning of struct to href table */
/*06*/ DWORD res06; /* 0xffffffff */
/*0a*/ DWORD elem_table; /* offset to members */
/*0e*/ DWORD res0e; /* 0xffffffff */
/*12*/ WORD major_version; /* major version number */
/*14*/ WORD minor_version; /* minor version number */
/*16*/ DWORD res16; /* 0xfffe0000 */
/*1a*/ BYTE typeflags1;/* 0x02 | top 5 bits hold l5sbs of TYPEFLAGS */
/*1b*/ BYTE typeflags2;/* TYPEFLAGS >> 5 */
/*1c*/ BYTE typeflags3;/* 0x02*/
/*1d*/ BYTE typekind; /* 0x03 == TKIND_INTERFACE etc. */
/*1e*/ DWORD res1e; /* 0x00000000 or 0xffffffff */
} SLTG_TypeInfoHeader;
#define SLTG_TIHEADER_MAGIC 0x0501
typedef struct {
/*00*/ WORD cFuncs;
/*02*/ WORD cVars;
/*04*/ WORD cImplTypes;
/*06*/ WORD res06;
/*08*/ WORD res08;
/*0a*/ WORD res0a;
/*0c*/ WORD res0c;
/*0e*/ WORD res0e;
/*10*/ WORD res10;
/*12*/ WORD res12;
/*14*/ WORD tdescalias_vt; /* for TKIND_ALIAS */
/*16*/ WORD res16;
/*18*/ WORD res18;
/*1a*/ WORD res1a;
/*1c*/ WORD res1c;
/*1e*/ WORD res1e;
/*20*/ WORD cbSizeInstance;
/*22*/ WORD cbAlignment;
/*24*/ WORD res24;
/*26*/ WORD res26;
/*28*/ WORD cbSizeVft;
/*2a*/ WORD res2a;
/*2c*/ WORD res2c;
/*2e*/ WORD res2e;
/*30*/ WORD res30;
/*32*/ WORD res32;
/*34*/ WORD res34;
} SLTG_TypeInfoTail;
typedef struct {
/*00*/ WORD res00; /* 0x0001 sometimes 0x0003 ?? */
/*02*/ WORD res02; /* 0xffff */
/*04*/ BYTE res04; /* 0x01 */
/*05*/ DWORD cbExtra; /* No of bytes that follow */
} SLTG_MemberHeader;
typedef struct {
/*00*/ WORD magic; /* 0x120a */
/*02*/ WORD next; /* offset in bytes to next block from start of block
group, 0xffff if last item */
/*04*/ WORD name; /* offset to name within name table */
/*06*/ WORD value; /* offset to value from start of block group */
/*08*/ WORD res08; /* 0x56 */
/*0a*/ DWORD memid; /* memid */
/*0e*/ WORD helpcontext;/* 0xfffe == no context, 0x0001 == stored in EnumInfo struct, else offset
to value from start of block group */
/*10*/ WORD helpstring;/* offset from start of block group to string offset */
} SLTG_EnumItem;
#define SLTG_ENUMITEM_MAGIC 0x120a
typedef struct {
/*00*/ WORD vt; /* vartype, 0xffff marks end. */
/*02*/ WORD res02; /* ?, 0xffff marks end */
} SLTG_AliasItem;
#define SLTG_ALIASITEM_MAGIC 0x001d
typedef struct {
BYTE magic; /* 0x4c or 0x6c */
BYTE inv; /* high nibble is INVOKE_KIND, low nibble = 2 */
WORD next; /* byte offset from beginning of group to next fn */
WORD name; /* Offset within name table to name */
DWORD dispid; /* dispid */
WORD helpcontext; /* helpcontext (again 1 is special) */
WORD helpstring;/* helpstring offset to offset */
WORD arg_off; /* offset to args from start of block */
BYTE nacc; /* lowest 3bits are CALLCONV, rest are no of args */
BYTE retnextopt;/* if 0x80 bit set ret type follows else next WORD
is offset to ret type. No of optional args is
middle 6 bits */
WORD rettype; /* return type VT_?? or offset to ret type */
WORD vtblpos; /* position in vtbl? */
WORD funcflags; /* present if magic == 0x6c */
/* Param list starts, repeat next two as required */
#if 0
WORD name; /* offset to 2nd letter of name */
WORD+ type; /* VT_ of param */
#endif
} SLTG_Function;
#define SLTG_FUNCTION_MAGIC 0x4c
#define SLTG_FUNCTION_WITH_FLAGS_MAGIC 0x6c
typedef struct {
/*00*/ BYTE magic; /* 0xdf */
/*01*/ BYTE res01; /* 0x00 */
/*02*/ DWORD res02; /* 0xffffffff */
/*06*/ DWORD res06; /* 0xffffffff */
/*0a*/ DWORD res0a; /* 0xffffffff */
/*0e*/ DWORD res0e; /* 0xffffffff */
/*12*/ DWORD res12; /* 0xffffffff */
/*16*/ DWORD res16; /* 0xffffffff */
/*1a*/ DWORD res1a; /* 0xffffffff */
/*1e*/ DWORD res1e; /* 0xffffffff */
/*22*/ DWORD res22; /* 0xffffffff */
/*26*/ DWORD res26; /* 0xffffffff */
/*2a*/ DWORD res2a; /* 0xffffffff */
/*2e*/ DWORD res2e; /* 0xffffffff */
/*32*/ DWORD res32; /* 0xffffffff */
/*36*/ DWORD res36; /* 0xffffffff */
/*3a*/ DWORD res3a; /* 0xffffffff */
/*3e*/ DWORD res3e; /* 0xffffffff */
/*42*/ WORD res42; /* 0xffff */
/*44*/ DWORD number; /* this is 8 times the number of refs */
/*48*/ /* Now we have number bytes (8 for each ref) of SLTG_UnknownRefInfo */
/*50*/ WORD res50; /* 0xffff */
/*52*/ BYTE res52; /* 0x01 */
/*53*/ DWORD res53; /* 0x00000000 */
/*57*/ SLTG_Name names[1];
/* Now we have number/8 SLTG_Names (first WORD is no of bytes in the ascii
* string). Strings look like "*\Rxxxx*#n". If xxxx == ffff then the
* ref refers to the nth type listed in this library (0 based). Else
* the xxxx (which maybe fewer than 4 digits) is the offset into the name
* table to a string "*\G{<guid>}#1.0#0#C:\WINNT\System32\stdole32.tlb#"
* The guid is the typelib guid; the ref again refers to the nth type of
* the imported typelib.
*/
/*xx*/ BYTE resxx; /* 0xdf */
} SLTG_RefInfo;
#define SLTG_REF_MAGIC 0xdf
typedef struct {
WORD res00; /* 0x0001 */
BYTE res02; /* 0x02 */
BYTE res03; /* 0x40 if internal ref, 0x00 if external ? */
WORD res04; /* 0xffff */
WORD res06; /* 0x0000, 0x0013 or 0xffff ?? */
} SLTG_UnknownRefInfo;
typedef struct {
WORD res00; /* 0x004a */
WORD next; /* byte offs to next interface */
WORD res04; /* 0xffff */
BYTE impltypeflags; /* IMPLTYPEFLAG_* */
BYTE res07; /* 0x80 */
WORD res08; /* 0x0012, 0x0028 ?? */
WORD ref; /* number in ref table ? */
WORD res0c; /* 0x4000 */
WORD res0e; /* 0xfffe */
WORD res10; /* 0xffff */
WORD res12; /* 0x001d */
WORD pos_in_table; /* 0x0, 0x4, ? */
} SLTG_ImplInfo;
#define SLTG_IMPL_MAGIC 0x004a
typedef struct {
BYTE magic; /* 0x0a */
BYTE typepos;
WORD next;
WORD name;
WORD byte_offs; /* pos in struct */
WORD type; /* if typepos == 0x02 this is the type, else offset to type */
DWORD memid;
WORD helpcontext; /* ?? */
WORD helpstring; /* ?? */
} SLTG_RecordItem;
#define SLTG_RECORD_MAGIC 0x0a
/* CARRAYs look like this
WORD type == VT_CARRAY
WORD offset from start of block to SAFEARRAY
WORD typeofarray
*/
#include "poppack.h"
/*---------------------------END--------------------------------------------*/
#endif
+197
View File
@@ -0,0 +1,197 @@
/*
* Utility routines
*
* Copyright 1998 Bertho A. Stultiens
* Copyright 2002 Ove Kaaven
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include "widl.h"
#include "utils.h"
#include "parser.h"
/* #define WANT_NEAR_INDICATION */
#ifdef WANT_NEAR_INDICATION
void make_print(char *str)
{
while(*str)
{
if(!isprint(*str))
*str = ' ';
str++;
}
}
#endif
static void generic_msg(const char *s, const char *t, const char *n, va_list ap)
{
fprintf(stderr, "%s:%d: %s: ", input_name ? input_name : "stdin", line_number, t);
vfprintf(stderr, s, ap);
#ifdef WANT_NEAR_INDICATION
{
char *cpy;
if(n)
{
cpy = xstrdup(n);
make_print(cpy);
fprintf(stderr, " near '%s'", cpy);
free(cpy);
}
}
#endif
fprintf(stderr, "\n");
}
int yyerror(const char *s, ...)
{
va_list ap;
va_start(ap, s);
generic_msg(s, "Error", yytext, ap);
va_end(ap);
exit(1);
return 1;
}
int yywarning(const char *s, ...)
{
va_list ap;
va_start(ap, s);
generic_msg(s, "Warning", yytext, ap);
va_end(ap);
return 0;
}
void internal_error(const char *file, int line, const char *s, ...)
{
va_list ap;
va_start(ap, s);
fprintf(stderr, "Internal error (please report) %s %d: ", file, line);
vfprintf(stderr, s, ap);
va_end(ap);
exit(3);
}
void error(const char *s, ...)
{
va_list ap;
va_start(ap, s);
fprintf(stderr, "error: ");
vfprintf(stderr, s, ap);
va_end(ap);
exit(2);
}
void warning(const char *s, ...)
{
va_list ap;
va_start(ap, s);
fprintf(stderr, "warning: ");
vfprintf(stderr, s, ap);
va_end(ap);
}
void chat(const char *s, ...)
{
if(debuglevel & DEBUGLEVEL_CHAT)
{
va_list ap;
va_start(ap, s);
fprintf(stderr, "chat: ");
vfprintf(stderr, s, ap);
va_end(ap);
}
}
char *dup_basename(const char *name, const char *ext)
{
int namelen;
int extlen = strlen(ext);
char *base;
char *slash;
if(!name)
name = "widl.tab";
slash = strrchr(name, '/');
if (slash)
name = slash + 1;
namelen = strlen(name);
/* +4 for later extension and +1 for '\0' */
base = (char *)xmalloc(namelen +4 +1);
strcpy(base, name);
if(!strcasecmp(name + namelen-extlen, ext))
{
base[namelen - extlen] = '\0';
}
return base;
}
void *xmalloc(size_t size)
{
void *res;
assert(size > 0);
res = malloc(size);
if(res == NULL)
{
error("Virtual memory exhausted.\n");
}
/*
* We set it to 0.
* This is *paramount* because we depend on it
* just about everywhere in the rest of the code.
*/
memset(res, 0, size);
return res;
}
void *xrealloc(void *p, size_t size)
{
void *res;
assert(size > 0);
res = realloc(p, size);
if(res == NULL)
{
error("Virtual memory exhausted.\n");
}
return res;
}
char *xstrdup(const char *str)
{
char *s;
assert(str != NULL);
s = (char *)xmalloc(strlen(str)+1);
return strcpy(s, str);
}
+45
View File
@@ -0,0 +1,45 @@
/*
* Utility routines' prototypes etc.
*
* Copyright 1998 Bertho A. Stultiens (BS)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WIDL_UTILS_H
#define __WIDL_UTILS_H
#include "widltypes.h"
#include <stddef.h> /* size_t */
void *xmalloc(size_t);
void *xrealloc(void *, size_t);
char *xstrdup(const char *str);
#ifndef __GNUC__
#define __attribute__(X)
#endif
int yyerror(const char *s, ...) __attribute__((format (printf, 1, 2)));
int yywarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void chat(const char *s, ...) __attribute__((format (printf, 1, 2)));
char *dup_basename(const char *name, const char *ext);
#endif
+392
View File
@@ -0,0 +1,392 @@
/*
* IDL Compiler
*
* Copyright 2002 Ove Kaaven
* based on WRC code by Bertho Stultiens
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <signal.h>
#ifdef HAVE_GETOPT_H
# include <getopt.h>
#endif
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "wine/wpp.h"
#include "header.h"
/* future options to reserve characters for: */
/* a = alignment of structures */
/* A = ACF input filename */
/* J = do not search standard include path */
/* O = generate interpreted stubs */
/* u = UUID file only? */
/* U = UUID filename */
/* w = select win16/win32 output (?) */
static char usage[] =
"Usage: widl [options...] infile.idl\n"
" -c Generate client stub\n"
" -C file Name of client stub file (default is infile_c.c)\n"
" -d n Set debug level to 'n'\n"
" -D id[=val] Define preprocessor identifier id=val\n"
" -E Preprocess only\n"
" -h Generate headers\n"
" -H file Name of header file (default is infile.h)\n"
" -I path Set include search dir to path (multiple -I allowed)\n"
" -N Do not preprocess input\n"
" --oldnames Use old naming conventions\n"
" -p Generate proxy\n"
" -P file Name of proxy file (default is infile_p.c)\n"
" -s Generate server stub\n"
" -S file Name of server stub file (default is infile_s.c)\n"
" -t Generate typelib\n"
" -T file Name of typelib file (default is infile.tlb)\n"
" -V Print version and exit\n"
" -W Enable pedantic warnings\n"
"Debug level 'n' is a bitmask with following meaning:\n"
" * 0x01 Tell which resource is parsed (verbose mode)\n"
" * 0x02 Dump internal structures\n"
" * 0x04 Create a parser trace (yydebug=1)\n"
" * 0x08 Preprocessor messages\n"
" * 0x10 Preprocessor lex messages\n"
" * 0x20 Preprocessor yacc trace\n"
;
static const char version_string[] = "Wine IDL Compiler version " PACKAGE_VERSION "\n"
"Copyright 2002 Ove Kaaven\n";
int win32 = 1;
int debuglevel = DEBUGLEVEL_NONE;
int yy_flex_debug;
int pedantic = 0;
static int do_everything = 1;
int preprocess_only = 0;
int do_header = 0;
int do_typelib = 0;
int do_proxies = 0;
int do_client = 0;
int do_server = 0;
int no_preprocess = 0;
int old_names = 0;
char *input_name;
char *header_name;
char *header_token;
char *typelib_name;
char *proxy_name;
char *proxy_token;
char *client_name;
char *client_token;
char *server_name;
char *server_token;
char *temp_name;
int line_number = 1;
FILE *header;
FILE *proxy;
time_t now;
static const char *short_options =
"cC:d:D:EhH:I:NpP:sS:tT:VW";
static struct option long_options[] = {
{ "oldnames", 0, 0, 1 },
{ 0, 0, 0, 0 }
};
static void rm_tempfile(void);
static void segvhandler(int sig);
static char *make_token(const char *name)
{
char *token;
char *slash;
int i;
slash = strrchr(name, '/');
if (slash) name = slash + 1;
token = xstrdup(name);
for (i=0; token[i]; i++) {
if (!isalnum(token[i])) token[i] = '_';
else token[i] = toupper(token[i]);
}
return token;
}
/* duplicate a basename into a valid C token */
static char *dup_basename_token(const char *name, const char *ext)
{
char *p, *ret = dup_basename( name, ext );
/* map invalid characters to '_' */
for (p = ret; *p; p++) if (!isalnum(*p)) *p = '_';
return ret;
}
/* clean things up when aborting on a signal */
static void exit_on_signal( int sig )
{
exit(1); /* this will call the atexit functions */
}
int main(int argc,char *argv[])
{
extern char* optarg;
extern int optind;
int optc;
int ret = 0;
int opti = 0;
signal(SIGSEGV, segvhandler);
signal( SIGTERM, exit_on_signal );
signal( SIGINT, exit_on_signal );
#ifdef SIGHUP
signal( SIGHUP, exit_on_signal );
#endif
now = time(NULL);
while((optc = getopt_long(argc, argv, short_options, long_options, &opti)) != EOF) {
switch(optc) {
case 1:
old_names = 1;
break;
case 'c':
do_everything = 0;
do_client = 1;
break;
case 'C':
client_name = strdup(optarg);
break;
case 'd':
debuglevel = strtol(optarg, NULL, 0);
break;
case 'D':
wpp_add_cmdline_define(optarg);
break;
case 'E':
do_everything = 0;
preprocess_only = 1;
break;
case 'h':
do_everything = 0;
do_header = 1;
break;
case 'H':
header_name = strdup(optarg);
break;
case 'I':
wpp_add_include_path(optarg);
break;
case 'N':
no_preprocess = 1;
break;
case 'p':
do_everything = 0;
do_proxies = 1;
break;
case 'P':
proxy_name = strdup(optarg);
break;
case 's':
do_everything = 0;
do_server = 1;
break;
case 'S':
server_name = strdup(optarg);
break;
case 't':
do_everything = 0;
do_typelib = 1;
break;
case 'T':
typelib_name = strdup(optarg);
break;
case 'V':
printf(version_string);
return 0;
case 'W':
pedantic = 1;
break;
default:
fprintf(stderr, usage);
return 1;
}
}
if(do_everything) {
do_header = do_typelib = do_proxies = do_client = do_server = 1;
}
if(optind < argc) {
input_name = xstrdup(argv[optind]);
}
else {
fprintf(stderr, usage);
return 1;
}
if(debuglevel)
{
setbuf(stdout,0);
setbuf(stderr,0);
}
yydebug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
yy_flex_debug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
wpp_set_debug( (debuglevel & DEBUGLEVEL_PPLEX) != 0,
(debuglevel & DEBUGLEVEL_PPTRACE) != 0,
(debuglevel & DEBUGLEVEL_PPMSG) != 0 );
if (!header_name) {
header_name = dup_basename(input_name, ".idl");
strcat(header_name, ".h");
}
if (!typelib_name && do_typelib) {
typelib_name = dup_basename(input_name, ".idl");
strcat(typelib_name, ".tlb");
}
if (!proxy_name && do_proxies) {
proxy_name = dup_basename(input_name, ".idl");
strcat(proxy_name, "_p.c");
}
if (!client_name && do_client) {
client_name = dup_basename(input_name, ".idl");
strcat(client_name, "_c.c");
}
if (!server_name && do_server) {
server_name = dup_basename(input_name, ".idl");
strcat(server_name, "_s.c");
}
if (do_proxies) proxy_token = dup_basename_token(proxy_name,"_p.c");
if (do_client) client_token = dup_basename_token(client_name,"_c.c");
if (do_server) server_token = dup_basename_token(server_name,"_s.c");
wpp_add_cmdline_define("__WIDL__");
atexit(rm_tempfile);
if (!no_preprocess)
{
chat("Starting preprocess\n");
if (!preprocess_only)
{
ret = wpp_parse_temp( input_name, header_name, &temp_name );
}
else
{
ret = wpp_parse( input_name, stdout );
}
if(ret) exit(1);
if(preprocess_only) exit(0);
if(!(yyin = fopen(temp_name, "r"))) {
fprintf(stderr, "Could not open %s for input\n", temp_name);
return 1;
}
}
else {
if(!(yyin = fopen(input_name, "r"))) {
fprintf(stderr, "Could not open %s for input\n", input_name);
return 1;
}
}
if(do_header) {
header_token = make_token(header_name);
if(!(header = fopen(header_name, "w"))) {
fprintf(stderr, "Could not open %s for output\n", header_name);
return 1;
}
fprintf(header, "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
fprintf(header, "#include <rpc.h>\n" );
fprintf(header, "#include <rpcndr.h>\n\n" );
fprintf(header, "#ifndef __WIDL_%s\n", header_token);
fprintf(header, "#define __WIDL_%s\n", header_token);
fprintf(header, "#ifdef __cplusplus\n");
fprintf(header, "extern \"C\" {\n");
fprintf(header, "#endif\n");
}
ret = yyparse();
if(do_header) {
fprintf(header, "/* Begin additional prototypes for all interfaces */\n");
fprintf(header, "\n");
write_user_types();
fprintf(header, "\n");
fprintf(header, "/* End additional prototypes */\n");
fprintf(header, "\n");
fprintf(header, "#ifdef __cplusplus\n");
fprintf(header, "}\n");
fprintf(header, "#endif\n");
fprintf(header, "#endif /* __WIDL_%s */\n", header_token);
fclose(header);
}
fclose(yyin);
if(ret) {
exit(1);
}
header_name = NULL;
client_name = NULL;
server_name = NULL;
return 0;
}
static void rm_tempfile(void)
{
abort_import();
if(temp_name)
unlink(temp_name);
if (header_name)
unlink(header_name);
if (client_name)
unlink(client_name);
if (server_name)
unlink(server_name);
}
static void segvhandler(int sig)
{
fprintf(stderr, "\n%s:%d: Oops, segment violation\n", input_name, line_number);
fflush(stdout);
fflush(stderr);
abort();
}
+68
View File
@@ -0,0 +1,68 @@
/*
* IDL Compiler
*
* Copyright 2002 Ove Kaaven
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WIDL_WIDL_H
#define __WIDL_WIDL_H
#include "widltypes.h"
#include <time.h>
#define WIDL_FULLVERSION "0.1"
extern int debuglevel;
#define DEBUGLEVEL_NONE 0x0000
#define DEBUGLEVEL_CHAT 0x0001
#define DEBUGLEVEL_DUMP 0x0002
#define DEBUGLEVEL_TRACE 0x0004
#define DEBUGLEVEL_PPMSG 0x0008
#define DEBUGLEVEL_PPLEX 0x0010
#define DEBUGLEVEL_PPTRACE 0x0020
extern int win32;
extern int pedantic;
extern int do_header;
extern int do_typelib;
extern int do_proxies;
extern int do_client;
extern int do_server;
extern int old_names;
extern char *input_name;
extern char *header_name;
extern char *typelib_name;
extern char *proxy_name;
extern char *proxy_token;
extern char *client_name;
extern char *client_token;
extern char *server_name;
extern char *server_token;
extern time_t now;
extern int line_number;
extern int char_number;
extern FILE* header;
extern void write_proxies(ifref_t *ifaces);
extern void write_client(ifref_t *ifaces);
extern void write_server(ifref_t *ifaces);
#endif
+131
View File
@@ -0,0 +1,131 @@
WIDL_BASE = $(TOOLS_BASE)$(SEP)widl
WIDL_BASE_ = $(WIDL_BASE)$(SEP)
WIDL_INT = $(INTERMEDIATE_)$(WIDL_BASE)
WIDL_INT_ = $(WIDL_INT)$(SEP)
WIDL_OUT = $(OUTPUT_)$(WIDL_BASE)
WIDL_OUT_ = $(WIDL_OUT)$(SEP)
$(WIDL_INT): | $(TOOLS_INT)
$(ECHO_MKDIR)
${mkdir} $@
ifneq ($(INTERMEDIATE),$(OUTPUT))
$(WIDL_OUT): | $(TOOLS_OUT)
$(ECHO_MKDIR)
${mkdir} $@
endif
WIDL_PORT_BASE = $(WIDL_BASE)$(SEP)port
WIDL_PORT_BASE_ = $(WIDL_PORT_BASE)$(SEP)
WIDL_PORT_INT = $(INTERMEDIATE_)$(WIDL_PORT_BASE)
WIDL_PORT_INT_ = $(WIDL_PORT_INT)$(SEP)
WIDL_PORT_OUT = $(OUTPUT_)$(WIDL_PORT_BASE)
WIDL_PORT_OUT_ = $(WIDL_PORT_OUT)$(SEP)
$(WIDL_PORT_INT): | $(WIDL_INT)
$(ECHO_MKDIR)
${mkdir} $@
ifneq ($(INTERMEDIATE),$(OUTPUT))
$(WIDL_PORT_OUT): | $(WIDL_OUT)
$(ECHO_MKDIR)
${mkdir} $@
endif
WIDL_TARGET = \
$(EXEPREFIX)$(WIDL_OUT_)widl$(EXEPOSTFIX)
WIDL_DEPENDS = $(BUILDNO_H)
WIDL_SOURCES = $(addprefix $(WIDL_BASE_), \
client.c \
hash.c \
header.c \
lex.yy.c \
proxy.c \
server.c \
typegen.c \
typelib.c \
utils.c \
widl.c \
write_msft.c \
parser.tab.c \
port$(SEP)mkstemps.c \
)
WIDL_OBJECTS = \
$(addprefix $(INTERMEDIATE_), $(WIDL_SOURCES:.c=.o))
WIDL_HOST_CFLAGS = $(TOOLS_CFLAGS) \
-DINT16=SHORT -D__USE_W32API -DYYDEBUG=1 -D__REACTOS__=1 \
-I$(WIDL_BASE) -I$(WPP_BASE) \
-Iinclude/reactos/wine -Iinclude/reactos -Iinclude -Iinclude/psdk \
-I$(INTERMEDIATE_)include
WIDL_HOST_LFLAGS = $(TOOLS_LFLAGS)
WIDL_LIBS = $(WPP_TARGET)
.PHONY: widl
widl: $(WIDL_TARGET)
$(WIDL_TARGET): $(WIDL_OBJECTS) $(WIDL_LIBS) | $(WIDL_OUT)
$(ECHO_LD)
${host_gcc} $(WIDL_OBJECTS) $(WIDL_LIBS) $(WIDL_HOST_LFLAGS) -o $@
$(WIDL_INT_)client.o: $(WIDL_BASE_)client.c $(WIDL_DEPENDS) | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)hash.o: $(WIDL_BASE_)hash.c $(WIDL_DEPENDS) | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)header.o: $(WIDL_BASE_)header.c $(WIDL_DEPENDS) | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)lex.yy.o: $(WIDL_BASE_)lex.yy.c $(WIDL_DEPENDS) | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)proxy.o: $(WIDL_BASE_)proxy.c $(WIDL_DEPENDS) | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)server.o: $(WIDL_BASE_)server.c $(WIDL_DEPENDS) | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)typegen.o: $(WIDL_BASE_)typegen.c $(WIDL_DEPENDS) | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)typelib.o: $(WIDL_BASE_)typelib.c $(WIDL_DEPENDS) | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)utils.o: $(WIDL_BASE_)utils.c $(WIDL_DEPENDS) | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)widl.o: $(WIDL_BASE_)widl.c $(WIDL_DEPENDS) | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)write_msft.o: $(WIDL_BASE_)write_msft.c $(WIDL_DEPENDS) | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_INT_)parser.tab.o: $(WIDL_BASE_)parser.tab.c $(WIDL_DEPENDS) | $(WIDL_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
$(WIDL_PORT_INT_)mkstemps.o: $(WIDL_PORT_BASE_)mkstemps.c $(WIDL_DEPENDS) | $(WIDL_PORT_INT)
$(ECHO_CC)
${host_gcc} $(WIDL_HOST_CFLAGS) -c $< -o $@
.PHONY: widl_clean
widl_clean:
-@$(rm) $(WIDL_TARGET) $(WIDL_OBJECTS) 2>$(NUL)
clean: widl_clean
+88
View File
@@ -0,0 +1,88 @@
.\" -*- nroff -*-
.TH WIDL 1 "October 2005" "@PACKAGE_STRING@" "Wine Developers Manual"
.SH NAME
widl \- Wine Interface Definition Language Compiler
.SH SYNOPSIS
.BR "widl "\fI[options]\fR " \fIinfile.idl\fR"
.SH DESCRIPTION
.B widl
is a Wine tool which purpose is to compile Interface Definition Language (IDL) files.
.PP
.SH OPTIONS
.B Help mode:
.nf
No options are used.
The program prints the help info and then exits.
.PP
.B General options:
.IP "\fB-V\fR"
Print version number and exits from the program.
.PP
.B Header options:
.IP "\fB-h\fR"
Generate header files.
.IP "\fB-H \fIfile\fR"
Name of header file to generate. The default header
filename is infile.h.
.IP "\fB--oldnames\fR"
Use old naming conventions.
.PP
.B Type library options:
.IP \fB-t\fR
Generate a type library.
.IP "\fB-T \fIfile\fR"
Define the name of the type library to be generated.
The default filename is infile.tlb.
.PP
.B Proxy/stub generation options:
.IP "\fB-c\fR"
Generate client stub.
.IP "\fB-C \fIfile\fR"
Name of client stub file (default is infile_c.c)
.IP "\fB-p\fR"
Generate proxy.
.IP "\fB-P \fIfile\fR"
Name of proxy file (default is infile_p.c)
.IP "\fB-s\fR"
Generate server stub.
.IP "\fB-S \fIfile\fR"
Name of server stub file (default is infile_s.c)
.PP
.B Preprocessor options:
.IP "\fB-I \fIpath\fR"
Add a header search dir to path. Multiple search
dirs are allowed.
.IP "\fB-D \fIid[=val]\fR"
Define preprocessor identifier id value.
.IP "\fB-E\fR"
Preprocess only.
.IP "\fB-N\fR"
Do not preprocess input.
.PP
.B Debug options:
.IP "\fB-W\fR"
Enable pedantic warnings.
.IP "\fB-d \fIn\fR"
.nf
Set debug level to n.
n may be '0x01', '0x02', '0x04', '0x08', '0x10' or '0x20'.
(See section \fBDebug\fR)
.PP
.SH Debug
Debug level 'n' is a bitmask with the following meaning:
* 0x01 Tell which resource is parsed (verbose mode)
* 0x02 Dump internal structures
* 0x04 Create a parser trace (yydebug=1)
* 0x08 Preprocessor messages
* 0x10 Preprocessor lex messages
* 0x20 Preprocessor yacc trace
.SH BUGS
Typelib generation doesn't work at the moment. It is still under development.
.SH AUTHORS
.B widl
was written by Ove Kaaven. This man page was written by Hannu
Valtonen.
.SH "SEE ALSO"
The Winelib User Guide
.nf
The Wine Developers Guide
+300
View File
@@ -0,0 +1,300 @@
/*
* IDL Compiler
*
* Copyright 2002 Ove Kaaven
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WIDL_WIDLTYPES_H
#define __WIDL_WIDLTYPES_H
#include <stdarg.h>
#include "guiddef.h"
#include "wine/rpcfc.h"
#ifndef UUID_DEFINED
#define UUID_DEFINED
typedef GUID UUID;
#endif
#define TRUE 1
#define FALSE 0
typedef struct _attr_t attr_t;
typedef struct _expr_t expr_t;
typedef struct _type_t type_t;
typedef struct _typeref_t typeref_t;
typedef struct _var_t var_t;
typedef struct _func_t func_t;
typedef struct _ifref_t ifref_t;
typedef struct _typelib_entry_t typelib_entry_t;
typedef struct _importlib_t importlib_t;
typedef struct _importinfo_t importinfo_t;
typedef struct _typelib_t typelib_t;
#define DECL_LINK(type) \
type *l_next; \
type *l_prev
#define LINK(x,y) do { x->l_next = y; if (y) y->l_prev = x; } while (0)
#define INIT_LINK(x) do { x->l_next = NULL; x->l_prev = NULL; } while (0)
#define NEXT_LINK(x) ((x)->l_next)
#define PREV_LINK(x) ((x)->l_prev)
#define END_OF_LIST(list) \
do { \
if (list) { \
while (NEXT_LINK(list)) \
list = NEXT_LINK(list); \
} \
} while(0)
enum attr_type
{
ATTR_AGGREGATABLE,
ATTR_APPOBJECT,
ATTR_ASYNC,
ATTR_AUTO_HANDLE,
ATTR_BINDABLE,
ATTR_CALLAS,
ATTR_CASE,
ATTR_CONTEXTHANDLE,
ATTR_CONTROL,
ATTR_DEFAULT,
ATTR_DEFAULTCOLLELEM,
ATTR_DEFAULTVALUE_EXPR,
ATTR_DEFAULTVALUE_STRING,
ATTR_DEFAULTVTABLE,
ATTR_DISPINTERFACE,
ATTR_DISPLAYBIND,
ATTR_DLLNAME,
ATTR_DUAL,
ATTR_ENDPOINT,
ATTR_ENTRY_ORDINAL,
ATTR_ENTRY_STRING,
ATTR_EXPLICIT_HANDLE,
ATTR_HANDLE,
ATTR_HELPCONTEXT,
ATTR_HELPFILE,
ATTR_HELPSTRING,
ATTR_HELPSTRINGCONTEXT,
ATTR_HELPSTRINGDLL,
ATTR_HIDDEN,
ATTR_ID,
ATTR_IDEMPOTENT,
ATTR_IIDIS,
ATTR_IMMEDIATEBIND,
ATTR_IMPLICIT_HANDLE,
ATTR_IN,
ATTR_INPUTSYNC,
ATTR_LENGTHIS,
ATTR_LOCAL,
ATTR_NONBROWSABLE,
ATTR_NONCREATABLE,
ATTR_NONEXTENSIBLE,
ATTR_OBJECT,
ATTR_ODL,
ATTR_OLEAUTOMATION,
ATTR_OPTIONAL,
ATTR_OUT,
ATTR_POINTERDEFAULT,
ATTR_POINTERTYPE,
ATTR_PROPGET,
ATTR_PROPPUT,
ATTR_PROPPUTREF,
ATTR_PUBLIC,
ATTR_RANGE,
ATTR_READONLY,
ATTR_REQUESTEDIT,
ATTR_RESTRICTED,
ATTR_RETVAL,
ATTR_SIZEIS,
ATTR_SOURCE,
ATTR_STRING,
ATTR_SWITCHIS,
ATTR_SWITCHTYPE,
ATTR_TRANSMITAS,
ATTR_UUID,
ATTR_V1ENUM,
ATTR_VARARG,
ATTR_VERSION,
ATTR_WIREMARSHAL
};
enum expr_type
{
EXPR_VOID,
EXPR_NUM,
EXPR_HEXNUM,
EXPR_IDENTIFIER,
EXPR_NEG,
EXPR_NOT,
EXPR_PPTR,
EXPR_CAST,
EXPR_SIZEOF,
EXPR_SHL,
EXPR_SHR,
EXPR_MUL,
EXPR_DIV,
EXPR_ADD,
EXPR_SUB,
EXPR_AND,
EXPR_OR,
EXPR_COND,
EXPR_TRUEFALSE,
};
enum type_kind
{
TKIND_PRIMITIVE = -1,
TKIND_ENUM,
TKIND_RECORD,
TKIND_MODULE,
TKIND_INTERFACE,
TKIND_DISPATCH,
TKIND_COCLASS,
TKIND_ALIAS,
TKIND_UNION,
TKIND_MAX
};
struct _attr_t {
enum attr_type type;
union {
unsigned long ival;
void *pval;
} u;
/* parser-internal */
DECL_LINK(attr_t);
};
struct _expr_t {
enum expr_type type;
const expr_t *ref;
union {
long lval;
const char *sval;
const expr_t *ext;
const typeref_t *tref;
} u;
const expr_t *ext2;
int is_const;
long cval;
/* parser-internal */
DECL_LINK(expr_t);
};
struct _type_t {
const char *name;
enum type_kind kind;
unsigned char type;
struct _type_t *ref;
const attr_t *attrs;
func_t *funcs; /* interfaces and modules */
var_t *fields; /* interfaces, structures and enumerations */
ifref_t *ifaces; /* coclasses */
int ignore, is_const, sign;
int defined, written, user_types_registered;
int typelib_idx;
/* parser-internal */
DECL_LINK(type_t);
};
struct _typeref_t {
char *name;
type_t *ref;
int uniq;
};
struct _var_t {
char *name;
int ptr_level;
expr_t *array;
type_t *type;
var_t *args; /* for function pointers */
const char *tname;
attr_t *attrs;
expr_t *eval;
/* parser-internal */
DECL_LINK(var_t);
};
struct _func_t {
var_t *def;
var_t *args;
int ignore, idx;
/* parser-internal */
DECL_LINK(func_t);
};
struct _ifref_t {
type_t *iface;
attr_t *attrs;
/* parser-internal */
DECL_LINK(ifref_t);
};
struct _typelib_entry_t {
enum type_kind kind;
union {
type_t *class;
type_t *interface;
type_t *module;
type_t *structure;
type_t *enumeration;
var_t *tdef;
} u;
DECL_LINK(typelib_entry_t);
};
struct _importinfo_t {
int offset;
GUID guid;
int flags;
int id;
char *name;
importlib_t *importlib;
};
struct _importlib_t {
char *name;
int version;
GUID guid;
importinfo_t *importinfos;
int ntypeinfos;
int allocated;
DECL_LINK(importlib_t);
};
struct _typelib_t {
char *name;
char *filename;
attr_t *attrs;
typelib_entry_t *entry;
importlib_t *importlibs;
};
#endif
File diff suppressed because it is too large Load Diff