Mercurial > pidgin
diff src/perl.c @ 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 | 2f0655e185b8 |
line wrap: on
line diff
--- 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"};
