static std::wstring generate_infotext( const std::wstring & filename, const openmpt::module & mod ) { std::wostringstream str; str << L"filename: " << filename << std::endl; str << L"duration: " << mod.get_duration_seconds() << L"seconds" << std::endl; std::vector<std::string> metadatakeys = mod.get_metadata_keys(); for ( std::vector<std::string>::iterator key = metadatakeys.begin(); key != metadatakeys.end(); ++key ) { if ( *key == "message_raw" ) { continue; } str << StringDecode( *key, CP_UTF8 ) << L": " << StringDecode( mod.get_metadata(*key), CP_UTF8 ) << std::endl; } return str.str(); }
int CCurveLine::InititalCurv( char* data ) { PointNum = 0; data = data + 10; for(int i = 0;data[i] != '\0' ;i++) { if(data[i] == ',') PointNum++; } //将最后一个添加进去 PointNum++; PointData = new double[PointNum]; for(int i = 0;i < PointNum;i++) { PointData[i] = 0; } int str_idx = 0; for(int i = 0;i < PointNum;i++) { char* SubStr = (i==(PointNum-1))?GetSubString(data,str_idx,'\0'):GetSubString(data,str_idx,','); PointData[i] = StringDecode(SubStr,0); //PointData[i] = atoi(SubStr); str_idx += strlen(SubStr)+1; } return 1; }
static void getfileinfo( const in_char * filename, in_char * title, int * length_in_ms ) { if ( !filename || *filename == '\0' ) { if ( length_in_ms ) { *length_in_ms = self->cached_length; } if ( title ) { std::wstring truncated_title = self->cached_title; if ( truncated_title.length() >= GETFILEINFO_TITLE_LENGTH ) { truncated_title.resize( GETFILEINFO_TITLE_LENGTH - 1 ); } wcscpy( title, truncated_title.c_str() ); } } else { try { std::ifstream s( filename, std::ios::binary ); openmpt::module mod( s ); if ( length_in_ms ) { *length_in_ms = static_cast<int>( mod.get_duration_seconds() * 1000.0 ); } if ( title ) { std::wstring truncated_title = StringDecode( mod.get_metadata("title"), CP_UTF8 ); if ( truncated_title.length() >= GETFILEINFO_TITLE_LENGTH ) { truncated_title.resize( GETFILEINFO_TITLE_LENGTH - 1 ); } wcscpy( title, truncated_title.c_str() ); } } catch ( ... ) { } } }
static void about( HWND hwndParent ) { std::ostringstream about; about << SHORT_TITLE << " version " << openmpt::string::get( "library_version" ) << " " << "(built " << openmpt::string::get( "build" ) << ")" << std::endl; about << " Copyright (c) 2013-2017 OpenMPT developers (https://openmpt.org/)" << std::endl; about << " OpenMPT version " << openmpt::string::get( "core_version" ) << std::endl; about << std::endl; about << openmpt::string::get( "contact" ) << std::endl; about << std::endl; about << "Show full credits?" << std::endl; if ( MessageBox( hwndParent, StringDecode( about.str(), CP_UTF8 ).c_str(), TEXT(SHORT_TITLE), MB_ICONINFORMATION | MB_YESNOCANCEL | MB_DEFBUTTON1 ) != IDYES ) { return; } std::ostringstream credits; credits << openmpt::string::get( "credits" ); libopenmpt::plugin::gui_show_file_info( hwndParent, TEXT(SHORT_TITLE), StringReplace( StringDecode( credits.str(), CP_UTF8 ), L"\n", L"\r\n" ) ); }
static int play( const in_char * fn ) { if ( !fn ) { return -1; } try { std::ifstream s( fn, std::ios::binary ); std::map< std::string, std::string > ctls; ctls["seek.sync_samples"] = "1"; self->mod = new openmpt::module( s, std::clog, ctls ); self->cached_filename = fn; self->cached_title = StringDecode( self->mod->get_metadata( "title" ), CP_UTF8 ); self->cached_length = static_cast<int>( self->mod->get_duration_seconds() * 1000.0 ); self->cached_infotext = generate_infotext( self->cached_filename, *self->mod ); apply_options(); self->samplerate = self->settings.samplerate; self->channels = self->settings.channels; int maxlatency = inmod.outMod->Open( self->samplerate, self->channels, BPS, -1, -1 ); std::ostringstream str; str << maxlatency; inmod.SetInfo( self->mod->get_num_channels(), self->samplerate/1000, self->channels, 1 ); inmod.SAVSAInit( maxlatency, self->samplerate ); inmod.VSASetInfo( self->channels, self->samplerate ); inmod.outMod->SetVolume( -666 ); inmod.outMod->SetPan( 0 ); self->paused = false; self->decode_position_frames = 0; self->PlayThread = CreateThread( NULL, 0, DecodeThread, NULL, 0, &self->PlayThreadID ); return 0; } catch ( ... ) { if ( self->mod ) { delete self->mod; self->mod = 0; } return -1; } }
int main() { int d,m,y; char query[1024]; char *env; char *coord=NULL; char *search=NULL; char buf[1024]; char *tmp; time_t t; struct tm *tt; time(&t); tt = localtime(&t); d = tt->tm_mday; m = tt->tm_mon+1; y = tt->tm_year+1900; env = getenv("QUERY_STRING"); if (env) { char *s; s = strstr(env, "d="); if (s) sscanf(s, "d=%d", &d); s = strstr(env, "m="); if (s) sscanf(s, "m=%d", &m); s = strstr(env, "y="); if (s) sscanf(s, "y=%d", &y); s = strstr(env, "c="); if (s) s+=2; else { // spatna kompatibilita so znackami s = strstr(env, "in="); if (s) s+=3; } if (s) { query[0]=0; sscanf(s, "%1000[^&]", query); coord=StringDecode(query); } s = strstr(env, "search="); if (s) { query[0]=0; sscanf(s+7, "%1000[^&]", query); search = StringDecode(query); } } if (db_init()<0) return 1; printf("Content-Type: text/html; charset=UTF-8\n\n"); printf("<html><head>\n" "<link rel=\"stylesheet\" href=\"breviar.css\">\n"); Rst(&kontext); kontext_last_hb=kontext_last_he=-1; first.h=last.h=-1; if (coord) { printf("<title>%s</title>\n" "</head><body>\n" "<div class=\"nadpis\">%s</div>\n\n", coord, coord); kalendar = 0; scan_string(coord); yyparse(); printf("<p>\n" "<form action=\"pismo.cgi\" method=\"get\">\n" "<input type=\"text\" name=\"c\">\n" "<input type=\"submit\" value=\"Zobraz\">\n" "</form>\n"); { char *tmp = StringEncode(kontext.buf+1); printf(// "<p>\n" "<a href=\"pismo.cgi?c=%s\">Kontext</a>", tmp); free(tmp); } printf(" "); if (first.h!=-1) { char *b; int h; get_prev(first.k, first.h, &b, &h); if (b!=NULL) { snprintf(buf, sizeof(buf), "%s %d", b, h); tmp = StringEncode(buf); printf(// "<p>\n" "<a href=\"pismo.cgi?c=%s\">Dozadu (%s %d)</a>", tmp, b, h); free(tmp); free(b); } } printf(" "); if (last.h!=-1){ char *b; int h; get_next(last.k, last.h, &b, &h); if (b!=NULL) { snprintf(buf, sizeof(buf), "%s %d", b, h); tmp = StringEncode(buf); printf(// "<p>\n" "<a href=\"pismo.cgi?c=%s\">Dopredu (%s %d)</a>", tmp, b, h); free(tmp); free(b); } } printf("<p>\n" "<form action=\"pismo.cgi\" method=\"get\">\n" "<input type=\"text\" name=\"search\">\n" "<input type=\"submit\" value=\"Hľadaj\">\n" "</form>\n"); } else if (search) { char *b,*t; int h,v; printf("<title>Vyhľadávanie \"%s\"</title>\n" "</head><body>\n" "<div class=\"nadpis\">Vyhľadávanie \"%s\"</div>\n\n", search, search); fulltext_search(search); while (get_fulltext_result(&b, &h, &v, &t)) { int i,in,var; snprintf(buf, sizeof(buf), "%s%d", b,h); tmp = StringEncode(buf); printf("\n<p> <a href=\"pismo.cgi?c=%s\">%s%d", tmp, b, h); if (v!=-1) printf(",%d", v); printf("</a>: "); free(tmp); for (i=in=var=0; t[i]; i++) { if (t[i]=='<') { in = 1; if (!strncmp(t+i+1, "var>", 4)) var = 1; if (!strncmp(t+i+1, "/var>", 5)) var = 0; } if (!in && !var) printf("%c", t[i]); if (t[i]=='>') in = 0; } } printf("<p>\n" "<form action=\"pismo.cgi\" method=\"get\">\n" "<input type=\"text\" name=\"c\">\n" "<input type=\"submit\" value=\"Zobraz\">\n" "</form>\n"); printf("<p>\n" "<form action=\"pismo.cgi\" method=\"get\">\n" "<input type=\"text\" name=\"search\">\n" "<input type=\"submit\" value=\"Hľadaj\">\n" "</form>\n"); free_fulltext_search(); } else { char *ct; if (!get_citania(y,m,d, &zalm, &ct)) return 3; kalendar = 1; // printf("%s %s %s %s\n", row[0], row[1], row[2], row[3]); printf("<title>Čítania na %d.%d.%d</title>\n" "</head><body>\n" "<div class=\"nadpis\">Liturgické čítania na %d.%d.%d</div>\n\n", d,m,y,d,m,y); scan_string(ct); yyparse(); /* toto asi nechceme { char *tmp = StringEncode(kontext.buf+1); printf("<p>\n" "<a href=\"pismo.cgi?c=%s\">Kontext</a>", tmp); free(tmp); } */ free(zalm); free(ct); } printf("</body></html>\n"); free_scan_string(); db_close(); return 0; }