visualtest/src/mischelper.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 21 Oct 2018 22:40:17 -0400
changeset 12345 50e1cca28b39
parent 7924 fcb86d323770
permissions -rw-r--r--
wasapi/win32: Sort initial device lists by device GUID.

This makes an unchanged set of hardware always report devices in the same
order on each run.
     1 /**
     2  * \file mischelper.c 
     3  *
     4  * Source file with miscellaneous helper functions.
     5  */
     6 
     7 #include <SDL_test.h>
     8 
     9 void
    10 SDLVisualTest_HashString(char* str, char hash[33])
    11 {
    12     SDLTest_Md5Context md5c;
    13     int i;
    14 
    15     if(!str)
    16     {
    17         SDLTest_LogError("str argument cannot be NULL");
    18         return;
    19     }
    20 
    21     SDLTest_Md5Init(&md5c);
    22     SDLTest_Md5Update(&md5c, (unsigned char*)str, SDL_strlen(str));
    23     SDLTest_Md5Final(&md5c);
    24 
    25     /* convert the md5 hash to an array of hexadecimal digits */
    26     for(i = 0; i < 16; i++)
    27         SDL_snprintf(hash + 2 * i, 33 - 2 * i, "%02x", (int)md5c.digest[i]);
    28 }