version 1.9 | | version 1.10 |
---|
| | |
/* | | /* |
* static char *rcsid_plugins_c = | | * static char *rcsid_plugins_c = |
* "$Id: plugins.c,v 1.9 2001/11/13 08:14:26 mwedel Exp $"; | | * "$Id: plugins.c,v 1.10 2001/11/16 03:34:00 michtoen Exp $"; |
*/ | | */ |
| | |
/*****************************************************************************/ | | /*****************************************************************************/ |
| | |
char buf[MAX_BUF]; | | char buf[MAX_BUF]; |
char buf2[MAX_BUF]; | | char buf2[MAX_BUF]; |
| | |
printf("Now initializing plugins\n"); | | LOG(llevInfo,"Now initializing plugins\n"); |
strcpy(buf,DATADIR); | | strcpy(buf,DATADIR); |
strcat(buf,"/plugins/"); | | strcat(buf,"/plugins/"); |
printf("Plugins directory is %s\n",buf); | | LOG(llevInfo,"Plugins directory is %s\n",buf); |
| | |
plugdir = opendir(buf); | | plugdir = opendir(buf); |
| | |
| | |
{ | | { |
strcpy(buf2,buf); | | strcpy(buf2,buf); |
strcat(buf2,currentfile->d_name); | | strcat(buf2,currentfile->d_name); |
printf("Registering plugin %s\n",currentfile->d_name); | | LOG(llevInfo,"Registering plugin %s\n",currentfile->d_name); |
initOnePlugin(buf2); | | initOnePlugin(buf2); |
} | | } |
} | | } |
| | |
{ | | { |
CFParm* InitParm; | | CFParm* InitParm; |
InitParm = PlugList[PlugNR].initfunc(NULL); | | InitParm = PlugList[PlugNR].initfunc(NULL); |
printf("Plugin name: %s, known as %s\n", | | LOG(llevInfo,"Plugin name: %s, known as %s\n", |
(char *)(InitParm->Value[1]), | | (char *)(InitParm->Value[1]), |
(char *)(InitParm->Value[0]) | | (char *)(InitParm->Value[0]) |
); | | ); |
| | |
/* Then we copy the rest on the list back one position */ | | /* Then we copy the rest on the list back one position */ |
PlugNR--; | | PlugNR--; |
if (plid==31) return; | | if (plid==31) return; |
printf("plid=%i, PlugNR=%i\n",plid,PlugNR); | | LOG(llevInfo,"plid=%i, PlugNR=%i\n",plid,PlugNR); |
for (j=plid+1;j<32;j++) | | for (j=plid+1;j<32;j++) |
{ | | { |
PlugList[j-1] = PlugList[j]; | | PlugList[j-1] = PlugList[j]; |
| | |
CFParm* HookParm; | | CFParm* HookParm; |
if ((ptr=dlopen(pluginfile,RTLD_NOW|RTLD_GLOBAL))==NULL) | | if ((ptr=dlopen(pluginfile,RTLD_NOW|RTLD_GLOBAL))==NULL) |
{ | | { |
printf("Plugin error: %s\n", dlerror()); | | LOG(llevInfo,"Plugin error: %s\n", dlerror()); |
return; | | return; |
}; | | }; |
PlugList[PlugNR].libptr = ptr; | | PlugList[PlugNR].libptr = ptr; |
PlugList[PlugNR].initfunc = (f_plugin)(dlsym(ptr,"initPlugin")); | | PlugList[PlugNR].initfunc = (f_plugin)(dlsym(ptr,"initPlugin")); |
if (PlugList[PlugNR].initfunc==NULL) | | if (PlugList[PlugNR].initfunc==NULL) |
{ | | { |
printf("Plugin init error: %s\n", dlerror()); | | LOG(llevInfo,"Plugin init error: %s\n", dlerror()); |
} | | } |
else | | else |
{ | | { |
| | |
PlugList[PlugNR].eventfunc = (f_plugin)(dlsym(ptr,"triggerEvent")); | | PlugList[PlugNR].eventfunc = (f_plugin)(dlsym(ptr,"triggerEvent")); |
PlugList[PlugNR].pinitfunc = (f_plugin)(dlsym(ptr,"postinitPlugin")); | | PlugList[PlugNR].pinitfunc = (f_plugin)(dlsym(ptr,"postinitPlugin")); |
PlugList[PlugNR].propfunc = (f_plugin)(dlsym(ptr,"getPluginProperty")); | | PlugList[PlugNR].propfunc = (f_plugin)(dlsym(ptr,"getPluginProperty")); |
printf("Done\n"); | | LOG(llevInfo,"Done\n"); |
if (PlugList[PlugNR].pinitfunc==NULL) | | if (PlugList[PlugNR].pinitfunc==NULL) |
{ | | { |
printf("Plugin postinit error: %s\n", dlerror()); | | LOG(llevInfo,"Plugin postinit error: %s\n", dlerror()); |
} | | } |
| | |
for(i=0;i<NR_EVENTS;i++) | | for(i=0;i<NR_EVENTS;i++) |
| | |
}; | | }; |
if (PlugList[PlugNR].hookfunc==NULL) | | if (PlugList[PlugNR].hookfunc==NULL) |
{ | | { |
printf("Plugin hook error: %s\n", dlerror()); | | LOG(llevInfo,"Plugin hook error: %s\n", dlerror()); |
} | | } |
else | | else |
{ | | { |
| | |
CFParm *CFP; | | CFParm *CFP; |
static int val; | | static int val; |
CFP = (CFParm*)(malloc(sizeof(CFParm))); | | CFP = (CFParm*)(malloc(sizeof(CFParm))); |
printf("CFWFindAnimation: %s\n",(char *)(PParm->Value[0])); | | LOG(llevInfo,"CFWFindAnimation: %s\n",(char *)(PParm->Value[0])); |
val = find_animation((char *)(PParm->Value[0])); | | val = find_animation((char *)(PParm->Value[0])); |
printf("Returned val: %i\n",val); | | LOG(llevInfo,"Returned val: %i\n",val); |
CFP->Value[0] = (void *)(&val); | | CFP->Value[0] = (void *)(&val); |
return CFP; | | return CFP; |
}; | | }; |