a4750516efd2d424cc3046b2b1f2dbbe0924ecc9
[openwrt/svn-archive/archive.git] / net / updatedd / patches / 001-service_libname.patch
1 Index: updatedd-2.6/src/updatedd.c
2 ===================================================================
3 --- updatedd-2.6.orig/src/updatedd.c 2007-09-16 21:00:07.000000000 +0200
4 +++ updatedd-2.6/src/updatedd.c 2007-09-16 21:00:07.000000000 +0200
5 @@ -36,7 +36,8 @@
6 #include <limits.h> /* PATH_MAX */
7 #include "updatedd.h"
8
9 -#define PLUGIN_ENDING ".so"
10 +#define LIBPREFIX "lib"
11 +#define LIBSUFFIX ".so"
12
13 void
14 print_usage(char *pname, FILE *fp)
15 @@ -92,23 +93,7 @@
16 void
17 get_plugin_path(char *service, char *buffer, size_t len)
18 {
19 - FILE *pipe;
20 - char la_path[PATH_MAX];
21 - char lib_name[256];
22 - char command[1024];
23 -
24 - (void)snprintf(la_path, PATH_MAX-1, LIBPATH "/lib%s.la", service);
25 -
26 - snprintf(command, 1023, ". %s; echo $dlname", la_path);
27 - if((pipe = popen(command, "r")) == NULL)
28 - err(PERR, "popen() failed");
29 - fscanf(pipe, "%255s", lib_name);
30 -
31 - if(fclose(pipe) == EOF)
32 - err(PERR, "fclose() failed");
33 -
34 - (void)memset(buffer, 0, len);
35 - snprintf(buffer, len-1, LIBPATH"/%s", lib_name);
36 + snprintf(buffer, len-1, LIBPATH "/" LIBPREFIX "%s" LIBSUFFIX, service);
37 }
38
39 void *
40 @@ -139,6 +124,7 @@
41
42 }
43
44 +#define SERVICE_MAXLEN 20
45 int
46 get_service(DIR *dir, char *buf, size_t size)
47 {
48 @@ -146,26 +132,19 @@
49 struct dirent *dir_info;
50
51 while( (dir_info = readdir(dir)) ) {
52 + char *p = dir_info->d_name;
53 int n;
54 - char *ptr = strstr(dir_info->d_name, ".la");
55 -
56 - if(strlen(dir_info->d_name) < 6)
57 - continue;
58 -
59 - if(ptr != NULL) {
60 - if(!dir_info->d_name[0] == 'l')
61 - continue;
62 - if(!dir_info->d_name[1] == 'i')
63 - continue;
64 - if(!dir_info->d_name[2] == 'b')
65 - continue;
66 -
67 - for(n = 0; dir_info->d_name+n+3 != ptr; n++) {
68 - buf[n] = dir_info->d_name[n+3];
69 - }
70 - buf[n] = '\0';
71 - return 1;
72 - }
73 + if( strlen(p) <= strlen(LIBPREFIX LIBSUFFIX) )
74 + continue;
75 + if( strstr(p, LIBPREFIX) != p )
76 + continue;
77 + p += strlen(LIBPREFIX);
78 + n = strlen(p) - strlen(LIBSUFFIX);
79 + if( strstr(p + n, LIBSUFFIX) != p + n )
80 + continue;
81 + p[n] = 0;
82 + strncpy(buf, p, size);
83 + return 1;
84 }
85
86 return 0;