home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
pub
/
researchmachines
/
rmlcsu.c
< prev
next >
Wrap
Text File
|
2020-01-01
|
3KB
|
189 lines
/* File KCSUPP.C - Useful routines for C programs;
Chris Kennington. RML. 5th July 1985. */
#include "stdio.h"
#define CTLC 0x03
#define BKSP 0x08
#define TAB 0x09
#define CR 0x0d
#define LF 0x0a
#define SP 0x20
extern char blanx[], null[], pager, scrline;
bell()
{
putchar(0x07);
return;
}
blockmv(to,from,len) /* move block of memory */
char *to, *from;
int len;
/* convert to new routine movmem() by parm swapping */
{
movmem(from,to,len);
return;
} /* end of blockmv() */
clrscrn() /* clear scrolling screen */
{
int i;
for (i=5; i<25; ++i)
vtline(i*256,blanx);
curset(6,0);
return;
} /* end of clrscrn() */
char decol8(line,arr,num) /* decollate command-line */
/* Splits up line into sections delimited by controls or blanks,
zeros all such chars & places start-addresses into array,
up to maximum of num entries; zeros rest of entries and
returns count of valid entries. */
char *line, *arr[], num;
{
char c, count, i, j, *start;
j = count = 0;
start = line;
for (i=0; i<80, j<num; ++i) {
if ( ( (c = line[i]) <= SP) || (c == '=') ) {
line[i] = 0; /* terminator */
if (count > 0) {
arr[j++] = start;
count = 0;
}
if (c == 0)
break; /* out of for */
}
else if (count++ == 0) /* printable */
start = &line[i]; /* start next parm */
} /* end else, for */
line[i] = 0; /* terminate last parm */
i = j; /* number of parms */
while (j < num)
arr[j++] = 0; /* clear garbage */
return(i);
} /* End of decol8() */
char strcop(s,t) /* as C manual p. 101; copy *s => *t */
char *s, *t;
{
while (*t++ = *s++)
;
} /* End of strcop() */
txtout(str) /* string to screen by outc() */
char *str;
{
char c;
while( (c = *str++) != 0 )
outc(c);
return;
} /* end of txtout() */
/************************************************************************/
/* printf() extracted form Aztec-c 1.06d CP/M
modified to use outfc() */
/* Copyright (C) 1981, 1982 by Manx Software Systems */
/* Copyright (C) 1983 by Manx Software Systems */
/* Copyright 1985 by RML - Chris K. March 1985. */
printf(fmt,args)
char *fmt; unsigned args;
{
int outfc();
format(outfc,fmt,&args);
}
format(putsub, fmt, args)
register int (*putsub)(); register char *fmt; unsigned *args;
{
register int c;
char *ps;
char s[8];
static char *dconv(), *hexconv();
while ( c = *fmt++ ) {
if ( c == '%' ) {
switch ( c = *fmt++ ) {
case 'x':
ps = hexconv(*args++, s+7);
break;
case 'u':
ps = dconv(*args++, s+7);
break;
case 'd':
if ( (int)*args < 0 ) {
ps = dconv(-*args++, s+7);
*--ps = '-';
} else
ps = dconv(*args++, s+7);
break;
case 's':
ps = *args++;
break;
case 'c':
c = *args++;
default:
goto deflt;
}
while ( *ps )
(*putsub)(*ps++);
} else
deflt:
(*putsub)(c);
}
}
static char *
dconv(n, s)
register char *s; register unsigned n;
{
*s = 0;
do {
*--s = n%10 + '0';
} while ( (n /= 10) != 0 );
return s;
}
static char *
hexconv(n, s)
register char *s; register unsigned n;
{
*s = 0;
do {
*--s = "0123456789abcdef" [n&15];
} while ( (n >>= 4) != 0 );
return s;
}
/************* End of Aztec printf.c ***********************************/
/**************** End of file KCSUPP.C *************************/