+ argv_sp=argv+1;
+ if (*argv_sp && (*argv_sp)[0]!='-')
+ image_filename=*argv_sp++;
+ if (*argv_sp && (*argv_sp)[0]!='-')
+ mountpoint=*argv_sp++;
+ if (*argv_sp && !strcmp(*argv_sp,"-n")) {
+ opt_n=TRUE;
+ argv_sp++;
+ }
+ if (*argv_sp && !strcmp(*argv_sp,"-v")) {
+ opt_v=TRUE;
+ argv_sp++;
+ }
+ if (argv_sp[0] && argv_sp[1] && !strcmp(argv_sp[0],"-o")) {
+ argv_sp++;
+ opt_o=*argv_sp++;
+ }
+ if (*argv_sp) {
+ /* Lethal path but still give chance for "--help" etc. */
+ /* Do not: POPT_CONTEXT_POSIXMEHARDER
+ * as mount(8) puts there first un-pre-dashed "ro"/"rw" etc. */
+ if ((context=poptGetContext(
+ PACKAGE, /* name */
+ argc,(/*en-const*/const char **)argv, /* argc,argv */
+ popt_table, /* options */
+ 0))) /* flags; && !POPT_CONTEXT_KEEP_FIRST */
+ while (0<=poptGetNextOpt(context));
+ g_error(_("Excessive argument: %s"),*argv_sp);
+ }
+
+ if (opt_o) {
+char *opt_o_spaced=(char */* de-const; length is not changed */)captive_strdup_alloca(opt_o);
+char *s,quote;
+
+ quote=0;
+ for (s=opt_o_spaced;*s;s++) {
+ /* Be compatible with: poptParseArgvString()
+ * which also does not differentiate '"' and "'" */
+ if (*s=='\\' && s[1]) {
+ s++;
+ continue;
+ }
+ if (quote) {
+ if (*s==quote)
+ quote=0;
+ continue;
+ }
+ switch (*s) {
+ case '"':
+ case '\'':
+ quote=*s;
+ continue;
+ case ',':
+ *s=' ';
+ continue;
+ }
+ }
+ if (poptParseArgvString(opt_o_spaced,&opt_o_argc,&opt_o_argv))
+ g_error(_("Error splitting arguments of the space-reparsed '-o': %s"),opt_o_spaced);
+ /* Pre-dash "ro"/"rw" to let libcaptive to be aware of the mode. */
+ for (csp=opt_o_argv;*csp;csp++) {
+ if (!strcmp(*csp,"ro"))
+ *csp="--ro";
+ if (!strcmp(*csp,"rw"))
+ *csp="--rw";
+ }
+ }
+