41char* __dw_strdup(
const char* a) {
42 char* str = malloc(strlen(a) + 1);
43 memcpy(str, a, strlen(a));
48char* __dw_strcat(
const char* a,
const char* b) {
49 char* str = malloc(strlen(a) + strlen(b) + 1);
50 memcpy(str, a, strlen(a));
51 memcpy(str + strlen(a), b, strlen(b));
52 str[strlen(a) + strlen(b)] = 0;
56bool __dw_strcaseequ(
const char* a,
const char* b) {
57 if(strlen(a) != strlen(b))
return false;
59 for(i = 0; a[i] != 0; i++) {
60 if(tolower(a[i]) != tolower(b[i]))
return false;
65bool __dw_lockfile(FILE* fp) {
66 off_t off = ftell(fp);
67 fseek(fp, 0, SEEK_SET);
70#elif defined(__MINGW32__)
71 OVERLAPPED overlap = {0};
72 LockFileEx(fp, LOCKFILE_EXCLUSIVE_LOCK, 0, MAXDWORD, MAXDWORD, &overlap);
74 lockf(fileno(fp), F_LOCK, 0);
76 fseek(fp, off, SEEK_SET);
80bool __dw_unlockfile(FILE* fp) {
81 off_t off = ftell(fp);
82 fseek(fp, 0, SEEK_SET);
86#elif defined(__MINGW32__)
87 OVERLAPPED overlap = {0};
88 UnlockFileEx(fp, 0, MAXDWORD, MAXDWORD, &overlap);
90 lockf(fileno(fp), F_ULOCK, 0);
92 fseek(fp, off, SEEK_SET);