Category : Alternate Operating Systems - Quarterdeck DesqView, CP/M, etc
Archive   : PCCAPP.ZIP
Filename : STRING.H

 
Output of file : STRING.H contained in archive : PCCAPP.ZIP
/*
* This file is part of the Choices Operating System
* Developed by: The TAPESTRY Parallel Computing Laboratory
* University of Illinois at Urbana-Champaign
* Department of Computer Science
* 1304 W. Springfield Ave.
* Urbana, IL 61801
*
* Copyright (c) 1987, 1988, 1989, 1990, 1991
* The University of Illinois Board of Trustees.
* All Rights Reserved.
* CONFIDENTIAL INFORMATION. Distribution restricted under license agreement.
*
* Author: Gary M. Johnston ([email protected])
* Contributing Author: Douglas E. Leyens ([email protected])
* Project Manager and Principal Investigator: Roy Campbell ([email protected])
*
* Funded by: NSF TAPESTRY Grant No. 1-5-30035, NASA ICLASS Grant
* No. 1-5-25469 and No. NSG1471 and AT&T Metronet Grant No. 1-5-37411.
*/
/*
* String.h
*/

#ifndef String_h
#define String_h
#ifdef __GNUG__
#pragma once
#pragma interface
#endif

#ifdef CFRONT

int strlen( const char * );
char * strcpy( char *, const char * );
char * strncpy( char *, const char *, int );
int strcmp( const char *, const char * );
int strncmp( const char *, const char *, int );
char * index( const char *, char );

#else

static inline int
strlen( const char * s )
{
for ( const char * p = s; *p; p++ ) ;
return p - s;
}

/*
* Copy s2 to s1.
* Return s1.
*/
static inline char *
strcpy( char * s1, const char * s2 )
{
for ( char * p = s1; *p = *s2; p++, s2++ ) ;
return s1;
}

/*
* Copy s2 to s1, copying at most n characters.
* Return s1.
*/

static inline char *
strncpy( char * s1, const char * s2, int n )
{
for ( char * p = s1; ( n > 0 ) && ( *p = *s2 ); p++, s2++, n-- ) ;
return s1;
}

/*
* Compare s1 to s2.
* Return negative/zero/positive if s1 is lexically less/equal/greater s2.
*/
static inline int
strcmp( const char * s1, const char * s2 )
{
for ( ; *s1 && *s2 && ( *s1 == *s2 ); s1++, s2++ ) ;
return *s1 - *s2;
}

/*
* Compare s1 to s2, comparing at most n characters.
* Return negative/zero/positive if s1 is lexically less/equal/greater s2.
*/

static inline int
strncmp( const char * s1, const char * s2, int n )
{
for ( ; n > 0; s1++, s2++, n-- )
if ( ! ( *s1 && *s2 && ( *s1 == *s2 ) ) )
return *s1 - *s2;
return 0;
}

/*
* Return pointer to c in s, if present.
* Null, otherwise.
*/
static inline char *
index( const char * s, char c )
{
for ( ; *s; s++ )
if ( *s == c )
return (char *) s;
if (*s == c) return (char *) s;
return (char *) 0;
}

#endif /* CFRONT */

/*
* Append s2 to s1.
* Return s1.
*/
static inline char *
strcat( char * s1, const char * s2 )
{
char * p = s1 + strlen( s1 );
(void) strcpy( p, s2 );
return s1;
}

/*
* Replace leftmost occurrence of c in string with a null character.
* (Primarily intended for chopping newlines from input strings.)
* Return string.
*/
static inline char *
chop( char * s, char c )
{
char * pos = index( s, c );
if( pos != 0 )
*pos = '\0';
return( s );
}

#endif String_h


  3 Responses to “Category : Alternate Operating Systems - Quarterdeck DesqView, CP/M, etc
Archive   : PCCAPP.ZIP
Filename : STRING.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/