/* $Id$ * Drivers acquiring installation utility * Copyright (C) 2003 Jan Kratochvil * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; exactly version 2 of June 1991 is required * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "captivemodid.h" #include #include "moduriload.h" #include "diskscan.h" int optarg_verbose; static int optarg_scan_disks; static GList *optarg_scan_path_list; /* of (char *) */ static void acquire_popt_callback (poptContext con,enum poptCallbackReason reason,const struct poptOption *opt,const char *arg,const void *data); static const struct poptOption popt_table[]={ { argInfo:POPT_ARG_CALLBACK,arg:(void *)acquire_popt_callback }, #define BUG_ACQUIRE_POPT(shortname,longname,argInfoP,argP,valP,descripP,argDescripP) \ { \ longName: (longname), \ shortName: (shortname), \ argInfo: (argInfoP)|(!(valP) ? 0 : POPT_ARG_VAL), \ arg: (void *)argP, \ val: (valP), \ descrip: (descripP), \ argDescrip: (argDescripP), \ } BUG_ACQUIRE_POPT('v',"verbose" ,POPT_ARG_NONE ,&optarg_verbose ,0,N_("Display additional debug information"),NULL), BUG_ACQUIRE_POPT(0 ,"scan-disks",POPT_ARG_NONE ,&optarg_scan_disks,0,N_("Scan all local disks"),NULL), BUG_ACQUIRE_POPT(0 ,"scan-path" ,POPT_ARG_STRING,NULL ,0,N_("Scan specified disk path"),N_("path/URI")), #undef BUG_ACQUIRE_POPT POPT_AUTOHELP POPT_TABLEEND }; /* poptCallbackType captive_popt_callback */ static void acquire_popt_callback (poptContext con,enum poptCallbackReason reason,const struct poptOption *opt,const char *arg,const void *data) { g_return_if_fail(reason==POPT_CALLBACK_REASON_OPTION); if (opt->longName && !strcmp(opt->longName,"scan-path")) { optarg_scan_path_list=g_list_append(optarg_scan_path_list,gnome_vfs_uri_new(arg)); } } int main(int argc,char **argv) { poptContext context; int errint; GList *scan_uri_list; #ifdef MAINTAINER_MODE g_log_set_always_fatal(~(0 |G_LOG_LEVEL_MESSAGE |G_LOG_LEVEL_INFO |G_LOG_LEVEL_DEBUG )); #endif /* Initialize the i18n stuff */ setlocale(LC_ALL,""); bindtextdomain(PACKAGE,LOCALEDIR); textdomain(PACKAGE); if (!gnome_vfs_init()) g_error(_("GnomeVFS failed to initialize")); context=poptGetContext( PACKAGE, /* name */ argc,(/*en-const*/const char **)argv, /* argc,argv */ popt_table, /* options */ POPT_CONTEXT_POSIXMEHARDER); /* flags; && !POPT_CONTEXT_KEEP_FIRST */ if (context==NULL) { g_assert_not_reached(); /* argument recognization args_error */ return EXIT_FAILURE; } errint=poptReadDefaultConfig(context, TRUE); /* useEnv */ if (errint!=0) { g_assert_not_reached(); /* argument recognization args_error */ return EXIT_FAILURE; } errint=poptGetNextOpt(context); if (errint!=-1) { g_assert_not_reached(); /* some non-callbacked argument reached */ return EXIT_FAILURE; } if (poptPeekArg(context)) { g_error(_("No arguments expected")); return EXIT_FAILURE; } scan_uri_list=NULL; scan_uri_list=g_list_concat(scan_uri_list,gnome_vfs_uri_list_copy(optarg_scan_path_list)); if (optarg_scan_disks) scan_uri_list=g_list_concat(scan_uri_list,mod_uri_list()); captivemodid_load("./w32-mod-id.captivemodid.xml"); g_list_foreach(scan_uri_list,(GFunc)mod_uri_load,NULL); gnome_vfs_shutdown(); return EXIT_SUCCESS; }