#include "private.h"
cairo_t *heliCairo;
int randomNumber(int min, int max)
{ return max <= min ? min : rand()%(max - min + 1) + min; }
double randomFloat()
{ return (double)rand()/(double)RAND_MAX; }
char* heliStringCopy(const char *x) {
int len = strlen(x) + 1;
char *cp = malloc(len + 1);
memcpy(cp, x, len);
return cp;
}
char* heliStringConcat3(const char *a, const char *b, const char *c) {
int la = strlen(a);
int lb = strlen(b);
int lc = strlen(c);
char *s = malloc(la + lb + lc + 1);
memcpy(s, a, la);
memcpy(s + la, b, lb);
memcpy(s + la + lb, c, lc);
s[la + lb + lc] = 0;
return s;
}
int heliStringEndsWithLowcase(const char *s, const char *tail) {
int ls = strlen(s);
int lt = strlen(tail);
if (lt > ls) return FALSE;
for(int i = 0; i < lt; ++i)
if (tolower(s[ls - i]) != tolower(tail[lt - i]))
return FALSE;
return TRUE;
}
void heliLowercase(char *x)
{ while(*x) { *x = tolower(*x); ++x; } }
void heliParseColor(const char *x, double *color) {
#warning "TODO: heliParseColor: not implemented yet"
}