diff options
author | Darkvater <Darkvater@openttd.org> | 2007-01-13 13:47:57 +0000 |
---|---|---|
committer | Darkvater <Darkvater@openttd.org> | 2007-01-13 13:47:57 +0000 |
commit | 95024bb21c21c38fde3453c34e7029b6cf3626ea (patch) | |
tree | c5dd340a09a075d06a70fed0556e127c470cc125 /src/string.cpp | |
parent | 574ded3afdab4c28b892101e550dc89ffd170e71 (diff) | |
download | openttd-95024bb21c21c38fde3453c34e7029b6cf3626ea.tar.xz |
(svn r8093) -Codechange: Add a function to get a string representation of an MD5SUM and use it.
Diffstat (limited to 'src/string.cpp')
-rw-r--r-- | src/string.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/string.cpp b/src/string.cpp index 872b6e08f..d55d9a70e 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -177,6 +177,24 @@ int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap) #endif /* WIN32 */ +/** Convert the md5sum to a hexadecimal string representation + * @param buf buffer to put the md5sum into + * @param last last character of buffer (usually lastof(buf)) + * @param md5sum the md5sum itself + * @return a pointer to the next character after the md5sum */ +char *md5sumToString(char *buf, const char *last, const uint8 md5sum[16]) +{ + char *p = buf; + + for (uint i = 0; i < 16; i++) { + p += snprintf(p, last + 1 - p, "%02X", md5sum[i]); + if (p >= last) break; + } + + return p; +} + + /* UTF-8 handling routines */ |