void* beforedawn() { //allocate void* addr = birth(); //libboot initstdin( addr+0x000000); initstdout(addr+0x100000); initstdev( addr+0x200000); initstdrel(addr+0x300000); //libsoft initdevice(addr+0x400000); initdriver(addr+0x400000); //libsoft initsystem(addr+0x800000); initartery(addr+0x800000); //libuser initarena(addr+0xc00000); initactor(addr+0xc00000); return addr; }
int main() { bool newreadings; bool buttonschanged; load_init(); initsystem(); watchdog_init(); initserial(); timer_init(); display_init(); initfan(); adc_init(); buttons_init(); enableInterrupts(); protocol_onbooted(); while (1) { watchdog_kick(); newreadings = adc_updatereadings(); if (newreadings) { checkstate(); } buttonschanged = buttons_check(); if (newreadings || buttonschanged) { protocol_sendstate(); display_update(); } protocol_checkcommand(); } }
void main() { int x; initsystem(); port_open(BAUD); for(;;) { costate { x=wfd login(); if(x<0) abort; } } }
main() { // initialize the controller initsystem(); sock_init(); http_init(); tcp_reserveport(80); // set the initial state of the LED's strcpy(led_LED0,"ledon.gif"); ledOut(LED0, ON); strcpy(led_LED1,"ledon.gif"); ledOut(LED1, ON); strcpy(led_LED2,"ledon.gif"); ledOut(LED2, ON); strcpy(led_LED3,"ledon.gif"); ledOut(LED3, ON); // process WEB page requests and update the LED's while (1) { update_leds(); http_handler(); } }
main() { auto unsigned wKey; auto int i; /* init FORM searchable names - must init ALL FORMSpec structs! */ FORMSpec[0].name = "email_from"; FORMSpec[0].value = emailTemp.from; FORMSpec[0].len = MAX_FROM_LEN; FORMSpec[1].name = "email_subject"; FORMSpec[1].value = emailTemp.subject; FORMSpec[1].len = MAX_SUBJECT_LEN; FORMSpec[2].name = "email_body"; FORMSpec[2].value = emailTemp.body; FORMSpec[2].len = MAX_BODY_LEN; initsystem(); sock_init(); http_init(); tcp_reserveport(80); FlagInit(); CreateEmailList(); LogInit(); DispBufferInit(); DispNoEmail(); while (1) { http_handler(); costate { keyProcess(); //scans for keypress waitfor (DelayMs(10)); } costate { waitfor (wKey = keyGet()); //get key from buffer switch (wKey) { case DELETE: if (emailList.ptr != -1) { LogAddEmailEntry("deleted", email.from, email.subject); DeleteEmail(); } DispEmail(); break; case READ: if ((emailList.ptr != -1) && (emailIndex[emailList.ptr].read != 1)) { LogAddEmailEntry("read", email.from, email.subject); emailIndex[emailList.ptr].read = 1; FlagCheck(); } break; case EMAIL_UP: if (emailList.ptr != -1) { if (emailIndex[emailList.ptr].prev != -1) { emailList.ptr = emailIndex[emailList.ptr].prev; } DispEmail(); } break; case EMAIL_DOWN: if (emailList.ptr != -1) { if (emailIndex[emailList.ptr].next != -1) { emailList.ptr = emailIndex[emailList.ptr].next; } DispEmail(); } break; case SCROLL_UP: if ((emailList.ptr != -1) && (emailDispLine > 0)) { emailDispLine--; DispUpdateWindow(); } break; case SCROLL_DOWN: if ((emailList.ptr != -1) && ((emailDispLine + 4) < emailLastLine)) { emailDispLine++; DispUpdateWindow(); } break; default: // Do nothing break; } //end switch } //end costate } }
int main( int argc , char ** argv ) { int ret = 0; struct DIVERSsysteme systeme; struct typeFORthreads online; Mix_Music *sound = NULL; SDL_GLContext contexteOpenGL; initonline(&online, &systeme); /*pthread_t lethread1;*/ if (argc == *argv[0]){}/*juste pour les warnings*/ srand(2); /*define a random*/ SDL_Init (SDL_INIT_VIDEO); atexit(SDL_Quit); TTF_Init(); atexit(TTF_Quit); IMG_Init(IMG_INIT_PNG); atexit(IMG_Quit); Mix_Init(MIX_INIT_MP3); atexit(Mix_Quit); systeme.screen = SDL_CreateWindow("Reconquete salvatrice", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 0, 0,SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN_DESKTOP); contexteOpenGL = SDL_GL_CreateContext(systeme.screen); SDL_GetWindowSize(systeme.screen , &screenw , &screenh); SDL_ShowCursor(SDL_DISABLE); SDL_SetRelativeMouseMode(true); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); gluOrtho2D(0,screenw,0,screenh); glEnable(GL_TEXTURE_2D); glAlphaFunc(GL_GREATER,0.5f); glEnable(GL_ALPHA_TEST); initsystem(&systeme); initsauvegarde(systeme.sauvegarde, NBargSAVE, C); Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 1, 1024); Mix_AllocateChannels(0); Mix_VolumeMusic(64); #if FASTLOG == 1/*juste pour moi, pour éviter le log*/ sprintf(systeme.sauvegarde[0], "cegdd"); sprintf(systeme.sauvegarde[1], "mdpbidon"); /*pthread_create(&lethread1, NULL, *thread1, &online);*/ chargersauvegarde(&systeme); if (chargementcarte(&systeme, &online) != 1) {return EXIT_FAILURE;} return EXIT_SUCCESS; #endif /* FASTLOG*/ sound = Mix_LoadMUS("game.mp3"); if (sound == NULL){ printf("musique non trouvée"); return EXIT_FAILURE;} else if (Mix_PlayMusic(sound, -1) < 0){ printf("musique non jouable"); return EXIT_FAILURE;} /*si le login est accepté*/ ret = login(&systeme); while (ret != 0) { if (ret == 2) { /*creation thread pour socket*/ /*pthread_create(&lethread1, NULL, *thread1, &online);*/ chargersauvegarde(&systeme); Mix_PauseMusic (); /*lancement du jeu*/ if (chargementcarte(&systeme, &online) != 1) {return EXIT_FAILURE;} return EXIT_SUCCESS; } else if (ret == 5) { Mix_PauseMusic (); chargementarcade(&systeme); if (Mix_PlayMusic(sound, -1) < 0){ printf("musique non jouable"); return EXIT_FAILURE;} } else { printf("login return : %d", ret); } ret = login(&systeme); } Mix_FreeMusic(sound); TTF_CloseFont(systeme.police1); TTF_CloseFont(systeme.police); SDL_GL_DeleteContext(contexteOpenGL); return 0; }
void main(void) { tcp_Socket tcpSock; char *messages[12]; unsigned int key; int i, send_response, test; // Initialize flag to indicate not ready to send response send_response = FALSE; // Initialize the message array with NULL pointers for (i = 0; i < (sizeof(messages)/sizeof(char*)); i++) { messages[i] = NULL; } // Define messages here--note that you only need define the messages // you will actually use. messages[0] = "I hear ya..."; messages[1] = "Hello, there..."; messages[2] = "It's a \"Rabbit\" Kind of place..."; initsystem(); sock_init(); // Configure the upper row of keys on the keypad, in order // from left to right. for (i = 0; i < 7; i++) { // Only enable a key if there is a corresponding message if (messages[i] != NULL) { keyConfig ( i, ('0'+ i), 0, 0, 0, 0, 0 ); } else { keyConfig ( i, IGNORE, 0, 0, 0, 0, 0 ); } } while (1) { // Process Keypad Press/Hold/Release costate { keyProcess (); waitfor ( DelayMs(10) ); } costate { // Wait for a message from another device if (send_response == FALSE) { glBlankScreen(); TextGotoXY(&wholewindow, 0, 0 ); TextPrintf(&wholewindow, "Waiting for a \nmessage to be sent!"); // Function is blocking until a message is received RecvMessage(&tcpSock); // Received message, prompt user to continue TextGotoXY(&wholewindow, 0, 3 ); TextPrintf(&wholewindow, "Press key to proceed"); // Allow the keyProcess function(above costate) to execute before // checking for keypress. waitfor(DelayMs(10)); // Check if a key has been pressed waitfor ( key = keyGet() ); // Wait for Keypress // Set flag to send respond back to controller that // sent the message. send_response = TRUE; } } costate { if(send_response) { glBlankScreen(); TextGotoXY(&wholewindow, 0, 0 ); TextPrintf(&wholewindow, "Press the key that \nis setup to send \nyour response..."); waitfor ( key = keyGet() ); // Wait for Keypress // Flash Leds to indicate that a key has been pressed flashled(key - '0'); // Only handle the keypress if it corresponds to a message and if // a response is currently needed if (key != IGNORE) { SendMessage(&tcpSock, (key - '0'), messages); send_response = FALSE; } } } } }
int main(void) { char delim[] = " \t"; char inbuf[MAX_BUFFER]; char **chargv; ServerID_t serverID; ACSHandle_t acsHandle; int i, numtokens; char *chInput; char *chargv0; //DJ_U8 g_u8UnitID = 255; int row, col; int curRow, curCol; char *chargv1; char *chargv2; initCursel(&row, &col); printstr(NULL, "This is a monitor tool to SS7\n"); printstr(NULL, "press q or ctrl+c exit programmer\n"); printstr(NULL, "Input service IP and port(q exit, h help):\n"); for (; ;) { getyx(stdscr, curRow, curCol); if (curRow == row -1) clear(); getstr(inbuf); if (ldebug_flag) printstr(NULL,"inbuf:%s\n", inbuf); chInput = strlwr(inbuf); if (strcmp(chInput, QUIT_STRING) == 0) { exitwin(); return 0; } else if(strcmp(chInput, HELP_STRING) == 0) { helpProc(); } else { if ((numtokens = makeargv(inbuf, delim, &chargv)) >= 4) { if (ldebug_flag) { for (i = 0; i < numtokens; i++) printstr(NULL,"%d:%s\n", i, chargv[i]); } chargv1 = strlwr(chargv[0]); chargv2 = strlwr(chargv[2]); if ((strcmp(chargv1, "ip") == 0) && (strcmp(chargv[1], "\0") != 0)) { strncpy(serverID.m_s8ServerIp, chargv[1], sizeof(serverID.m_s8ServerIp)); if ((strcmp(chargv2, "port") == 0)&& (strcmp(chargv[3], "\0") != 0)) { serverID.m_u32ServerPort = atoi(chargv[3]); if (initsystem(serverID, &acsHandle) >= 0) { getyx(stdscr, curRow, curCol); mvprintw(curRow, 0,"Service has been monitored\n"); usleep(500); break; } else printstr(NULL,"Please check IP and Port, and please input again(q exit, h help)\n"); } else { printstr(NULL,"Input Port error, please input again(q exit, h help)\n"); } } else { printstr(NULL,"Input IP error,please input again(q exit, h help)\n"); } } else { printstr(NULL,"Input IP and Port has been omittem,please input again(q exit, h help)\n"); } } } for(; ;) { getyx(stdscr, curRow, curCol); if (curRow == row -1) clear(); getstr(inbuf); chInput = strlwr(inbuf); if (ldebug_flag) printstr(NULL,"inbuf:%s\n", chInput); if (strcmp(chInput, QUIT_STRING) == 0) { exitsystem(acsHandle); exitwin(); exit(0); } else if(strcmp(chInput, HELP_STRING) == 0) { helpProc(); } else { if ((numtokens = makeargv(inbuf, delim, &chargv)) > 0) { chargv0 = strlwr(chargv[0]); if (strcmp(chargv0, "monitor") == 0) { if (ldebug_flag) printstr(NULL,"monitor paramiter number is %d\n", numtokens); monitorProc(chargv, acsHandle, numtokens); printstr(NULL,"Input command again if operator(q exit, h help)\n"); } else if(strcmp(chargv0, "maintain") == 0) { maintainProc(chargv, acsHandle, numtokens); printstr(NULL,"Input command again if operator(q exit, h help)\n");; } else { printstr(NULL,"Input command error, please input again(q exit, h help)\n"); } } free(chargv); } usleep(30); } exitwin(); return 0; }