diff -up nspluginwrapper-1.4.0/src/npw-config.c.dir nspluginwrapper-1.4.0/src/npw-config.c --- nspluginwrapper-1.4.0/src/npw-config.c.dir 2011-05-15 21:35:06.000000000 +0200 +++ nspluginwrapper-1.4.0/src/npw-config.c 2011-05-16 08:43:22.217437588 +0200 @@ -41,10 +41,14 @@ #include +#include + static bool g_auto = false; static bool g_verbose = false; static bool g_allow_native = false; static const char NPW_CONFIG[] = "nspluginwrapper"; +static char *p_plugin_dir = NULL; +static char *p_plugin_prefix = NULL; static void error(const char *format, ...) { @@ -650,7 +654,9 @@ static int do_install_plugin(const char plugin_base += 1; char d_plugin_path[PATH_MAX]; - int n = snprintf(d_plugin_path, sizeof(d_plugin_path), "%s/%s.%s", plugin_dir, NPW_WRAPPER_BASE, plugin_base); + int n = snprintf(d_plugin_path, sizeof(d_plugin_path), + "%s/%s.%s", plugin_dir, p_plugin_prefix ? p_plugin_prefix : NPW_WRAPPER_BASE, + plugin_base); if (n < 0 || n >= sizeof(d_plugin_path)) return 3; @@ -743,6 +749,10 @@ static int install_plugin(const char *pl if (g_verbose) printf("Install plugin %s\n", plugin_path); + if(p_plugin_dir) { + ret = do_install_plugin(plugin_path, p_plugin_dir, plugin_info); + } + else { // don't install plugin system-wide if it is only accessible by root if (!is_root_only_accessible_plugin(plugin_path)) { ret = do_install_plugin(plugin_path, get_system_mozilla_plugin_dir(), plugin_info); @@ -765,6 +775,7 @@ static int install_plugin(const char *pl ret = do_install_plugin(plugin_path, user_plugin_dir, plugin_info); if (ret == 0) return 0; + } return ret; } @@ -936,6 +947,8 @@ static void print_usage(void) printf(" -h --help print this message\n"); printf(" -v --verbose flag: set verbose mode\n"); printf(" -a --auto flag: set automatic mode for plugins discovery\n"); + printf(" -d --dir plugin-dir flag: target plugin(s) directory\n"); + printf(" -p --prefix prefix flag: a prefix of wrapped plugin file\n"); printf(" -n --native flag: allow native plugin(s) to be wrapped\n"); printf(" -l --list list plugins currently installed\n"); printf(" -u --update [FILE(S)] update plugin(s) currently installed\n"); @@ -968,6 +981,18 @@ static int process_native(int argc, char return 0; } +static int process_dir(int argc, char *argv[]) +{ + p_plugin_dir = argv[0]; + return 0; +} + +static int process_prefix(int argc, char *argv[]) +{ + p_plugin_prefix = argv[0]; + return 0; +} + static int process_list(int argvc, char *argv[]) { const char **plugin_dirs = get_mozilla_plugin_dirs(); @@ -1063,57 +1088,56 @@ static int process_remove(int argc, char int main(int argc, char *argv[]) { - char **args; - int i, j, n_args; - - n_args = argc - 1; - args = argv + 1; + int i, j; - if (n_args < 1) { + if (argc < 2) { print_usage(); return 1; } - - if (args[0][0] != '-') { - print_usage(); - return 1; + + if (argv[1][0] != '-') { + print_usage(); + return 1; } - + static const struct option { - char short_option; - const char *long_option; - int (*process_callback)(int argc, char *argv[]); - bool terminal; + const char *short_option; + const char *long_option; + int (*process_callback)(int argc, char *argv[]); + bool terminal; + int extra_args; } options[] = { - { 'h', "help", process_help, 1 }, - { 'v', "verbose", process_verbose, 0 }, - { 'a', "auto", process_auto, 0 }, - { 'n', "native", process_native, 0 }, - { 'l', "list", process_list, 1 }, - { 'u', "update", process_update, 1 }, - { 'i', "install", process_install, 1 }, - { 'r', "remove", process_remove, 1 }, - { 0, NULL, NULL, 1 } - }; - - for (i = 0; i < n_args; i++) { - const char *arg = args[i]; + { "-h", "--help", process_help, 1, 0 }, + { "-v", "--verbose", process_verbose, 0, 0 }, + { "-a", "--auto", process_auto, 0, 0 }, + { "-d", "--dir", process_dir, 0, 1 }, + { "-p", "--prefix", process_prefix, 0, 1 }, + { "-n", "--native", process_native, 0, 0 }, + { "-l", "--list", process_list, 1, 0 }, + { "-u", "--update", process_update, 1, 0 }, + { "-i", "--install", process_install, 1, 0 }, + { "-r", "--remove", process_remove, 1, 0 } + }; + + for (i = 1; i < argc; i++) { const struct option *opt = NULL; - for (j = 0; opt == NULL && options[j].process_callback != NULL; j++) { - if ((arg[0] == '-' && arg[1] == options[j].short_option && arg[2] == '\0') || - (arg[0] == '-' && arg[1] == '-' && strcmp(&arg[2], options[j].long_option) == 0)) - opt = &options[j]; - } - if (opt == NULL) { - fprintf(stderr, "invalid option %s\n", arg); - print_usage(); - return 1; - } - int ret = opt->process_callback(n_args - i - 1, args + i + 1); - if (opt->terminal) - return ret; + for (j = 0; j < sizeof(options)/sizeof(options[0]); j++) { + if (!strcmp(options[j].short_option,argv[i]) || !strcmp(options[j].long_option,argv[i])) { + opt = &options[j]; + break; + } + } + if (opt == NULL) { + fprintf(stderr, "invalid option %s\n", argv[i]); + print_usage(); + return 1; + } + int ret = opt->process_callback(argc - i - 1, argv + i + 1); + if (opt->terminal) + return ret; + i += opt->extra_args; } - + return 0; } diff -up nspluginwrapper-1.4.0/src/npw-viewer.sh.dir nspluginwrapper-1.4.0/src/npw-viewer.sh --- nspluginwrapper-1.4.0/src/npw-viewer.sh.dir 2011-05-15 21:35:06.000000000 +0200 +++ nspluginwrapper-1.4.0/src/npw-viewer.sh 2011-05-16 08:10:05.185367523 +0200 @@ -100,6 +100,9 @@ if test "$ARCH" != "$TARGET_ARCH"; then NPW_USE_XSHM="no" fi ;; + x86_64) + LOADER="" + ;; ppc) if test "$ARCH" = "ppc64"; then case "$OS" in