#include <locale.h>
#include <captive/client-vfs.h>
+#include <captive/client.h>
#include "main.h" /* self */
#include "cmd_shell.h"
#include "cmd_close.h"
#include "cmd_quit.h"
#include "cmd_help.h"
+#include "utf8.h"
CaptiveVfsObject *cmdline_captive_vfs_object;
poptContext cmd_context;
int errint;
const char **cmdarg_argv;
-int cmdarg_argc;
-const char **csp;
+int cmdarg_argc,argci;
+const char **csp,*cs;
const char *emptyargv_NULL=NULL;
g_return_if_fail(cmd_argc>=0);
cmd_argv=stub_shell;
}
+ for (argci=0;argci<cmd_argc;argci++) {
+ if ((cs=CMD_LOCALE_TO_UTF8_ALLOCA(cmd_argv[argci])))
+ cmd_argv[argci]=cs;
+ }
+
cmd_name=*cmd_argv;
for (commandp=cmdline_command_table;commandp->name;commandp++) {
if (!cmd_name /* NULL cmd_name fallback to the first table entry - "shell" */
}
if (!commandp->name) {
g_set_error(errp,CMDLINE_MAIN_ERROR,CMDLINE_MAIN_ERROR_UNKNOWN_COMMAND,
- _("Unknown command, try 'help': %s"),cmd_name);
+ _("Unknown command, try 'help': %s"),CMD_LOCALE_FROM_UTF8_ALLOCA(cmd_name));
return;
}
displayArgs_hit=FALSE;
POPT_CONTEXT_POSIXMEHARDER); /* flags; !POPT_CONTEXT_KEEP_FIRST */
if (cmd_context==NULL) {
g_set_error(errp,CMDLINE_MAIN_ERROR,CMDLINE_MAIN_ERROR_INVALID_COMMAND_ARGUMENTS,
- _("Invalid arguments for command: %s"),cmd_name);
+ _("Invalid arguments for command: %s"),CMD_LOCALE_FROM_UTF8_ALLOCA(cmd_name));
return;
}
errint=poptReadDefaultConfig(cmd_context,
TRUE); /* useEnv */
if (errint!=0) {
g_set_error(errp,CMDLINE_MAIN_ERROR,CMDLINE_MAIN_ERROR_READING_COMMAND_CONFIG,
- _("Error '%s' reading default configuration for command: %s"),poptStrerror(errint),cmd_name);
+ _("Error '%s' reading default configuration for command: %s"),
+ poptStrerror(errint),CMD_LOCALE_FROM_UTF8_ALLOCA(cmd_name));
goto err_free_context;
}
errint=poptGetNextOpt(cmd_context);
if (errint!=-1) {
g_set_error(errp,CMDLINE_MAIN_ERROR,CMDLINE_MAIN_ERROR_EXCEEDING_COMMAND_OPTION,
- _("Exceeding command option for command: %s"),cmd_name);
+ _("Exceeding command option for command: %s"),CMD_LOCALE_FROM_UTF8_ALLOCA(cmd_name));
goto err_free_context;
}
if (!(cmdarg_argv=poptGetArgs(cmd_context)))
if (cmdarg_argc<commandp->argsn_min || cmdarg_argc>commandp->argsn_max) {
g_set_error(errp,CMDLINE_MAIN_ERROR,CMDLINE_MAIN_ERROR_INVALID_COMMAND_ARGUMENT_COUNT,
_("Invalid number of command '%s' arguments: %d; expected from %d to %d incl."),
- cmd_name,cmdarg_argc,commandp->argsn_min,commandp->argsn_max);
+ CMD_LOCALE_FROM_UTF8_ALLOCA(cmd_name),cmdarg_argc,commandp->argsn_min,commandp->argsn_max);
goto err_free_context;
}
return FALSE;
}
-static GIOChannel *main_giochannel;
-
void main_exit(void) G_GNUC_NORETURN;
void main_exit(void)
{
g_object_unref(cmdline_captive_vfs_object);
cmdline_captive_vfs_object=NULL;
}
- if (main_giochannel) {
- g_io_channel_unref(main_giochannel);
- main_giochannel=NULL;
- }
exit(EXIT_SUCCESS);
}
* to restart failed children due to communication-failure alarms.
*/
- /* Prevent output block buffering if redirecting stdout to file. */
- setvbuf(stdout,(char *)NULL,_IONBF,0);
- setvbuf(stderr,(char *)NULL,_IONBF,0);
-
- /* Initialize the i18n stuff */
- setlocale(LC_ALL,"");
- bindtextdomain(PACKAGE,LOCALEDIR);
- textdomain(PACKAGE);
-
- /* Initialize GObject subsystem of GLib. */
- g_type_init();
+ captive_standalone_init();
captive_options_init(&options);
captive_options=&options; /* for parsing by 'CAPTIVE_POPT_INCLUDE' */