int WINAPI ThreadDrawOn() { if(!RunningCreateFont) { CreateFont("Arial"); CreateFontMenu(); RunningCreateFont = true; } /*TesteDraw();*/ /*ObjectTeste();*/ for(int i = 0; i < MAX_SCRIPT_RUN; i++) { if(LS[i].active) { executescript(L, LS[i].FileScrips, "OnMain"); executescript(L, LS[i].FileScrips, "OnDraw"); } } /* FillR(20, 20, 200, 200, D3DCOLOR_ARGB(255, 0, 255, 200)); FillR(200, 200, 200, 200, D3DCOLOR_ARGB(185, 0, 255, 255)); */ AutoCursorTarget(); return 0; }
int processAiRDB(char* filename) { int lineno = 1, p; char* Buff = malloc(sizeof(char) * SCRIPT_MAXLINESIZE); FILE* file; fopen_s(&file, filename, "r"); if (!file) { printf("Invalid File name/path"); return INVALID_PARAMETER; } Menu = (list*)malloc(sizeof(list)); Menu->front = Menu->end = NULL; fgets(Buff, SCRIPT_MAXLINESIZE, file); Buff[strlen(Buff) - 1] = 0; if ((!_stricmp("!AiRscript v0.1", Buff))) { printf("\n\nAiR Database Engine is starting"); #ifndef __DEBUG_ENGINE for (p = 0; p < 200000000; p++); printf("."); for (p = 0; p < 400000000; p++); printf("."); for (p = 0; p < 300000000; p++); printf(".\n"); #endif while (fgets(Buff, SCRIPT_MAXLINESIZE, file) != NULL) { Buff[strlen(Buff) - 1] = 0; lineno++; handleScript(file, Buff); } } int menuvalue,xa; while (1) { printf("\n[DB]> "); scanf_s("%d", &menuvalue); list_node* me = Menu->front; menuentry* mentry; xa = menuvalue; while (xa--) { me = me->next; } mentry = (menuentry*)me->data; if(executescript(&mentry->script, &mentry->sql, mentry->tsql)==121) mentry->tsql = NULL; // Memory Leakage } fclose(file); return 0; }
int handleScript(FILE* file, char* BuffLine) { char* tok = NULL, *a, *b = NULL; a = strtok_s(BuffLine, " ", &tok); if (a == NULL) return 0; if (!_stricmp(a, "login")) { UserList = (list*)malloc(sizeof(list)); UserList->front = UserList->end = NULL; while (a = strtok_s(NULL, " ", &tok)) { a[strlen(a) - 1] = 0; a++; a = strtok_s(a, ",", &b); user* User = (user*)malloc(sizeof(user)); strcpy_s(User->username, _countof(User->username), a); strcpy_s(User->password, _countof(User->password), b); list_insert(UserList, LIST_LASTPOS, User); } int i = 0; a = malloc(sizeof(char) * 32); b = malloc(sizeof(char) * 64); printf("Please enter your credentials.\n"); printf("Username :"******"%s", a, 32); printf("Password :"******"\n Invalid Username / Password. Relaunch the application to try again."); exit(0); } UserNode = UserNode->next; } if (!UserNode) { printf("\n Invalid Username / Password. Relaunch the application to try again."); return INVALID_LOGIN; } queue SQL, Script; SQL.start = SQL.end = Script.start = Script.end = NULL; parse(file, &Script, &SQL); executescript(&Script, &SQL, NULL); // no get in login <<< workedaround } else if (!_stricmp(a,"menuentry")) { int i; a = strtok_s(NULL, "\"", &tok); if (a == NULL) return; menuentry* t = (menuentry*)malloc(sizeof(menuentry)); t->name = malloc(sizeof(char)*(i = strlen(a)+1)); strcpy_s(t->name, i, a); t->script.start = t->script.end = NULL; t->sql.start = t->sql.end = NULL; t->tsql = t->tsql = NULL; parse(file, &t->script, &t->sql); list_insert(Menu, LIST_LASTPOS, t); } }