mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Integrated Peter Bengtsson's termios code. Thank you very much! I chose
to add it to libunix.a rather than keeping it in a separate libtermios.a library. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14971 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: limits.h,v 1.7 2005-05-12 13:21:47 obarthel Exp $
|
||||
* $Id: limits.h,v 1.8 2005-06-04 10:46:23 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -88,9 +88,9 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define LLONG_MIN (-0x7fffffffffffffffLL-1)
|
||||
#define LLONG_MAX 0x7fffffffffffffffLL
|
||||
#define ULLONG_MAX 0xffffffffffffffffULL
|
||||
#define LLONG_MIN (-0x7fffffffffffffffLL-1)
|
||||
#define LLONG_MAX 0x7fffffffffffffffLL
|
||||
#define ULLONG_MAX 0xffffffffffffffffULL
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
@ -110,4 +110,63 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define WORD_BIT 32
|
||||
#define LONG_BIT 32 /* For now, at least. */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/*
|
||||
* POSIX, POSIX... These are minimum maximum values. I.e. the maximum must be
|
||||
* at least this large. I am not sure all of these make much sense on the Amiga
|
||||
* (yet), but here they are anyway.
|
||||
*
|
||||
* Actually, these symbols should be defined only if the preprocessor symbol
|
||||
* _POSIX_SOURCE is defined. Other symbols which should be defined, too, are
|
||||
* ARG_MAX, CHILD_MAX, LINK_MAX, MAX_CANON, MAX_INPUT, NAME_MAX, NGROUPS_MAX,
|
||||
* OPEN_MAX, PATH_MAX, PIPE_BUF, SSIZE_MAX, STREAM_MAX and TZNAME_MAX.
|
||||
*/
|
||||
|
||||
#define _POSIX_AIO_LISTIO_MAX 2
|
||||
#define _POSIX_AIO_MAX 1
|
||||
#define _POSIX_ARG_MAX 4096
|
||||
#define _POSIX_CHILD_MAX 6
|
||||
#define _POSIX_DELAYTIMER_MAX 32
|
||||
#define _POSIX_LINK_MAX 8
|
||||
#define _POSIX_LOGIN_NAME_MAX 9
|
||||
#define _POSIX_MAX_CANON 255
|
||||
#define _POSIX_MAX_INPUT 255
|
||||
#define _POSIX_MQ_OPEN_MAX 8
|
||||
#define _POSIX_MQ_PRIO_MAX 32
|
||||
#define _POSIX_NAME_MAX 14
|
||||
#define _POSIX_NGROUPS_MAX 0
|
||||
#define _POSIX_OPEN_MAX 16
|
||||
#define _POSIX_PATH_MAX 255
|
||||
#define _POSIX_PIPE_BUF 512
|
||||
#define _POSIX_RTSIG_MAX 8
|
||||
#define _POSIX_SEM_NSEMS_MAX 256
|
||||
#define _POSIX_SEM_VALUE_MAX 32767
|
||||
#define _POSIX_SIGQUEUE_MAX 32
|
||||
#define _POSIX_SSIZE_MAX 32767
|
||||
#define _POSIX_STREAM_MAX 8
|
||||
#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
|
||||
#define _POSIX_THREAD_KEYS_MAX 128
|
||||
#define _POSIX_THREADS_MAX 64
|
||||
#define _POSIX_TIMER_MAX 32
|
||||
#define _POSIX_TTY_NAME_MAX 9
|
||||
#define _POSIX_TZNAME_MAX 3
|
||||
#define _POSIX2_BC_BASE_MAX 99
|
||||
#define _POSIX2_BC_DIM_MAX 2048
|
||||
#define _POSIX2_BC_SCALE_MAX 99
|
||||
#define _POSIX2_BC_STRING_MAX 1000
|
||||
#define _POSIX2_COLL_WEIGHTS_MAX 2
|
||||
#define _POSIX2_EXPR_NEST_MAX 32
|
||||
#define _POSIX2_LINE_MAX 2048
|
||||
#define _POSIX2_RE_DUP_MAX 255
|
||||
#define _XOPEN_IOV_MAX 16
|
||||
|
||||
/* And a maximum minimum value. */
|
||||
#define _POSIX_CLOCKRES_MIN 20000000 /* Nanoseconds */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#endif /* _LIMITS_H */
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio.h,v 1.14 2005-05-11 20:15:28 obarthel Exp $
|
||||
* $Id: stdio.h,v 1.15 2005-06-04 10:46:23 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -342,6 +342,14 @@ extern char *tmpnam(char *buf);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define L_ctermid 32
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
extern char *ctermid(char *);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/*
|
||||
* A special buffer flush routine which returns the last character written
|
||||
* in case of success and EOF in case of failure. This is used by the
|
||||
|
||||
189
library/include/termios.h
Normal file
189
library/include/termios.h
Normal file
@ -0,0 +1,189 @@
|
||||
/*
|
||||
* $Id: termios.h,v 1.1 2005-06-04 10:46:23 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||
* Copyright (c) 2002-2005 by Olaf Barthel <olsen@sourcery.han.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Neither the name of Olaf Barthel nor the names of contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Almost-but-not-quite termios.
|
||||
*/
|
||||
|
||||
#ifndef _TERMIOS_H
|
||||
#define _TERMIOS_H
|
||||
|
||||
typedef unsigned int tcflag_t;
|
||||
typedef unsigned char cc_t;
|
||||
typedef unsigned int speed_t;
|
||||
|
||||
#define NCCS 16 /* Number of Control Characters = Length of the c_cc array. */
|
||||
|
||||
enum { /* All the control characters in c_cc[] in a struct termios (below) */
|
||||
VINTR=0, /* ^C (break) */
|
||||
VQUIT, /* ^\ (quit) */
|
||||
VERASE, /* ^H (eraase) */
|
||||
VKILL, /* ^X (erase-line) */
|
||||
VEOF, /* ^D (end-of-file) */
|
||||
VMIN, /* Minimum number of characters to read. Interacts with VTIME. */
|
||||
VEOL, /* NUL */
|
||||
VTIME, /* Timeout in 1/10:ths of a second. Interacts with VMIN. */
|
||||
VSTART, /* ^Q (continue) */
|
||||
VSTOP, /* ^S (stop) */
|
||||
VSUSP, /* ^Z (suspend) */
|
||||
VWERASE, /* ^W (word-erase) */
|
||||
};
|
||||
|
||||
struct termios {
|
||||
tcflag_t c_iflag;
|
||||
tcflag_t c_oflag;
|
||||
tcflag_t c_cflag;
|
||||
tcflag_t c_lflag;
|
||||
cc_t c_cc[NCCS];
|
||||
/* Private */
|
||||
speed_t c_ispeed;
|
||||
speed_t c_ospeed;
|
||||
int type;
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
/* c_iflag */
|
||||
|
||||
#define IGNBRK (1<<0L) /* Ignore VINTR */
|
||||
#define BRKINT (1<<1L) /* Unimpl. */
|
||||
#define IGNPAR (1<<2L) /* Unimpl. */
|
||||
#define PARMRK (1<<3L) /* Unimpl. */
|
||||
#define INPCK (1<<4L) /* Unimpl. */
|
||||
#define ISTRIP (1<<5L) /* 7-bit data (strip high bit) */
|
||||
#define INLCR (1<<6L) /* Map NL->CR */
|
||||
#define IGNCR (1<<7L) /* Map CR->nothing */
|
||||
#define ICRNL (1<<8L) /* Map CR->NL */
|
||||
#define IXON (1<<9L) /* Unimpl. Enable XON/XOFF for output. */
|
||||
#define IXOFF (1<<10L) /* Unimpl. Enable XON/XOFF for input. */
|
||||
|
||||
/* c_oflag */
|
||||
|
||||
#define OPOST (1<<0L) /* Enable output processing. */
|
||||
#define ONLCR (1<<1L) /* Map NL->CR+NL */
|
||||
#define OCRNL (1<<2L) /* Map CR->NL */
|
||||
#define ONOCR (1<<3L) /* Map CR->nothing, but only in column 0. */
|
||||
#define ONLRET (1<<4L) /* Map CR->nothing */
|
||||
|
||||
/* c_cflag */
|
||||
|
||||
#define CSIZE (0x07) /* Bit-width mask. */
|
||||
#define CS5 (0x01) /* 5-bits */
|
||||
#define CS6 (0x02) /* 6-bits */
|
||||
#define CS7 (0x03) /* 7-bits */
|
||||
#define CS8 (0x04) /* 8-bits */
|
||||
#define CSTOPB (1<<3L) /* Use 2 stop bits. */
|
||||
#define CREAD (1<<4L) /* Enable reading/receiving. */
|
||||
#define PARENB (1<<5L) /* Enable parity generation/checking. */
|
||||
#define PARODD (1<<6L) /* Parity is odd. */
|
||||
#define HUPCL (1<<7L) /* Hangup on close (when the device is closed). */
|
||||
#define CLOCAL (1<<8L) /* Ignore modem control lines (i.e. a null-modem) */
|
||||
|
||||
/* c_lflag */
|
||||
|
||||
#define ISIG (1<<0L) /* Send SIGINT for ^C, SIGQUIT for ^\ etc. */
|
||||
#define ICANON (1<<1L) /* Canonical mode. Line buffered with EOF, EOL etc. enabled. */
|
||||
#define ECHO (1<<2L) /* Echo input characters. */
|
||||
#define ECHONL (1<<3L) /* Echo newline characters even if ECHO is not set. */
|
||||
#define IEXTEN (1<<4L) /* Enable implementation defined input processing. (none) */
|
||||
|
||||
/* Speeds */
|
||||
|
||||
enum {
|
||||
B0=0, /* 0 baud => disconnect. */
|
||||
B50=50,
|
||||
B75=75,
|
||||
B110=110,
|
||||
B134=134,
|
||||
B150=150,
|
||||
B200=200,
|
||||
B300=300,
|
||||
B600=600,
|
||||
B1200=1200,
|
||||
B1800=1800,
|
||||
B2400=2400,
|
||||
B4800=4800,
|
||||
B9600=9600,
|
||||
B19200=19200,
|
||||
B31250=31250,
|
||||
B38400=38400,
|
||||
B57600=57600,
|
||||
B115200=115200,
|
||||
B230400=230400,
|
||||
B460800=460800,
|
||||
B576000=576000,
|
||||
B1152000=1152000
|
||||
};
|
||||
|
||||
#define EXTA 1 /* Tell applications we have speeds > 9600 baud. */
|
||||
|
||||
/* Action types for tcsetattr() */
|
||||
|
||||
enum {
|
||||
TCSANOW,
|
||||
TCSADRAIN,
|
||||
TCSAFLUSH
|
||||
};
|
||||
|
||||
/* Action types for tcflush() */
|
||||
|
||||
enum {
|
||||
TCIFLUSH,
|
||||
TCOFLUSH,
|
||||
TCIOFLUSH
|
||||
};
|
||||
|
||||
/* Action types for tcflow() */
|
||||
|
||||
enum {
|
||||
TCOOFF,
|
||||
TCOON,
|
||||
TCIOFF,
|
||||
TCION
|
||||
};
|
||||
|
||||
/* Prototypes. */
|
||||
|
||||
extern int tcgetattr(int file_descriptor,struct termios *tios_p);
|
||||
extern int tcsetattr(int file_descriptor,int action,struct termios *tios_p);
|
||||
extern int tcsendbreak(int file_descriptor,int duration);
|
||||
extern int tcdrain(int file_descriptor);
|
||||
extern int tcflush(int file_descriptor,int what);
|
||||
extern int tcflow(int file_descriptor,int action);
|
||||
extern int cfmakeraw(struct termios *tios_p);
|
||||
extern speed_t cfgetispeed(struct termios *tios_p);
|
||||
extern speed_t cfgetospeed(struct termios *tios_p);
|
||||
extern int cfsetispeed(struct termios *tios_p,speed_t input_speed);
|
||||
extern int cfsetospeed(struct termios *tios_p,speed_t output_speed);
|
||||
|
||||
#endif /* _TERMIOS_H */
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: unistd.h,v 1.9 2005-02-04 15:03:14 obarthel Exp $
|
||||
* $Id: unistd.h,v 1.10 2005-06-04 10:46:23 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -100,6 +100,9 @@ extern pid_t getpid(void);
|
||||
extern char *realpath(const char *file_name, char *resolved_name);
|
||||
extern int fsync(int file_descriptor);
|
||||
extern int fdatasync(int file_descriptor);
|
||||
extern char *ttyname(int);
|
||||
extern int ttyname_r(int file_descriptor,char *name,size_t buflen);
|
||||
extern int ttyname_t(int,char *,size_t);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user