wok-6.x diff busybox/stuff/busybox-1.12.0-modinfo.u @ rev 5098
add xplc (wvdial new dep)
author | Rohit Joshi <jozee@slitaz.org> |
---|---|
date | Tue Mar 16 11:31:45 2010 +0000 (2010-03-16) |
parents | 85fbd04c1fd6 |
children |
line diff
1.1 --- a/busybox/stuff/busybox-1.12.0-modinfo.u Fri Oct 24 21:24:55 2008 +0000 1.2 +++ b/busybox/stuff/busybox-1.12.0-modinfo.u Tue Mar 16 11:31:45 2010 +0000 1.3 @@ -59,7 +59,7 @@ 1.4 1.5 --- busybox-1.12.0/modutils/modinfo.c 1.6 +++ busybox-1.12.0/modutils/modinfo.c 1.7 -@@ -0,0 +1,82 @@ 1.8 +@@ -0,0 +1,104 @@ 1.9 +/* vi: set sw=4 ts=4: */ 1.10 +/* 1.11 + * modinfo - retrieve module info 1.12 @@ -73,43 +73,66 @@ 1.13 +#include <libbb.h> 1.14 +#include <fnmatch.h> 1.15 + 1.16 ++#define ALL_TAGS 0x3F 1.17 ++ 1.18 +enum { 1.19 -+ ARG_F = (1<<4), /* field name */ 1.20 -+ ARG_0 = (1<<5) /* \0 as separator */ 1.21 ++ ARG_F = (1<<6), /* field name */ 1.22 ++ ARG_0 = (1<<7) /* \0 as separator */ 1.23 +}; 1.24 + 1.25 +struct modinfo_env { 1.26 + char **argv; 1.27 ++ const char **literals; 1.28 + char *field; 1.29 ++ int tags; 1.30 +}; 1.31 + 1.32 ++static int display(char *data, const char *pattern, int flag) 1.33 ++{ 1.34 ++ if (flag) { 1.35 ++ int n = printf("%s:",pattern); 1.36 ++ while (n++ < 16) bb_putchar(' '); 1.37 ++ } 1.38 ++ return printf("%s%c",data, (option_mask32 & ARG_0) ? '\0' : '\n'); 1.39 ++} 1.40 ++ 1.41 +static void modinfo(char *name, char *path, void *env) 1.42 +{ 1.43 + size_t len; 1.44 -+ int i, length; 1.45 ++ int i, j, length; 1.46 + char *ptr, *the_module; 1.47 + char **argv = ((struct modinfo_env *) env)->argv; 1.48 -+ char *field = ((struct modinfo_env *) env)->field; 1.49 ++ const char **literals = ((struct modinfo_env *) env)->literals; 1.50 ++ const char *field = ((struct modinfo_env *) env)->field; 1.51 ++ int tags = ((struct modinfo_env *) env)->tags; 1.52 + extern void *xalloc_load_module(const char filename[], size_t *len); 1.53 + 1.54 + for (i = 0; argv[i]; i++) { 1.55 + if (fnmatch(argv[i],name,0) == 0) { 1.56 ++ if (tags & 1) { /* filename */ 1.57 ++ display(path,literals[0],1 != tags); 1.58 ++ } 1.59 + len = MAXINT(ssize_t); 1.60 -+ ptr = the_module = xalloc_load_module(path, &len); 1.61 -+ length = strlen(field); 1.62 -+ do { 1.63 -+ ptr = memchr(ptr, *field, len - (ptr - (char*)the_module)); 1.64 -+ if (ptr == NULL) /* no occurance left, done */ 1.65 -+ break; 1.66 -+ if (!strncmp(ptr, field, length) && ptr[length] == '=') { 1.67 -+ ptr += length + 1; 1.68 -+ ptr += printf("%s%c",ptr, 1.69 -+ (option_mask32 & ARG_0) ? '\0' : '\n'); 1.70 -+ } 1.71 -+ ++ptr; 1.72 -+ } while (1); 1.73 ++ the_module = xalloc_load_module(path, &len); 1.74 ++ if (field) tags |= ALL_TAGS+1; 1.75 ++ for (j = 1; (1<<j) & (ALL_TAGS+ALL_TAGS+1); j++) { 1.76 ++ const char *pattern = field; 1.77 ++ if ((1<<j) & ALL_TAGS) pattern = literals[j]; 1.78 ++ if (!((1<<j) & tags)) continue; 1.79 ++ length = strlen(pattern); 1.80 ++ ptr = the_module; 1.81 ++ do { 1.82 ++ ptr = memchr(ptr, *pattern, len - (ptr - (char*)the_module)); 1.83 ++ if (ptr == NULL) /* no occurance left, done */ 1.84 ++ break; 1.85 ++ if (!strncmp(ptr, pattern, length) && ptr[length] == '=') { 1.86 ++ ptr += length + 1; 1.87 ++ ptr += display(ptr,pattern,(1<<j) != tags); 1.88 ++ } 1.89 ++ ++ptr; 1.90 ++ } while (1); 1.91 ++ } 1.92 + free(the_module); 1.93 -+ break; 1.94 + } 1.95 + } 1.96 +} 1.97 @@ -118,25 +141,24 @@ 1.98 +int modinfo_main(int argc UNUSED_PARAM, char **argv) 1.99 +{ 1.100 + static const char *shortcuts[] = { 1.101 ++ "filename", 1.102 ++ "description", 1.103 + "author", 1.104 -+ "description", 1.105 + "license", 1.106 -+ "parm" 1.107 ++ "vermagic", 1.108 ++ "parm", 1.109 + }; 1.110 -+ int i; 1.111 + struct modinfo_env env; 1.112 + extern void mod_walk(void (*action)(char *name, char *path, void *env), 1.113 + void *data); 1.114 + 1.115 + env.field = NULL; 1.116 -+ getopt32(argv, "adlpF:0", &env.field); 1.117 ++ env.literals = shortcuts; 1.118 ++ getopt32(argv, "fdalvpF:0", &env.field); 1.119 + env.argv = argv += optind; 1.120 ++ env.tags = (option_mask32) ? option_mask32 & ALL_TAGS : ALL_TAGS; 1.121 + 1.122 -+ for (i = 0; i < sizeof(shortcuts)/sizeof(shortcuts[0]); i++) 1.123 -+ if (option_mask32 & (1 << i)) 1.124 -+ env.field = (char *) shortcuts[i]; 1.125 -+ 1.126 -+ if (!env.field || !*env.argv) 1.127 ++ if (!*env.argv) 1.128 + bb_show_usage(); 1.129 + 1.130 + mod_walk(modinfo, &env);