plugins/tcl/tcl.c

changeset 13456
4949b0656a2b
parent 13439
1ef0c638a216
child 13812
a10499942a3c
equal deleted inserted replaced
13455:c3e38377942f 13456:4949b0656a2b
323 return; 323 return;
324 } 324 }
325 325
326 static gboolean tcl_load(GaimPlugin *plugin) 326 static gboolean tcl_load(GaimPlugin *plugin)
327 { 327 {
328 if(!tcl_loaded) 328 if(!tcl_loaded)
329 return FALSE; 329 return FALSE;
330 tcl_glib_init(); 330 tcl_glib_init();
331 tcl_signal_init(); 331 tcl_signal_init();
332 tcl_plugins = g_hash_table_new(g_direct_hash, g_direct_equal); 332 tcl_plugins = g_hash_table_new(g_direct_hash, g_direct_equal);
333 333
334 #ifdef HAVE_TK 334 #ifdef HAVE_TK
380 NULL, 380 NULL,
381 NULL 381 NULL
382 }; 382 };
383 383
384 #ifdef _WIN32 384 #ifdef _WIN32
385 extern Tcl_Interp* (CALLBACK* wtcl_CreateInterp)(); 385 typedef Tcl_Interp* (CALLBACK* LPFNTCLCREATEINTERP)(void);
386 extern void (CALLBACK* wtk_Init)(Tcl_Interp*); 386 typedef void (CALLBACK* LPFNTKINIT)(Tcl_Interp*);
387
388 LPFNTCLCREATEINTERP wtcl_CreateInterp = NULL;
389 LPFNTKINIT wtk_Init = NULL;
387 #undef Tcl_CreateInterp 390 #undef Tcl_CreateInterp
388 #define Tcl_CreateInterp wtcl_CreateInterp 391 #define Tcl_CreateInterp wtcl_CreateInterp
389 #undef Tk_Init 392 #undef Tk_Init
390 #define Tk_Init wtk_Init 393 #define Tk_Init wtk_Init
394
395 static gboolean tcl_win32_init() {
396 gaim_debug(GAIM_DEBUG_INFO, "tcl",
397 "Initializing the Tcl runtime. If Gaim doesn't load, it is "
398 "most likely because you have cygwin in your PATH and you "
399 "should remove it. See http://gaim.sf.net/win32 for more "
400 "information\n");
401
402 if(!(wtcl_CreateInterp = (LPFNTCLCREATEINTERP) wgaim_find_and_loadproc("tcl84.dll", "Tcl_CreateInterp"))) {
403 gaim_debug(GAIM_DEBUG_INFO, "tcl", "tcl_win32_init error loading Tcl_CreateInterp\n");
404 return FALSE;
405 }
406
407 if(!(wtk_Init = (LPFNTKINIT) wgaim_find_and_loadproc("tk84.dll", "Tk_Init"))) {
408 HMODULE mod;
409 gaim_debug(GAIM_DEBUG_INFO, "tcl", "tcl_win32_init error loading Tk_Init\n");
410 if((mod = GetModuleHandle("tcl84.dll")))
411 FreeLibrary(mod);
412 return FALSE;
413 }
414
415 if (GetModuleHandle("cygwin1.dll")) {
416 HMODULE mod;
417 gaim_debug(GAIM_DEBUG_INFO, "tcl", "Cygwin has been loaded by tcl84.dll and/or tk84.dll. Disabling Tcl support to avoid problems.\n");
418 if((mod = GetModuleHandle("tcl84.dll")))
419 FreeLibrary(mod);
420 if((mod = GetModuleHandle("tk84.dll")))
421 FreeLibrary(mod);
422 return FALSE;
423 }
424
425 return TRUE;
426 }
427
391 #endif /* _WIN32 */ 428 #endif /* _WIN32 */
392 429
393 static void tcl_init_plugin(GaimPlugin *plugin) 430 static void tcl_init_plugin(GaimPlugin *plugin)
394 { 431 {
395 #ifdef USE_TCL_STUBS 432 #ifdef USE_TCL_STUBS
396 Tcl_Interp *interp=NULL; 433 Tcl_Interp *interp = NULL;
397 #endif 434 #endif
398 _tcl_plugin = plugin; 435 _tcl_plugin = plugin;
399 436
400 #ifdef USE_TCL_STUBS 437 #ifdef USE_TCL_STUBS
401 if(!(interp=Tcl_CreateInterp())) 438 #ifdef _WIN32
402 return; 439 if(!tcl_win32_init())
403 440 return;
404 if(!Tcl_InitStubs(interp, TCL_VERSION, 0)) { 441 #endif
405 gaim_debug(GAIM_DEBUG_ERROR, "tcl", "Tcl_InitStubs: %s\n", interp->result); 442 if(!(interp = Tcl_CreateInterp()))
406 return; 443 return;
407 } 444
445 if(!Tcl_InitStubs(interp, TCL_VERSION, 0)) {
446 gaim_debug(GAIM_DEBUG_ERROR, "tcl", "Tcl_InitStubs: %s\n", interp->result);
447 return;
448 }
408 #endif 449 #endif
409 450
410 Tcl_FindExecutable("gaim"); 451 Tcl_FindExecutable("gaim");
411 452
412 #if defined(USE_TK_STUBS) && defined(HAVE_TK) 453 #if defined(USE_TK_STUBS) && defined(HAVE_TK)
413 Tk_Init(interp); 454 Tk_Init(interp);
414 455
415 if(!Tk_InitStubs(interp, TK_VERSION, 0)) { 456 if(!Tk_InitStubs(interp, TK_VERSION, 0)) {
416 gaim_debug(GAIM_DEBUG_ERROR, "tcl", "Error Tk_InitStubs: %s\n", interp->result); 457 gaim_debug(GAIM_DEBUG_ERROR, "tcl", "Error Tk_InitStubs: %s\n", interp->result);
417 Tcl_DeleteInterp(interp); 458 Tcl_DeleteInterp(interp);
418 return; 459 return;
419 } 460 }
420 #endif 461 #endif
421 tcl_loaded = TRUE; 462 tcl_loaded = TRUE;
422 #ifdef USE_TCL_STUBS 463 #ifdef USE_TCL_STUBS
423 Tcl_DeleteInterp(interp); 464 Tcl_DeleteInterp(interp);
424 #endif 465 #endif
425 tcl_loader_info.exts = g_list_append(tcl_loader_info.exts, "tcl"); 466 tcl_loader_info.exts = g_list_append(tcl_loader_info.exts, "tcl");
426 } 467 }
427 468
428 GAIM_INIT_PLUGIN(tcl, tcl_init_plugin, tcl_info) 469 GAIM_INIT_PLUGIN(tcl, tcl_init_plugin, tcl_info)

mercurial