4 #include <limits.h> /* PATH_MAX */
7 -#define PLUGIN_ENDING ".so"
8 +#define LIBPREFIX "lib"
9 +#define LIBSUFFIX ".so"
12 print_usage(char *pname, FILE *fp)
15 get_plugin_path(char *service, char *buffer, size_t len)
18 - char la_path[PATH_MAX];
22 - (void)snprintf(la_path, PATH_MAX-1, LIBPATH "/lib%s.la", service);
24 - snprintf(command, 1023, ". %s; echo $dlname", la_path);
25 - if((pipe = popen(command, "r")) == NULL)
26 - err(PERR, "popen() failed");
27 - fscanf(pipe, "%255s", lib_name);
29 - if(fclose(pipe) == EOF)
30 - err(PERR, "fclose() failed");
32 - (void)memset(buffer, 0, len);
33 - snprintf(buffer, len-1, LIBPATH"/%s", lib_name);
34 + snprintf(buffer, len-1, LIBPATH "/" LIBPREFIX "%s" LIBSUFFIX, service);
42 +#define SERVICE_MAXLEN 20
44 get_service(DIR *dir, char *buf, size_t size)
47 struct dirent *dir_info;
49 while( (dir_info = readdir(dir)) ) {
50 + char *p = dir_info->d_name;
52 - char *ptr = strstr(dir_info->d_name, ".la");
54 - if(strlen(dir_info->d_name) < 6)
58 - if(!dir_info->d_name[0] == 'l')
60 - if(!dir_info->d_name[1] == 'i')
62 - if(!dir_info->d_name[2] == 'b')
65 - for(n = 0; dir_info->d_name+n+3 != ptr; n++) {
66 - buf[n] = dir_info->d_name[n+3];
71 + if( strlen(p) <= strlen(LIBPREFIX LIBSUFFIX) )
73 + if( strstr(p, LIBPREFIX) != p )
75 + p += strlen(LIBPREFIX);
76 + n = strlen(p) - strlen(LIBSUFFIX);
77 + if( strstr(p + n, LIBSUFFIX) != p + n )
80 + strncpy(buf, p, size);