Fix blank.htm resources.
[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 typedef enum
35 {
36     TYPE_VARIABLE,     /* variable */
37     TYPE_PASCAL,       /* pascal function (Win16) */
38     TYPE_ABS,          /* absolute value (Win16) */
39     TYPE_STUB,         /* unimplemented stub */
40     TYPE_STDCALL,      /* stdcall function (Win32) */
41     TYPE_CDECL,        /* cdecl function (Win32) */
42     TYPE_VARARGS,      /* varargs function (Win32) */
43     TYPE_EXTERN,       /* external symbol (Win32) */
44     TYPE_NBTYPES
45 } ORD_TYPE;
46
47 typedef enum
48 {
49     SPEC_WIN16,
50     SPEC_WIN32
51 } SPEC_TYPE;
52
53 typedef struct
54 {
55     int n_values;
56     int *values;
57 } ORD_VARIABLE;
58
59 typedef struct
60 {
61     char arg_types[21];
62 } ORD_FUNCTION;
63
64 typedef struct
65 {
66     int value;
67 } ORD_ABS;
68
69 typedef struct
70 {
71     ORD_TYPE    type;
72     int         ordinal;
73     int         offset;
74     int         lineno;
75     int         flags;
76     char       *name;         /* public name of this function */
77     char       *link_name;    /* name of the C symbol to link to */
78     char       *export_name;  /* name exported under for noname exports */
79     union
80     {
81         ORD_VARIABLE   var;
82         ORD_FUNCTION   func;
83         ORD_ABS        abs;
84     } u;
85 } ORDDEF;
86
87 typedef struct
88 {
89     char            *file_name;          /* file name of the dll */
90     char            *dll_name;           /* internal name of the dll */
91     char            *owner_name;         /* name of the 32-bit dll owning this one */
92     char            *init_func;          /* initialization routine */
93     SPEC_TYPE        type;               /* type of dll (Win16/Win32) */
94     int              base;               /* ordinal base */
95     int              limit;              /* ordinal limit */
96     int              stack_size;         /* exe stack size */
97     int              heap_size;          /* exe heap size */
98     int              nb_entry_points;    /* number of used entry points */
99     int              alloc_entry_points; /* number of allocated entry points */
100     int              nb_names;           /* number of entry points with names */
101     unsigned int     nb_resources;       /* number of resources */
102     int              characteristics;    /* characteristics for the PE header */
103     int              subsystem;          /* subsystem id */
104     int              subsystem_major;    /* subsystem version major number */
105     int              subsystem_minor;    /* subsystem version minor number */
106     ORDDEF          *entry_points;       /* dll entry points */
107     ORDDEF         **names;              /* array of entry point names (points into entry_points) */
108     ORDDEF         **ordinals;           /* array of dll ordinals (points into entry_points) */
109     struct resource *resources;          /* array of dll resources (format differs between Win16/Win32) */
110 } DLLSPEC;
111
112 enum target_cpu
113 {
114     CPU_x86, CPU_SPARC, CPU_ALPHA, CPU_POWERPC
115 };
116
117 enum target_platform
118 {
119     PLATFORM_UNSPECIFIED, PLATFORM_APPLE, PLATFORM_SVR4, PLATFORM_WINDOWS
120 };
121
122 extern enum target_cpu target_cpu;
123 extern enum target_platform target_platform;
124
125 /* entry point flags */
126 #define FLAG_NORELAY   0x01  /* don't use relay debugging for this function */
127 #define FLAG_NONAME    0x02  /* don't import function by name */
128 #define FLAG_RET16     0x04  /* function returns a 16-bit value */
129 #define FLAG_RET64     0x08  /* function returns a 64-bit value */
130 #define FLAG_I386      0x10  /* function is i386 only */
131 #define FLAG_REGISTER  0x20  /* use register calling convention */
132 #define FLAG_PRIVATE   0x40  /* function is private (cannot be imported) */
133
134 #define FLAG_FORWARD   0x80  /* function is a forwarded name */
135
136   /* Offset of a structure field relative to the start of the struct */
137 #define STRUCTOFFSET(type,field) ((int)&((type *)0)->field)
138
139   /* Offset of register relative to the start of the CONTEXT struct */
140 #define CONTEXTOFFSET(reg)  STRUCTOFFSET(CONTEXT86,reg)
141
142   /* Offset of register relative to the start of the STACK16FRAME struct */
143 #define STACK16OFFSET(reg)  STRUCTOFFSET(STACK16FRAME,reg)
144
145   /* Offset of register relative to the start of the STACK32FRAME struct */
146 #define STACK32OFFSET(reg)  STRUCTOFFSET(STACK32FRAME,reg)
147
148   /* Offset of the stack pointer relative to %fs:(0) */
149 #define STACKOFFSET (STRUCTOFFSET(TEB,WOW32Reserved))
150
151
152 #define MAX_ORDINALS  65535
153
154 /* global functions */
155
156 #ifndef __GNUC__
157 #define __attribute__(X)
158 #endif
159
160 extern void *xmalloc (size_t size);
161 extern void *xrealloc (void *ptr, size_t size);
162 extern char *xstrdup( const char *str );
163 extern char *strupper(char *s);
164 extern int strendswith(const char* str, const char* end);
165 extern void fatal_error( const char *msg, ... )
166    __attribute__ ((__format__ (__printf__, 1, 2)));
167 extern void fatal_perror( const char *msg, ... )
168    __attribute__ ((__format__ (__printf__, 1, 2)));
169 extern void error( const char *msg, ... )
170    __attribute__ ((__format__ (__printf__, 1, 2)));
171 extern void warning( const char *msg, ... )
172    __attribute__ ((__format__ (__printf__, 1, 2)));
173 extern void output_standard_file_header( FILE *outfile );
174 extern FILE *open_input_file( const char *srcdir, const char *name );
175 extern void close_input_file( FILE *file );
176 extern void dump_bytes( FILE *outfile, const unsigned char *data, int len,
177                         const char *label, int constant );
178 extern int remove_stdcall_decoration( char *name );
179 extern DLLSPEC *alloc_dll_spec(void);
180 extern void free_dll_spec( DLLSPEC *spec );
181 extern const char *make_c_identifier( const char *str );
182 extern unsigned int get_alignment(unsigned int align);
183 extern unsigned int get_page_size(void);
184 extern const char *asm_name( const char *func );
185 extern const char *func_declaration( const char *func );
186 extern const char *func_size( const char *func );
187 extern const char *get_asm_string_keyword(void);
188 extern const char *get_asm_short_keyword(void);
189
190 extern void add_import_dll( const char *name, const char *filename );
191 extern void add_delayed_import( const char *name );
192 extern void add_ignore_symbol( const char *name );
193 extern void read_undef_symbols( char **argv );
194 extern int resolve_imports( DLLSPEC *spec );
195 extern int output_imports( FILE *outfile, DLLSPEC *spec, int *nb_delayed );
196 extern void output_import_thunks( FILE *outfile, DLLSPEC *spec );
197 extern int load_res32_file( const char *name, DLLSPEC *spec );
198 extern void output_resources( FILE *outfile, DLLSPEC *spec );
199 extern void load_res16_file( const char *name, DLLSPEC *spec );
200 extern unsigned int get_res16_data_size( DLLSPEC *spec, unsigned int res_offset,
201                                          unsigned int alignment );
202 extern unsigned int output_res16_data( unsigned char **ret_buf, DLLSPEC *spec,
203                                        unsigned int res_offset, unsigned int alignment );
204 extern unsigned int get_res16_directory_size( DLLSPEC *spec );
205 extern unsigned int output_res16_directory( unsigned char **ret_buf, DLLSPEC *spec,
206                                             unsigned int res_offset, unsigned int alignment );
207 extern void output_dll_init( FILE *outfile, const char *constructor, const char *destructor );
208
209 extern void BuildRelays16( FILE *outfile );
210 extern void BuildRelays32( FILE *outfile );
211 extern void BuildSpec16File( FILE *outfile, DLLSPEC *spec );
212 extern void BuildSpec32File( FILE *outfile, DLLSPEC *spec );
213 extern void BuildDef32File( FILE *outfile, DLLSPEC *spec );
214 extern void BuildDebugFile( FILE *outfile, const char *srcdir, char **argv );
215
216 extern int parse_spec_file( FILE *file, DLLSPEC *spec );
217 extern int parse_def_file( FILE *file, DLLSPEC *spec );
218 extern int parse_debug_channels( const char *srcdir, const char *filename );
219
220 /* global variables */
221
222 extern int current_line;
223 extern int UsePIC;
224 extern int debugging;
225 extern int nb_debug_channels;
226 extern int nb_lib_paths;
227 extern int nb_errors;
228 extern int display_warnings;
229 extern int kill_at;
230
231 extern char *input_file_name;
232 extern char *spec_file_name;
233 extern const char *output_file_name;
234 extern char **debug_channels;
235 extern char **lib_path;
236
237 extern char *ld_command;
238 extern char *nm_command;
239
240 #endif  /* __WINE_BUILD_H */