Index: C:/ROS/reactos/tools/spec2def/spec2def.c =================================================================== --- tools/spec2def/spec2def.c (revision 63983) +++ tools/spec2def/spec2def.c (working copy) @@ -7,6 +7,8 @@ #define strcasecmp _stricmp #endif +#define ARRAYSIZE(a) (sizeof(a) / sizeof((a)[0])) + typedef struct _STRING { const char *buf; @@ -38,6 +40,7 @@ typedef int (*PFNOUTLINE)(FILE *, EXPORT *); int gbMSComp = 0; int gbImportLib = 0; +int gbNotPrivateNoWarn = 0; int giArch = ARCH_X86; char *pszArchString = "i386"; char *pszArchString2; @@ -85,6 +88,25 @@ "EXTERN" }; +static const char *astrShouldBePrivate[] = +{ + "DllCanUnloadNow", + "DllGetClassFactoryFromClassString", + "DllGetClassObject", + "DllGetDocumentation", + "DllInitialize", + "DllInstall", + "DllRegisterServer", + "DllRegisterServerEx", + "DllRegisterServerExW", + "DllUnload", + "DllUnregisterServer", + "RasCustomDeleteEntryNotify", + "RasCustomDial", + "RasCustomDialDlg", + "RasCustomEntryDlg", +}; + static int IsSeparator(char chr) @@ -532,6 +554,7 @@ EXPORT exp; int included; char namebuffer[16]; + unsigned int i; //fprintf(stderr, "info: line %d, pcStart:'%.30s'\n", nLine, pcStart); @@ -803,6 +826,7 @@ { int i; + fprintf(stderr, "warning: Truncating stub name %.*s\n", exp.strName.len, exp.strName.buf); /* Truncate the name to before the @ */ exp.strName.len = (int)(p - pc); if (exp.strName.len < 1) @@ -836,7 +860,7 @@ } else { - exp.strTarget.buf = 0; + exp.strTarget.buf = NULL; exp.strTarget.len = 0; } @@ -847,6 +871,19 @@ return -1; } + if (!gbNotPrivateNoWarn && gbImportLib && !(exp.uFlags & FL_PRIVATE)) + { + for (i = 0; i < ARRAYSIZE(astrShouldBePrivate); i++) + { + if (strlen(astrShouldBePrivate[i]) == exp.strName.len && + !strncmp(exp.strName.buf, astrShouldBePrivate[i], exp.strName.len)) + { + fprintf(stderr, "warning: line %d, export of %.*s should be private.\n", + nLine, exp.strName.len, exp.strName.buf); + } + } + } + OutputLine(fileDest, &exp); gbDebug = 0; } @@ -859,14 +896,15 @@ { printf("syntax: spec2pdef [ ...] \n" "Possible options:\n" - " -h --help prints this screen\n" - " -l= generates an asm lib stub\n" - " -d= generates a def file\n" - " -s= generates a stub file\n" - " --ms msvc compatibility\n" - " -n= name of the dll\n" - " --implib generate a def file for an import library\n" - " -a= Set architecture to . (i386, x86_64, arm)\n"); + " -h --help print this screen\n" + " -l= generate an asm lib stub\n" + " -d= generate a def file\n" + " -s= generate a stub file\n" + " --ms msvc compatibility\n" + " -n= name of the dll\n" + " --implib generate a def file for an import library\n" + " --no-private-warnings supress warnings about symbols that should be -private\n" + " -a= set architecture to . (i386, x86_64, arm)\n"); } int main(int argc, char *argv[]) @@ -916,6 +954,10 @@ { gbMSComp = 1; } + else if ((strcasecmp(argv[i], "--no-private-warnings") == 0)) + { + gbNotPrivateNoWarn = 1; + } else if (argv[i][1] == 'a' && argv[i][2] == '=') { pszArchString = argv[i] + 3;