Use 'inline', not 'INLINE'.
[bpt/emacs.git] / src / msdos.c
index f6ac1d3..73804df 100644 (file)
@@ -81,6 +81,9 @@ extern int spawnve (int, const char *, char *const [], char *const []);
 #include <signal.h>
 #include "syssignal.h"
 
+#include "careadlinkat.h"
+#include "allocator.h"
+
 #ifndef SYSTEM_MALLOC
 
 #ifdef GNU_MALLOC
@@ -284,7 +287,7 @@ mouse_button_depressed (int b, int *xp, int *yp)
 void
 mouse_get_pos (FRAME_PTR *f, int insist, Lisp_Object *bar_window,
               enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y,
-              unsigned long *time)
+              Time *time)
 {
   int ix, iy;
   Lisp_Object frame, tail;
@@ -839,11 +842,12 @@ IT_set_face (int face)
 
 /* According to RBIL (INTERRUP.A, V-1000), 160 is the maximum possible
    width of a DOS display in any known text mode.  We multiply by 2 to
-   accomodate the screen attribute byte.  */
+   accommodate the screen attribute byte.  */
 #define MAX_SCREEN_BUF 160*2
 
 extern unsigned char *encode_terminal_code (struct glyph *, int,
                                            struct coding_system *);
+
 static void
 IT_write_glyphs (struct frame *f, struct glyph *str, int str_len)
 {
@@ -1389,8 +1393,6 @@ IT_delete_glyphs (struct frame *f, int n)
 void
 x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
 {
-  extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
-
   set_menu_bar_lines (f, value, oldval);
 }
 
@@ -2810,7 +2812,7 @@ dos_keyread (void)
    left), but I don't think it's worth the effort.  */
 
 /* These hold text of the current and the previous menu help messages.  */
-static char *menu_help_message, *prev_menu_help_message;
+static const char *menu_help_message, *prev_menu_help_message;
 /* Pane number and item number of the menu item which generated the
    last menu help message.  */
 static int menu_help_paneno, menu_help_itemno;
@@ -2837,7 +2839,7 @@ IT_menu_make_room (XMenu *menu)
       menu->text = (char **) xmalloc (count * sizeof (char *));
       menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *));
       menu->panenumber = (int *) xmalloc (count * sizeof (int));
-      menu->help_text = (char **) xmalloc (count * sizeof (char *));
+      menu->help_text = (const char **) xmalloc (count * sizeof (char *));
     }
   else if (menu->allocated == menu->count)
     {
@@ -2849,7 +2851,7 @@ IT_menu_make_room (XMenu *menu)
       menu->panenumber
        = (int *) xrealloc (menu->panenumber, count * sizeof (int));
       menu->help_text
-       = (char **) xrealloc (menu->help_text, count * sizeof (char *));
+       = (const char **) xrealloc (menu->help_text, count * sizeof (char *));
     }
 }
 
@@ -3000,17 +3002,17 @@ XMenuCreate (Display *foo1, Window foo2, char *foo3)
    to do.  */
 
 int
-XMenuAddPane (Display *foo, XMenu *menu, char *txt, int enable)
+XMenuAddPane (Display *foo, XMenu *menu, const char *txt, int enable)
 {
   int len;
-  char *p;
+  const char *p;
 
   if (!enable)
     abort ();
 
   IT_menu_make_room (menu);
   menu->submenu[menu->count] = IT_menu_create ();
-  menu->text[menu->count] = txt;
+  menu->text[menu->count] = (char *)txt;
   menu->panenumber[menu->count] = ++menu->panecount;
   menu->help_text[menu->count] = NULL;
   menu->count++;
@@ -3031,7 +3033,7 @@ XMenuAddPane (Display *foo, XMenu *menu, char *txt, int enable)
 
 int
 XMenuAddSelection (Display *bar, XMenu *menu, int pane,
-                  int foo, char *txt, int enable, char *help_text)
+                  int foo, char *txt, int enable, char const *help_text)
 {
   int len;
   char *p;
@@ -3084,7 +3086,7 @@ struct IT_menu_state
 int
 XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
               int x0, int y0, unsigned ButtonMask, char **txt,
-              void (*help_callback)(char *, int, int))
+              void (*help_callback)(char const *, int, int))
 {
   struct IT_menu_state *state;
   int statecount, x, y, i, b, screensize, leave, result, onepane;
@@ -3934,6 +3936,41 @@ readlink (const char *name, char *dummy1, size_t dummy2)
 }
 #endif
 
+char *
+careadlinkat (int fd, char const *filename,
+              char *buffer, size_t buffer_size,
+              struct allocator const *alloc,
+              ssize_t (*preadlinkat) (int, char const *, char *, size_t))
+{
+  if (!buffer)
+    {
+      /* We don't support the fancy auto-allocation feature.  */
+      if (!buffer_size)
+       errno = ENOSYS;
+      else
+       errno = EINVAL;
+      buffer = NULL;
+    }
+  else
+    {
+      ssize_t len = preadlinkat (fd, filename, buffer, buffer_size);
+
+      if (len < 0 || len == buffer_size)
+       buffer = NULL;
+      else
+       buffer[len + 1] = '\0';
+    }
+  return buffer;
+}
+
+ssize_t
+careadlinkatcwd (int fd, char const *filename, char *buffer,
+                 size_t buffer_size)
+{
+  (void) fd;
+  return readlink (filename, buffer, buffer_size);
+}
+
 \f
 #if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2
 
@@ -4248,4 +4285,3 @@ This variable is used only by MS-DOS terminals.  */);
 }
 
 #endif /* MSDOS */
-