visualtest/src/mischelper.c
author Ryan C. Gordon
Tue, 29 Dec 2015 02:29:56 -0500
changeset 9986 081fbd89a347
parent 7924 fcb86d323770
permissions -rw-r--r--
NetBSD: improved joystick support (thanks, Thomas!).

This patch skips non-joystick HID devices and gives joysticks on NetBSD
a human readable name.

Fixes Bugzilla #3178.
     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 }