#include "util.h"

#include <string.h>
#include <ctype.h>

int isTagChar(int ch)
{
  if (ch==0x21||
      (ch>=0x23&&ch<=0x27)||(ch>=0x2c&&ch<=0x5b)||
      (ch>=0x5d&&ch<=0x7a)||(ch>=0x7c&&ch<=0x7e))
    return 1;
  else
    return 0;
}

int isQuotedChar(int ch)
{
  if (ch=='\\'||(ch>=0x01&&ch<=0x09)||
      (ch>=0x0b&&ch<=0x0c)||(ch>=0x0e&&ch<=0x21)||
      (ch>=0x23&&ch<=0x5b)||(ch>=0x5d&&ch<=0x7f))
    return 1;
  else
    return 0;
}

int isCRLF(char *str)
{
  return str[0]==0x0a||str[0]==0x0d;
}

int containsCRLF(char *str)
{
  for (; *str; str++)
    if (*str=='\n'||*str=='\r')
      return 1;

  return 0;
}

void strToUpper(char *str)
{
  for (;*str;str++)
    *str = toupper(*str);
}
