/* MS-DOS specific Lisp utilities. Coded by Manabu Higashida, 1991.
Major changes May-July 1993 Morten Welinder (only 10% original code left)
- Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1993, 1996, 1997, 1998, 2001
+ Free Software Foundation, Inc.
This file is part of GNU Emacs.
/* The entire file is within this conditional */
#include <stdio.h>
+#include <string.h>
#include <dos.h>
#include "lisp.h"
#include "buffer.h"
#include "window.h"
#include "dosfns.h"
#include "msdos.h"
+#include "dispextern.h"
+#include "charset.h"
+#include "coding.h"
#include <dpmi.h>
#include <go32.h>
#include <dirent.h>
+#include <sys/vfs.h>
#ifndef __DJGPP_MINOR__
# define __tb _go32_info_block.linear_address_of_transfer_buffer;
else
return Qnil;
}
-
-/* Function to translate colour names to integers. See lisp/term/pc-win.el
- for its definition. */
-
-Lisp_Object Qmsdos_color_translate;
#endif
/* Obtain the country code via DPMI, use DJGPP transfer buffer. */
dpmiregs.x.ax = 0x3800;
- dpmiregs.x.ds = xbuf;
+ dpmiregs.x.ds = xbuf >> 4;
dpmiregs.x.dx = 0;
dpmiregs.x.ss = dpmiregs.x.sp = dpmiregs.x.flags = 0;
_go32_dpmi_simulate_int (0x21, &dpmiregs);
}
\f
#ifndef HAVE_X_WINDOWS
+
+/* 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
}
#endif /* !HAVE_X_WINDOWS */
\f
+DEFUN ("file-system-info", Ffile_system_info, Sfile_system_info, 1, 1, 0,
+ "Return storage information about the file system FILENAME is on.\n\
+Value is a list of floats (TOTAL FREE AVAIL), where TOTAL is the total\n\
+storage of the file system, FREE is the free storage, and AVAIL is the\n\
+storage available to a non-superuser. All 3 numbers are in bytes.\n\
+If the underlying system call fails, value is nil.")
+ (filename)
+ Lisp_Object filename;
+{
+ struct statfs stfs;
+ Lisp_Object encoded, value;
+
+ CHECK_STRING (filename, 0);
+ filename = Fexpand_file_name (filename, Qnil);
+ encoded = ENCODE_FILE (filename);
+
+ if (statfs (XSTRING (encoded)->data, &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;
+}
+\f
void
dos_cleanup (void)
{
#ifndef HAVE_X_WINDOWS
restore_parent_vm_title ();
#endif
+ /* Make sure the termscript file is committed, in case we are
+ crashing and some vital info was written there. */
+ if (termscript)
+ {
+ fflush (termscript);
+ fsync (fileno (termscript));
+ }
}
/*
defsubr (&Smsdos_set_keyboard);
defsubr (&Sinsert_startup_screen);
defsubr (&Smsdos_mouse_disable);
+ defsubr (&Sfile_system_info);
#ifndef HAVE_X_WINDOWS
defsubr (&Smsdos_mouse_p);
- Qmsdos_color_translate = intern ("msdos-color-translate");
- staticpro (&Qmsdos_color_translate);
#endif
DEFVAR_INT ("dos-country-code", &dos_country_code,
865 Norway/Denmark");
DEFVAR_INT ("dos-timezone-offset", &dos_timezone_offset,
- "The current timezone offset to UTC in minutes.
+ "The current timezone offset to UTC in minutes.\n\
Implicitly modified when the TZ variable is changed.");
DEFVAR_LISP ("dos-version", &Vdos_version,