void PASCAL FAR TTXInit(PTTSet ts, PComVar cv) { ExtensionList * extensionList = NULL; int i; // 環境変数の設定有無に関わらず、TTXを有効にする。 //if (getenv("TERATERM_EXTENSIONS") != NULL) { if (1) { char buf[1024]; int index; struct _finddata_t searchData; long searchHandle; if (GetModuleFileName(hInst, buf, sizeof(buf)) == 0) { return; } for (index = strlen(buf) - 1; index >= 0 && buf[index] != '\\' && buf[index] != ':' && buf[index] != '/'; index--) { } index++; strncpy_s(buf + index, sizeof(buf) - index, "TTX*.DLL", _TRUNCATE); searchHandle = _findfirst(buf,&searchData); if (searchHandle != -1L) { loadExtension(&extensionList, searchData.name); while (_findnext(searchHandle, &searchData)==0) { loadExtension(&extensionList, searchData.name); } _findclose(searchHandle); } if (NumExtensions==0) return; Extensions = (TTXExports * *)malloc(sizeof(TTXExports *)*NumExtensions); for (i = 0; i < NumExtensions; i++) { ExtensionList * old; Extensions[i] = extensionList->exports; old = extensionList; extensionList = extensionList->next; free(old); } qsort(Extensions, NumExtensions, sizeof(Extensions[0]), compareOrder); for (i = 0; i < NumExtensions; i++) { if (Extensions[i]->TTXInit != NULL) { Extensions[i]->TTXInit(ts, cv); } } } }
void ExtensionMgr::loadExtension(const QString& name) { KService::List sl = KServiceType::offers("Kst Extension"); for (KService::List::ConstIterator it = sl.begin(); it != sl.end(); ++it) { KService::Ptr service = *it; if (name == service->property("Name").toString()) { loadExtension(service); return; } } }
void ExtensionMgr::updateExtensions() { for (QMap<QString,bool>::ConstIterator i = _extensions.begin(); i != _extensions.end(); ++i) { QMap<QString,KstExtension*>::Iterator j = _registry.find(i.key()); if (i.data()) { if (j == _registry.end()) { loadExtension(i.key()); } } else { if (j != _registry.end()) { delete j.data(); // Does this automatically //_registry.remove(j); } } } }
void ExtensionProxy::loadExtension(const TQCString& desktopFile, const TQCString& configFile) { TQString df; // try simple path first TQFileInfo finfo( desktopFile ); if ( finfo.exists() ) { df = finfo.absFilePath(); } else { // locate desktop file df = TDEGlobal::dirs()->findResource("extensions", TQString(desktopFile)); } TQFile file(df); // does the config file exist? if (df.isNull() || !file.exists()) { kdError() << "Failed to locate extension desktop file: " << desktopFile << endl; exit(0); } // create AppletInfo instance _info = new AppletInfo(df); // set the config file if (!configFile.isNull()) _info->setConfigFile(configFile); // load extension DSO _extension = loadExtension(*_info); // sanity check if (!_extension) { kdError() << "Failed to load extension: " << _info->library() << endl; exit(0); } // connect updateLayout signal connect(_extension, TQT_SIGNAL(updateLayout()), TQT_SLOT(slotUpdateLayout())); }
/** * lädt die driverwrapper-extensions. * * @author flosoft */ bool VideoDriverWrapper::LoadAllExtensions() { // auf VSync-Extension testen #ifdef _WIN32 if((GLOBALVARS.ext_swapcontrol = hasExtension("WGL_EXT_swap_control"))) { if( (wglSwapIntervalEXT = pto2ptf<PFNWGLSWAPINTERVALFARPROC>(loadExtension("wglSwapIntervalEXT"))) == NULL) GLOBALVARS.ext_swapcontrol = false; } #else /*if((GLOBALVARS.ext_swapcontrol = hasExtension("GLX_SGI_swap_control"))) {*/ // fix for buggy video driver... GLOBALVARS.ext_swapcontrol = true; if( (wglSwapIntervalEXT = pto2ptf<PFNWGLSWAPINTERVALFARPROC>(loadExtension("glXSwapIntervalSGI"))) == NULL) GLOBALVARS.ext_swapcontrol = false; //} #endif // auf VertexBufferObject-Extension testen if((GLOBALVARS.ext_vbo = hasExtension("GL_ARB_vertex_buffer_object"))) { #ifndef __APPLE__ if ( (glBindBufferARB = pto2ptf<PFNGLBINDBUFFERARBPROC>(loadExtension("glBindBufferARB"))) == NULL) GLOBALVARS.ext_vbo = false; else if ( (glDeleteBuffersARB = pto2ptf<PFNGLDELETEBUFFERSARBPROC>(loadExtension("glDeleteBuffersARB"))) == NULL) GLOBALVARS.ext_vbo = false; else if ( (glGenBuffersARB = pto2ptf<PFNGLGENBUFFERSARBPROC>(loadExtension("glGenBuffersARB"))) == NULL) GLOBALVARS.ext_vbo = false; else if ( (glBufferDataARB = pto2ptf<PFNGLBUFFERDATAARBPROC>(loadExtension("glBufferDataARB"))) == NULL) GLOBALVARS.ext_vbo = false; else if ( (glBufferSubDataARB = pto2ptf<PFNGLBUFFERSUBDATAARBPROC>(loadExtension("glBufferSubDataARB"))) == NULL) GLOBALVARS.ext_vbo = false; #endif // ! __APPLE__ } return true; }
int loadCEServerExtension(HANDLE hProcess) { printf("loadCEServerExtension\n"); if (GetHandleType(hProcess) == htProcesHandle ) { PProcessData p=(PProcessData)GetPointerFromHandle(hProcess); if (p->isDebugged) { printf("this process id being debugged\n"); //make sure this is executed by the debugger thread if (p->debuggerThreadID!=pthread_self()) { printf("Not the debugger thread. Switching...\n"); //tell the debugger thread to do this int result=0; #pragma pack(1) struct { uint8_t command; uint32_t pHandle; } lx; #pragma pack() lx.command=CMD_LOADEXTENSION; lx.pHandle=hProcess; if (pthread_mutex_lock(&debugsocketmutex) == 0) { sendall(p->debuggerClient, &lx, sizeof(lx), 0); WakeDebuggerThread(); recvall(p->debuggerClient, &result, sizeof(result), MSG_WAITALL); printf("Returned from debugger thread. Result:%d\n", result); pthread_mutex_unlock(&debugsocketmutex); } return result; } else printf("This is the debugger thread\n"); } if (p->hasLoadedExtension==0) { char modulepath[256], modulepath2[256]; int l; memset(modulepath, 0, 256); memset(modulepath2, 0, 256); char *mp; l=readlink("/proc/self/exe", modulepath2, 256); if (l!=-1) { modulepath2[l]=0; printf("modulepath2=%s\n", modulepath2); sscanf(modulepath2,"%s", modulepath); //sometimes it has a (deleted) text after it printf("modulepath=%s\n", modulepath); mp=dirname(modulepath); printf("after dirname: %s\n", mp); strcpy(modulepath, mp); strcat(modulepath, "/libceserver-extension.so"); printf("modulepath = %s\n", modulepath); } else { strcpy(modulepath, "libceserver-extension.so"); } if (p->isDebugged) { printf("This process is being debugged. Checking if it's already loaded\n"); pthread_mutex_lock(&p->extensionMutex); p->hasLoadedExtension=openExtension(p->pid, &p->extensionFD); pthread_mutex_unlock(&p->extensionMutex); } // else if (p->hasLoadedExtension) printf("The extension is already loaded\n"); { pthread_mutex_lock(&p->extensionMutex); if (p->hasLoadedExtension==0) //still 0 { if (p->neverForceLoadExtension==0) { printf("Calling loadExtension\n"); p->hasLoadedExtension=loadExtension(p->pid, modulepath, p->isDebugged); } if (p->hasLoadedExtension) p->hasLoadedExtension=openExtension(p->pid, &p->extensionFD); } pthread_mutex_unlock(&p->extensionMutex); } } else printf("Already loaded\n"); return p->hasLoadedExtension; } else { printf("Invalid handle type"); return 0; } }
void loadDirectory(const char *dir) { char find[512]; char *e,*ext; #ifdef _WIN32 WIN32_FIND_DATA fd; HANDLE fh; bool ok; #else DIR *d; struct dirent *de; struct stat s; #endif strcpy(find,dir); e = strchr(find,0); # ifdef _WIN32 strcat(find,"*.*"); fh = FindFirstFile(find,&fd); ok = (fh!=INVALID_HANDLE_VALUE); while (ok){ if (fd.cFileName[0]!='.'){ strcpy(e,fd.cFileName); if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){ strcat(e,"\\"); SetCurrentDirectory(find); loadDirectory(find); } else{ ext = strrchr(fd.cFileName,'.'); if (stricmp(ext,".mtx")==0){ loadExtension(find); }; }; }; ok = FindNextFile(fh,&fd)!=0; }; FindClose(fh); # else if (*(e-1)!='/'){ *e++ = '/'; *e = 0; }; d = opendir(find); while ((de = readdir(d))){ if (de->d_name[0]!='.'){ strcpy(e,de->d_name); stat(find,&s); if ((s.st_mode & S_IFMT)==S_IFDIR){ chdir(find); loadDirectory(find); } else{ ext = strrchr(de->d_name,'.'); if (stricmp(ext,".mtx")==0) loadExtension(find); }; }; }; closedir(d); # endif }