+/* Emulation of some X window features from xfns.c and xfaces.c. */
+
+/* Standard VGA colors, in the order of their standard numbering
+ in the default VGA palette. */
+static char *vga_colors[16] = {
+ "black", "blue", "green", "cyan", "red", "magenta", "brown",
+ "lightgray", "darkgray", "lightblue", "lightgreen", "lightcyan",
+ "lightred", "lightmagenta", "yellow", "white"
+};
+
+/* Given a color name, return its index, or -1 if not found. Note
+ that this only performs case-insensitive comparison against the
+ standard names. For anything more sophisticated, like matching
+ "gray" with "grey" or translating X color names into their MSDOS
+ equivalents, call the Lisp function Qtty_color_desc (defined
+ on lisp/term/tty-colors.el). */
+int
+msdos_stdcolor_idx (const char *name)
+{
+ int i;
+
+ for (i = 0; i < sizeof (vga_colors) / sizeof (vga_colors[0]); i++)
+ if (strcasecmp (name, vga_colors[i]) == 0)
+ return i;
+
+ return
+ strcmp (name, unspecified_fg) == 0 ? FACE_TTY_DEFAULT_FG_COLOR
+ : strcmp (name, unspecified_bg) == 0 ? FACE_TTY_DEFAULT_BG_COLOR
+ : FACE_TTY_DEFAULT_COLOR;
+}
+
+/* Given a color index, return its standard name. */
+Lisp_Object
+msdos_stdcolor_name (int idx)
+{
+ extern Lisp_Object Qunspecified;
+
+ if (idx == FACE_TTY_DEFAULT_FG_COLOR)
+ return build_string (unspecified_fg);
+ else if (idx == FACE_TTY_DEFAULT_BG_COLOR)
+ return build_string (unspecified_bg);
+ else if (idx >= 0 && idx < sizeof (vga_colors) / sizeof (vga_colors[0]))
+ return build_string (vga_colors[idx]);
+ else
+ return Qunspecified; /* meaning the default */
+}
+
+/* Support for features that are available when we run in a DOS box
+ on MS-Windows. */
+int
+ms_windows_version (void)
+{
+ return dos_windows_version;
+}
+
+/* Set the title of the current virtual machine, to appear on
+ the caption bar of that machine's window. */
+
+int
+w95_set_virtual_machine_title (const char *title_string)
+{
+ /* Only Windows 9X (version 4 and higher) support this function. */
+ if (!NILP (Vdos_windows_version)
+ && (dos_windows_version & 0xff) >= 4)
+ {
+ _go32_dpmi_registers regs;
+ dosmemput (title_string, strlen (title_string) + 1, __tb);
+ regs.x.ax = 0x168e;
+ regs.x.dx = 1;
+ regs.x.es = __tb >> 4;
+ regs.x.di = __tb & 15;
+ regs.x.sp = regs.x.ss = regs.x.flags = 0;
+ _go32_dpmi_simulate_int (0x2f, ®s);
+ return regs.x.ax == 1;
+ }
+ return 0;
+}
+
+/* Change the title of frame F to NAME.
+ If NAME is nil, use the frame name as the title.
+
+ If Emacs is not run from a DOS box on Windows 9X, this only
+ sets the name in the frame struct, but has no other effects. */
+
+void
+x_set_title (f, name)
+ struct frame *f;
+ Lisp_Object name;
+{
+ /* Don't change the title if it's already NAME. */
+ if (EQ (name, f->title))
+ return;
+
+ update_mode_lines = 1;
+
+ f->title = name;
+
+ if (NILP (name))
+ name = f->name;
+
+ if (FRAME_MSDOS_P (f))
+ {
+ BLOCK_INPUT;
+ w95_set_virtual_machine_title (SDATA (name));
+ UNBLOCK_INPUT;
+ }
+}
+#endif /* !HAVE_X_WINDOWS */
+\f
+DEFUN ("file-system-info", Ffile_system_info, Sfile_system_info, 1, 1, 0,
+ doc: /* Return storage information about the file system FILENAME is on.
+Value is a list of floats (TOTAL FREE AVAIL), where TOTAL is the total
+storage of the file system, FREE is the free storage, and AVAIL is the
+storage available to a non-superuser. All 3 numbers are in bytes.
+If the underlying system call fails, value is nil. */)
+ (filename)
+ Lisp_Object filename;
+{
+ struct statfs stfs;
+ Lisp_Object encoded, value;
+
+ CHECK_STRING (filename);
+ filename = Fexpand_file_name (filename, Qnil);
+ encoded = ENCODE_FILE (filename);
+
+ if (statfs (SDATA (encoded), &stfs))
+ value = Qnil;
+ else
+ value = list3 (make_float ((double) stfs.f_bsize * stfs.f_blocks),
+ make_float ((double) stfs.f_bsize * stfs.f_bfree),
+ make_float ((double) stfs.f_bsize * stfs.f_bavail));
+
+ return value;