summaryrefslogtreecommitdiffstats
path: root/src/trigger.c
diff options
context:
space:
mode:
authorroman65536 <roman65536@yahoo.com>2017-03-16 23:25:12 +0100
committerroman65536 <roman65536@yahoo.com>2017-03-16 23:25:12 +0100
commit3e91cbd69fbd9fea6caf1952c71a8033056179c3 (patch)
tree080a5498b47119405cf474806625f1e683dd4a95 /src/trigger.c
parent51d960f743fd1f6a2147d573342504751e693e20 (diff)
Search for for lua trigger and c trigger included. Now the lua scripts are search in ~/.scim/lua/ or /usr/local/share/scim/lua
C triggers have to be placed in ~/.scim/module/ or /usr/local/share/scim/module
Diffstat (limited to 'src/trigger.c')
-rw-r--r--src/trigger.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/trigger.c b/src/trigger.c
index b0a819d..df3dde6 100644
--- a/src/trigger.c
+++ b/src/trigger.c
@@ -83,8 +83,13 @@ void set_trigger(int r, int c, int rf, int cf, char * str) {
#endif
if (strcmp(get(d,"type"), "C")== 0) {
char * error;
+ char buffer[PATHLEN];
+ char buffer1[PATHLEN];
tmp|=TRG_C;
- n->trigger->handle=dlopen(n->trigger->file,RTLD_LAZY);
+ sprintf(buffer,"module/%s",n->trigger->file);
+
+ if(plugin_exists(buffer,strlen(buffer),buffer1))
+ n->trigger->handle=dlopen(buffer1,RTLD_LAZY);
if(!n->trigger->handle) {
fputs (dlerror(), stderr);
exit(1);
@@ -152,3 +157,32 @@ void do_C_Trigger_cell(struct ent * p, int rw) {
printf ("%d\n", (*function)(p,rw ));
return;
}
+
+
+
+
+int plugin_exists(char *name, int len, char *path)
+{
+ FILE *fp;
+ static char *HomeDir;
+
+ if ((HomeDir = getenv("HOME"))) {
+ strcpy((char *)path, HomeDir);
+ strcat((char *)path, "/.scim/");
+ strncat((char *)path, name, len);
+ if ((fp = fopen((char *)path, "r"))) {
+ fclose(fp);
+ return 1;
+ }
+ }
+ strcpy((char *)path, HELP_PATH);
+ strcat((char *)path, "/");
+ strncat((char *)path, name, len);
+ if ((fp = fopen((char *)path, "r"))) {
+ fclose(fp);
+ return 1;
+ }
+ return 0;
+}
+
+