]> code.delx.au - gnu-emacs/blobdiff - src/hftctl.c
*** empty log message ***
[gnu-emacs] / src / hftctl.c
index 6ba1e2fb7fd59e5214496426ebd6d2bbdaf28064..0609f840e2063d55697c13cbfc64067fe2c165a2 100644 (file)
@@ -20,7 +20,7 @@
 /*      2. places fildes into raw mode                         */
 /*      3. converts ioctl arguments to datastream              */
 /*      4. waits for 2 secs for acknowledgement before         */
-/*         timimg out.                                         */
+/*         timing out.                                         */
 /*      5. places response in callers buffer ( just like       */
 /*         ioctl.                                              */
 /*      6. returns fildes to its original mode                 */
 /*                                                             */
 /***************************************************************/
 
-
+#include <config.h>
+#include <sys/signal.h>
+#include <errno.h>
 #include <stdio.h>
 #include <fcntl.h>
-#include <errno.h>
 #include <setjmp.h>
 #include <sys/ioctl.h>
-#include <sys/signal.h>
 #include <sys/devinfo.h>
 #include <termios.h>
 #include <termio.h>
@@ -55,6 +55,7 @@
 #include <sys/uio.h>
 #include <sys/tty.h>
 /* #include <sys/pty.h> */
+
 #define REMOTE 0x01
 
 #undef ioctl
@@ -62,13 +63,11 @@ static char     SCCSid[] = "com/gnuemacs/src,3.1,9021-90/05/03-5/3/90";
 
 /*************** LOCAL DEFINES **********************************/
 
-typedef int    (*FUNC)();     /* pointer to a function        */
-
 #define QDEV   ((HFQPDEVCH<<8)|HFQPDEVCL)
 #define QLOC   ((HFQLOCCH<<8)|HFQLOCCL)
 #define QPS    ((HFQPRESCH<<8)|HFQPRESCL)
 
-#ifndef TCGETS 
+#ifndef TCGETS
 #define TCGETS TCGETA
 #endif
 #ifndef TCSETS
@@ -79,12 +78,12 @@ typedef int    (*FUNC)();     /* pointer to a function        */
 
 static int              hfqry();
 static int              hfskbd();
-       char            *malloc();
+       char            *xmalloc();
 
 extern int              errno;
 static jmp_buf          hftenv;
 static int              is_ack_vtd;
-static FUNC             sav_alrm;
+static SIGTYPE             (*sav_alrm) ();
 static struct hfctlreq  req =
                        { 0x1b,'[','x',0,0,0,21,HFCTLREQCH,HFCTLREQCL};
 static struct hfctlack  ACK =
@@ -101,20 +100,20 @@ static struct hfctlack  ACK =
                                        /* read a buffer        */
 #define RD_BUF(f,p,l) \
         while ((l)) \
-          if ((j = read((f),(p),(l))) < 0) \
+          if ((j = emacs_read (f, p, l)) < 0) \
              if (errno != EINTR) return (-1); \
              else continue; \
           else { (l) -= j; (p) += j; }
 
 /*************** function prototypes ***************************/
-#ifdef __STDC__
+#ifdef PROTOTYPES
 static GT_ACK (int fd, int req, char *buf);
 static WR_REQ (int fd, int request, int cmdlen, char *cmd, int resplen);
-static hft_alrm(int sig);
+static void hft_alrm(int sig);
 #else
 static GT_ACK ();
 static WR_REQ ();
-static hft_alrm ();
+static void hft_alrm ();
 #endif
 
 /*************** HFTCTL FUNCTION *******************************/
@@ -275,14 +274,14 @@ GT_ACK (fd, req, buf)
 }
 
 /*************** HFT_ALRM FUNCTION ******************************/
-static int
-hft_alrm (sig)                    /* Function hft_alrm - handle  */
-        int sig;               /* alarm signal               */
+static void
+hft_alrm (sig)                  /* Function hft_alrm - handle */
+     int sig;                  /* alarm signal               */
 {
   signal (SIGALRM, sav_alrm);  /* reset to previous          */
 
   if (is_ack_vtd)              /* has ack vtd arrived ?      */
-    return(0);                 /* yes, then continue         */
+    return;                    /* yes, then continue         */
   else                         /* no, then return with error */
     longjmp (hftenv, -1);
 
@@ -319,7 +318,7 @@ WR_REQ (fd, request, cmdlen, cmd, resplen)
   if (cmdlen)                  /* if arg structure to pass    */
     {
       size = sizeof (struct hfctlreq) + cmdlen;
-      if ((p.c = malloc(size)) == NULL) /* malloc one area            */
+      if ((p.c = xmalloc(size)) == NULL) /* malloc one area            */
        return (-1);
 
       memcpy (p.c, &req, sizeof (req)); /* copy CTL REQ struct         */
@@ -332,9 +331,12 @@ WR_REQ (fd, request, cmdlen, cmd, resplen)
     }
 
   /* write request to terminal   */
-  if (write(fd,p.c,size) == -1) return (-1);
+  if (emacs_write (fd, p.c, size) == -1) return (-1);
   if (p.req != &req)           /* free if allocated           */
-    free (p.c);
+    xfree (p.c);
   return (0);
 
 }
+
+/* arch-tag: cfd4f3bd-fd49-44e6-9f69-c8abdf367650
+   (do not change this comment) */