/* Convert an unsigned long integer to a string representation with a specified radix.  */
char* ultoa(unsigned long value, char *string, int radix)
/* Convert an unsigned long integer to a string representation with a specified radix.  */
char* ultoa(unsigned long value, char *string, int radix)
{
    char tmp[33];
    char *tp = tmp;
    long i;
    unsigned long v = value;
    char *sp;
    if (string == NULL)
    {
        return 0;
    }
    if (radix > 36 || radix <= 1)
    {
        return 0;
    }
    while (v || tp == tmp)
    {
        i = v % radix;
        v = v / radix;
        if (i < 10)
            *tp++ = (char)(i + '0');
        else
            *tp++ = (char)(i + 'a' - 10);
    }
    sp = string;
    while (tp > tmp)
        *sp++ = *--tp;
    *sp = 0;
    return string;
}