/****************************************************************************
** File Name: main.c
** Description:
** Generated Automatically for: ARM7TDMI-S3c4510b Evaluation Board.
** Time: Monday, May 26, 2003 11:08:05
** Copyright 1999-2004 Jedi Systems Inc.
****************************************************************************/
#include <string.h>
#include <stdio.h>
#include "uart_ev2500.h"

int _write (int file, char *ptr, int len);

void print (char *ptr);

int main() 
{ 
        int i;
        char *str = "helo, world\na new line here\n";
        char buf[100];
        i = sizeof (str);

        /* test our serial I/O */
        dev_uart_init (0, 0, 0);

        crtio (115200);  /* change baund rate */
        buf[18] = 0;
        printf ("printed by printf\n");
        printf ("printed by printf again\n");
                //print (str); 
                //_write (1, str, 18);
        printf ("printed byte(s) of str is: %d \n", i);

        while (1) {
                if ((i = inbyte()) != EOF) {
                        buf[0] = (char)i;
			printf("%c",buf[0]);
                        break;
                }
        }
        return (i);
} 


/*
 * print -- do a raw print of a string
 */
void
print (char *ptr)
{
        while (*ptr) {
                outbyte (*ptr++);
        }
}

/* my own _write */
#if 0
int
_write (int file, char *ptr, int len)
{
        int i;

        for (i = 0; i< len; i++) {
                outbyte (*ptr++);
        }
        /*
          while (*ptr) {
          outbyte (*ptr++);
          }
        */
        return (1);
}
//#else
int
_write (int fd, char *buf, int nbytes)
{
  int i;

  for (i = 0; i < nbytes; i++) {
    if (*(buf + i) == '\n') {
      outbyte ('\r');
    }
    outbyte (*(buf + i));
  }
  return (nbytes);
}
#endif
void
_exit (int n)
{
  /* FIXME: return code is thrown away.  */
  n = n;
}

void
initialise_monitor_handles (void)
{

}


