const char * format_string(const WAVEFORMATEX* wfx) { static char str[64]; sprintf(str, "%5dx%2dx%d %s", wfx->nSamplesPerSec, wfx->wBitsPerSample, wfx->nChannels, get_format_str(wfx->wFormatTag)); return str; }
const char* TextResItem::str_item_desc(int itemId) { if( !itemId ) return ""; static char checkMark[CHECK_MARK_STRLEN+1] = "D000"; err_when( itemId >= 100); checkMark[2] = itemId / 10 + '0'; checkMark[3] = itemId % 10 + '0'; return get_format_str( 40+itemId, checkMark ); }
// text id 1 - 9 // [CAM1]Occidental Herores // [CAM2]reserved campaign // ... // [CAM9]reserved campaign const char* TextResCampaign::str_campaign_name(int campaignId) { switch( campaignId ) { case CAMPAIGN_EAST_WEST: return get_format_str( 1, "CAM1" ); default: err_here(); return "?"; } }
/* * Export data out of GPDB. * invoked by GPDB, be careful with C++ exceptions. */ Datum s3_export(PG_FUNCTION_ARGS) { /* Must be called via the external table format manager */ if (!CALLED_AS_EXTPROTOCOL(fcinfo)) elog(ERROR, "extprotocol_import: not called by external protocol manager"); /* Get our internal description of the protocol */ GPWriter *gpwriter = (GPWriter *)EXTPROTOCOL_GET_USER_CTX(fcinfo); /* last call. destroy writer */ if (EXTPROTOCOL_IS_LAST_CALL(fcinfo)) { thread_cleanup(); if (!writer_cleanup(&gpwriter)) { ereport(ERROR, (0, errmsg("Failed to cleanup S3 extension: %s", s3extErrorMessage.c_str()))); } EXTPROTOCOL_SET_USER_CTX(fcinfo, NULL); PG_RETURN_INT32(0); } /* first call. do any desired init */ if (gpwriter == NULL) { const char *url_with_options = EXTPROTOCOL_GET_URL(fcinfo); const char *format = get_format_str(fcinfo); thread_setup(); gpwriter = writer_init(url_with_options, format); if (!gpwriter) { ereport(ERROR, (0, errmsg("Failed to init S3 extension, segid = %d, " "segnum = %d, please check your " "configurations and net connection: %s", s3ext_segid, s3ext_segnum, s3extErrorMessage.c_str()))); } EXTPROTOCOL_SET_USER_CTX(fcinfo, gpwriter); } char *data_buf = EXTPROTOCOL_GET_DATABUF(fcinfo); int32 data_len = EXTPROTOCOL_GET_DATALEN(fcinfo); if (!writer_transfer_data(gpwriter, data_buf, data_len)) { ereport(ERROR, (0, errmsg("s3_export: could not write data: %s", s3extErrorMessage.c_str()))); } PG_RETURN_INT32(data_len); }
/* print format debug info */ __inline__ void dprintff(const char *str, const char c, const int len) { char *fstr = NULL; if(debugf == TRUE) { if((str == NULL) || (len < 1)) return ; fstr = get_format_str(str, c, len); if(fstr == NULL) { return ; } printf("\n%s\n", fstr); FREE_OBJ(fstr); } }
// text id 2 // [TUT2]Learning Campaign Two char* TextResTutorial::str_tutor_2() { return get_format_str( 2, "TUT2" ); }
// text id 1 // [TUT1]Learning Campaign One char* TextResTutorial::str_tutor_1() { return get_format_str( 1, "TUT1" ); }
// text id 16 // [NOTU]Tutorial files not found. char* TextResTutorial::str_no_tutorial() { return get_format_str( 16, "NOTU" ); }
// text id 74 // [CATK]Click to Attack char* TextResCampaign::str_click_to_attack() { return get_format_str( 74, "CATK" ); }
// text id 15 // [CHIN]Close Hints char* TextResTutorial::str_close_hints() { return get_format_str( 15, "CHIN" ); }
// text id 13 // [<task><total tasks>TOFT]%1d of %2d char* TextResTutorial::str_task_of_total( int curPage, int totalPage ) { return process( get_format_str( 13, "TOFT" ), curPage, totalPage ); }
// text id 11 // [CLKC]Click to continue. char* TextResTutorial::str_click_to_continue() { return get_format_str( 11, "CLCK" ); }
// text id 14 // [ITR5]Now rouse a host and take the field char* TextResCampaign::str_intro_5() { return get_format_str( 14, "ITR5" ); }
// text id 13 // [ITR4]Before your Foes can you repay char* TextResCampaign::str_intro_4() { return get_format_str( 13, "ITR4" ); }
// text id 12 // [ITR3]Naught but Years of Torment are assured char* TextResCampaign::str_intro_3() { return get_format_str( 12, "ITR3" ); }
// text id 11 // [ITR2]An Empire lost and Pain and Scorn and Death endured char* TextResCampaign::str_intro_2() { return get_format_str( 11, "ITR2" ); }
// text id 10 // [ITR1]Where once you strode the World assured, you are the Huniers prey char* TextResCampaign::str_intro_1() { return get_format_str( 10, "ITR1" ); }
// text id 76 // [VIC9]Yet tis you who rules this grateful World char* TextResCampaign::str_victory_9() { return get_format_str( 76, "VIC9" ); }
// text id 75 // [NATK]Cannot select this state to attack char* TextResCampaign::str_cannot_attack() { return get_format_str( 75, "NATK" ); }
// text id 3 // [TUT3]Learning Campaign Three char* TextResTutorial::str_tutor_3() { return get_format_str( 3, "TUT3" ); }
// text id 4 // [TUTQ]Learning Campaign Quick char* TextResTutorial::str_tutor_quick() { return get_format_str( 4, "TUTQ" ); }
// text id 15 // [ITR6]Choose men of whom canst boast char* TextResCampaign::str_intro_6() { return get_format_str( 15, "ITR6" ); }
// text id 12 // [GUID]Learning Campaign Guidlines char* TextResTutorial::str_guidelines() { return get_format_str( 12, "GUID" ); }
// text id 72 // [<kingdom>STON]State of %1s char* TextResCampaign::str_state_of_cnation( char* cNationName ) { return process( get_format_str( 72, "STON" ), cNationName ); }
// text id 14 // [<page><total page>POFT]Page %1d of %2d char* TextResTutorial::str_page_of_total( int curPage, int totalPage ) { return process( get_format_str( 14, "POFT" ), curPage, totalPage ); }
// text id 71 // [ATKS]Please select a state to attack char* TextResCampaign::str_select_attack_state() { return get_format_str( 71, "ATKS" ); }
// text id 16 // [ITR7]Did pledge their Liege, their Lives their Ghost char* TextResCampaign::str_intro_7() { return get_format_str( 16, "ITR7" ); }
// text id 73 // [STIN]Independent state char* TextResCampaign::str_independent_state() { return get_format_str( 73, "STIN" ); }
static void wave_in_test_deviceIn(int device, LPWAVEFORMATEX pwfx, DWORD format, DWORD flags, LPWAVEINCAPS pcaps) { HWAVEIN win; HANDLE hevent; WAVEHDR frag; MMRESULT rc; DWORD res; MMTIME mmt; WORD nChannels = pwfx->nChannels; WORD wBitsPerSample = pwfx->wBitsPerSample; DWORD nSamplesPerSec = pwfx->nSamplesPerSec; hevent=CreateEvent(NULL,FALSE,FALSE,NULL); ok(hevent!=NULL,"CreateEvent(): error=%d\n",GetLastError()); if (hevent==NULL) return; win=NULL; rc=waveInOpen(&win,device,pwfx,(DWORD_PTR)hevent,0,CALLBACK_EVENT|flags); /* Note: Win9x doesn't know WAVE_FORMAT_DIRECT */ ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NOTENABLED || rc==MMSYSERR_NODRIVER || rc==MMSYSERR_ALLOCATED || ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) && (flags & WAVE_FORMAT_DIRECT) && !(pcaps->dwFormats & format)) || ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) && (!(flags & WAVE_FORMAT_DIRECT) || (flags & WAVE_MAPPED)) && !(pcaps->dwFormats & format)) || (rc==MMSYSERR_INVALFLAG && (flags & WAVE_FORMAT_DIRECT)), "waveInOpen(%s): format=%dx%2dx%d flags=%x(%s) rc=%s\n", dev_name(device),pwfx->nSamplesPerSec,pwfx->wBitsPerSample, pwfx->nChannels,CALLBACK_EVENT|flags, wave_open_flags(CALLBACK_EVENT|flags),wave_in_error(rc)); if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) && (flags & WAVE_FORMAT_DIRECT) && (pcaps->dwFormats & format)) trace(" Reason: The device lists this format as supported in it's " "capabilities but opening it failed.\n"); if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) && !(pcaps->dwFormats & format)) trace("waveInOpen(%s): format=%dx%2dx%d %s rc=%s failed but format " "not supported so OK.\n",dev_name(device),pwfx->nSamplesPerSec, pwfx->wBitsPerSample,pwfx->nChannels, flags & WAVE_FORMAT_DIRECT ? "flags=WAVE_FORMAT_DIRECT" : flags & WAVE_MAPPED ? "flags=WAVE_MAPPED" : "", mmsys_error(rc)); if (rc!=MMSYSERR_NOERROR) { CloseHandle(hevent); return; } res=WaitForSingleObject(hevent,1000); ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for open\n"); ok(pwfx->nChannels==nChannels && pwfx->wBitsPerSample==wBitsPerSample && pwfx->nSamplesPerSec==nSamplesPerSec, "got the wrong format: %dx%2dx%d instead of %dx%2dx%d\n", pwfx->nSamplesPerSec, pwfx->wBitsPerSample, pwfx->nChannels, nSamplesPerSec, wBitsPerSample, nChannels); /* Check that the position is 0 at start */ check_position(device, win, 0, pwfx); frag.lpData=HeapAlloc(GetProcessHeap(), 0, pwfx->nAvgBytesPerSec); frag.dwBufferLength=pwfx->nAvgBytesPerSec; frag.dwBytesRecorded=0; frag.dwUser=0; frag.dwFlags=0; frag.dwLoops=0; frag.lpNext=0; rc=waveInPrepareHeader(win, &frag, sizeof(frag)); ok(rc==MMSYSERR_NOERROR, "waveInPrepareHeader(%s): rc=%s\n", dev_name(device),wave_in_error(rc)); ok(frag.dwFlags&WHDR_PREPARED,"waveInPrepareHeader(%s): prepared flag " "not set\n",dev_name(device)); if (winetest_interactive && rc==MMSYSERR_NOERROR) { trace("Recording for 1 second at %5dx%2dx%d %s %s\n", pwfx->nSamplesPerSec, pwfx->wBitsPerSample,pwfx->nChannels, get_format_str(pwfx->wFormatTag), flags & WAVE_FORMAT_DIRECT ? "WAVE_FORMAT_DIRECT" : flags & WAVE_MAPPED ? "WAVE_MAPPED" : ""); rc=waveInAddBuffer(win, &frag, sizeof(frag)); ok(rc==MMSYSERR_NOERROR,"waveInAddBuffer(%s): rc=%s\n", dev_name(device),wave_in_error(rc)); /* Check that the position is 0 at start */ check_position(device, win, 0, pwfx); rc=waveInStart(win); ok(rc==MMSYSERR_NOERROR,"waveInStart(%s): rc=%s\n", dev_name(device),wave_in_error(rc)); res = WaitForSingleObject(hevent,1200); ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for header\n"); ok(frag.dwFlags&WHDR_DONE,"WHDR_DONE not set in frag.dwFlags\n"); ok(frag.dwBytesRecorded==pwfx->nAvgBytesPerSec, "frag.dwBytesRecorded=%d, should=%d\n", frag.dwBytesRecorded,pwfx->nAvgBytesPerSec); mmt.wType = TIME_SAMPLES; rc=waveInGetPosition(win, &mmt, sizeof(mmt)); ok(rc==MMSYSERR_NOERROR,"waveInGetPosition(%s): rc=%s\n", dev_name(device),wave_in_error(rc)); ok(mmt.u.cb == frag.dwBytesRecorded, "Got wrong position: %u\n", mmt.u.cb); /* stop playing on error */ if (res!=WAIT_OBJECT_0) { rc=waveInStop(win); ok(rc==MMSYSERR_NOERROR, "waveInStop(%s): rc=%s\n",dev_name(device),wave_in_error(rc)); } } rc=waveInUnprepareHeader(win, &frag, sizeof(frag)); ok(rc==MMSYSERR_NOERROR,"waveInUnprepareHeader(%s): rc=%s\n", dev_name(device),wave_in_error(rc)); rc=waveInClose(win); ok(rc==MMSYSERR_NOERROR, "waveInClose(%s): rc=%s\n",dev_name(device),wave_in_error(rc)); res=WaitForSingleObject(hevent,1000); ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for close\n"); if (winetest_interactive) { /* * Now play back what we recorded */ HWAVEOUT wout; trace("Playing back recorded sound\n"); rc=waveOutOpen(&wout,WAVE_MAPPER,pwfx,(DWORD_PTR)hevent,0,CALLBACK_EVENT); ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NOTENABLED || rc==MMSYSERR_NODRIVER || rc==MMSYSERR_ALLOCATED || ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) && !(pcaps->dwFormats & format)), "waveOutOpen(%s) format=%dx%2dx%d flags=%x(%s) rc=%s\n", dev_name(device),pwfx->nSamplesPerSec,pwfx->wBitsPerSample, pwfx->nChannels,CALLBACK_EVENT|flags, wave_open_flags(CALLBACK_EVENT),wave_out_error(rc)); if (rc==MMSYSERR_NOERROR) { rc=waveOutPrepareHeader(wout, &frag, sizeof(frag)); ok(rc==MMSYSERR_NOERROR,"waveOutPrepareHeader(%s): rc=%s\n", dev_name(device),wave_out_error(rc)); if (rc==MMSYSERR_NOERROR) { WaitForSingleObject(hevent,INFINITE); rc=waveOutWrite(wout, &frag, sizeof(frag)); ok(rc==MMSYSERR_NOERROR,"waveOutWrite(%s): rc=%s\n", dev_name(device),wave_out_error(rc)); WaitForSingleObject(hevent,INFINITE); rc=waveOutUnprepareHeader(wout, &frag, sizeof(frag)); ok(rc==MMSYSERR_NOERROR,"waveOutUnprepareHeader(%s): rc=%s\n", dev_name(device),wave_out_error(rc)); } rc=waveOutClose(wout); ok(rc==MMSYSERR_NOERROR,"waveOutClose(%s): rc=%s\n", dev_name(device),wave_out_error(rc)); } else trace("Unable to play back the recorded sound\n"); } HeapFree(GetProcessHeap(), 0, frag.lpData); CloseHandle(hevent); }
// text id 55 // [WESE]Western Empire char* TextResCampaign::str_western_empire() { return get_format_str( 55, "WESE" ); }