Added regedit unit test, a couple minor changes to regedit.
[wine] / tools / winebuild / build.h
1 /*
2  * Copyright 1993 Robert J. Amstadt
3  * Copyright 1995 Martin von Loewis
4  * Copyright 1995, 1996, 1997 Alexandre Julliard
5  * Copyright 1997 Eric Youngdale
6  * Copyright 1999 Ulrich Weigand
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #ifndef __WINE_BUILD_H
24 #define __WINE_BUILD_H
25
26 #ifndef __WINE_CONFIG_H
27 # error You must include config.h to use this header
28 #endif
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33
34 #ifdef NEED_UNDERSCORE_PREFIX
35 # define PREFIX "_"
36 #else
37 # define PREFIX
38 #endif
39
40 #ifdef HAVE_ASM_STRING
41 # define STRING ".string"
42 #else
43 # define STRING ".ascii"
44 #endif
45
46 typedef enum
47 {
48     TYPE_VARIABLE,     /* variable */
49     TYPE_PASCAL_16,    /* pascal function with 16-bit return (Win16) */
50     TYPE_PASCAL,       /* pascal function with 32-bit return (Win16) */
51     TYPE_ABS,          /* absolute value (Win16) */
52     TYPE_STUB,         /* unimplemented stub */
53     TYPE_STDCALL,      /* stdcall function (Win32) */
54     TYPE_CDECL,        /* cdecl function (Win32) */
55     TYPE_VARARGS,      /* varargs function (Win32) */
56     TYPE_EXTERN,       /* external symbol (Win32) */
57     TYPE_FORWARD,      /* forwarded function (Win32) */
58     TYPE_NBTYPES
59 } ORD_TYPE;
60
61 typedef enum
62 {
63     SPEC_WIN16,
64     SPEC_WIN32
65 } SPEC_TYPE;
66
67 typedef enum
68 {
69     SPEC_MODE_DLL,
70     SPEC_MODE_GUIEXE,
71     SPEC_MODE_CUIEXE,
72     SPEC_MODE_GUIEXE_UNICODE,
73     SPEC_MODE_CUIEXE_UNICODE
74 } SPEC_MODE;
75
76 typedef struct
77 {
78     int n_values;
79     int *values;
80 } ORD_VARIABLE;
81
82 typedef struct
83 {
84     int  n_args;
85     char arg_types[21];
86 } ORD_FUNCTION;
87
88 typedef struct
89 {
90     int value;
91 } ORD_ABS;
92
93 typedef struct
94 {
95     ORD_TYPE    type;
96     int         ordinal;
97     int         offset;
98     int         lineno;
99     int         flags;
100     char       *name;
101     char       *link_name;
102     union
103     {
104         ORD_VARIABLE   var;
105         ORD_FUNCTION   func;
106         ORD_ABS        abs;
107     } u;
108 } ORDDEF;
109
110 /* entry point flags */
111 #define FLAG_NOIMPORT  0x01  /* don't make function available for importing */
112 #define FLAG_NORELAY   0x02  /* don't use relay debugging for this function */
113 #define FLAG_RET64     0x04  /* function returns a 64-bit value */
114 #define FLAG_I386      0x08  /* function is i386 only */
115 #define FLAG_REGISTER  0x10  /* use register calling convention */
116 #define FLAG_INTERRUPT 0x20  /* function is an interrupt handler */
117
118   /* Offset of a structure field relative to the start of the struct */
119 #define STRUCTOFFSET(type,field) ((int)&((type *)0)->field)
120
121   /* Offset of register relative to the start of the CONTEXT struct */
122 #define CONTEXTOFFSET(reg)  STRUCTOFFSET(CONTEXT86,reg)
123
124   /* Offset of register relative to the start of the STACK16FRAME struct */
125 #define STACK16OFFSET(reg)  STRUCTOFFSET(STACK16FRAME,reg)
126
127   /* Offset of register relative to the start of the STACK32FRAME struct */
128 #define STACK32OFFSET(reg)  STRUCTOFFSET(STACK32FRAME,reg)
129
130   /* Offset of the stack pointer relative to %fs:(0) */
131 #define STACKOFFSET (STRUCTOFFSET(TEB,cur_stack))
132
133
134 #define MAX_ORDINALS  65535
135
136 /* global functions */
137
138 extern void *xmalloc (size_t size);
139 extern void *xrealloc (void *ptr, size_t size);
140 extern char *xstrdup( const char *str );
141 extern char *strupper(char *s);
142 extern void fatal_error( const char *msg, ... );
143 extern void fatal_perror( const char *msg, ... );
144 extern void warning( const char *msg, ... );
145 extern void output_standard_file_header( FILE *outfile );
146 extern void dump_bytes( FILE *outfile, const unsigned char *data, int len,
147                         const char *label, int constant );
148 extern const char *make_c_identifier( const char *str );
149 extern int get_alignment(int alignBoundary);
150
151 extern void add_import_dll( const char *name, int delay );
152 extern void add_ignore_symbol( const char *name );
153 extern int resolve_imports( void );
154 extern int output_imports( FILE *outfile );
155 extern void load_res32_file( const char *name );
156 extern int output_resources( FILE *outfile );
157 extern void load_res16_file( const char *name );
158 extern int output_res16_data( FILE *outfile );
159 extern int output_res16_directory( unsigned char *buffer );
160 extern void output_dll_init( FILE *outfile, const char *constructor, const char *destructor );
161 extern void parse_debug_channels( const char *srcdir, const char *filename );
162
163 extern void BuildGlue( FILE *outfile, FILE *infile );
164 extern void BuildRelays16( FILE *outfile );
165 extern void BuildRelays32( FILE *outfile );
166 extern void BuildSpec16File( FILE *outfile );
167 extern void BuildSpec32File( FILE *outfile );
168 extern void BuildDef32File( FILE *outfile );
169 extern void BuildDebugFile( FILE *outfile );
170 extern SPEC_TYPE ParseTopLevel( FILE *file, int def_only );
171
172 /* global variables */
173
174 extern int current_line;
175 extern int nb_entry_points;
176 extern int nb_names;
177 extern int Base;
178 extern int Limit;
179 extern int DLLHeapSize;
180 extern int UsePIC;
181 extern int debugging;
182 extern int stack_size;
183 extern int nb_debug_channels;
184 extern int nb_lib_paths;
185 extern int display_warnings;
186
187 extern char DLLName[80];
188 extern char DLLFileName[80];
189 extern char owner_name[80];
190 extern char *init_func;
191 extern const char *input_file_name;
192 extern const char *output_file_name;
193 extern char **debug_channels;
194 extern char **lib_path;
195
196 extern ORDDEF *EntryPoints[MAX_ORDINALS];
197 extern ORDDEF *Ordinals[MAX_ORDINALS];
198 extern ORDDEF *Names[MAX_ORDINALS];
199 extern SPEC_MODE SpecMode;
200
201 #endif  /* __WINE_BUILD_H */