Mercurial > pidgin
changeset 800:022048cde898
[gaim-migrate @ 810]
perl! yay! finally :-P
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 30 Aug 2000 19:45:01 +0000 |
parents | 72f8ac951c11 |
children | 1a47432e2ba1 |
files | ChangeLog src/aim.c src/gaim.h src/perl.c |
diffstat | 4 files changed, 40 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Aug 30 18:54:02 2000 +0000 +++ b/ChangeLog Wed Aug 30 19:45:01 2000 +0000 @@ -26,6 +26,8 @@ * Optionally Ignore TiK's Automated Messages * Option to beep instead of play sound * New icons for panel (depends on some GNOME pixmaps) + * Perl scripting. See plugins/PERL-HOWTO for how to write perl scripts. + All .pl files in ~/.gaim are autoloaded when gaim starts. version 0.9.20 (07/14/2000): * More plugin events, more plugin features
--- a/src/aim.c Wed Aug 30 18:54:02 2000 +0000 +++ b/src/aim.c Wed Aug 30 19:45:01 2000 +0000 @@ -560,6 +560,7 @@ #ifdef USE_PERL perl_init(); + perl_autoload(); #endif #ifdef USE_APPLET
--- a/src/gaim.h Wed Aug 30 18:54:02 2000 +0000 +++ b/src/gaim.h Wed Aug 30 19:45:01 2000 +0000 @@ -401,7 +401,7 @@ #define TYPE_SIGNOFF 4 #define TYPE_KEEPALIVE 5 -#define REVISION "gaim:$Revision: 808 $" +#define REVISION "gaim:$Revision: 810 $" #define FLAPON "FLAPON\r\n\r\n" #define ROAST "Tic/Toc" @@ -735,6 +735,7 @@ /* Functions in perl.c */ #ifdef USE_PERL extern void perl_init(); +extern void perl_autoload(); extern int perl_load_file(char *); extern void perl_end(); extern int perl_event(enum gaim_event, char *);
--- a/src/perl.c Wed Aug 30 18:54:02 2000 +0000 +++ b/src/perl.c Wed Aug 30 19:45:01 2000 +0000 @@ -43,6 +43,7 @@ #include <fcntl.h> #undef PACKAGE #include <stdio.h> +#include <dirent.h> #include <gtk/gtk.h> #include "pixmaps/add.xpm" #include "pixmaps/cancel.xpm" @@ -142,6 +143,40 @@ return SvNV (return_val); } +static int is_pl_file(char *filename) +{ + int len; + if (!filename) return 0; + if (!filename[0]) return 0; + len = strlen(filename); + len -= 3; + return (!strncmp(filename + len, ".pl", 3)); +} + +void perl_autoload() +{ + DIR *dir; + struct dirent *ent; + char *buf; + char path[BUF_LONG]; + + g_snprintf(path, sizeof(path), "%s/.gaim", getenv("HOME")); + dir = opendir(path); + if (dir) { + while ((ent = readdir(dir))) { + if (strcmp(ent->d_name, ".") && strcmp(ent->d_name, "..")) { + if (is_pl_file(ent->d_name)) { + buf = g_malloc(strlen(path) + strlen(ent->d_name) + 2); + sprintf(buf, "%s/%s", path, ent->d_name); + perl_load_file(buf); + g_free(buf); + } + } + } + closedir(dir); + } +} + void perl_init() { char *perl_args[] = {"", "-e", "0"};