void DRInterface::releaseMem(DRInterface* data, const char* dllname) { if(!data) LOG_ERROR_VOID("data, ZERO-POINTER"); if(!mDLL) { if(!loadDll(dllname)) { LOG_WARNING("keine dll"); DR_SAVE_DELETE(data); } } if(!releaseInstance) loadDll(dllname); if(releaseInstance) { releaseInstance(data); } else { LOG_WARNING("function didn't exist in dll"); DR_SAVE_DELETE(data); } }
DRInterface* DRInterface::Instance(const char* dllName) { //try to load from dll if(!mDLL) { if(loadDll(dllName)) { LOG_ERROR("keine dll", NULL); //LOG_WARNING("keine dll"); //return new DRInterface(); } } if(!getInstance) loadDll(dllName); if(getInstance) { return getInstance(); } else { LOG_ERROR("function didn't exist in dll", NULL); //return new DRInterface(); } return NULL; }
void TestPlugIn::reloadDll() { m_manager.unload( m_copyFileName ); makeDllCopy(); loadDll(); }
bool DecodeAudioFile::decode(QString audioFilePath, QString outFilePath) { if (loadDll() == false) { DecodeAudioFileDebug("DecodeAudioFile decode loadDll() == false"); return false; } // decode from file infile, put data to outfile DecodeAudioFileDebug("decodeMp3File(%s,%s)...",audioFilePath.toUtf8().data(), outFilePath.toUtf8().data()); QFile mp3InFile(audioFilePath); if(!mp3InFile.open(QIODevice::ReadOnly)) { DecodeAudioFileDebug("open mp3 file failed:%s",audioFilePath.toUtf8().data()); return false; } if (outFilePath != NULL) { QFile::remove(outFilePath); } QFile pcmFile(outFilePath); if(!pcmFile.open(QIODevice::WriteOnly|QIODevice::Append)) { DecodeAudioFileDebug("open out file failed:%s", outFilePath.toUtf8().data()); return false; } //write wav head info,put into mp3InFile QByteArray mp3Data = mp3InFile.readAll(); DecodeAudioFileDebug("mp3Data size is:%d", mp3Data.size()); int decorderHandle = pSEFunDecoderInit(mp3Data.size()*15); int outLen = 0; unsigned char *pcmData = pSEFunDecode(decorderHandle, (unsigned char*)mp3Data.data(), mp3Data.size(), 0, &outLen); DecodeAudioFileDebug("decorderHandle is @%d ,pcmData is: @%p",decorderHandle , pcmData); if (NULL == pcmData) { DecodeAudioFileDebug("error: pcmData is NULL!"); return false; } this->channel = pSEFunGetChannels(decorderHandle); this->sampleSize = 16; this->sampleRate = pSEFunGetSampleRate(decorderHandle); DecodeAudioFileDebug("mp3SampleRate is:%d",sampleRate); // pcm2wav(pcmFile,outLen,this->sampleRate,this->channel,this->sampleSize); WriteWavHeadToFile(pcmFile,outLen,this->sampleRate,this->sampleSize,this->channel); DecodeAudioFileDebug("this->sampleRate:%d,this->channel:%d,this->sampleSize:%d",this->sampleRate,this->channel,this->sampleSize); pcmFile.write((char*)pcmData,outLen); pcmFile.close(); pSEFunDecoderUninit(decorderHandle); unLoadDll(); return true; }
// FUZZ: disable check_for_improper_main_declaration int main (int, char *[]) { #if !defined (CAN_RUN_TEST) # ifndef ACE_FACE_SAFETY_EXTENDED PRINTF ("Terminating because this test has not been designed " "to run on WIN32 or VXWORKS.\n"); # endif #else PRINTF ("main called\n"); PRINTF ("main - calling loadDll\n"); # if defined (CAN_USE_THREADS) int result = 0; pthread_t tid1; result = pthread_create(&tid1, 0, &loadDll, 0); if (result != 0) { PRINTF ("pthread_create() failed: %d\n", result); return result; } pthread_join(tid1, 0); PRINTF ("loadDll thread finished and re-joined\n"); # else loadDll(0); PRINTF ("loadDll finished\n"); # endif /* defined (CAN_USE_THREADS) */ PRINTF ("main - calling unloadDll\n"); # if defined (CAN_USE_THREADS) pthread_t tid2; result = pthread_create(&tid2, 0, &unloadDll, 0); if (result != 0) { PRINTF ("pthread_create() failed: %d\n", result); return 1; } pthread_join(tid2, 0); PRINTF ("unloadDll thread finished and re-joined\n"); # else unloadDll(0); PRINTF ("unloadDll finished\n"); # endif /* defined (CAN_USE_THREADS) */ PRINTF ("main finished\n"); #endif /* defined (CAN_RUN_TEST) */ return 0; }
LmHandle LmLanguageManagerC::loadContainer( const char *containerName, const char *externalPath, LmHandle extLoader, ComUInt32 *containerSize, ComDiagsArea *da) { return loadDll(containerName, externalPath, extLoader, containerSize, da, collHeap()); }
virtual void * createInterface( const char * moduleName, const char * interfaceName ) { E_ASSERT(moduleName); E_ASSERT(interfaceName); // std::cerr << __FUNCTION__ << " (" << moduleName << ", " << interfaceName << ")\n"; ModIter it = mods.find( moduleName ); bool found = 0; do // once { if ( it != mods.end() ) { found = true; break; } if ( ! loadDll ( moduleName ) ) { // sys::alert( __FUNCTION__, "mod not found %s :: %s", moduleName, interfaceName ); break; } it = mods.find( moduleName ); if ( it == mods.end() ) { sys::alert( __FUNCTION__, "mod not inserted %s :: %s", moduleName, interfaceName ); break; } found = true; } while(0); // do once if ( ! found ) { return 0; } Dll* h = it->second; ClassInfo * info = h->getClassInfo( ); if ( ! info ) { sys::alert( __FUNCTION__, "ClassInfo not found %s :: %s", moduleName, interfaceName ); return 0; } while ( info && info->cname ) { if ( ! strcmp( info->iname, interfaceName ) ) { return info->create(); } ++ info; } sys::alert( __FUNCTION__, "could not create %s :: %s", moduleName, interfaceName ); return 0; }
void InputPlugin::listDllFiles() { //========================== CFileFind cFileFind; CString searchFile; BOOL found; BOOL foundMatch; // match with the ini config bool canRecord; CString temp; int i; int matchIndex; //========================== searchFile = _T(".\\*.dll"); found = cFileFind.FindFile(searchFile); foundMatch = FALSE; i = 0; matchIndex = 0; canRecord = false; if(!found) { MessageBox(_T("No valid dlls found.")); return; } while(found) { found = cFileFind.FindNextFile(); if(checkDllFile(cFileFind.GetFilePath())) { m_cboxInputPlugin.AddString(cFileFind.GetFileName()); if(cFileFind.GetFileName() == config.plugin) { m_cboxInputPlugin.SetCurSel(i); foundMatch = TRUE; matchIndex = i; canRecord = checkRecording(cFileFind.GetFilePath()); } i++; } } m_cboxInputPlugin.SetCurSel(matchIndex); m_cboxInputPlugin.GetLBText(matchIndex,temp); temp = _T(".\\") + temp; loadDll(temp); enableWindows(canRecord); }
void * loadunloadDll(void *pp) { loadDll(pp); #if defined (CAN_RUN_TEST) assert(capi_dosomething != 0); capi_dosomething(); #endif /* defined (CAN_RUN_TEST) */ unloadDll(pp); return 0; }
/*******************************************************//** * Initializes this object. * * @return . *******************************************************/ int MainController::init() { Logger::getInstance()->printDebug(_T("-=MainController::init=-\n")); int result1 = loadDll(); if (result1) return result1; int result2 = instantiateSlave_(); if (result2) return result2; mainDataModel_->setStartValues(); int result3 = initializeSlave_(); return result3; }
dpBinary* dpLoader::load(const char *path) { size_t len = strlen(path); if(len>=4) { if (_stricmp(&path[len-4], ".obj")==0) { return loadObj(path); } else if(_stricmp(&path[len-4], ".lib")==0) { return loadLib(path); } else if(_stricmp(&path[len-4], ".dll")==0 || _stricmp(&path[len-4], ".exe")==0) { return loadDll(path); } } dpPrintError("unrecognized file %s\n", path); return nullptr; }
VideoDecoderDXVAPrivate(): VideoDecoderD3DPrivate() { // d3d9+gl interop may not work on optimus moble platforms, 0-copy is enabled only for egl interop if (d3d9::InteropResource::isSupported(d3d9::InteropEGL) && QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) copy_mode = VideoDecoderFFmpegHW::ZeroCopy; hd3d9_dll = 0; hdxva2_dll = 0; d3dobj = 0; d3ddev = 0; token = 0; devmng = 0; device = 0; vs = 0; decoder = 0; available = loadDll(); }
bool LoadDll::loadByDir(const string & dir) { searchDllFile(dir); if (m_dll_info_vec.size() == 0) { DEF_LOG_ERROR("get empey dll info by dir <%s>\n", dir.c_str()); return false; } if (loadDll()) { return true; } else { DEF_LOG_ERROR("failed to load dll by dir : <%s>\n", dir.c_str()); return false; } }
virtual uint loadAllModules() { uint n=0; char binPath[300]; sprintf( binPath, "%s%cbin", e6Path, sys::fileSeparator() ); const char * oldPath = sys::getCurrentDir(); sys::setCurrentDir( binPath ); FILE * f = fopen("_dllCache","rb"); if ( ! f ) return 0; char buf[512]; while ( fgets( buf,512,f ) ) { int z=(int)strlen(buf)-2; buf[z]=0; n += (loadDll( buf )!=0); } sys::setCurrentDir( oldPath ); return n; }
int main(int argc, char *argv[]) { void *p; HINSTANCE hRtsDll, hProgDll; LPTSTR oldPath; StgClosure *main_p; RtsConfig rts_config; hs_main_t hs_main_p; // MSDN says: An environment variable has a maximum size limit of // 32,767 characters, including the null-terminating character. oldPath = malloc(32767); if (oldPath == NULL) { die("Mallocing 32767 for oldPath failed"); } if (!GetEnvironmentVariable(TEXT("PATH"), oldPath, 32767)) { if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) { oldPath[0] = '\0'; } else { die("Looking up PATH env var failed"); } } setPath(); hProgDll = loadDll(progDll); if (! SetEnvironmentVariable(TEXT("PATH"), oldPath)) { printf("SetEnvironmentVariable failed (%d)\n", GetLastError()); } free(oldPath); hRtsDll = GetNonNullModuleHandle(rtsDll); hs_main_p = GetNonNullProcAddress(hRtsDll, "hs_main"); main_p = GetNonNullProcAddress(hProgDll, "ZCMain_main_static_closure"); rts_config.rts_opts_enabled = rtsOpts; rts_config.rts_opts = NULL; return hs_main_p(argc, argv, main_p, rts_config); }
bool AudioOutputDSoundPrivate::init() { if (!loadDll()) return false; typedef HRESULT (WINAPI *DirectSoundCreateFunc)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN); //typedef HRESULT (WINAPI *DirectSoundEnumerateFunc)(LPDSENUMCALLBACKA, LPVOID); DirectSoundCreateFunc dsound_create = (DirectSoundCreateFunc)GetProcAddress(dll, "DirectSoundCreate"); //DirectSoundEnumerateFunc dsound_enumerate = (DirectSoundEnumerateFunc)GetProcAddress(dll, "DirectSoundEnumerateA"); if (!dsound_create) { qWarning("Failed to resolve 'DirectSoundCreate'"); unloadDll(); return false; } if (FAILED(dsound_create(NULL/*dev guid*/, &dsound, NULL))){ unloadDll(); return false; } /* DSSCL_EXCLUSIVE: can modify the settings of the primary buffer, only the sound of this app will be hearable when it will have the focus. */ if (FAILED(dsound->SetCooperativeLevel(GetDesktopWindow(), DSSCL_EXCLUSIVE))) { qWarning("Cannot set direct sound cooperative level"); SafeRelease(&dsound); return false; } qDebug("DirectSound initialized."); DSCAPS dscaps; memset(&dscaps, 0, sizeof(DSCAPS)); dscaps.dwSize = sizeof(DSCAPS); if (FAILED(dsound->GetCaps(&dscaps))) { qWarning("Cannot get device capabilities."); SafeRelease(&dsound); return false; } if (dscaps.dwFlags & DSCAPS_EMULDRIVER) qDebug("DirectSound is emulated"); write_offset = 0; return true; }
CourgetteI* newInstance() { bool loaded = false; m_ScriptLock.lock(); if (m_uiInstanceCount == 0) loaded = loadDll(); else loaded = true; bool didLoad = (loaded && m_pFactory); if (didLoad) m_uiInstanceCount++; m_ScriptLock.unlock(); if (didLoad == false) throw gcException(ERR_LIBRARY_LOADFAILED, "Failed to load courgette"); return (CourgetteI*)m_pFactory(COURGETTE); }
ScriptCoreI* newInstance() { bool loaded = false; m_ScriptLock.lock(); if (m_uiInstanceCount == 0) loaded = loadDll(); else loaded = true; bool didLoad = (loaded && m_pFactory); if (didLoad) m_uiInstanceCount++; m_ScriptLock.unlock(); if (didLoad == false) throw gcException(ERR_LIBRARY_LOADFAILED, "Failed to load script engine"); return (ScriptCoreI*)m_pFactory(SCRIPT_CORE); }
void InputPlugin::OnCbnSelchangeInputPlugin() { //====================== int cursorSelection; CString file; bool validFile; bool canRecord; //====================== unloadDll(); cursorSelection = m_cboxInputPlugin.GetCurSel(); m_cboxInputPlugin.GetLBText(m_cboxInputPlugin.GetCurSel(),file); file = _T(".\\") + file; validFile = checkDllFile(file); canRecord = checkRecording(file); if(!validFile) MessageBox(_T("Invalid dll file"),_T("Error"),0); loadDll(file); enableWindows(canRecord); }
int main(int argc, char *argv[]) { const char* fmuFileName; char* fmuPath; char* tmpPath; char* xmlPath; char* dllPath; // define default argument values double tEnd = 1.0; double h=0.1; int loggingOn = 0; char csv_separator = ';'; // parse command line arguments if (argc>1) { fmuFileName = argv[1]; } else { printf("error: no fmu file\n"); printHelp(argv[0]); exit(EXIT_FAILURE); } if (argc>2) { if (sscanf(argv[2],"%lf", &tEnd) != 1) { printf("error: The given end time (%s) is not a number\n", argv[2]); exit(EXIT_FAILURE); } } if (argc>3) { if (sscanf(argv[3],"%lf", &h) != 1) { printf("error: The given stepsize (%s) is not a number\n", argv[3]); exit(EXIT_FAILURE); } } if (argc>4) { if (sscanf(argv[4],"%d", &loggingOn) != 1 || loggingOn<0 || loggingOn>1) { printf("error: The given logging flag (%s) is not boolean\n", argv[4]); exit(EXIT_FAILURE); } } if (argc>5) { if (strlen(argv[5]) != 1) { printf("error: The given CSV separator char (%s) is not valid\n", argv[5]); exit(EXIT_FAILURE); } csv_separator = argv[5][0]; } if (argc>6) { printf("warning: Ignoring %d additional arguments: %s ...\n", argc-6, argv[6]); printHelp(argv[0]); } // get absolute path to FMU, NULL if not found fmuPath = getFmuPath(fmuFileName); if (!fmuPath) exit(EXIT_FAILURE); // unzip the FMU to the tmpPath directory tmpPath = getTmpPath(); if (!unzip(fmuPath, tmpPath)) exit(EXIT_FAILURE); // parse tmpPath\modelDescription.xml xmlPath = calloc(sizeof(char), strlen(tmpPath) + strlen(XML_FILE) + 1); sprintf(xmlPath, "%s%s", tmpPath, XML_FILE); fmu.modelDescription = parse(xmlPath); free(xmlPath); if (!fmu.modelDescription) exit(EXIT_FAILURE); // load the FMU dll dllPath = calloc(sizeof(char), strlen(tmpPath) + strlen(DLL_DIR) + strlen( getModelIdentifier(fmu.modelDescription)) + strlen(".dll") + 1); sprintf(dllPath,"%s%s%s.dll", tmpPath, DLL_DIR, getModelIdentifier(fmu.modelDescription)); if (!loadDll(dllPath, &fmu)) exit(EXIT_FAILURE); free(dllPath); free(fmuPath); free(tmpPath); // run the simulation printf("FMU Simulator: run '%s' from t=0..%g with step size h=%g, loggingOn=%d, csv separator='%c'\n", fmuFileName, tEnd, h, loggingOn, csv_separator); simulate(&fmu, tEnd, h, loggingOn, csv_separator); printf("CSV file '%s' written", RESULT_FILE); // release FMU FreeLibrary(fmu.dllHandle); freeElement(fmu.modelDescription); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { unsigned char *data; //Comprobar Parametros if (argc != 3) { fprintf(stderr,"\nHow to use: %s I|D funcion.ini\n",argv[0]); return 1; } else { if (toupper(argv[1][0])!='I' && toupper(argv[1][0])!='D') { fprintf(stderr,"\nThe first parameter has to be I or D\n"); return 1; } strcpy(route,".\\"); strcat(route,argv[2]); //obtenemos los parametros del .ini errors=GetPrivateProfileInt("DLL","Errores",0,route); velocity=GetPrivateProfileInt("Serie","Velocidad",80,route); tam=GetPrivateProfileInt("Enlace","tamTrama",1500,route); mode=GetPrivateProfileInt("Preferencias","verTramasYprimitivas",0,route); } //cargamos la dll if(loadDll() == 1) { fprintf(stderr,"\nError loading: loadDll\n"); return 1; } //si es el lado I(emisor) if(toupper(argv[1][0]) == 'I') { system("cls"); printf("=====================================\n"); printf("| Transmitter |\n"); printf("=====================================\n"); printf("\n"); initiateSideI(errors,velocity,mode); //conexion switch(L_CONNECT_request(0,0,0)) { case 0://ha llegado ACK L_CONNECT_confirm(0,0,0); break; case 1://trys agotados fprintf(stderr,"\nTry to connection time out\n"); L_DISCONNECT_request(0,0); return 0; break; } //datos while(1) { data = (char*) malloc(sizeof(char)*80); printf("\nEnter a phrase: ");fgets(data,MTU,stdin); //si introducimos FIN provocamos el disconnect if(strcmp(data,"FIN\n")==0){break;} switch(L_DATA_request(0,0,data)) { case 0: //nos ha llegado un dato en morse L_DATA_indication(0,0); printf("\nIn morse: %s",fI->data); break; case 1: L_DISCONNECT_request(0,0); return 0; break; } } L_DISCONNECT_request(0,0); return 0; } //si es el lado D(receptor) if(toupper(argv[1][0]) == 'D') { system("cls"); printf("=====================================\n"); printf("| Receptor |\n"); printf("=====================================\n"); printf("\n"); initiateSideD(errors,velocity,mode); //conexion do { switch(L_CONNECT_indication(0,0,0)) { case 0: L_CONNECT_response(0,0,0); break; case 1: L_DISCONNECT_indication(0,0,0); return 0; break; } }while(conexionOK != 1); //datos while(1) { switch(L_DATA_request(0,0,NULL)) { case 0: L_DATA_indication(0,0); //este sleep es para que no se envien al mismo tiempo ACK y morse Sleep(2000); L_DATA_request(0,0,fD->data); break; case 1: L_DISCONNECT_indication(0,0,0); return 0; break; } } } }
/////////////////////////////////////////////////////////////////////////////// /// main routine of the demo code /// ///\param argc Number of arguments ///\param argv Arguments ///\return 0 if no error occurred /////////////////////////////////////////////////////////////////////////////// int main(int argc, char *argv[]) { const char* fmuFilNam; char* fmuPat; char* tmpPat; char* xmlPat; char* dllPat; // define default argument values double tEnd = 1.0; double h=0.1; int loggingOn = 0; char csv_separator = ','; // parse command line arguments if (argc>1) { fmuFilNam = argv[1]; if(!strcmp(fmuFilNam, "-h") | !strcmp(fmuFilNam, "--help")) { printHelp(argv[0]); return 0; } /*if(!strstr(fmuFilNam,"DoubleInputDoubleOutput.fmu")) { printf("Sorry, this demo only works with the FMU file DoubleInputDoubleOutput.fmu"); return 0; }*/ } else { printError("No fmu file.\n"); printHelp(argv[0]); exit(EXIT_FAILURE); } if (argc>2) { if (sscanf(argv[2],"%lf", &tEnd) != 1) { printfError("The given end time (%s) is not a number.\n", argv[2]); exit(EXIT_FAILURE); } } if (argc>3) { if (sscanf(argv[3],"%lf", &h) != 1) { printfError("The given stepsize (%s) is not a number.\n", argv[3]); exit(EXIT_FAILURE); } } if (argc>4) { if (sscanf(argv[4],"%d", &loggingOn) != 1 || loggingOn<0 || loggingOn>1) { printfError("The given logging flag (%s) is not boolean.\n", argv[4]); exit(EXIT_FAILURE); } if(loggingOn) setDebug(); } if (argc>5) { if (strlen(argv[5]) != 1) { printfError("The given CSV separator char (%s) is not valid.\n", argv[5]); exit(EXIT_FAILURE); } csv_separator = argv[5][0]; } if (argc>6) { printf("warning: Ignoring %d additional arguments: %s ...\n", argc-6, argv[6]); printHelp(argv[0]); } // Get absolute path to FMU, NULL if not found tmpPat = getTmpPath(fmuFilNam, strlen(fmuFilNam)-4); if(tmpPat==NULL){ printError("Cannot allocate temporary path.\n"); exit(EXIT_FAILURE); } // Unzip the FMU to the tmpPat directory if (unpack(fmuFilNam, tmpPat)) { printfError("Fail to unpack fmu \"%s\".\n", fmuFilNam); exit(EXIT_FAILURE); } printDebug("parse tmpPat\\modelDescription.xml.\n"); xmlPat = calloc(sizeof(char), strlen(tmpPat) + strlen(XML_FILE) + 1); sprintf(xmlPat, "%s%s", tmpPat, XML_FILE); // Parse only parses the model description and store in structure fmu.modelDescription fmu.modelDescription = parse(xmlPat); free(xmlPat); if (!fmu.modelDescription) exit(EXIT_FAILURE); // Allocate the memory for dllPat dllPat = calloc(sizeof(char), strlen(tmpPat) + strlen(DLL_DIR) + strlen( getModelIdentifier(fmu.modelDescription)) + strlen(".dll") + 1); sprintf(dllPat,"%s%s%s.dll", tmpPat, DLL_DIR, getModelIdentifier(fmu.modelDescription)); // Load the FMU dll if (loadDll(dllPat, &fmu)) exit(EXIT_FAILURE); printfDebug("Loaded \"%s\"\n", dllPat); free(dllPat); free(tmpPat); // Run the simulation printf("FMU Simulator: run '%s' from t=0..%g with step size h=%g, loggingOn=%d, csv separator='%c'\n", fmuFilNam, tEnd, h, loggingOn, csv_separator); if (simulate(&fmu, tEnd, h, loggingOn, csv_separator)){ printError("Simulation failed.\n"); exit(EXIT_FAILURE); } printf("CSV file '%s' written", RESULT_FILE); // Release FMU FreeLibrary(fmu.dllHandle); freeElement(fmu.modelDescription); return EXIT_SUCCESS; }
void loadDlls() { loadDll("jhtree"); }