annotate src/hftctl.c @ 26088:b7aa6ac26872

Add support for large files, 64-bit Solaris, system locale codings. * Makefile.in (emacs): Set the LC_ALL environment variable to "C" when dumping, so that the dumped Emacs doesn't have stray locale info. (dired.o): Depend on systime.h. (editfns.o): Depend on coding.h. * alloc.c, buffer.c, callproc.c, ccl.c, charset.c, coding.c, data.c, dispnew.c, editfns.c, emacs.c, filelock.c, floatfns.c, hftctl.c, keyboard.c, process.c, sysdep.c, unexelf.c, unexhp9k800.c, unexsunos4.c, vmsfns.c, vmsgmalloc.c, w32faces.c, w32menu.c, w32term.c, w32xfns.c, xfaces.c, xfns.c, xmenu.c, xterm.c: Include <config.h> before any system include files. * alloc.c, buffer.c, ccl.c, data.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, frame.c, insdel.c, keymap.c, lread.c, m/alpha.h, print.c, search.c, sysdep.c, xdisp.c, xfaces.c, xfns.c, xmenu.c, xterm.c: Do not include <stdlib.h>, as <config.h> does this now. * callproc.c (Fcall_process): Synchronize messages locale before invoking strerror. Decode resulting string with locale-coding-system. * coding.c (Vlocale_coding_system): New var. (syms_of_coding): Adjust to above change. (emacs_strerror): New function. * coding.h (emacs_strerror, Vlocale_coding_system): New decls. * config.in (HAVE_STDIO_EXT_H, HAVE_TM_GMTOFF, HAVE___FPENDING, HAVE_FTELLO, HAVE_GETLOADAVG, HAVE_MBLEN, HAVE_MBRLEN, HAVE_STRSIGNAL): New macros. (BITS_PER_LONG): Default to 64 if _LP64 is defined. <stdlib.h>: Include if HAVE_STDLIB_H is defined and NOT_C_CODE isn't. * dired.c: Include "systime.h". (Ffile_attributes): Do not cast s.st_size to int; this loses information if int is 32 bits but st_size and EMACS_INT are larger. Treat large device numbers like large inode numbers. * dispnew.c (PENDING_OUTPUT_COUNT): Use __fpending if available. * editfns.c: Include coding.h. (emacs_strftime): Remove decl. (emacs_strftimeu): New decl. (emacs_memftimeu): Renamed from emacs_memftime; new arg UT. Use emacs_strftimeu instead of emacs_strftime. (Fformat_time_string): Convert format string using Vlocale_coding_system, and convert result back. Synchronize time locale before invoking lower level function. Invoke emacs_memftimeu, passing ut, instead of emacs_memftime. * emacs.c: Include <locale.h> if HAVE_SETLOCALE is defined. (Vmessages_locale, Vprevious_messages_locale, Vtime_locale, Vprevious_time_locale): New variables. (main): Invoke setlocale early, so that initial error messages are localized properly. But skip locale-setting if LC_ALL is "C". Fix up locale when it's safe to do so. (fixup_locale): Moved here from xterm.c. (synchronize_locale, synchronize_time_locale, synchronize_messages_locale): New functions. (syms_of_emacs): Accommodate above changes. * fileio.c (report_file_error): Convert strerror output according to Vlocale_coding_system. (Finsert_file_contents): Check for arithmetic overflow in computations that depend on file size. Report IO errors with emacs_strerror, not strerror. * fns.c (Fgethash): Declare dflt parameter. * gmalloc.c: Do not define const to nothing if HAVE_CONFIG_H is defined; that's config.h's job. * lisp.h (EMACS_INT, BITS_PER_EMACS_INT, EMACS_UINT): If _LP64, default these values to long, BITS_PER_LONG, and unsigned long. (VALBITS, MARKBIT, XINT): Do not assume 32-bit EMACS_INT. (PNTR_COMPARISON_TYPE): Default to EMACS_UINT, not to unsigned int. (code_convert_string_norecord, fixup_locale, synchronize_messages_locale, synchronize_time_locale, emacs_open, emacs_close, emacs_read, emacs_write): New decls. All Emacs callers of open, close, read, write changed to use emacs_open, emacs_close, emacs_read, emacs_write. * lread.c (file_offset, file_tell): New macros. All uses of ftell changed to file_tell. (saved_doc_string_position, prev_saved_doc_string_position): Now of type file_offset. (init_lread): Do not fix locale here; fixup_locale now does this. * m/amdahl.h, s/usg5-4.h: (NSIG): Remove. (NSIG_MINIMUM): New macro. * m/cydra5.h, m/dpx2.h, m/mips.h, m/pfa50.h, m/sps7.h, m/stride.h, m/ustation.h, s/gnu-linux.h, s/hpux.h, s/iris3-5.h, s/iris3-6.h, s/umips.h, s/usg5-4.h: (SIGIO): Do not undef. (BROKEN_SIGIO): New macro. * m/ustation.h: (SIGTSTP): Do not undef. (BROKEN_SIGTSTP): New macro. * s/gnu-linux.h: (SIGPOLL, SIGURG): Do not undef. (BROKEN_SIGPOLL, BROKEN_SIGURG): New macros. * s/ptx4.h: (SIGINFO): Do not undef. (BROKEN_SIGINFO): New macros. * m/delta.h, s/ptx.h, s/template.h: Doc fix. * mktime.c, strftime.c: Update to glibc 2.1.2 version, with some Emacs-related changes merged. * print.c (float_to_string): Prepend "-" to representation of a NaN if the NaN is negative. * process.c (sys_siglist): Omit if HAVE_STRSIGNAL. (wait_reading_process_input): Use emacs_strerror, not strerror. * process.c (status_message, sigchld_handler): Synchronize locale, then use strsignal istead of sys_siglist. * w32proc.c (sys_wait): Likewise. * s/aix3-1.h, s/bsd4-1.h, s/dgux.h, s/gnu-linux.h, s/hiuxmpp.h, s/hpux.h, s/iris3-5.h, s/iris3-6.h, s/irix3-3.h, s/osf1.h, s/rtu.h, s/sunos4-1.h, s/unipl5-0.h, s/unipl5-2.h, s/usg5-0.h, s/usg5-2-2.h, s/usg5-2.h, s/usg5-3.h, s/xenix.h: (open, close, read, write, INTERRUPTIBLE_OPEN, INTERRUPTIBLE_CLOSE, INTERRUPTIBLE_IO): Remove. * s/sol2-5.h (_LARGEFILE_SOURCE, _FILE_OFFSET_BITS): New macros. * sysdep.c (sys_read, sys_write, read, write, sys_close, close, sys_open, open): Remove. (emacs_open, emacs_close, emacs_read, emacs_write): Always define; the old INTERRUPTIBLE_OPEN, INTERRUPTIBLE_CLOSE, and INTERRUPTIBLE_IO macros are no longer used. (emacs_open): Renamed from sys_open. Merge BSD4_1 version. (emacs_close): Renamed from sys_close. (emacs_read): Renamed from sys_read. (emacs_write): Renamed from sys_write. (sys_siglist): Do not declare if HAVE_STRSIGNAL. (dup2): Do not print error on failure; the real dup2 doesn't. (strsignal): New function, defined if !HAVE_STRSIGNAL. * syssignal.h (SIGINFO): Undef if defined and if BROKEN_SIGINFO is defined. (SIGIO, SIGPOLL, SIGTSTP, SIGURG): Likewise. (NSIG): If less than NSIG_MINIMUM, define to NSIG_MINIMUM. (strsignal): Declare if !HAVE_STRSIGNAL. * unexelf.c (ElfBitsW, ELFSIZE, ElfExpandBitsW): New macros. (ElfW): Define in terms of ElfExpandBitsW. * w32proc.c (sys_siglist): Remove decl. * xdisp.c (decode_mode_spec): 3rd arg is int, not char, to comply with ANSI C. (display_string): Declare face_string_pos arg. * xfns.c (Fx_show_tip): Declare timeout param. * xterm.c: No need to include locale.h. (x_alloc_lighter_color, x_setup_relief_color): Pass arg as double, not float, for compatibility with ANSI C. (fixup_locale): Move to emacs.c. (x_term_init): Do not setlocale or fixup locale; the main program does this now.
author Paul Eggert <eggert@twinsun.com>
date Tue, 19 Oct 1999 07:25:11 +0000
parents c52147cf10b1
children 872ca4a12e3d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
1 /* IBM has disclaimed copyright on this module. */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
2
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
3 /***************************************************************/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
4 /* */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
5 /* Function: hftctl */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
6 /* */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
7 /* Syntax: */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
8 /* #include <sys/ioctl.h> */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
9 /* #include <sys/hft.h> */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
10 /* */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
11 /* int hftctl(fildes, request, arg ) */
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
12 /* int fildes, request; */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
13 /* char *arg; */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
14 /* */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
15 /* Description: */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
16 /* */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
17 /* Does the following: */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
18 /* 1. determines if fildes is pty */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
19 /* does normal ioctl it is not */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
20 /* 2. places fildes into raw mode */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
21 /* 3. converts ioctl arguments to datastream */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
22 /* 4. waits for 2 secs for acknowledgement before */
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3470
diff changeset
23 /* timing out. */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
24 /* 5. places response in callers buffer ( just like */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
25 /* ioctl. */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
26 /* 6. returns fildes to its original mode */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
27 /* */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
28 /* User of this program should review steps 1,4, and 3. */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
29 /* hftctl makes no check on the request type. It must be */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
30 /* a HFT ioctl that is supported remotely. */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
31 /* This program will use the SIGALRM and alarm(2). Any */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
32 /* Previous alarms are lost. */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
33 /* */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
34 /* Users of this program are free to modify it any way */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
35 /* they want. */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
36 /* */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
37 /* Return Value: */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
38 /* */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
39 /* If ioctl fails, a value of -1 is returned and errno */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
40 /* is set to indicate the error. */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
41 /* */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
42 /***************************************************************/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
43
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 7897
diff changeset
44 #include <config.h>
7897
c52147cf10b1 Put sys/signal.h and errno.h first, then config.h.
Richard M. Stallman <rms@gnu.org>
parents: 5098
diff changeset
45 #include <sys/signal.h>
c52147cf10b1 Put sys/signal.h and errno.h first, then config.h.
Richard M. Stallman <rms@gnu.org>
parents: 5098
diff changeset
46 #include <errno.h>
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
47 #include <stdio.h>
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
48 #include <fcntl.h>
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
49 #include <setjmp.h>
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
50 #include <sys/ioctl.h>
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
51 #include <sys/devinfo.h>
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
52 #include <termios.h>
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
53 #include <termio.h>
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
54 #include <sys/hft.h>
560
68111c4a3885 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
55 #include <sys/uio.h>
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
56 #include <sys/tty.h>
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
57 /* #include <sys/pty.h> */
5098
a770e7708711 Include config.h. Include sys/signal.h before config.h.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
58
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
59 #define REMOTE 0x01
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
60
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
61 #undef ioctl
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
62 static char SCCSid[] = "com/gnuemacs/src,3.1,9021-90/05/03-5/3/90";
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
63
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
64 /*************** LOCAL DEFINES **********************************/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
65
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
66 #define QDEV ((HFQPDEVCH<<8)|HFQPDEVCL)
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
67 #define QLOC ((HFQLOCCH<<8)|HFQLOCCL)
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
68 #define QPS ((HFQPRESCH<<8)|HFQPRESCL)
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
69
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
70 #ifndef TCGETS
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
71 #define TCGETS TCGETA
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
72 #endif
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
73 #ifndef TCSETS
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
74 #define TCSETS TCSETA
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
75 #endif
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
76
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
77 /*************** EXTERNAL / GLOBAL DATA AREA ********************/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
78
560
68111c4a3885 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
79 static int hfqry();
68111c4a3885 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
80 static int hfskbd();
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 560
diff changeset
81 char *xmalloc();
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
82
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
83 extern int errno;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
84 static jmp_buf hftenv;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
85 static int is_ack_vtd;
5098
a770e7708711 Include config.h. Include sys/signal.h before config.h.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
86 static SIGTYPE (*sav_alrm) ();
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
87 static struct hfctlreq req =
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
88 { 0x1b,'[','x',0,0,0,21,HFCTLREQCH,HFCTLREQCL};
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
89 static struct hfctlack ACK =
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
90 { 0x1b,'[','x',0,0,0,21,HFCTLACKCH,HFCTLACKCL};
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
91
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
92 /* FUNC signal(); */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
93
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
94 /*************** LOCAL MACROS ***********************************/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
95
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
96 #define HFTYPE(p) ((p->hf_typehi<<8)|(p->hf_typelo))
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
97
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
98 #define BYTE4(p) ((p)[0]<<24 | (p)[1]<<16 | (p)[2]<<8 | (p)[3])
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
99
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
100 /* read a buffer */
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
101 #define RD_BUF(f,p,l) \
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
102 while ((l)) \
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 7897
diff changeset
103 if ((j = emacs_read (f, p, l)) < 0) \
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
104 if (errno != EINTR) return (-1); \
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
105 else continue; \
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
106 else { (l) -= j; (p) += j; }
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
107
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
108 /*************** function prototypes ***************************/
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
109 #ifdef __STDC__
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
110 static GT_ACK (int fd, int req, char *buf);
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
111 static WR_REQ (int fd, int request, int cmdlen, char *cmd, int resplen);
3315
dcc64ab7de8c * hftctl.c (hft_alrm): Declare and define this to return void, not
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
112 static void hft_alrm(int sig);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
113 #else
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
114 static GT_ACK ();
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
115 static WR_REQ ();
3470
a6dde97d8166 (hft_alrm): Don't return a value.
Richard M. Stallman <rms@gnu.org>
parents: 3315
diff changeset
116 static void hft_alrm ();
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
117 #endif
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
118
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
119 /*************** HFTCTL FUNCTION *******************************/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
120
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
121 hftctl (fd, request, arg)
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
122 int fd;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
123 int request;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
124 union {
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
125 struct hfintro *intro;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
126 struct hfquery *query;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
127 char *c;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
128 } arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
129 {
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
130
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
131 int i;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
132 int fd_flag; /* fcntl flags */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
133 register union {
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
134 struct hfintro *cmd; /* p.cmd - intro des. */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
135 struct hfqphdevc *ph; /* p.ph - physical dev.*/
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
136 char *c; /* p.c - char ptr */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
137 } p; /* general pointer */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
138 int pty_new; /* pty modes */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
139 int pty_old;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
140 int retcode;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
141 struct termios term_new; /* terminal attributes */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
142 struct termios term_old;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
143 struct devinfo devInfo; /* defined in sys/devinfo.h */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
144
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
145
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
146 if (ioctl (fd, IOCINFO, &devInfo) == -1) return(-1);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
147
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
148 if (devInfo.devtype != DD_PSEU) /* is it a pty? */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
149 return (ioctl(fd, request, arg)); /* no, do IOCTL */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
150
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
151 /******* START PTY **************/
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
152 /** Pty found, possible HFT */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
153 /** set new file des as raw */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
154 /** as you can. */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
155 /********************************/
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
156
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
157 /* Get current state of file */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
158 /* descriptor & save */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
159 if ((fd_flag = fcntl (fd, F_GETFL, 0)) == -1) return (-1);
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
160 if (ioctl (fd, TCGETS, &term_old) == -1) return (-1);
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
161 /* set terminal attr to raw */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
162 /* and to delay on read */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
163 pty_new = pty_old | REMOTE;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
164 memcpy (&term_new, &term_old, sizeof (term_new));
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
165 term_new.c_iflag = 0;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
166 term_new.c_oflag = 0;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
167 term_new.c_lflag = 0;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
168 /* term_new.c_line = 0; */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
169 for (i = 1; i <= 5; i++)
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
170 term_new.c_cc[i] = 0;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
171 term_new.c_cc[0] = -1;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
172 ioctl (fd, TCSETS, &term_new);
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
173 if (fcntl (fd, F_SETFL, fd_flag & ~O_NDELAY) == -1)
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
174 return(-1);
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
175 /* call spacific function */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
176 if (request == HFSKBD)
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
177 retcode = hfskbd (fd, request, arg.c);
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
178 else /* assume HFQUERY */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
179 retcode = hfqry (fd, request, arg.c);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
180
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
181 fcntl (fd, F_SETFL, fd_flag); /* reset terminal to original */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
182 ioctl (fd, TCSETS, &term_old);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
183
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
184
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
185 return (retcode); /* return error */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
186 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
187
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
188 /*************** HFSKBD FUNCTION ******************************/
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
189 static int
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
190 hfskbd (fd, request, arg)
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
191 int fd;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
192 int request;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
193 struct hfbuf *arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
194 {
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
195 WR_REQ(fd, request, arg->hf_buflen, arg->hf_bufp,0);
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
196 return (GT_ACK(fd, request, arg->hf_bufp));
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
197 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
198
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
199 /*************** HFQUERY FUNCTION ******************************/
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
200 static int
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
201 hfqry (fd, request, arg)
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
202 int fd;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
203 int request;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
204 struct hfquery *arg;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
205 {
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
206 WR_REQ(fd, request, arg->hf_cmdlen, arg->hf_cmd, arg->hf_resplen);
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
207 return (GT_ACK(fd, request, arg->hf_resp));
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
208 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
209
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
210
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
211 /*************** GT_ACK FUNCTION ******************************/
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
212 static int
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
213 GT_ACK (fd, req, buf)
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
214 int fd;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
215 int req;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
216 char *buf;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
217 {
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
218 struct hfctlack ack;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
219 int i = sizeof (ack);
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
220 int j = 0;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
221 union {
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
222 char *c;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
223 struct hfctlack *ack;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
224 } p;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
225
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
226 is_ack_vtd = 0; /* flag no ACT VTD yet */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
227
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
228 if (setjmp (hftenv)) /* set environment in case */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
229 { /* of time out */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
230 errno = ENODEV; /* if time out, set errno */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
231 return (-1); /* flag error */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
232 }
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
233
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
234 alarm(3); /* time out in 3 secs */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
235 sav_alrm = signal (SIGALRM, hft_alrm); /* prepare to catch time out */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
236
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
237 p.ack = &ack;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
238 while (! is_ack_vtd) /* do until valid ACK VTD */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
239 {
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
240 RD_BUF(fd, p.c, i); /* read until a ACK VTD is fill*/
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
241
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
242 if (! memcmp (&ack, &ACK, sizeof (HFINTROSZ)) /* the ACK intro & */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
243 && (ack.hf_request == req)) /* is it the response we want ?*/
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
244 { /* yes, ACK VTD found */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
245 is_ack_vtd = 1; /* quickly, flag it */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
246 break; /* get the %$%#@ out of here */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
247 }
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
248
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
249 p.ack = &ack; /* no, then skip 1st */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
250 ++p.c; /* char and start over */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
251 i = sizeof (ack) - 1; /* one less ESC to cry over */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
252
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
253 while ((*p.c != 0x1b) && i) /* scan for next ESC */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
254 { ++p.c; --i; } /* if any */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
255
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
256 (i ? memcpy (&ack, p.c, i) : 0); /* if any left over, then move */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
257 p.ack = &ack; /* ESC to front of ack struct */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
258 p.c += i; /* skip over whats been read */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
259 i = sizeof (ack) - i; /* set whats left to be read */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
260 } /***** TRY AGAIN */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
261
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
262 alarm(0); /* ACK VTD received, reset alrm*/
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
263 signal (SIGALRM, sav_alrm); /* reset signal */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
264
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
265 if (i = ack.hf_arg_len) /* any data following ? */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
266 { /* yes, */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
267 RD_BUF(fd,buf,i); /* read until it is received */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
268 }
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
269
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
270 if (errno = ack.hf_retcode) /* set errno based on returned */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
271 return (-1); /* code, if 0, then no error */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
272 else
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
273 return (0); /* if set, then error returned */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
274 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
275
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
276 /*************** HFT_ALRM FUNCTION ******************************/
3315
dcc64ab7de8c * hftctl.c (hft_alrm): Declare and define this to return void, not
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
277 static void
dcc64ab7de8c * hftctl.c (hft_alrm): Declare and define this to return void, not
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
278 hft_alrm (sig) /* Function hft_alrm - handle */
dcc64ab7de8c * hftctl.c (hft_alrm): Declare and define this to return void, not
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
279 int sig; /* alarm signal */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
280 {
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
281 signal (SIGALRM, sav_alrm); /* reset to previous */
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
282
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
283 if (is_ack_vtd) /* has ack vtd arrived ? */
3470
a6dde97d8166 (hft_alrm): Don't return a value.
Richard M. Stallman <rms@gnu.org>
parents: 3315
diff changeset
284 return; /* yes, then continue */
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
285 else /* no, then return with error */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
286 longjmp (hftenv, -1);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
287
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
288 }
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
289
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
290 /*********************************************************************/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
291 /*** ***/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
292 /*** NOTE: Both the HFCTLREQ and the arg structure should be ***/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
293 /*** sent in one io write operation. If terminal ***/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
294 /*** emulators are in NODELAY mode then multiple writes ***/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
295 /*** may cause bogus information to be read by the emulator ***/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
296 /*** depending on the timing. ***/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
297 /*** ***/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
298 /*********************************************************************/
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
299
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
300 static int
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
301 WR_REQ (fd, request, cmdlen, cmd, resplen)
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
302 int fd;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
303 int request;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
304 int cmdlen;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
305 char *cmd;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
306 int resplen;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
307 {
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
308 struct {
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
309 char *c;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
310 struct hfctlreq *req;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
311 } p;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
312 int size;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
313
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
314 req.hf_request = request;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
315 req.hf_arg_len = cmdlen;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
316 req.hf_rsp_len = resplen;
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
317
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
318 if (cmdlen) /* if arg structure to pass */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
319 {
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
320 size = sizeof (struct hfctlreq) + cmdlen;
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 560
diff changeset
321 if ((p.c = xmalloc(size)) == NULL) /* malloc one area */
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
322 return (-1);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
323
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
324 memcpy (p.c, &req, sizeof (req)); /* copy CTL REQ struct */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
325 memcpy (p.c + sizeof (req), cmd, cmdlen); /* copy arg struct */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
326 }
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
327 else
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
328 {
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
329 p.req = &req; /* otherwise use only CTL REQ */
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
330 size = sizeof (req);
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
331 }
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
332
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
333 /* write request to terminal */
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 7897
diff changeset
334 if (emacs_write (fd, p.c, size) == -1) return (-1);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
335 if (p.req != &req) /* free if allocated */
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 560
diff changeset
336 xfree (p.c);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 102
diff changeset
337 return (0);
102
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
338
0d3a6b3b64a4 Initial revision
Mike Rowan <mtr@gnu.org>
parents:
diff changeset
339 }