void say(const char *text) { printf("Simon says \"%s\"...\n", text); if(!active){ return; } printf("Simon really says \"%s\"...\n", text); speech_length = strlen(text); XPLMSpeakString(text); }
void do_httpd_core(){ static int socketsInit = 0; if( ! socketsInit ){ if( strcmp("username:password", (const char*)auth_token_raw) == 0 ){ XPLMSpeakString("x-httpd; This is the first time you have used x-httpd, please change the password."); //dialog_ChangePassword(); } printf("Running sockets init...\n"); initSockets(); socketsInit = 1; } int c = 0; int clientCount = 0; do{ clientCount++; if( clientCount >= 10 ){ break; } //we want to give x-plane priority, 10 clients per frame event. struct sockaddr_in from; memset( &from, 0, sizeof( sockaddr_in )); socklen_t len; //printf( "foo\n"); c = accept( sock, (sockaddr*)&from, &len ); switch( c ){ case EBADF: printf("x-httpd error: Bad file descriptor.\n"); break; case ENOTSOCK: printf("x-httpd error: accept() error: Not a socket.\n"); break; case EOPNOTSUPP: printf("x-httpd error: accept() error: Socket is not a STREAM.\n"); break; case EFAULT: printf("x-httpd error: accept() error: Address parameter fault.\n"); break; case EWOULDBLOCK: printf( "x-httpd error: accept() error: Would block.\n" ); break; case EMFILE: printf( "x-httpd error: accept() error: Process file table is full.\n" ); break; case ENFILE: printf( "x-httpd error: accept() error: Would block.\n" ); break; case -1: break; default: //printf("accept()ed a connect: %i\n", c); char remoteAddress[32]; strcpy( remoteAddress, inet_ntoa(from.sin_addr) ); if( (strcmp( "127.0.0.1", remoteAddress ) == 0) || bAllowRemoteConnections ){ //ntohl( &(from.sin_addr) ); if( bLogDebugToConsole ){ printf( "*** Connection from: %s\n", remoteAddress ); } processConnection(c); }else{ close(c); } break; } }while( c != -1 ); }