/[gentoo-projects]/pax-utils/scanelf.c
Gentoo

Diff of /pax-utils/scanelf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.142 Revision 1.143
1/* 1/*
2 * Copyright 2003-2006 Gentoo Foundation 2 * Copyright 2003-2006 Gentoo Foundation
3 * Distributed under the terms of the GNU General Public License v2 3 * Distributed under the terms of the GNU General Public License v2
4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.142 2006/05/10 22:45:08 kevquinn Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.143 2006/05/11 05:44:22 solar Exp $
5 * 5 *
6 * Copyright 2003-2006 Ned Ludd - <solar@gentoo.org> 6 * Copyright 2003-2006 Ned Ludd - <solar@gentoo.org>
7 * Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org> 7 * Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org>
8 */ 8 */
9 9
13#endif 13#endif
14#if defined(__FreeBSD__) || defined(__DragonFly__) 14#if defined(__FreeBSD__) || defined(__DragonFly__)
15 #include <elf-hints.h> 15 #include <elf-hints.h>
16#endif 16#endif
17 17
18static const char *rcsid = "$Id: scanelf.c,v 1.142 2006/05/10 22:45:08 kevquinn Exp $"; 18static const char *rcsid = "$Id: scanelf.c,v 1.143 2006/05/11 05:44:22 solar Exp $";
19#define argv0 "scanelf" 19#define argv0 "scanelf"
20 20
21#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') 21#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+')
22 22
23#define do_state(option, flag) \ 23#define do_state(option, flag) \
138 * if the file is listed */ 138 * if the file is listed */
139static int file_matches_list(const char *filename, char **matchlist) { 139static int file_matches_list(const char *filename, char **matchlist) {
140 char **file; 140 char **file;
141 char *match; 141 char *match;
142 char buf[__PAX_UTILS_PATH_MAX]; 142 char buf[__PAX_UTILS_PATH_MAX];
143
143 if (matchlist!=NULL) { 144 if (matchlist == NULL)
144 for (file=matchlist; 145 return 0;
145 *file!=NULL; 146
146 file++) { 147 for (file = matchlist; *file != NULL; file++) {
147 if (search_path) { 148 if (search_path) {
148 snprintf(buf,__PAX_UTILS_PATH_MAX,"%s%s",search_path,*file); 149 snprintf(buf,__PAX_UTILS_PATH_MAX, "%s%s", search_path, *file);
149 match=buf; 150 match=buf;
150 } else { 151 } else {
151 match=*file; 152 match=*file;
152 } 153 }
153 if (fnmatch(match, filename, 0) == 0) 154 if (fnmatch(match, filename, 0) == 0)
154 return 1; /* TRUE */ 155 return 1; /* TRUE */
155 }
156 } 156 }
157 return 0; /* FALSE */ 157 return 0; /* FALSE */
158} 158}
159 159
160/* sub-funcs for scanelf_file() */ 160/* sub-funcs for scanelf_file() */
1330 if (len >= sizeof(buf)) { 1330 if (len >= sizeof(buf)) {
1331 warnf("Skipping '%s': len > sizeof(buf); %lu > %lu\n", path, 1331 warnf("Skipping '%s': len > sizeof(buf); %lu > %lu\n", path,
1332 (unsigned long)len, (unsigned long)sizeof(buf)); 1332 (unsigned long)len, (unsigned long)sizeof(buf));
1333 continue; 1333 continue;
1334 } 1334 }
1335 sprintf(buf, "%s%s%s", path, path[pathlen-1]=='/'?"":"/", dentry->d_name); 1335 snprintf(buf, sizeof(buf), "%s%s%s", path, (path[pathlen-1] == '/') ? "" : "/", dentry->d_name);
1336 if (lstat(buf, &st) != -1) { 1336 if (lstat(buf, &st) != -1) {
1337 if (S_ISREG(st.st_mode)) 1337 if (S_ISREG(st.st_mode))
1338 scanelf_file(buf); 1338 scanelf_file(buf);
1339 else if (dir_recurse && S_ISDIR(st.st_mode)) { 1339 else if (dir_recurse && S_ISDIR(st.st_mode)) {
1340 if (dir_crossmount || (st_top.st_dev == st.st_dev)) 1340 if (dir_crossmount || (st_top.st_dev == st.st_dev))
1841 if (ldcache != 0) 1841 if (ldcache != 0)
1842 munmap(ldcache, ldcache_size); 1842 munmap(ldcache, ldcache_size);
1843} 1843}
1844 1844
1845static char **get_split_env(const char *envvar) { 1845static char **get_split_env(const char *envvar) {
1846 char **envvals=NULL; 1846 char **envvals = NULL;
1847 char *saveptr=NULL; 1847 char *saveptr = NULL;
1848 char *env; 1848 char *env;
1849 char *s; 1849 char *s;
1850 int nentry; 1850 int nentry;
1851 1851
1852 env=getenv(envvar); 1852 if ((env = getenv(envvar)) == NULL)
1853 if (env==NULL) return NULL; 1853 return NULL;
1854 1854
1855 env=xstrdup(env); 1855 env = xstrdup(env);
1856 if (env==NULL) return NULL; 1856 if (env == NULL)
1857 return NULL;
1857 1858
1858 nentry=0; 1859 nentry = 0;
1859 for (s=strtok_r(env, " \t\n", &saveptr); 1860 for (s = strtok_r(env, " \t\n", &saveptr); s != NULL; s = strtok_r(NULL, " \t\n", &saveptr)) {
1860 s!=NULL;
1861 s=strtok_r(NULL, " \t\n", &saveptr)) {
1862 envvals=xrealloc(envvals, sizeof(char *)*(nentry+1)); 1861 if ((envvals = xrealloc(envvals, sizeof(char *)*(nentry+1))) == NULL)
1863 if (envvals==NULL) return NULL; 1862 return NULL;
1864 envvals[nentry++]=s; 1863 envvals[nentry++] = s;
1865 } 1864 }
1866 envvals[nentry]=NULL; 1865 envvals[nentry] = NULL;
1867 1866
1868 return envvals; 1867 return envvals;
1869} 1868}
1870 1869
1871static void parseenv() { 1870static void parseenv() {

Legend:
Removed from v.1.142  
changed lines
  Added in v.1.143

  ViewVC Help
Powered by ViewVC 1.1.20