8#define strcasecmp(_String1, _String2) _stricmp(_String1, _String2)
9#define strncasecmp(_String1, _String2, _MaxCount) _strnicmp(_String1, _String2, _MaxCount)
12#define ARRAYSIZE(a) (sizeof(a) / sizeof((a)[0]))
77#define DbgPrint(...) (!gbDebug || fprintf(stderr, __VA_ARGS__))
130 "DllGetClassFactoryFromClassString",
131 "DllGetDocumentation",
135 "DllRegisterServerEx",
136 "DllRegisterServerExW",
138 "DllUnregisterServer",
139 "RasCustomDeleteEntryNotify",
149 return ((chr <=
',' && chr !=
'$' && chr !=
'#') ||
150 (chr >=
':' && chr <
'?') );
158 if (*
token != *comparand)
return 0;
183 if (pc[0] ==
'\n' && pc[1] ==
'\r')
return pc + 2;
184 else if (pc[0] ==
'\n')
return pc + 1;
207 while (*pc ==
' ' || *pc ==
'\t') pc++;
210 if (*pc ==
'\n' || *pc ==
'\r' || *pc == 0)
return 0;
213 if (*pc ==
'#' || *pc ==
';')
return 0;
221 fprintf(
file,
"/* This file is autogenerated, do not edit. */\n\n"
222 "#include <stubs.h>\n");
228 fprintf(
file,
"WINE_DECLARE_DEBUG_CHANNEL(relay);\n");
239 int bInPrototype = 0;
248 fprintf(
file,
"#pragma comment(linker,\"/export:%s%.*s=%.*s,DATA\")\n\n",
302 if (!bRelay || bInPrototype)
330 }
while (bInPrototype--);
334 fprintf(
file,
")\n{\n\tDbgPrint(\"WARNING: calling stub %.*s(",
352 fprintf(
file,
"\tif (TRACE_ON(relay))\n\t\tDPRINTF(\"%s: %.*s(",
419 fprintf(
file,
"\tif (TRACE_ON(relay))\n\t\tDPRINTF(\"%s: %.*s: retval = 0x%%\"PRIx64\"\\n\", retval);\n",
424 fprintf(
file,
"\tif (TRACE_ON(relay))\n\t\tDPRINTF(\"%s: %.*s: retval = 0x%%lx\\n\", retval);\n",
436 fprintf(
file,
"; File generated automatically, do not edit!\n\n");
448 fprintf(
file,
" AREA |.text|,ALIGN=2,CODE,READONLY\n\n");
458 "\tEXPORT |%s| [FUNC]\n|%s|\n",
465 "PUBLIC %s\n%s: nop\n",
474 char szNameBuffer[128];
479 sprintf(szNameBuffer,
"%s_stub_ordinal%d",
490 sprintf(szNameBuffer,
"_stub_%.*s",
496 sprintf(szNameBuffer,
"_stub_%.*s",
502 sprintf(szNameBuffer,
"__stub_%.*s@%d",
507 sprintf(szNameBuffer,
"@_stub_%.*s@%d",
515 sprintf(szNameBuffer,
"__stub_%.*s",
533 "; File generated automatically, do not edit!\n\n"
542 const char *pcName = pstr->
buf;
543 int nNameLength = pstr->
len;
544 const char* pcDot, *pcAt;
547 if ((nNameLength == 1) && (pcName[0] ==
'@'))
551 nNameLength =
strlen(namebuffer);
559 if (pcAt && (pcAt < (pcName + nNameLength)) && (pcName[0] ==
'_'))
563 nNameLength = (
int)(pcAt - pcName);
567 fprintf(fileDest,
"%.*s", nNameLength, pcName);
574 int is_cpp = pcName[0] ==
'?';
581 nNameLength = (
int)(pcDot - pcName);
582 fprintf(fileDest,
"%.*s.", nNameLength, pcName);
591 if (pcAt && (pcAt < (pcName + nNameLength)))
601 fprintf(fileDest,
"%.*s", nNameLength, pcName);
618 fprintf(fileDest,
"%.*s", nNameLength, pcName);
708 PrintName(fileDest, pexp, &strTarget, 1);
725 (pcDeco < pexp->strName.buf + pexp->
strName.
len))
754 DbgPrint(
"OutputLine_def: skipping forwarded extern export '%.*s' ->'%.*s'...\n",
803 unsigned i, errorpos,
len;
804 const char* pcLineEnd;
807 pcLineEnd =
strpbrk(pcLine,
"\r\n");
812 pc = pcLine +
len - 1;
831 for (
i = 0;
i < errorpos + 2;
i++)
835 for (
i = 0;
i < errorlen;
i++)
864 const char *pc, *pcLine;
875 for (cLines = 1, pcLine = pcStart; *pcLine; pcLine =
NextLine(pcLine), cLines++)
882 if (pexports ==
NULL)
891 for (pcLine = pcStart; *pcLine; pcLine =
NextLine(pcLine), nLine++)
898 exp.strTarget.len = 0;
902 exp.nStartVersion = 0;
903 exp.nEndVersion = 0xFFFFFFFF;
904 exp.bVersionIncluded = 1;
907 while (*pc ==
' ' || *pc ==
'\t') pc++;
910 if ((*pc ==
'\r') || (*pc ==
'\n') ||
911 (*pc ==
';') || (*pc ==
'#'))
927 else if ((*pc >=
'0') && (*pc <=
'9'))
931 if ((*
end !=
' ') && (*
end !=
'\t'))
1018 while (*pc >
',') pc++;
1019 }
while (*pc ==
',');
1027 const char *pcVersionStart = pc + 9;
1030 exp.bVersionIncluded = 0;
1040 if ((pc[0] ==
'0') && (pc[1] ==
'x')) pc += 2;
1051 else if (pc[0] ==
'-')
1055 if ((pc[0] ==
'0') && (pc[1] ==
'x')) pc += 2;
1056 endversion =
strtoul(pc, (
char**)&pc, 16);
1066 pc - pcVersionStart,
1067 "Invalid version range");
1071 exp.nEndVersion = endversion;
1077 exp.bVersionIncluded = 1;
1081 while (*pc >
',') pc++;
1083 }
while (*pc ==
',');
1120 "INFO: %s line %d: Ignored option: '%.*s'\n",
1134 if (!included)
continue;
1137 exp.strName.buf = pc;
1142 if ((
exp.strName.len == 1) && (
exp.strName.buf[0] ==
'@'))
1148 exp.nStackBytes = 0;
1165 while (*pc ==
' ' || *pc ==
'\t') pc++;
1167 exp.nStackBytes = 0;
1172 exp.nStackBytes += 4;
1177 exp.nStackBytes += 8;
1182 exp.nStackBytes += 4;
1187 exp.nStackBytes += 4;
1192 exp.nStackBytes += 4;
1197 exp.nStackBytes += 8;
1202 exp.nStackBytes += 16;
1207 exp.nStackBytes += 4;
1238 if (
exp.nArgCount != 0)
1245 if (
exp.strName.buf[0] ==
'?')
1254 if (
p && (
p -
exp.strName.buf <
exp.strName.len))
1259 exp.strName.len = (
int)(
p -
exp.strName.buf);
1260 if (
exp.strName.len < 1)
1265 exp.nArgCount =
exp.nStackBytes / 4;
1268 for (
i = 0;
i <
exp.nArgCount;
i++)
1277 exp.strTarget.buf = pc;
1292 exp.strTarget.len = 0;
1312 if (bIsNotPrivate || bHasOrdinal)
1322 fprintf(
stderr,
"WARNING: %s line %d: Exported symbol '%.*s' should be PRIVATE\n",
1327 fprintf(
stderr,
"WARNING: %s line %d: exported symbol '%.*s' should not be assigned an ordinal\n",
1336 pexports[*cExports] =
exp;
1347 unsigned short i,
j;
1354 fprintf(
stderr,
"Failed to allocate memory for ordinal use table\n");
1360 for (
i = 0;
i < cExports;
i++)
1364 if (
used[pexports[
i].nOrdinal] != 0)
1366 fprintf(
stderr,
"Found duplicate ordinal: %u\n", pexports[
i].nOrdinal);
1374 for (
i = 0,
j = 1;
i < cExports;
i++)
1378 while (
used[
j] != 0)
1392 printf(
"syntax: spec2def [<options> ...] <spec file>\n"
1393 "Possible options:\n"
1394 " -h --help print this help screen\n"
1395 " -l=<file> generate an asm lib stub\n"
1396 " -d=<file> generate a def file\n"
1397 " -s=<file> generate a stub file\n"
1398 " --ms MSVC compatibility\n"
1399 " -n=<name> name of the dll\n"
1400 " --version=<version> Sets the version to create exports for\n"
1401 " --implib generate a def file for an import library\n"
1402 " --no-private-warnings suppress warnings about symbols that should be -private\n"
1403 " -a=<arch> set architecture to <arch> (i386, x86_64, arm, arm64)\n"
1404 " --with-tracing generate wine-like \"+relay\" trace trampolines (needs -s)\n");
1410 char *pszSource, *pszDefFileName =
NULL, *pszStubFileName =
NULL, *pszLibStubName =
NULL;
1411 const char* pszVersionOption =
"--version=0x";
1412 char achDllName[40];
1414 unsigned cExports = 0,
i;
1432 else if (
argv[
i][1] ==
'd' &&
argv[
i][2] ==
'=')
1434 pszDefFileName =
argv[
i] + 3;
1436 else if (
argv[
i][1] ==
'l' &&
argv[
i][2] ==
'=')
1438 pszLibStubName =
argv[
i] + 3;
1440 else if (
argv[
i][1] ==
's' &&
argv[
i][2] ==
'=')
1442 pszStubFileName =
argv[
i] + 3;
1444 else if (
argv[
i][1] ==
'n' &&
argv[
i][2] ==
'=')
1466 if (!pszStubFileName)
1468 fprintf(
stderr,
"Error: cannot use --with-tracing without -s option.\n");
1473 else if (
argv[
i][1] ==
'a' &&
argv[
i][2] ==
'=')
1510 p2 = p1 = p1 ? p1 + 1 :
argv[
i];
1513 while (*p2 !=
'.' && *p2 != 0) p2++;
1515 if (
len >=
sizeof(achDllName) - 5)
1522 strncpy(achDllName +
len,
".dll",
sizeof(achDllName) -
len);
1541 pszSource =
malloc(nFileSize + 1);
1549 nFileSize =
fread(pszSource, 1, nFileSize,
file);
1553 pszSource[nFileSize] =
'\0';
1556 if (pexports ==
NULL)
1583 for (
i = 0;
i < cExports;
i++)
1585 if (pexports[
i].bVersionIncluded)
1592 if (pszStubFileName)
1604 for (
i = 0;
i < cExports;
i++)
1606 if (pexports[
i].bVersionIncluded)
1625 for (
i = 0;
i < cExports;
i++)
1627 if (pexports[
i].bVersionIncluded)
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
char * strpbrk(const char *String, const char *Delimiters)
static const WCHAR version[]
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
_CRTIMP void __cdecl rewind(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE *_File)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
_Check_return_ long __cdecl strtol(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix)
#define sprintf(buf, format,...)
static unsigned int number
static unsigned(__cdecl *hash_bstr)(bstr_t s)
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
const char * astrCallingConventions[]
const char * NextLine(const char *pc)
void OutputHeader_stub(FILE *file)
void OutputLine_def_MS(FILE *fileDest, EXPORT *pexp)
int OutputLine_stub(FILE *file, EXPORT *pexp)
const char * NextToken(const char *pc)
void OutputLine_def_GCC(FILE *fileDest, EXPORT *pexp)
void OutputHeader_def(FILE *file, char *libname)
void Fatal(const char *filename, unsigned nLine, const char *pcLine, const char *pc, size_t errorlen, const char *format,...)
int CompareToken(const char *token, const char *comparand)
const char * ScanToken(const char *token, char chr)
void OutputHeader_asmstub(FILE *file, char *libname)
static const char * astrOlePrivateExports[]
int TokenLength(const char *pc)
int ApplyOrdinals(EXPORT *pexports, unsigned cExports)
int(* PFNOUTLINE)(FILE *, EXPORT *)
void Output_stublabel(FILE *fileDest, char *pszSymbolName)
int OutputLine_asmstub(FILE *fileDest, EXPORT *pexp)
static int IsSeparator(char chr)
void Fatalv(const char *filename, unsigned nLine, const char *pcLine, const char *pc, size_t errorlen, const char *format, va_list argptr)
int OutputLine_def(FILE *fileDest, EXPORT *pexp)
EXPORT * ParseFile(char *pcStart, FILE *fileDest, unsigned *cExports)
void PrintName(FILE *fileDest, EXPORT *pexp, PSTRING pstr, int fDeco)