new tool functions

This commit is contained in:
ac-stef
2015-02-08 17:39:15 +01:00
parent af70d5c069
commit 348f640507
2 changed files with 25 additions and 0 deletions
+13
View File
@@ -422,6 +422,19 @@ const char *hiddenpwd(const char *pwd, int showchars)
for(int i = (int)strlen(text) - 1; i >= sc; i--) text[i] = '*';
return text;
}
int getlistindex(const char *key, const char *list[], bool acceptnumeric, int deflt)
{
int max = 0;
while(list[max][0]) if(!strcasecmp(key, list[max])) return max; else max++;
if(acceptnumeric && isdigit(key[0]))
{
int i = (int)strtol(key, NULL, 0);
if(i >= 0 && i < max) return i;
}
return deflt;
}
//////////////// geometry utils ////////////////
static inline float det2x2(float a, float b, float c, float d) { return a*d - b*c; }