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]))
78#define DbgPrint(...) (!gbDebug || fprintf(stderr, __VA_ARGS__))
132 "DllGetClassFactoryFromClassString",
133 "DllGetDocumentation",
137 "DllRegisterServerEx",
138 "DllRegisterServerExW",
140 "DllUnregisterServer",
141 "RasCustomDeleteEntryNotify",
151 return ((chr <=
',' && chr !=
'$' && chr !=
'#') ||
152 (chr >=
':' && chr <
'?') );
160 if (*
token != *comparand)
return 0;
185 if (pc[0] ==
'\n' && pc[1] ==
'\r')
return pc + 2;
186 else if (pc[0] ==
'\n')
return pc + 1;
209 while (*pc ==
' ' || *pc ==
'\t') pc++;
212 if (*pc ==
'\n' || *pc ==
'\r' || *pc == 0)
return 0;
215 if (*pc ==
'#' || *pc ==
';')
return 0;
223 fprintf(
file,
"/* This file is autogenerated, do not edit. */\n\n"
224 "#include <stubs.h>\n");
230 fprintf(
file,
"WINE_DECLARE_DEBUG_CHANNEL(relay);\n");
241 int bInPrototype = 0;
250 fprintf(
file,
"#pragma comment(linker,\"/export:%s%.*s=%.*s,DATA\")\n\n",
304 if (!bRelay || bInPrototype)
332 }
while (bInPrototype--);
336 fprintf(
file,
")\n{\n\tDbgPrint(\"WARNING: calling stub %.*s(",
354 fprintf(
file,
"\tif (TRACE_ON(relay))\n\t\tDPRINTF(\"%s: %.*s(",
421 fprintf(
file,
"\tif (TRACE_ON(relay))\n\t\tDPRINTF(\"%s: %.*s: retval = 0x%%\"PRIx64\"\\n\", retval);\n",
426 fprintf(
file,
"\tif (TRACE_ON(relay))\n\t\tDPRINTF(\"%s: %.*s: retval = 0x%%lx\\n\", retval);\n",
438 fprintf(
file,
"; File generated automatically, do not edit!\n\n");
450 fprintf(
file,
" AREA |.text|,ALIGN=2,CODE,READONLY\n\n");
460 "\tEXPORT |%s| [FUNC]\n|%s|\n",
467 "PUBLIC %s\n%s: nop\n",
476 char szNameBuffer[128];
481 sprintf(szNameBuffer,
"%s_stub_ordinal%d",
492 sprintf(szNameBuffer,
"_stub_%.*s",
498 sprintf(szNameBuffer,
"_stub_%.*s",
504 sprintf(szNameBuffer,
"__stub_%.*s@%d",
509 sprintf(szNameBuffer,
"@_stub_%.*s@%d",
517 sprintf(szNameBuffer,
"__stub_%.*s",
535 "; File generated automatically, do not edit!\n\n"
544 const char *pcName = pstr->
buf;
545 int nNameLength = pstr->
len;
546 const char* pcDot, *pcAt;
549 if ((nNameLength == 1) && (pcName[0] ==
'@'))
553 nNameLength =
strlen(namebuffer);
561 if (pcAt && (pcAt < (pcName + nNameLength)) && (pcName[0] ==
'_'))
565 nNameLength = (
int)(pcAt - pcName);
569 fprintf(fileDest,
"%.*s", nNameLength, pcName);
576 int is_cpp = pcName[0] ==
'?';
583 nNameLength = (
int)(pcDot - pcName);
584 fprintf(fileDest,
"%.*s.", nNameLength, pcName);
593 if (pcAt && (pcAt < (pcName + nNameLength)))
603 fprintf(fileDest,
"%.*s", nNameLength, pcName);
620 fprintf(fileDest,
"_%.*s", nNameLength, pcName);
625 fprintf(fileDest,
"%.*s", nNameLength, pcName);
715 PrintName(fileDest, pexp, &strTarget, 1);
732 (pcDeco < pexp->strName.buf + pexp->
strName.
len))
772 DbgPrint(
"OutputLine_def: skipping forwarded extern export '%.*s' ->'%.*s'...\n",
837 fprintf(fileDest,
":PROC\n ALIAS <");
869 unsigned i, errorpos,
len;
870 const char* pcLineEnd;
873 pcLineEnd =
strpbrk(pcLine,
"\r\n");
878 pc = pcLine +
len - 1;
897 for (
i = 0;
i < errorpos + 2;
i++)
901 for (
i = 0;
i < errorlen;
i++)
930 const char *pc, *pcLine;
941 for (cLines = 1, pcLine = pcStart; *pcLine; pcLine =
NextLine(pcLine), cLines++)
948 if (pexports ==
NULL)
957 for (pcLine = pcStart; *pcLine; pcLine =
NextLine(pcLine), nLine++)
964 exp.strTarget.len = 0;
968 exp.nStartVersion = 0;
969 exp.nEndVersion = 0xFFFFFFFF;
970 exp.bVersionIncluded = 1;
973 while (*pc ==
' ' || *pc ==
'\t') pc++;
976 if ((*pc ==
'\r') || (*pc ==
'\n') ||
977 (*pc ==
';') || (*pc ==
'#'))
993 else if ((*pc >=
'0') && (*pc <=
'9'))
997 if ((*
end !=
' ') && (*
end !=
'\t'))
1076 int negated = 0,
match = 0;
1093 if (
match != negated)
1099 while (*pc >
',') pc++;
1100 }
while (*pc ==
',');
1108 const char *pcVersionStart = pc + 9;
1111 exp.bVersionIncluded = 0;
1121 if ((pc[0] ==
'0') && (pc[1] ==
'x')) pc += 2;
1132 else if (pc[0] ==
'-')
1136 if ((pc[0] ==
'0') && (pc[1] ==
'x')) pc += 2;
1137 endversion =
strtoul(pc, (
char**)&pc, 16);
1147 pc - pcVersionStart,
1148 "Invalid version range");
1152 exp.nEndVersion = endversion;
1158 exp.bVersionIncluded = 1;
1162 while (*pc >
',') pc++;
1164 }
while (*pc ==
',');
1216 "INFO: %s line %d: Ignored option: '%.*s'\n",
1230 if (!included)
continue;
1233 exp.strName.buf = pc;
1238 if ((
exp.strName.len == 1) && (
exp.strName.buf[0] ==
'@'))
1244 exp.nStackBytes = 0;
1261 while (*pc ==
' ' || *pc ==
'\t') pc++;
1263 exp.nStackBytes = 0;
1268 exp.nStackBytes += 4;
1273 exp.nStackBytes += 8;
1278 exp.nStackBytes += 4;
1283 exp.nStackBytes += 4;
1288 exp.nStackBytes += 4;
1293 exp.nStackBytes += 8;
1298 exp.nStackBytes += 16;
1303 exp.nStackBytes += 4;
1334 if (
exp.nArgCount != 0)
1341 if (
exp.strName.buf[0] ==
'?')
1350 if (
p && (
p -
exp.strName.buf <
exp.strName.len))
1355 exp.strName.len = (
int)(
p -
exp.strName.buf);
1356 if (
exp.strName.len < 1)
1361 exp.nArgCount =
exp.nStackBytes / 4;
1364 for (
i = 0;
i <
exp.nArgCount;
i++)
1373 exp.strTarget.buf = pc;
1388 exp.strTarget.len = 0;
1414 if (bIsNotPrivate || bHasOrdinal)
1424 fprintf(
stderr,
"WARNING: %s line %d: Exported symbol '%.*s' should be PRIVATE\n",
1429 fprintf(
stderr,
"WARNING: %s line %d: exported symbol '%.*s' should not be assigned an ordinal\n",
1438 pexports[*cExports] =
exp;
1449 unsigned short i,
j;
1451 unsigned short firstOrdinal = 0xFFFF, firstIndex = 0;
1457 fprintf(
stderr,
"Failed to allocate memory for ordinal use table\n");
1463 for (
i = 0;
i < cExports;
i++)
1467 if (
used[pexports[
i].nOrdinal] != 0)
1469 fprintf(
stderr,
"Found duplicate ordinal: %u\n", pexports[
i].nOrdinal);
1474 if (pexports[
i].nOrdinal < firstOrdinal)
1476 firstOrdinal = pexports[
i].nOrdinal;
1483 if ((firstOrdinal != 0xFFFF) && (firstOrdinal > firstIndex))
1486 firstOrdinal -= firstIndex;
1495 for (
i = 0,
j = firstOrdinal;
i < cExports;
i++)
1499 while (
used[
j] != 0)
1513 printf(
"syntax: spec2def [<options> ...] <spec file>\n"
1514 "Possible options:\n"
1515 " -h --help print this help screen\n"
1516 " -l=<file> generate an asm lib stub\n"
1517 " -d=<file> generate a def file\n"
1518 " -s=<file> generate a stub file\n"
1519 " -i=<file> generate an import alias file\n"
1520 " --ms MSVC compatibility\n"
1521 " --dbg Enable debug exports\n"
1522 " -n=<name> name of the dll\n"
1523 " --version=<version> Sets the version to create exports for\n"
1524 " --implib generate a def file for an import library\n"
1525 " --no-private-warnings suppress warnings about symbols that should be -private\n"
1526 " -a=<arch> set architecture to <arch> (i386, x86_64, arm, arm64)\n"
1527 " --with-tracing generate wine-like \"+relay\" trace trampolines (needs -s)\n");
1533 char *pszSource, *pszDefFileName =
NULL, *pszStubFileName =
NULL, *pszLibStubName =
NULL;
1534 char *pszImpLibAliasFileName =
NULL;
1535 const char* pszVersionOption =
"--version=0x";
1536 char achDllName[40];
1538 unsigned cExports = 0,
i;
1556 else if (
argv[
i][1] ==
'd' &&
argv[
i][2] ==
'=')
1558 pszDefFileName =
argv[
i] + 3;
1560 else if (
argv[
i][1] ==
'l' &&
argv[
i][2] ==
'=')
1562 pszLibStubName =
argv[
i] + 3;
1564 else if (
argv[
i][1] ==
's' &&
argv[
i][2] ==
'=')
1566 pszStubFileName =
argv[
i] + 3;
1568 else if (
argv[
i][1] ==
'i' &&
argv[
i][2] ==
'=')
1570 pszImpLibAliasFileName =
argv[
i] + 3;
1572 else if (
argv[
i][1] ==
'n' &&
argv[
i][2] ==
'=')
1598 if (!pszStubFileName)
1600 fprintf(
stderr,
"Error: cannot use --with-tracing without -s option.\n");
1605 else if (
argv[
i][1] ==
'a' &&
argv[
i][2] ==
'=')
1642 p2 = p1 = p1 ? p1 + 1 :
argv[
i];
1645 while (*p2 !=
'.' && *p2 != 0) p2++;
1647 if (
len >=
sizeof(achDllName) - 5)
1654 strncpy(achDllName +
len,
".dll",
sizeof(achDllName) -
len);
1673 pszSource =
malloc(nFileSize + 1);
1681 nFileSize =
fread(pszSource, 1, nFileSize,
file);
1685 pszSource[nFileSize] =
'\0';
1688 if (pexports ==
NULL)
1706 fprintf(
stderr,
"error: could not open output file %s\n", pszDefFileName);
1712 for (
i = 0;
i < cExports;
i++)
1714 if (pexports[
i].bVersionIncluded)
1721 if (pszStubFileName)
1727 fprintf(
stderr,
"error: could not open output file %s\n", pszStubFileName);
1733 for (
i = 0;
i < cExports;
i++)
1735 if (pexports[
i].bVersionIncluded)
1748 fprintf(
stderr,
"error: could not open output file %s\n", pszLibStubName);
1754 for (
i = 0;
i < cExports;
i++)
1756 if (pexports[
i].bVersionIncluded)
1764 if (pszImpLibAliasFileName)
1767 file =
fopen(pszImpLibAliasFileName,
"w");
1770 fprintf(
stderr,
"error: could not open output file %s\n", pszImpLibAliasFileName);
1776 for (
i = 0;
i < cExports;
i++)
1778 if (pexports[
i].bVersionIncluded)
static const WCHAR version[]
int CDECL fclose(FILE *file)
int WINAPIV fprintf(FILE *file, const char *format,...)
size_t CDECL fread(void *ptr, size_t size, size_t nmemb, FILE *file)
int CDECL vfprintf(FILE *file, const char *format, va_list valist)
FILE *CDECL fopen(const char *path, const char *mode)
void CDECL rewind(FILE *file)
_ACRTIMP __msvcrt_long __cdecl strtol(const char *, char **, int)
_ACRTIMP int __cdecl atoi(const char *)
_ACRTIMP __msvcrt_ulong __cdecl strtoul(const char *, char **, int)
_ACRTIMP size_t __cdecl strlen(const char *)
_ACRTIMP char *__cdecl strpbrk(const char *, const char *)
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
_ACRTIMP char *__cdecl strrchr(const char *, int)
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
static unsigned int number
static unsigned(__cdecl *hash_bstr)(bstr_t s)
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)
#define fseek(stream, offset, whence)
#define ftell(stream, offset, whence)