From 3ea542769f94e15e371302fb4ed5d87178211b8a Mon Sep 17 00:00:00 2001 From: ceriel Date: Tue, 27 Jan 1987 16:33:21 +0000 Subject: [PATCH] Initial revision --- include/_tail_cc/ctype.h | 45 +++++++++++++++++++++++++++ include/_tail_cc/stdio.h | 62 ++++++++++++++++++++++++++++++++++++++ include/_tail_cc/sys/dir.h | 34 +++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 include/_tail_cc/ctype.h create mode 100644 include/_tail_cc/stdio.h create mode 100644 include/_tail_cc/sys/dir.h diff --git a/include/_tail_cc/ctype.h b/include/_tail_cc/ctype.h new file mode 100644 index 000000000..b9e84109b --- /dev/null +++ b/include/_tail_cc/ctype.h @@ -0,0 +1,45 @@ +/* File : ctypes.h + Author : Richard A. O'Keefe. + Updated: 26 April 1984 + Purpose: Reimplement the UNIX ctype(3) library. + + isaneol(c) means that c is a line terminating character. + isalnum, ispunct, isspace, and isaneol are defined on the + range -1..127, i.e. on ASCII U {EOF}, while all the other + macros are defined for any integer. + + isodigit(c) checks for Octal digits. + isxdigit(c) checkx for heXadecimal digits. +*/ + +#define isdigit(c) ((unsigned)((c)-'0') < 10) +#define islower(c) ((unsigned)((c)-'a') < 26) +#define isupper(c) ((unsigned)((c)-'A') < 26) +#define isprint(c) ((unsigned)((c)-' ') < 95) +#define iscntrl(c) ((unsigned)((c)-' ') >= 95) +#define isascii(c) ((unsigned)(c) < 128) +#define isalpha(c) ((unsigned)(((c)|32)-'a') < 26) + +extern char _c2type[]; + +#define isalnum(c) (_c2type[(c)+1] < 36) +#define ispunct(c) (_c2type[(c)+1] == 36) +#define isspace(c) (_c2type[(c)+1] > 37) +#define isaneol(c) (_c2type[(c)+1] > 38) + +#define isxdigit(c) (_c2type[(c)+1] < 16) +#define isodigit(c) ((unsigned)((c)-'0') < 8) + +/* The following "conversion" macros have been in some versions of UNIX + but are not in all. tocntrl is new. The original motivation for ^? + being a name for DEL was that (x)^64 mapped A..Z to ^A..^Z and also + ? to DEL. The trouble is that this trick doesn't work for lower case + letters. The version given here is not mine. I wish it was. It has + the nice property that DEL is mapped to itself (so does EOF). + tolower(c) and toupper(c) are only defined when isalpha(c). +*/ +#define tolower(c) ((c)|32) +#define toupper(c) ((c)&~32) +#define tocntrl(c) (((((c)+1)&~96)-1)&127) +#define toascii(c) ((c)&127) + diff --git a/include/_tail_cc/stdio.h b/include/_tail_cc/stdio.h new file mode 100644 index 000000000..e106f1910 --- /dev/null +++ b/include/_tail_cc/stdio.h @@ -0,0 +1,62 @@ +#define BUFSIZ 1024 +#define _NFILES 20 +#define NULL 0 +#define EOF (-1) +#define CMASK 0377 + +#define IO_READMODE 1 +#define IO_WRITEMODE 2 +#define IO_UNBUFF 4 +#define IO_EOF 8 +#define IO_ERR 16 +#define IO_MYBUF 32 +#define IO_PERPRINTF 64 + +#ifndef FILE + +extern struct _io_buf { + int _fd; + int _count; + int _flags; + unsigned char *_buf; + unsigned char *_ptr; +} *_io_table[_NFILES]; + + +#endif /* FILE */ + +#define FILE struct _io_buf + + +#define stdin (_io_table[0]) +#define stdout (_io_table[1]) +#define stderr (_io_table[2]) + +#define getchar() getc(stdin) +#define putchar(c) putc(c,stdout) +#define getc(p) (--(p)->_count >= 0 ? (int) (*(p)->_ptr++) : \ + _fillbuf(p)) +#define putc(c, p) (--(p)->_count >= 0 ? \ + (int) (*(p)->_ptr++ = (c)) : \ + _flushbuf((c),(p))) +#define feof(p) (((p)->_flags & IO_EOF) != 0) +#define ferror(p) (((p)->_flags & IO_ERR) != 0) +#define fileno(p) ((p)->_fd) +#define io_testflag(p,x) ((p)->_flags & (x)) + +/* If you want a stream to be flushed after each printf use: + * + * io_perprintf(stream); + * + * If you want to stop with this kind of buffering use: + * + * io_noperprintf(stream); + */ + +#define io_noperprintf(p) ((p)->_flags &= ~IO_PERPRINTF) +#define io_perprintf(p) ((p)->_flags |= IO_PERPRINTF) + +extern FILE *fopen(), *fdopen(), *freopen(), *popen(); +extern long ftell(); +extern setbuf(), rewind(); +extern char *fgets(), *gets(); diff --git a/include/_tail_cc/sys/dir.h b/include/_tail_cc/sys/dir.h new file mode 100644 index 000000000..256222e09 --- /dev/null +++ b/include/_tail_cc/sys/dir.h @@ -0,0 +1,34 @@ +#ifdef BSD4_2 +#include "/usr/include/sys/dir.h" +#else +#define DIRBLKSIZ 512 +#define MAXNAMLEN 14 +#undef DIRSIZ +#define DIRSIZ(dp) \ + ((sizeof(struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1+3)&~3)) +struct direct { + long d_ino; + short d_reclen; + short d_namlen; + char d_name[MAXNAMLEN+1]; +}; + +struct _dirdesc { + int dd_fd; + long dd_loc; + long dd_size; + char dd_buf[DIRBLKSIZ]; +}; + +typedef struct _dirdesc DIR; + +#ifndef NULL +#define NULL 0 +#endif +extern DIR *opendir(); +extern struct direct *readdir(); +extern long telldir(); +extern seekdir(); +#define rewinddir(dirp) seekdir((dirp), 0L) +extern closedir(); +#endif -- 2.34.1