picoc/platform_surveyor.c
zik.saleeba 968fc12e69 Now printing '\n' on the srv-1 will send "\r\n" so it behaves as expected
rather than having to explicitly send '\r'.


git-svn-id: http://picoc.googlecode.com/svn/trunk@343 21eae674-98b7-11dd-bd71-f92a316d2d60
2009-10-22 20:14:47 +00:00

59 lines
1 KiB
C

#include "picoc.h"
/* deallocate any storage */
void PlatformCleanup()
{
}
/* get a line of interactive input */
char *PlatformGetLine(char *Buf, int MaxLen)
{
int ix;
char ch, *cp;
ix = 0;
cp = Buf;
while (ix++ < MaxLen) {
ch = getch();
if (ch == 0x1B) { // ESC character - exit
printf("leaving picoC\n\r");
return NULL;
}
if (ch == '\n') {
*cp++ = '\n'; // if newline, send newline character followed by null
*cp = 0;
return Buf;
}
*cp++ = ch;
ix++;
}
return NULL;
}
/* write a character to the console */
void PlatformPutc(unsigned char OutCh, union OutputStreamInfo *Stream)
{
if (OutCh == '\n')
putchar('\r');
putchar(OutCh);
}
/* read a character */
int PlatformGetCharacter()
{
return getch();
}
/* mark where to end the program for platforms which require this */
int ExitBuf[41];
/* exit the program */
void PlatformExit()
{
ExitBuf[40] = 1;
longjmp(ExitBuf, 1);
}