#define DOS_CRLF

//------------------------------------------------------------
int readLine(char *str,unsigned max_strlen)
{
  char character_read = '\0';
  unsigned num_chars = 0;

#ifdef DOS_CRLF
  short read_lf = 1;
#endif

  if ((max_strlen <= 1) || (str == NULL))
    return(ILLEGAL_ARGUMENTS);

#ifdef DOS_CRLF
  while((character_read = getchar()) != 0x0d)
#else
  while((character_read = getchar()) != '\n')
#endif
  {
    *str++ = character_read;
    if (++num_chars >= max_strlen)
    {
#ifdef DOS_CRLF
      read_lf = 0;
#endif
      break;
    }
  }
#ifdef DOS_CRLF
  if (read_lf)
    getchar();
#endif
  *str = '\0';
  return(num_chars);
}

