2c25c09420
--HG-- rename : tools/gamedata md5/Makefile => tools/gamedata_md5/Makefile rename : tools/gamedata md5/TextParsers.cpp => tools/gamedata_md5/TextParsers.cpp rename : tools/gamedata md5/TextParsers.h => tools/gamedata_md5/TextParsers.h rename : tools/gamedata md5/main.cpp => tools/gamedata_md5/main.cpp rename : tools/gamedata md5/main.h => tools/gamedata_md5/main.h rename : tools/gamedata md5/md5.cpp => tools/gamedata_md5/md5.cpp rename : tools/gamedata md5/md5.h => tools/gamedata_md5/md5.h rename : tools/gamedata md5/msvc9/gamedatamd5.sln => tools/gamedata_md5/msvc9/gamedatamd5.sln rename : tools/gamedata md5/msvc9/gamedatamd5.vcproj => tools/gamedata_md5/msvc9/gamedatamd5.vcproj rename : tools/gamedata md5/sm_memtable.cpp => tools/gamedata_md5/sm_memtable.cpp rename : tools/gamedata md5/sm_memtable.h => tools/gamedata_md5/sm_memtable.h extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402463
46 lines
839 B
C++
46 lines
839 B
C++
#include "main.h"
|
|
#include <stdarg.h>
|
|
|
|
BuildMD5ableBuffer g_MD5Builder;
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
SMCStates states;
|
|
SMCError error;
|
|
|
|
if (argc < 2)
|
|
{
|
|
fprintf(stderr, "Usage: <file>\n");
|
|
return -1;
|
|
}
|
|
|
|
error = g_TextParser.ParseFile_SMC(argv[1], &g_MD5Builder, &states);
|
|
|
|
if (error == SMCError_Okay)
|
|
{
|
|
printf("%s", g_MD5Builder.GetMD5String());
|
|
return 0;
|
|
}
|
|
|
|
fprintf(stderr, "Failed to parse file, Error %i at line %i and col %i\n", error, states.line, states.col);
|
|
return -1;
|
|
}
|
|
|
|
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
va_start(ap, fmt);
|
|
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
|
va_end(ap);
|
|
|
|
if (len >= maxlength)
|
|
{
|
|
buffer[maxlength - 1] = '\0';
|
|
return (maxlength - 1);
|
|
}
|
|
else
|
|
{
|
|
return len;
|
|
}
|
|
}
|