void rsxgltest_pad(const padData * paddata) { if(paddata -> BTN_UP) { tcp_printf("up\n"); } else if(paddata -> BTN_DOWN) { tcp_printf("down\n"); } }
void rsxgltest_exit() { tcp_printf("%s\n",__PRETTY_FUNCTION__); glDeleteShader(shaders[0]); glDeleteProgram(program); glDeleteShader(shaders[1]); }
int pserver_connect(const struct protocol_interface *protocol, int verify_only) { char crypt_password[64]; const char *begin_request = "BEGIN AUTH REQUEST"; const char *end_request = "END AUTH REQUEST"; const char *username = NULL; CScramble scramble; username = get_username(current_server()->current_root); if(!username || !current_server()->current_root->hostname || !current_server()->current_root->directory) return CVSPROTO_BADPARMS; if(tcp_connect(current_server()->current_root)) return CVSPROTO_FAIL; if(current_server()->current_root->password) strncpy(crypt_password,scramble.Scramble(current_server()->current_root->password),sizeof(crypt_password)); else { if(pserver_get_user_password(username,current_server()->current_root->hostname,current_server()->current_root->port,current_server()->current_root->directory,crypt_password,sizeof(crypt_password))) { /* Using null password - trace something out here */ server_error(0,"Empty password used - try 'cvs login' with a real password\n"); strncpy(crypt_password,scramble.Scramble(""),sizeof(crypt_password)); } } if(verify_only) { begin_request = "BEGIN VERIFICATION REQUEST"; end_request = "END VERIFICATION REQUEST"; } if(tcp_printf("%s\n%s\n%s\n%s\n%s\n",begin_request,current_server()->current_root->directory,username,crypt_password,end_request)<0) return CVSPROTO_FAIL; return CVSPROTO_SUCCESS; }
int sserver_connect(const struct protocol_interface *protocol, int verify_only) { char crypt_password[64]; char server_version[128]; char tmp_keyname[256]; const char *begin_request = "BEGIN SSL AUTH REQUEST"; const char *end_request = "END SSL AUTH REQUEST"; const char *username = NULL; const char *cert = current_server()->current_root->optional_3; int l; int sserver_version = 0; int strict = 0; CScramble scramble; bool send_client_version = false; if(current_server()->current_root->optional_1) { sserver_version = atoi(current_server()->current_root->optional_1); if(sserver_version != 0 && sserver_version != 1) { server_error(0,"version must be one of:"); server_error(0,"0 - All CVSNT-type servers"); server_error(0,"1 - Unix server using Corey Minards' sserver patches"); server_error(1,"Please specify a valid value"); } } if(!CGlobalSettings::GetUserValue("cvsnt","sserver","StrictChecking",server_version,sizeof(server_version))) { strict = atoi(server_version); } if(!cert && !CGlobalSettings::GetUserValue("cvsnt","sserver","ClientCert",tmp_keyname,sizeof(tmp_keyname))) { cert = tmp_keyname; } if(current_server()->current_root->optional_2) strict = atoi(current_server()->current_root->optional_2); if(sserver_version == 1) /* Old sserver */ { begin_request = verify_only?"BEGIN SSL VERIFICATION REQUEST":"BEGIN SSL REQUEST"; end_request = verify_only?"END SSL VERIFICATION REQUEST":"END SSL REQUEST"; } else if(verify_only) { begin_request = "BEGIN SSL VERIFICATION REQUEST"; end_request = "END SSL VERIFICATION REQUEST"; } username = get_username(current_server()->current_root); if(!username || !current_server()->current_root->hostname || !current_server()->current_root->directory) return CVSPROTO_BADPARMS; if(tcp_connect(current_server()->current_root)) return CVSPROTO_FAIL; if(current_server()->current_root->password) strncpy(crypt_password,scramble.Scramble(current_server()->current_root->password),sizeof(crypt_password)); else { if(sserver_get_user_password(username,current_server()->current_root->hostname,current_server()->current_root->port,current_server()->current_root->directory,crypt_password,sizeof(crypt_password))) { /* Using null password - trace something out here */ server_error(0,"Using an empty password; you may need to do 'cvs login' with a real password\n"); strncpy(crypt_password,scramble.Scramble(""),sizeof(crypt_password)); } } if(sserver_version == 0) /* Pre-CVSNT had no version check */ { if(tcp_printf("%s\n",begin_request)<0) return CVSPROTO_FAIL; for(;;) { *server_version='\0'; if((l=tcp_readline(server_version,sizeof(server_version))<0)) return CVSPROTO_FAIL; if(*server_version) break; #ifdef _WIN32 Sleep(10); #else usleep(10); #endif } if(strncmp(server_version,"SSERVER ",8)) { server_error(0,"%s\n",server_version); return CVSPROTO_FAIL; } if(strncmp(server_version+8,"1.0 ",4)) send_client_version = true; } if(!ClientAuthenticate(cert,current_server()->current_root->hostname)) return CVSPROTO_AUTHFAIL; QueryContextAttributes(&contextHandle,SECPKG_ATTR_STREAM_SIZES,&secSizes); PCERT_CONTEXT sc; PCCERT_CHAIN_CONTEXT pcc; CERT_SIMPLE_CHAIN *psc; CERT_CHAIN_PARA para = { sizeof(CERT_CHAIN_PARA) }; DWORD trust,rc; rc = QueryContextAttributes(&contextHandle,SECPKG_ATTR_REMOTE_CERT_CONTEXT,&sc); if(rc) server_error(1,"Couldn't get server certificate"); if(!CertGetCertificateChain(NULL, sc, NULL, NULL, ¶, 0, NULL, &pcc)) server_error(1,"Couldn't get server certificate chain"); psc = pcc->rgpChain[0]; trust = psc->TrustStatus.dwErrorStatus; if (trust) { if (trust & (CERT_TRUST_IS_PARTIAL_CHAIN | CERT_TRUST_IS_UNTRUSTED_ROOT)) ; // Seld signed else if (trust & (CERT_TRUST_IS_NOT_TIME_VALID)) server_error(1,"Server certificate expired"); else server_error(1,"Server certificate verification failed - %08x",trust); } if(strict) { char certname[256]; CertGetNameString(sc, CERT_NAME_DNS_TYPE, 0, NULL, certname, sizeof(certname)); if(strcasecmp(certname,current_server()->current_root->hostname)) server_error(1, "Certificate CommonName '%s' does not match server name '%s'\n",certname,current_server()->current_root->hostname); } CertFreeCertificateChain(pcc); FreeContextBuffer(sc); g_sslBufferInPos=g_sslBufferOutPos=0; g_sslBufferInLen=g_sslBufferOutLen=0; if(sserver_version == 1) { if(sserver_printf("%s\n",begin_request)<0) return CVSPROTO_FAIL; } // For server versions 1.1+ send CLIENT_VERSION_STRING if(send_client_version && sserver_printf(SSERVER_CLIENT_VERSION_STRING)<0) return CVSPROTO_FAIL; if(sserver_printf("%s\n%s\n",current_server()->current_root->directory,username)<0) return CVSPROTO_FAIL; if(sserver_printf("%s\n",crypt_password)<0) return CVSPROTO_FAIL; if(sserver_printf("%s\n",end_request)<0) return CVSPROTO_FAIL; return CVSPROTO_SUCCESS; }
void rsxgltest_init(int argc,const char ** argv) { tcp_printf("%s\n",__PRETTY_FUNCTION__); // Set up us the program: shaders[0] = glCreateShader(GL_VERTEX_SHADER); shaders[1] = glCreateShader(GL_FRAGMENT_SHADER); program = glCreateProgram(); glAttachShader(program,shaders[0]); glAttachShader(program,shaders[1]); // Supply shader binaries: glShaderBinary(1,shaders,0,textures_vpo,textures_vpo_size); glShaderBinary(1,shaders + 1,0,textures_fpo,textures_fpo_size); // Link the program for real: glLinkProgram(program); glValidateProgram(program); GLint vertex_location = glGetAttribLocation(program,"vertex"), texcoord_location = glGetAttribLocation(program,"texcoord"); tcp_printf("vertex_location: %i\n",vertex_location); tcp_printf("texcoord_location: %i\n",texcoord_location); ProjMatrix_location = glGetUniformLocation(program,"ProjMatrix"); TransMatrix_location = glGetUniformLocation(program,"TransMatrix"); c_location = glGetUniformLocation(program,"c"); texture_location = glGetUniformLocation(program,"texture"); tcp_printf("ProjMatrix_location: %i TransMatrix_location: %i c_location: %i texture_location: %i\n", ProjMatrix_location,TransMatrix_location,c_location,texture_location); // Report on attributes: { GLint num_attribs = 0, attrib_name_length = 0; glGetProgramiv(program,GL_ACTIVE_ATTRIBUTES,&num_attribs); glGetProgramiv(program,GL_ACTIVE_ATTRIBUTE_MAX_LENGTH,&attrib_name_length); tcp_printf("%u attribs, name max length: %u\n",num_attribs,attrib_name_length); char szName[attrib_name_length + 1]; for(size_t i = 0;i < num_attribs;++i) { GLint size = 0; GLenum type = 0; GLint location = 0; glGetActiveAttrib(program,i,attrib_name_length + 1,0,&size,&type,szName); location = glGetAttribLocation(program,szName); tcp_printf("\t%u: %s %u %u %u\n",i,szName,(unsigned int)location,(unsigned int)size,(unsigned int)type); } } // Report on uniforms: { GLint num_uniforms = 0, uniform_name_length = 0; glGetProgramiv(program,GL_ACTIVE_UNIFORMS,&num_uniforms); glGetProgramiv(program,GL_ACTIVE_UNIFORM_MAX_LENGTH,&uniform_name_length); tcp_printf("%u uniforms, name max length: %u\n",num_uniforms,uniform_name_length); char szName[uniform_name_length + 1]; for(size_t i = 0;i < num_uniforms;++i) { GLint size = 0; GLenum type = 0; GLint location = 0; glGetActiveUniform(program,i,uniform_name_length + 1,0,&size,&type,szName); location = glGetUniformLocation(program,szName); tcp_printf("\t%u: %s %u %u %u\n",i,szName,(unsigned int)location,(unsigned int)size,(unsigned int)type); } } glUseProgram(program); const float identity[4][4] = { {1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1} }; glUniformMatrix4fv(ProjMatrix_location,1,GL_FALSE,(const GLfloat *)identity); glUniformMatrix4fv(TransMatrix_location,1,GL_FALSE,(const GLfloat *)identity); glUniform1i(texture_location,0); // Set up us the vertex data: float geometry[] = { 0, 0, 0, 1, 0,0, 1.0, 0, 0, 1, 1,0, 0.0, 1.0, 0, 1, 0,1, 1.0, 0, 0, 1, 1,0, 1.0, 1.0, 0, 1, 1,1, 0.0, 1.0, 0, 1, 0,1 }; glGenBuffers(1,&buffer); glBindBuffer(GL_ARRAY_BUFFER,buffer); glBufferData(GL_ARRAY_BUFFER,sizeof(float) * 6 * 6,geometry,GL_STATIC_DRAW); glEnableVertexAttribArray(vertex_location); glEnableVertexAttribArray(texcoord_location); glVertexAttribPointer(vertex_location,4,GL_FLOAT,GL_FALSE,sizeof(float) * 6,0); glVertexAttribPointer(texcoord_location,2,GL_FLOAT,GL_FALSE,sizeof(float) * 6,(const GLvoid *)(sizeof(float) * 4)); glBindBuffer(GL_ARRAY_BUFFER,0); // Textures: dice = loadPng(dice_bin); tcp_printf("dice size: %u %u\n",dice.width,dice.height); GLuint dice_buffer = 0; glGenBuffers(1,&dice_buffer); glBindBuffer(GL_PIXEL_UNPACK_BUFFER,dice_buffer); glBufferData(GL_PIXEL_UNPACK_BUFFER,4 * dice.width * dice.height,dice.data,GL_STATIC_DRAW); glBindBuffer(GL_PIXEL_UNPACK_BUFFER,0); uint8_t checkerboard_bgra[] = { 255,0,0,255, 0,255,0,255, 0,0,255,255, 255,255,255,255 }; uint8_t test_bgra[] = { 192,128,64,255, 192,128,64,255, 192,128,64,255, 192,128,64,255 }; glActiveTexture(GL_TEXTURE0); glGenTextures(1,&texture); glBindTexture(GL_TEXTURE_2D,texture); tcp_printf("texture name: %u\n",texture); //glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,2,2,0,GL_BGRA,GL_UNSIGNED_BYTE,checkerboard_bgra); //glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,2,2,0,GL_BGRA,GL_UNSIGNED_BYTE,0); //glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,dice.width,dice.height,0,GL_BGRA,GL_UNSIGNED_BYTE,dice.data); //glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,dice.width,dice.height,0,GL_BGRA,GL_UNSIGNED_BYTE,0); glTexStorage2D(GL_TEXTURE_2D,1,GL_RGBA,dice.width,dice.height); //glTexSubImage2D(GL_TEXTURE_2D,0,0,0,dice.width,dice.height,GL_BGRA,GL_UNSIGNED_BYTE,dice.data); glBindBuffer(GL_PIXEL_UNPACK_BUFFER,dice_buffer); glTexSubImage2D(GL_TEXTURE_2D,0,0,0,dice.width,dice.height,GL_BGRA,GL_UNSIGNED_BYTE,0); glBindBuffer(GL_PIXEL_UNPACK_BUFFER,0); report_glerror("glTexImage2D"); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); }
int sspi_connect(const struct protocol_interface *protocol, int verify_only) { char crypt_password[64]; const char *password; char domain_buffer[128],*domain; char user_buffer[128],*p; const char *user; const char *begin_request = "BEGIN SSPI"; char protocols[1024]; const char *proto; CScramble scramble; if(!current_server()->current_root->hostname || !current_server()->current_root->directory) return CVSPROTO_BADPARMS; if(tcp_connect(current_server()->current_root)) return CVSPROTO_FAIL; user = get_username(current_server()->current_root); password = current_server()->current_root->password; domain = NULL; if(!current_server()->current_root->password) { if(!sspi_get_user_password(user,current_server()->current_root->hostname,current_server()->current_root->port,current_server()->current_root->directory,crypt_password,sizeof(crypt_password))) { password = scramble.Unscramble(crypt_password); } } if(strchr(user,'\\')) { strncpy(domain_buffer,user,sizeof(domain_buffer)); domain_buffer[sizeof(domain_buffer)-1]='\0'; domain=strchr(domain_buffer,'\\'); if(domain) { *domain = '\0'; strncpy(user_buffer,domain+1,sizeof(user_buffer)); domain = domain_buffer; user = user_buffer; } } if(tcp_printf("%s\nNTLM\n",begin_request)<0) return CVSPROTO_FAIL; tcp_readline(protocols, sizeof(protocols)); if((p=strstr(protocols,"[server aborted"))!=NULL) { server_error(1, p); } if(strstr(protocols,"NTLM")) proto="NTLM"; else server_error(1, "Can't authenticate - server and client cannot agree on an authentication scheme (got '%s')\n",protocols); if(!ClientAuthenticate(proto,user,password,domain,current_server()->current_root->hostname)) { /* Actually we never get here... NTLM seems to allow the client to authenticate then fails at the server end. Wierd huh? */ if(user) server_error(1, "Can't authenticate - Username, Password or Domain is incorrect\n"); else server_error(1, "Can't authenticate - perhaps you need to login first?\n"); return CVSPROTO_FAIL; } if(tcp_printf("%s\n",current_server()->current_root->directory)<0) return CVSPROTO_FAIL; return CVSPROTO_SUCCESS; }
void request_handle( struct request *r ) { FILE *file; const char *mimetype=0; char line[REQUEST_LINE_MAX]; int length, actual; signal(SIGPIPE,SIG_IGN); char *filetype = strrchr(r->filename,'.'); if(filetype) { filetype++; if(!strcmp(filetype,"jpg")) { mimetype = "image/jpeg"; } else if(!strcmp(filetype,"html")) { mimetype = "text/html"; } else if(!strcmp(filetype,"txt")) { mimetype = "text/plain"; } else { mimetype = "application/binary"; } } else { mimetype = "application/binary"; } time_t current = time(0); file = fopen(r->filename,"r"); if(file) { tcp_printf(r->conn,"HTTP/1.1 200 OK\n"); tcp_printf(r->conn,"Date: %s",ctime(¤t)); tcp_printf(r->conn,"Server: wwwserver\n"); tcp_printf(r->conn,"Connection: close\n"); tcp_printf(r->conn,"Expires: 0\n"); tcp_printf(r->conn,"Content-type: %s\n\n",mimetype); // artificially delay approx every three requests if(rand()%3==0) sleep(5); while(1) { length = fread(line,1,sizeof(line),file); if(length<=0) break; actual = tcp_write(r->conn,line,length,current+60); if(actual!=length) { printf("error sending data: %s\n",strerror(errno)); break; } } fclose(file); } else { tcp_printf(r->conn,"HTTP/1.1 404 File Not Found\n"); tcp_printf(r->conn,"Date: %s",ctime(¤t)); tcp_printf(r->conn,"Server: wwwserver\n"); tcp_printf(r->conn,"Connection: close\n"); tcp_printf(r->conn,"Content-type: text/html\n\n"); tcp_printf(r->conn,"<b>File not found.</b>\n"); } }