Bank::Bank(const QString &name){ dbname = name; QByteArray ba = name.toLatin1(); int needinit = 0; if(!fileExists(ba.data())) needinit = 1; sqlite3_open(ba.data(),&interface); if(needinit) databaseInit(); }
int main (void) { srand(time(0)); struct StringDatabase* D = databaseInit(); FILE* databaseFile = fopen ("base.txt", "r"); databaseRead(D, databaseFile); //BTreePrintTree(D->root, 0, stdout); fclose (databaseFile); //return; // databasePrint(D, stdout); // printf ("%d\n", databaseFindPrefix(D, "")); char array[SIZE * SIZE] = {}; array[0] = 'b'; array[1] = 'a'; array[2] = 's'; array[3] = 'i'; array[4] = 's'; //array[9] = 's'; //array[7] = 'd'; char result[SIZE * SIZE] = {}; databaseRemove(D, "basis"); #define PRINT_FIELD(field) \ {\ int i, j;\ for (i = 0; i < SIZE; i++)\ { \ for ( j = 0; j < SIZE; j++) \ printf("%c ", array[SIZE * i + j] ? array[SIZE * i + j] : '-');\ printf ("\n");\ }\ } PRINT_FIELD(array); int k; for (k = 0; k < SIZE * SIZE; k++) { int location = 0; char inserted = 0; computerNext (array, SIZE, SIZE, D, result, &location, &inserted); printf ("result = %s, location = (%d, %d), inserted = %c\n", result, location / SIZE + 1, location % SIZE + 1, inserted); if (inserted == 0) break; databaseRemove(D, result); memset(result, 0, SIZE * SIZE); array[location] = inserted; PRINT_FIELD(array); } //*/ databaseDestroy(D); }
int main(int argc, char* argv[]) { //do some system initialation appInitEvents(); databaseInit(); //getVehicleID(&g_VehicleID); startSocket(); sendDatabaseVersion(); //initialize the glut glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); glutInitWindowPosition(200, 200); glutInitWindowSize(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT); glutCreateWindow("Vehicle View"); Init3DEngine(); //create each thread, there are three threads. //now use _beginthreadex to create thread for more flexible // _beginthreadex has more parameter to control the thread HANDLE threadHandle[4]; threadHandle[0] = (HANDLE) _beginthreadex(0,0,&Thread_RecvSensors,0,0,0); threadHandle[1] = (HANDLE) _beginthreadex(0,0,&Thread_DBUpdate,0,0,0); threadHandle[2] = (HANDLE) _beginthreadex(0,0,&Thread_DiffDetRpt,0,0,0); threadHandle[3] = (HANDLE) _beginthreadex(0,0,&Thread_VisualizePreProc,0,0,0); //threadHandle[3] = (HANDLE) _beginthreadex(0,0,&Thread_LookAhead,0,CREATE_SUSPENDED,0); //set thread priority SetThreadPriority(threadHandle[0],THREAD_PRIORITY_NORMAL); //+1 priority SetThreadPriority(threadHandle[1],THREAD_PRIORITY_NORMAL); SetThreadPriority(threadHandle[2],THREAD_PRIORITY_LOWEST); SetThreadPriority(threadHandle[3],THREAD_PRIORITY_NORMAL); //SetThreadAffinityMask(threadHandle[0],0x00000001); //SetThreadAffinityMask(threadHandle[1],0x00000002); //SetThreadAffinityMask(threadHandle[2],0x00000003); //SetThreadAffinityMask(threadHandle[3],0x00000004); glutDisplayFunc(&myDisplay); glutTimerFunc((unsigned int)(1000/FRAME_NUM_PER_SECOND),&myTimer,1); glutKeyboardFunc(&keyboardFunc); glutSpecialFunc(&specialKeyFunc); glutReshapeFunc(&reshapeWindow); glutMouseFunc(&mouseButtonFunc); glutMotionFunc(&mouseMoveFunc); glutMainLoop(); WaitForMultipleObjects(4, threadHandle, true, INFINITE); CloseHandle(threadHandle[0]); CloseHandle(threadHandle[1]); CloseHandle(threadHandle[2]); CloseHandle(threadHandle[3]); delete3DEngine(); WSACleanup(); return 0; }