2 * Drivers acquiring installation utility
3 * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <glib/gmessages.h>
28 #include <glib/ghash.h>
29 #include <glib/gstrfuncs.h>
33 #include <libgnomevfs/gnome-vfs-init.h>
35 #include <captive/macros.h>
38 #include "captivemodid.h"
39 #include <glib/glist.h>
40 #include "moduriload.h"
45 static int optarg_scan_disks;
46 static GList *optarg_scan_path_list; /* of (char *) */
48 static void acquire_popt_callback
49 (poptContext con,enum poptCallbackReason reason,const struct poptOption *opt,const char *arg,const void *data);
51 static const struct poptOption popt_table[]={
52 { argInfo:POPT_ARG_CALLBACK,arg:(void *)acquire_popt_callback },
54 #define BUG_ACQUIRE_POPT(shortname,longname,argInfoP,argP,valP,descripP,argDescripP) \
56 longName: (longname), \
57 shortName: (shortname), \
58 argInfo: (argInfoP)|(!(valP) ? 0 : POPT_ARG_VAL), \
61 descrip: (descripP), \
62 argDescrip: (argDescripP), \
65 BUG_ACQUIRE_POPT('v',"verbose" ,POPT_ARG_NONE ,&optarg_verbose ,0,N_("Display additional debug information"),NULL),
66 BUG_ACQUIRE_POPT(0 ,"scan-disks",POPT_ARG_NONE ,&optarg_scan_disks,0,N_("Scan all local disks"),NULL),
67 BUG_ACQUIRE_POPT(0 ,"scan-path" ,POPT_ARG_STRING,NULL ,0,N_("Scan specified disk path"),N_("path/URI")),
69 #undef BUG_ACQUIRE_POPT
75 /* poptCallbackType captive_popt_callback */
76 static void acquire_popt_callback
77 (poptContext con,enum poptCallbackReason reason,const struct poptOption *opt,const char *arg,const void *data)
79 g_return_if_fail(reason==POPT_CALLBACK_REASON_OPTION);
81 if (opt->longName && !strcmp(opt->longName,"scan-path")) {
82 optarg_scan_path_list=g_list_append(optarg_scan_path_list,gnome_vfs_uri_new(arg));
87 int main(int argc,char **argv)
93 #ifdef MAINTAINER_MODE
94 g_log_set_always_fatal(~(0
101 /* Initialize the i18n stuff */
102 setlocale(LC_ALL,"");
103 bindtextdomain(PACKAGE,LOCALEDIR);
106 if (!gnome_vfs_init())
107 g_error(_("GnomeVFS failed to initialize"));
109 context=poptGetContext(
111 argc,(/*en-const*/const char **)argv, /* argc,argv */
112 popt_table, /* options */
113 POPT_CONTEXT_POSIXMEHARDER); /* flags; && !POPT_CONTEXT_KEEP_FIRST */
115 g_assert_not_reached(); /* argument recognization args_error */
118 errint=poptReadDefaultConfig(context,
121 g_assert_not_reached(); /* argument recognization args_error */
124 errint=poptGetNextOpt(context);
126 g_assert_not_reached(); /* some non-callbacked argument reached */
129 if (poptPeekArg(context)) {
130 g_error(_("No arguments expected"));
135 scan_uri_list=g_list_concat(scan_uri_list,gnome_vfs_uri_list_copy(optarg_scan_path_list));
136 if (optarg_scan_disks)
137 scan_uri_list=g_list_concat(scan_uri_list,mod_uri_list());
139 captivemodid_load("./w32-mod-id.captivemodid.xml");
140 g_list_foreach(scan_uri_list,(GFunc)mod_uri_load,NULL);
142 gnome_vfs_shutdown();