Mercurial > pidgin.yaz
comparison 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 |
comparison
equal
deleted
inserted
replaced
799:72f8ac951c11 | 800:022048cde898 |
---|---|
41 #include <sys/types.h> | 41 #include <sys/types.h> |
42 #include <sys/stat.h> | 42 #include <sys/stat.h> |
43 #include <fcntl.h> | 43 #include <fcntl.h> |
44 #undef PACKAGE | 44 #undef PACKAGE |
45 #include <stdio.h> | 45 #include <stdio.h> |
46 #include <dirent.h> | |
46 #include <gtk/gtk.h> | 47 #include <gtk/gtk.h> |
47 #include "pixmaps/add.xpm" | 48 #include "pixmaps/add.xpm" |
48 #include "pixmaps/cancel.xpm" | 49 #include "pixmaps/cancel.xpm" |
49 | 50 |
50 | 51 |
138 int perl_load_file(char *script_name) | 139 int perl_load_file(char *script_name) |
139 { | 140 { |
140 SV *return_val; | 141 SV *return_val; |
141 return_val = execute_perl("load_file", script_name); | 142 return_val = execute_perl("load_file", script_name); |
142 return SvNV (return_val); | 143 return SvNV (return_val); |
144 } | |
145 | |
146 static int is_pl_file(char *filename) | |
147 { | |
148 int len; | |
149 if (!filename) return 0; | |
150 if (!filename[0]) return 0; | |
151 len = strlen(filename); | |
152 len -= 3; | |
153 return (!strncmp(filename + len, ".pl", 3)); | |
154 } | |
155 | |
156 void perl_autoload() | |
157 { | |
158 DIR *dir; | |
159 struct dirent *ent; | |
160 char *buf; | |
161 char path[BUF_LONG]; | |
162 | |
163 g_snprintf(path, sizeof(path), "%s/.gaim", getenv("HOME")); | |
164 dir = opendir(path); | |
165 if (dir) { | |
166 while ((ent = readdir(dir))) { | |
167 if (strcmp(ent->d_name, ".") && strcmp(ent->d_name, "..")) { | |
168 if (is_pl_file(ent->d_name)) { | |
169 buf = g_malloc(strlen(path) + strlen(ent->d_name) + 2); | |
170 sprintf(buf, "%s/%s", path, ent->d_name); | |
171 perl_load_file(buf); | |
172 g_free(buf); | |
173 } | |
174 } | |
175 } | |
176 closedir(dir); | |
177 } | |
143 } | 178 } |
144 | 179 |
145 void perl_init() | 180 void perl_init() |
146 { | 181 { |
147 char *perl_args[] = {"", "-e", "0"}; | 182 char *perl_args[] = {"", "-e", "0"}; |