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__))
131 "DllGetClassFactoryFromClassString",
132 "DllGetDocumentation",
136 "DllRegisterServerEx",
137 "DllRegisterServerExW",
139 "DllUnregisterServer",
140 "RasCustomDeleteEntryNotify",
150 return ((chr <=
',' && chr !=
'$' && chr !=
'#') ||
151 (chr >=
':' && chr <
'?') );
159 if (*
token != *comparand)
return 0;
184 if (pc[0] ==
'\n' && pc[1] ==
'\r')
return pc + 2;
185 else if (pc[0] ==
'\n')
return pc + 1;
208 while (*pc ==
' ' || *pc ==
'\t') pc++;
211 if (*pc ==
'\n' || *pc ==
'\r' || *pc == 0)
return 0;
214 if (*pc ==
'#' || *pc ==
';')
return 0;
222 fprintf(
file,
"/* This file is autogenerated, do not edit. */\n\n"
223 "#include <stubs.h>\n");
229 fprintf(
file,
"WINE_DECLARE_DEBUG_CHANNEL(relay);\n");
240 int bInPrototype = 0;
249 fprintf(
file,
"#pragma comment(linker,\"/export:%s%.*s=%.*s,DATA\")\n\n",
303 if (!bRelay || bInPrototype)
331 }
while (bInPrototype--);
335 fprintf(
file,
")\n{\n\tDbgPrint(\"WARNING: calling stub %.*s(",
353 fprintf(
file,
"\tif (TRACE_ON(relay))\n\t\tDPRINTF(\"%s: %.*s(",
420 fprintf(
file,
"\tif (TRACE_ON(relay))\n\t\tDPRINTF(\"%s: %.*s: retval = 0x%%\"PRIx64\"\\n\", retval);\n",
425 fprintf(
file,
"\tif (TRACE_ON(relay))\n\t\tDPRINTF(\"%s: %.*s: retval = 0x%%lx\\n\", retval);\n",
437 fprintf(
file,
"; File generated automatically, do not edit!\n\n");
449 fprintf(
file,
" AREA |.text|,ALIGN=2,CODE,READONLY\n\n");
459 "\tEXPORT |%s| [FUNC]\n|%s|\n",
466 "PUBLIC %s\n%s: nop\n",
475 char szNameBuffer[128];
480 sprintf(szNameBuffer,
"%s_stub_ordinal%d",
491 sprintf(szNameBuffer,
"_stub_%.*s",
497 sprintf(szNameBuffer,
"_stub_%.*s",
503 sprintf(szNameBuffer,
"__stub_%.*s@%d",
508 sprintf(szNameBuffer,
"@_stub_%.*s@%d",
516 sprintf(szNameBuffer,
"__stub_%.*s",
534 "; File generated automatically, do not edit!\n\n"
543 const char *pcName = pstr->
buf;
544 int nNameLength = pstr->
len;
545 const char* pcDot, *pcAt;
548 if ((nNameLength == 1) && (pcName[0] ==
'@'))
552 nNameLength =
strlen(namebuffer);
560 if (pcAt && (pcAt < (pcName + nNameLength)) && (pcName[0] ==
'_'))
564 nNameLength = (
int)(pcAt - pcName);
568 fprintf(fileDest,
"%.*s", nNameLength, pcName);
575 int is_cpp = pcName[0] ==
'?';
582 nNameLength = (
int)(pcDot - pcName);
583 fprintf(fileDest,
"%.*s.", nNameLength, pcName);
592 if (pcAt && (pcAt < (pcName + nNameLength)))
602 fprintf(fileDest,
"%.*s", nNameLength, pcName);
619 fprintf(fileDest,
"_%.*s", nNameLength, pcName);
624 fprintf(fileDest,
"%.*s", nNameLength, pcName);
714 PrintName(fileDest, pexp, &strTarget, 1);
731 (pcDeco < pexp->strName.buf + pexp->
strName.
len))
771 DbgPrint(
"OutputLine_def: skipping forwarded extern export '%.*s' ->'%.*s'...\n",
836 fprintf(fileDest,
":PROC\n ALIAS <");
868 unsigned i, errorpos,
len;
869 const char* pcLineEnd;
872 pcLineEnd =
strpbrk(pcLine,
"\r\n");
877 pc = pcLine +
len - 1;
896 for (
i = 0;
i < errorpos + 2;
i++)
900 for (
i = 0;
i < errorlen;
i++)
929 const char *pc, *pcLine;
940 for (cLines = 1, pcLine = pcStart; *pcLine; pcLine =
NextLine(pcLine), cLines++)
947 if (pexports ==
NULL)
956 for (pcLine = pcStart; *pcLine; pcLine =
NextLine(pcLine), nLine++)
963 exp.strTarget.len = 0;
967 exp.nStartVersion = 0;
968 exp.nEndVersion = 0xFFFFFFFF;
969 exp.bVersionIncluded = 1;
972 while (*pc ==
' ' || *pc ==
'\t') pc++;
975 if ((*pc ==
'\r') || (*pc ==
'\n') ||
976 (*pc ==
';') || (*pc ==
'#'))
992 else if ((*pc >=
'0') && (*pc <=
'9'))
996 if ((*
end !=
' ') && (*
end !=
'\t'))
1075 int negated = 0,
match = 0;
1092 if (
match != negated)
1098 while (*pc >
',') pc++;
1099 }
while (*pc ==
',');
1107 const char *pcVersionStart = pc + 9;
1110 exp.bVersionIncluded = 0;
1120 if ((pc[0] ==
'0') && (pc[1] ==
'x')) pc += 2;
1131 else if (pc[0] ==
'-')
1135 if ((pc[0] ==
'0') && (pc[1] ==
'x')) pc += 2;
1136 endversion =
strtoul(pc, (
char**)&pc, 16);
1146 pc - pcVersionStart,
1147 "Invalid version range");
1151 exp.nEndVersion = endversion;
1157 exp.bVersionIncluded = 1;
1161 while (*pc >
',') pc++;
1163 }
while (*pc ==
',');
1204 "INFO: %s line %d: Ignored option: '%.*s'\n",
1218 if (!included)
continue;
1221 exp.strName.buf = pc;
1226 if ((
exp.strName.len == 1) && (
exp.strName.buf[0] ==
'@'))
1232 exp.nStackBytes = 0;
1249 while (*pc ==
' ' || *pc ==
'\t') pc++;
1251 exp.nStackBytes = 0;
1256 exp.nStackBytes += 4;
1261 exp.nStackBytes += 8;
1266 exp.nStackBytes += 4;
1271 exp.nStackBytes += 4;
1276 exp.nStackBytes += 4;
1281 exp.nStackBytes += 8;
1286 exp.nStackBytes += 16;
1291 exp.nStackBytes += 4;
1322 if (
exp.nArgCount != 0)
1329 if (
exp.strName.buf[0] ==
'?')
1338 if (
p && (
p -
exp.strName.buf <
exp.strName.len))
1343 exp.strName.len = (
int)(
p -
exp.strName.buf);
1344 if (
exp.strName.len < 1)
1349 exp.nArgCount =
exp.nStackBytes / 4;
1352 for (
i = 0;
i <
exp.nArgCount;
i++)
1361 exp.strTarget.buf = pc;
1376 exp.strTarget.len = 0;
1402 if (bIsNotPrivate || bHasOrdinal)
1412 fprintf(
stderr,
"WARNING: %s line %d: Exported symbol '%.*s' should be PRIVATE\n",
1417 fprintf(
stderr,
"WARNING: %s line %d: exported symbol '%.*s' should not be assigned an ordinal\n",
1426 pexports[*cExports] =
exp;
1437 unsigned short i,
j;
1439 unsigned short firstOrdinal = 0xFFFF, firstIndex = 0;
1445 fprintf(
stderr,
"Failed to allocate memory for ordinal use table\n");
1451 for (
i = 0;
i < cExports;
i++)
1455 if (
used[pexports[
i].nOrdinal] != 0)
1457 fprintf(
stderr,
"Found duplicate ordinal: %u\n", pexports[
i].nOrdinal);
1461 if (pexports[
i].nOrdinal < firstOrdinal)
1463 firstOrdinal = pexports[
i].nOrdinal;
1470 if ((firstOrdinal != 0xFFFF) && (firstOrdinal > firstIndex))
1473 firstOrdinal -= firstIndex;
1482 for (
i = 0,
j = firstOrdinal;
i < cExports;
i++)
1486 while (
used[
j] != 0)
1500 printf(
"syntax: spec2def [<options> ...] <spec file>\n"
1501 "Possible options:\n"
1502 " -h --help print this help screen\n"
1503 " -l=<file> generate an asm lib stub\n"
1504 " -d=<file> generate a def file\n"
1505 " -s=<file> generate a stub file\n"
1506 " -i=<file> generate an import alias file\n"
1507 " --ms MSVC compatibility\n"
1508 " -n=<name> name of the dll\n"
1509 " --version=<version> Sets the version to create exports for\n"
1510 " --implib generate a def file for an import library\n"
1511 " --no-private-warnings suppress warnings about symbols that should be -private\n"
1512 " -a=<arch> set architecture to <arch> (i386, x86_64, arm, arm64)\n"
1513 " --with-tracing generate wine-like \"+relay\" trace trampolines (needs -s)\n");
1519 char *pszSource, *pszDefFileName =
NULL, *pszStubFileName =
NULL, *pszLibStubName =
NULL;
1520 char *pszImpLibAliasFileName =
NULL;
1521 const char* pszVersionOption =
"--version=0x";
1522 char achDllName[40];
1524 unsigned cExports = 0,
i;
1542 else if (
argv[
i][1] ==
'd' &&
argv[
i][2] ==
'=')
1544 pszDefFileName =
argv[
i] + 3;
1546 else if (
argv[
i][1] ==
'l' &&
argv[
i][2] ==
'=')
1548 pszLibStubName =
argv[
i] + 3;
1550 else if (
argv[
i][1] ==
's' &&
argv[
i][2] ==
'=')
1552 pszStubFileName =
argv[
i] + 3;
1554 else if (
argv[
i][1] ==
'i' &&
argv[
i][2] ==
'=')
1556 pszImpLibAliasFileName =
argv[
i] + 3;
1558 else if (
argv[
i][1] ==
'n' &&
argv[
i][2] ==
'=')
1580 if (!pszStubFileName)
1582 fprintf(
stderr,
"Error: cannot use --with-tracing without -s option.\n");
1587 else if (
argv[
i][1] ==
'a' &&
argv[
i][2] ==
'=')
1624 p2 = p1 = p1 ? p1 + 1 :
argv[
i];
1627 while (*p2 !=
'.' && *p2 != 0) p2++;
1629 if (
len >=
sizeof(achDllName) - 5)
1636 strncpy(achDllName +
len,
".dll",
sizeof(achDllName) -
len);
1655 pszSource =
malloc(nFileSize + 1);
1663 nFileSize =
fread(pszSource, 1, nFileSize,
file);
1667 pszSource[nFileSize] =
'\0';
1670 if (pexports ==
NULL)
1688 fprintf(
stderr,
"error: could not open output file %s\n", pszDefFileName);
1694 for (
i = 0;
i < cExports;
i++)
1696 if (pexports[
i].bVersionIncluded)
1703 if (pszStubFileName)
1709 fprintf(
stderr,
"error: could not open output file %s\n", pszStubFileName);
1715 for (
i = 0;
i < cExports;
i++)
1717 if (pexports[
i].bVersionIncluded)
1730 fprintf(
stderr,
"error: could not open output file %s\n", pszLibStubName);
1736 for (
i = 0;
i < cExports;
i++)
1738 if (pexports[
i].bVersionIncluded)
1746 if (pszImpLibAliasFileName)
1749 file =
fopen(pszImpLibAliasFileName,
"w");
1752 fprintf(
stderr,
"error: could not open output file %s\n", pszImpLibAliasFileName);
1758 for (
i = 0;
i < cExports;
i++)
1760 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 *
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)
_CRT_RESTORE_GCC_WARNINGS _CRT_DISABLE_GCC_WARNINGS _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)
int OutputLine_implib_asm(FILE *fileDest, EXPORT *pexp)
static const char * astrOlePrivateExports[]
void PrintNameOrImpName(FILE *fileDest, EXPORT *pexp, PSTRING pstr, int fDeco, int fImp)
int TokenLength(const char *pc)
int ApplyOrdinals(EXPORT *pexports, unsigned cExports)
int(* PFNOUTLINE)(FILE *, EXPORT *)
void Output_stublabel(FILE *fileDest, char *pszSymbolName)
void OutputAlias(FILE *fileDest, EXPORT *pexp, int fImp)
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)