comparison plugins/perl/perl.c @ 12873:96d611ab3fcb

[gaim-migrate @ 15225] Some more whitespace I missed before. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Sat, 14 Jan 2006 08:32:01 +0000
parents 59ff3e1c874e
children e1603fd610fa
comparison
equal deleted inserted replaced
12872:59ff3e1c874e 12873:96d611ab3fcb
117 xs_init(pTHX) 117 xs_init(pTHX)
118 #endif 118 #endif
119 { 119 {
120 char *file = __FILE__; 120 char *file = __FILE__;
121 121
122 /* This one allows dynamic loading of perl modules in perl 122 /* This one allows dynamic loading of perl modules in perl scripts by
123 scripts by the 'use perlmod;' construction*/ 123 * the 'use perlmod;' construction */
124 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); 124 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
125 } 125 }
126 126
127 static void 127 static void
128 perl_init(void) 128 perl_init(void)
129 { 129 {
130 /* changed the name of the variable from load_file to 130 /* changed the name of the variable from load_file to perl_definitions
131 perl_definitions since now it does much more than defining 131 * since now it does much more than defining the load_file sub.
132 the load_file sub. Moreover, deplaced the initialisation to 132 * Moreover, deplaced the initialisation to the xs_init function.
133 the xs_init function. (TheHobbit) */ 133 * (TheHobbit) */
134 char *perl_args[] = { "", "-e", "0", "-w" }; 134 char *perl_args[] = { "", "-e", "0", "-w" };
135 char perl_definitions[] = 135 char perl_definitions[] =
136 { 136 {
137 /* We use to function one to load a file the other to 137 /* We use to function one to load a file the other to execute
138 execute the string obtained from the first and holding 138 * the string obtained from the first and holding the file
139 the file contents. This allows to have a really local $/ 139 * contents. This allows to have a really local $/ without
140 without introducing temp variables to hold the old 140 * introducing temp variables to hold the old value. Just a
141 value. Just a question of style:) */ 141 * question of style:) */
142 "package Gaim::PerlLoader;" 142 "package Gaim::PerlLoader;"
143 "use Symbol;" 143 "use Symbol;"
144 144
145 "sub load_file {" 145 "sub load_file {"
146 "my $f_name=shift;" 146 "my $f_name=shift;"
198 { 198 {
199 if (my_perl == NULL) 199 if (my_perl == NULL)
200 return; 200 return;
201 201
202 PL_perl_destruct_level = 1; 202 PL_perl_destruct_level = 1;
203 PERL_SET_CONTEXT(my_perl); 203 PERL_SET_CONTEXT(my_perl);
204 perl_eval_pv( 204 perl_eval_pv(
205 "foreach my $lib (@DynaLoader::dl_modules) {" 205 "foreach my $lib (@DynaLoader::dl_modules) {"
206 "if ($lib =~ /^Gaim\\b/) {" 206 "if ($lib =~ /^Gaim\\b/) {"
207 "$lib .= '::deinit();';" 207 "$lib .= '::deinit();';"
208 "eval $lib;" 208 "eval $lib;"
260 } else { 260 } else {
261 SV **key; 261 SV **key;
262 int perl_api_ver; 262 int perl_api_ver;
263 263
264 key = hv_fetch(plugin_info, "perl_api_version", 264 key = hv_fetch(plugin_info, "perl_api_version",
265 strlen("perl_api_version"), 0); 265 strlen("perl_api_version"), 0);
266 266
267 perl_api_ver = SvIV(*key); 267 perl_api_ver = SvIV(*key);
268 268
269 if (perl_api_ver != 2) 269 if (perl_api_ver != 2)
270 status = FALSE; 270 status = FALSE;
305 info->ui_requirement = GAIM_GTK_PLUGIN_TYPE; 305 info->ui_requirement = GAIM_GTK_PLUGIN_TYPE;
306 306
307 if ((key = hv_fetch(plugin_info, "url", 307 if ((key = hv_fetch(plugin_info, "url",
308 strlen("url"), 0))) 308 strlen("url"), 0)))
309 info->homepage = g_strdup(SvPV(*key, len)); 309 info->homepage = g_strdup(SvPV(*key, len));
310 310
311 if ((key = hv_fetch(plugin_info, "author", 311 if ((key = hv_fetch(plugin_info, "author",
312 strlen("author"), 0))) 312 strlen("author"), 0)))
313 info->author = g_strdup(SvPV(*key, len)); 313 info->author = g_strdup(SvPV(*key, len));
314 314
315 if ((key = hv_fetch(plugin_info, "summary", 315 if ((key = hv_fetch(plugin_info, "summary",
341 /* */ 341 /* */
342 /* prefs_info - Uses non-GUI (read GTK) gaim API calls */ 342 /* prefs_info - Uses non-GUI (read GTK) gaim API calls */
343 /* and creates a GaimPluginPrefInfo type. */ 343 /* and creates a GaimPluginPrefInfo type. */
344 /* */ 344 /* */
345 /* gtk_prefs_info - Requires gtk2-perl be installed by */ 345 /* gtk_prefs_info - Requires gtk2-perl be installed by */
346 /* the user and he must create a GtkWidget */ 346 /* the user and he must create a */
347 /* representing the plugin preferences */ 347 /* GtkWidget the user and he must */
348 /* page. */ 348 /* create a GtkWidget representing the */
349 /* plugin preferences page. */
349 /********************************************************/ 350 /********************************************************/
350 if ((key = hv_fetch(plugin_info, "prefs_info", 351 if ((key = hv_fetch(plugin_info, "prefs_info",
351 strlen("prefs_info"), 0))) { 352 strlen("prefs_info"), 0))) {
352 /* key now is the name of the Perl sub that 353 /* key now is the name of the Perl sub that
353 * will create a frame for us */ 354 * will create a frame for us */
526 } 527 }
527 528
528 static void 529 static void
529 destroy_perl_plugin(GaimPlugin *plugin) 530 destroy_perl_plugin(GaimPlugin *plugin)
530 { 531 {
531 if (plugin->info != NULL) 532 if (plugin->info != NULL) {
532 {
533 GaimPerlScript *gps; 533 GaimPerlScript *gps;
534 534
535 g_free(plugin->info->name); 535 g_free(plugin->info->name);
536 g_free(plugin->info->version); 536 g_free(plugin->info->version);
537 g_free(plugin->info->summary); 537 g_free(plugin->info->summary);