#include <sys/types.h>
#include <sys/wait.h>
#include <locale.h>
+#include <langinfo.h>
#include <termios.h>
#ifdef HAVE_LIBREADLINE
char *mountpoint;
};
+static void set_up_terminal (void);
static char add_drives (struct drv *drv, char next_drive);
static void prepare_drives (struct drv *drv);
static void mount_mps (struct mp *mp);
int keys_from_stdin = 0;
const char *libvirt_uri = NULL;
int inspector = 0;
+int utf8_mode = 0;
+int have_terminfo = 0;
static void __attribute__((noreturn))
usage (int status)
bindtextdomain (PACKAGE, LOCALEBASEDIR);
textdomain (PACKAGE);
+ set_up_terminal ();
+
enum { HELP_OPTION = CHAR_MAX + 1 };
static const char *options = "a:c:d:Df:h::im:nN:rv?Vx";
exit (EXIT_SUCCESS);
}
+/* The <term.h> header file which defines this has "issues". */
+extern int tgetent (char *, const char *);
+
+static void
+set_up_terminal (void)
+{
+ /* http://www.cl.cam.ac.uk/~mgk25/unicode.html#activate */
+ utf8_mode = STREQ (nl_langinfo (CODESET), "UTF-8");
+
+ char *term = getenv ("TERM");
+ if (term == NULL) {
+ //fprintf (stderr, _("guestfish: TERM (terminal type) not defined.\n"));
+ return;
+ }
+
+ int r = tgetent (NULL, term);
+ if (r == -1) {
+ fprintf (stderr, _("guestfish: could not access termcap or terminfo database.\n"));
+ return;
+ }
+ if (r == 0) {
+ fprintf (stderr, _("guestfish: terminal type \"%s\" not defined.\n"),
+ term);
+ return;
+ }
+
+ have_terminfo = 1;
+}
+
void
pod2text (const char *name, const char *shortdesc, const char *str)
{
extern int quit;
extern int verbose;
extern int command_num;
+extern int utf8_mode;
+extern int have_terminfo;
extern const char *libvirt_uri;
extern int issue_command (const char *cmd, char *argv[], const char *pipe);
extern void pod2text (const char *name, const char *shortdesc, const char *body);