#include #include #include #include #ifndef _MSC_VER #define stricmp strcasecmp #endif // trim spaces off left of string void LeftTrim(char *str) { int k,n; k = strlen(str); if (k) { n = strspn(str," \t"); memmove(str,str+n, k-n+1); } } // trim spaces off right of string void RightTrim(char *str) { int k,n; n = k = strlen(str); if (k) { n--; while (n>=0 && (str[n]==' ' || str[n]=='\t')) n--; str[n+1]='\0'; } } // trim spaces off both ends of a string void Trim(char *str) { RightTrim(str); LeftTrim(str); } // If the extension is missing, add the extension ext // If the extension is present, leave it be void SupplyExt(char *str,char *ext) { char *p,*q; if (!str || !*str) return; p = strrchr(str,'\\'); // last backslash q = strrchr(str,'.'); // last period if (p && q && q