Category : C Source Code
Archive   : E_C_STR.ZIP
Filename : ASCII.H

 
Output of file : ASCII.H contained in archive : E_C_STR.ZIP
/* File : strings.d/ascii.h
Author : Richard A. O'Keefe
Updated: 28 April 1984
Purpose: Define Ascii mnemonics.

This file defines the ASCII control characters. Note that these
names refer to their use in communication; it is an ERROR to use
these names to talk about keyboard commands. For example, DO NOT
use EOT when you mean "end of file", as many people prefer ^Z (if
the Ascii code were taken seriously, EOT would log you off and
hang up the line as well). Similarly, DO NOT use DEL when you
mean "interrupt", many people prefer ^C. When writing a screen
editor, you should speak of tocntrl('C') rather than ETX (see the
header file "ctypes.h").
*/

#define NUL '\000' /* null character */
#define SOH '\001' /* Start Of Heading, start of message */
#define STX '\002' /* Start Of Text, end of address */
#define ETX '\003' /* End of TeXt, end of message */
#define EOT '\004' /* End Of Transmission */
#define ENQ '\005' /* ENQuiry "who are you" */
#define ACK '\006' /* (positive) ACKnowledge */
#define BEL '\007' /* ring the BELl */
#define BS '\010' /* BackSpace */
#define HT '\011' /* Horizontal Tab */
#define TAB '\011' /* an unofficial name for HT */
#define LF '\012' /* Line Feed (does not imply cr) */
#define NL '\012' /* unix unofficial name for LF: new line */
#define VT '\013' /* Vertical Tab */
#define FF '\014' /* Form Feed (new page starts AFTER this) */
#define CR '\015' /* Carriage Return */
#define SO '\016' /* Shift Out; select alternate character set */
#define SI '\017' /* Shift In; select ASCII again */
#define DLE '\020' /* Data Link Escape */
#define DC1 '\021' /* Device Control 1 */
#define XON '\021' /* transmitter on, resume output */
#define DC2 '\022' /* Device Control 2 (auxiliary on) */
#define DC3 '\023' /* Device Control 3 */
#define XOFF '\023' /* transmitter off, suspend output */
#define DC4 '\024' /* Device Control 4 (auxiliary off) */
#define NAK '\025' /* Negative AcKnowledge (signal error) */
#define SYN '\026' /* SYNchronous idle */
#define ETB '\027' /* End of Transmission Block, logical end of medium */
#define CAN '\030' /* CANcel */
#define EM '\031' /* End of Medium */
#define SUB '\032' /* SUBstitute */
#define ESC '\033' /* ESCape */
#define FS '\034' /* File Separator */
#define GS '\035' /* Group Separator */
#define RS '\036' /* Record Separator */
#define US '\037' /* Unit Separator */
#define SP '\040' /* SPace */
#define DEL '\177' /* DELete, rubout */
SHAR_EOF
sed 's/^X//' << 'SHAR_EOF' > bcmp.c
/* File : bcmp.c
Author : Richard A. O'Keefe.
Updated: 23 April 1984
Defines: bcmp()

bcmp(s1, s2, len) returns 0 if the "len" bytes starting at "s1" are
identical to the "len" bytes starting at "s2", non-zero if they are
different. The 4.2bsd manual page doesn't say what non-zero value
is returned, though the BUGS note says that it takes its parameters
backwards from strcmp. This suggests that it is something like
for (; --len >= 0; s1++, s2++)
if (*s1 != *s2) return *s2-*s1;
return 0;
There, I've told you how to do it. As the manual page doesn't come
out and *say* that this is the result, I tried to figure out what a
useful result might be. (I'd forgotten than strncmp stops when it
hits a NUL, which the above does not do.) What I came up with was:
the result is the number of bytes in the differing tails. That is,
after you've skipped the equal parts, how many characters are left?
To put it another way, N-bcmp(s1,s2,N) is the number of equal bytes
(the size of the common prefix). After deciding on this definition
I discovered that the CMPC3 instruction does exactly what I wanted.
The code assumes that N is non-negative.

Note: the "b" routines are there to exploit certain VAX order codes,
but the CMPC3 instruction will only test 65535 characters. The asm
code is presented for your interest and amusement.
*/

#include "strings.h"

#if VaxAsm

int bcmp(s1, s2, len)
char *s1, *s2;
int len;
{
asm("cmpc3 12(ap),*4(ap),*8(ap)");
}

#else ~VaxAsm

int bcmp(s1, s2, len)
register char *s1, *s2;
register int len;
{
while (--len >= 0 && *s1++ == *s2++) ;
return len+1;
}

#endif VaxAsm



  3 Responses to “Category : C Source Code
Archive   : E_C_STR.ZIP
Filename : ASCII.H

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/