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