Files
Digital-Research-Source-Code/CPM OPERATING SYSTEMS/CPM 68K/cpm68k_pgms/sdbas/JUNK.C
Sepp J Morris 31738079c4 Upload
Digital Research
2020-11-06 18:50:37 +01:00

1 line
1.5 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* PCJUNK.C Misc. procedures */
#include <stdio.h>
#include "sdbio.h"
/* Replaces JUNK.C for the IBM/PC version dns */
char *alloc(n)
int n;
{
return (char*) malloc(n);
}
int getcx(fp)
FILE *fp;
{
#ifdef Lattice
static char buf[LINEMAX] = {0};
static char *pbuf = buf;
int ch, i;
if (fp!=stdin)
if ((ch = getc(fp)) == '\r')
return getc(fp);
else
return ch;
if (*pbuf > 0)
return *pbuf++;
pbuf = buf;
for (i = 0; (ch = getc(fp)) != -1; )
if (i < LINEMAX) {
if (ch == ESC) { i=0; putchar('\n'); fflush(stdout); } else
if (ch == BS) { if (i>0) i--; } else
buf[i++] = ch;
if (ch == '\n') break;
}
else {
printf("*** line too long ***\nRetype> ");
i = 0;
}
buf[i] = EOS;
return getcx(fp);
#else
return(getc(fp));
#endif
}
/* string copy up to n characters */
#ifdef Lattice
strncpy(to, from, n)
char *to, *from;
int n;
{
char *cp;
for( cp=to; n-- && (*cp++ = *from++); ) ;
if( n<0 ) *cp = 0;
return to;
}
/* string compare up to n characters */
strncmp(s1, s2, n)
char *s1, *s2;
int n;
{
for( ;n-- && (*s1==*s2); s2++ )
if( !*s1++ )
return 0;
if( n < 0 )
return 0;
if( *s1 < *s2 )
return -1;
return 1;
}
#endif