Edit

kc3-lang/SDL/visualtest/src/mischelper.c

Branch :

  • Show log

    Commit

  • Author : Ozkan Sezer
    Date : 2021-12-21 14:24:20
    Hash : 449ef08d
    Message : minimal fixes to visual test, so that it actually builds w/o warnings: - linux_process.c: add an SDLVisualTest_ScreenshotProcess() stub for linux builds succeed. - action_configparser.c: fixes -Wswitch warnings. - testharness.c: fixes 'is used uninitialized' warnings for userevents. - testharness.c: fixes format string argument to 'Force killing...' - testquit.c: fix type of options array in main(). - windows_screenshot.c: lowercase windows.h header name. - ran dos2unix on all sources and add missing newlines at files' ends. - minor adjustments to autotools build system (which actually seems to need more surgery for unnecessary stuff...)

  • visualtest/src/mischelper.c
  • /**
     * \file mischelper.c
     *
     * Source file with miscellaneous helper functions.
     */
    
    #include <SDL_test.h>
    
    void
    SDLVisualTest_HashString(char* str, char hash[33])
    {
        SDLTest_Md5Context md5c;
        int i;
    
        if(!str)
        {
            SDLTest_LogError("str argument cannot be NULL");
            return;
        }
    
        SDLTest_Md5Init(&md5c);
        SDLTest_Md5Update(&md5c, (unsigned char*)str, SDL_strlen(str));
        SDLTest_Md5Final(&md5c);
    
        /* convert the md5 hash to an array of hexadecimal digits */
        for(i = 0; i < 16; i++)
            SDL_snprintf(hash + 2 * i, 33 - 2 * i, "%02x", (int)md5c.digest[i]);
    }