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