Example #1
0
File: html.cpp Project: pikma/Snap
void THtmlLx::GetEscCh(){
  GetCh();
  EscCh=(Ch=='&');
  if (EscCh){
    EscChA.Clr(); EscChA.AddCh(Ch); GetCh();
    if (Ch=='#'){
      EscChA.AddCh(Ch); GetCh();
      if (('0'<=Ch)&&(Ch<='9')){
        do {EscChA.AddCh(Ch); GetCh();} while (('0'<=Ch)&&(Ch<='9'));
        if (Ch==';'){GetCh();}
        PutStr(ChDef.GetEscStr(EscChA));
      } else {
        PutCh('#'); PutCh('&');
      }
    } else
    if (('a'<=Ch)&&(Ch<='z')||('A'<=Ch)&&(Ch<='Z')){
      do {
        EscChA.AddCh(Ch); GetCh();
      } while (('A'<=Ch)&&(Ch<='Z')||('a'<=Ch)&&(Ch<='z')||('0'<=Ch)&&(Ch<='9'));
      if (Ch==';'){GetCh();}
      PutStr(ChDef.GetEscStr(EscChA));
    } else {
      PutCh('&');
    }
  }
}
Example #2
0
static void WriteField(CARDINAL position, BOOLEAN allowSpace, 
                       CARDINAL *i)
{
  CARDINAL spaces;
  BOOLEAN  quoted = FALSE;
  /*Get to right position*/
  Tab(position);
  while ((!quoted && (!TermCheck(currentLinePointer[*i]) ||
    (allowSpace && (currentLinePointer[*i] == Space)))) ||
    (quoted && (currentLinePointer[*i] != CR))) {
    if (currentLinePointer[*i] == Space) {
      spaces = 0;
      while (currentLinePointer[*i + spaces] == Space) spaces++;

      if ((currentLinePointer[*i + spaces] == CR) || (!quoted && (currentLinePointer[*i + spaces] == CommentSymbol)))
       {
        i += spaces;
        return;
      }; /* if */
      do PutCh(currentLinePointer[(*i)++]);
      while (currentLinePointer[*i] == Space);
    } else {
      PutCh(currentLinePointer[*i]);
      if (currentLinePointer[*i] == Quotes) quoted = !quoted;
      (*i)++;
    }; /* if */
  }; /* while */
  while (currentLinePointer[*i] == Space) (*i)++;
} /* End WriteField */
Example #3
0
static void lib_int_RawDoFmtNumber(UINT32 ul, int base, void (*PutCh)(INT32, APTR), APTR PutChData, int pad0flag, int width)
{
	// hold a long in base 2
	char *p, buf[(sizeof(long) * 8) + 1];
	int i;

	p = buf;

	do {
		*p++ = "0123456789abcdef"[ul % base];
	} while (ul /= base);

	if(p-buf < width)
	{
		if(pad0flag == 1)
		{
			for(i=0; i < width - (p-buf); i++)
				PutCh('0', PutChData);
		}
		else
		{
			for(i=0; i < width - (p-buf); i++)
				PutCh(' ', PutChData);
		}

	}

	do {
		PutCh(*--p, PutChData);
	} while (p > buf);
}
Example #4
0
int TSOut::PutSep(const int& NextStrLen){
  int Cs=0;
  if (MxLnLen==-1){
    Cs+=PutCh(' ');
  } else {
    if (LnLen>0){
      if (LnLen+1+NextStrLen>MxLnLen){Cs+=PutLn();} else {Cs+=PutCh(' ');}
    }
  }
  return Cs;
}
Example #5
0
void ListRegValue(CARDINAL reg)
{
  if (((1 << ListPC) & listStatus) && printState) {
    PutChs("       ");
    PutHexCh(reg);
    PutCh(Space);
  }; /* if */
} /* End ListRegValue */
Example #6
0
void ListWordValue(CARDINAL w)
{
  if (printState && ((1 << ListPC) & listStatus)) {
    if (linePosition >= TextStart) PutLine();
    Tab(CodeStart);
    PutHexCardinal(w);
    PutCh(Space);
  }; /* if */
} /* End ListWordValue */
Example #7
0
void PutStrPgm(PGM_P str)
{
	char ch;
	do {
		ch=pgm_read_byte(str++);
		if(ch)
			PutCh(ch);
	}while(ch);
}
Example #8
0
void GetB(char buf[BUF_MAX])
{	
	int i = 0;

	while (i < BUF_MAX)
	{
		buf[i] = GetCh();
		PutCh(buf[i]);
		i++;
		if (buf[i-1] == CR)
		{
			buf[i] = '\0';
			break;
		}
	}	
	PutCh(CR);
	PutCh(LF);
	return;
}
Example #9
0
/* GSTrans character output */
static void EscapeWriteCh(char ch)
{
 if ((ch >= Space) && (ch < Del))
  PutCh(ch) ;
 else
  if (ch == Del)
   PutChs("|?") ;
  else
   if (ch > Del)
    {
     PutChs("|!") ;
     EscapeWriteCh(ch - 0x80) ;
    }
   else
    {
     PutCh('|') ;
     PutCh(ch + 0x40) ;
    }
} /* End EscapeWriteCh */
Example #10
0
void ListByteValue(char b)
{
  if (printState && ((1 << ListPC) & listStatus)) {
    if (linePosition >= TextStart) PutLine();
    Tab(CodeStart);
    PutHexCh(b / 0x10);
    PutHexCh(b % 0x10);
    PutCh(Space);
  }; /* if */
} /* End ListByteValue */
Example #11
0
File: flx.cpp Project: Accio/snap
int TMOut::PutBf(const void* LBf, const int& LBfL){
  int LBfS=0;
  if (BfL+LBfL>MxBfL){
    for (int LBfC=0; LBfC<LBfL; LBfC++){
      LBfS+=PutCh(((char*)LBf)[LBfC]);}
  } else {
    for (int LBfC=0; LBfC<LBfL; LBfC++){
      LBfS+=(Bf[BfL++]=((char*)LBf)[LBfC]);}
  }
  return LBfS;
}
Example #12
0
void PutLine(void)
{
  CARDINAL i;
  if (linePosition != 0) {
    PutCh(CR);
    newLine[linePosition] = 0;
    i = 0;
    while (newLine[i] != 0) WriteCh(newLine[i++]);
    linePosition = 0;
  }; /* if */
} /* End PutLine */
bool THttpLx::IsLws(){
  if ((Ch==' ')||(Ch==TCh::TabCh)){
    return true;
  } else
  if (Ch==TCh::CrCh){
    GetCh();
    if (Ch==TCh::LfCh){
      GetCh(); bool Ok=(Ch==' ')||(Ch==TCh::TabCh);
      PutCh(TCh::LfCh); PutCh(TCh::CrCh); return Ok;
    } else {
      PutCh(TCh::CrCh); return false;
    }
  } else
  if (Ch==TCh::LfCh){
    GetCh(); bool Ok=(Ch==' ')||(Ch==TCh::TabCh);
    PutCh(TCh::LfCh); return Ok;
  } else {
    return false;
  }
}
Example #14
0
int TMOut::PutBf(const void* LBf, const TSize& LBfL){
  int LBfS=0;
  if (TSize(BfL+LBfL)>TSize(MxBfL)){
    for (TSize LBfC=0; LBfC<LBfL; LBfC++){
      LBfS+=PutCh(((char*)LBf)[LBfC]);}
  } else {
    for (TSize LBfC=0; LBfC<LBfL; LBfC++){
      LBfS+=(Bf[BfL++]=((char*)LBf)[LBfC]);}
  }
  return LBfS;
}
Example #15
0
static void WriteComment(CARDINAL *i)
{
  CARDINAL tempPosition,
           length;
  if (currentLinePointer[*i] != CommentSymbol)
   {

    /*This is the silly line format case*/
    while (currentLinePointer[*i] != CR) PutCh(currentLinePointer[(*i)++]);
    PutLine();
  } else {
    if (linePosition <= TextStart) tempPosition = TextStart;
    else {
      tempPosition = CommentStart;
      PutCh(Space);
    }; /* if */
    Tab(tempPosition);
    if (linePosition > CommentStart) {
      length = 0;
      while (currentLinePointer[*i + length] != CR) length++;
      if ((linePosition + length > maxCols) &&
        (tempPosition + length <= maxCols)) {
        PutLine();
        Tab(CommentStart);
      }; /* if */
    }; /* if */
    do {
      while (linePosition < maxCols) {
        if (currentLinePointer[*i] == CR) break;
        PutCh(currentLinePointer[(*i)++]);
      }; /* while */
      if (linePosition < maxCols) break;
        /* The previous break was meant to leave the loop */
      PutLine();
      Tab(tempPosition);
    } while (1);
  }; /* if */
} /* End WriteComment */
Example #16
0
int GetS(char* buf)
{
	int i = 0;

	while (i < MAX_BUF)
	{
		buf[i]  = GetCh();
		if (!( zIsAlnum(buf[i]) || buf[i] == ENTER || buf[i] == BACKSPACE || buf[i] == '+' || buf[i] == '-' || buf[i] == '*' || buf[i] == '/' || buf[i] == '%' || buf[i] == '(' || buf[i] == ')' || buf[i] == '=' ))
		{
			continue;
		}		
		PutCh(buf[i]);
		buf[i] = zToLower(buf[i]);	// 대문자가 입력되면 소문자로 변환해버려라
		i++;
		if (buf[i-1] == CR)	// 엔터가 입력되면 마지막에 NULL을 추가하고 멈춘다.
		{
			buf[i] = '\0';
			break;
		}
	}
	PutCh(CR);
	PutCh(LF);
	return i;
}
Example #17
0
void PrintLineNumber(void)
{
  char     digits[7];
  int      i;
  CARDINAL j;
  BOOLEAN  suppress = FALSE;
  j = lineNumber;
  for (i = 5; i >= 0; i--) {
    digits[i] = (suppress) ? Space : '0' + (j % 10);
    j = j / 10;
    suppress = j == 0;
  }; /* for */
  if (linePosition > 0) PutLine();
  digits[6] = 0;
  PutChs(digits);
  PutCh(Space);
} /* End PrintLineNumber */
bool THttpLx::IsRespStatusLn(){
  static const TChA MouldChA="http/N.N NNN ";
  TChA TestChA(MouldChA);
  int TestLen=TestChA.Len();
  if (1+Len()<TestLen){return false;}
  TestChA.PutCh(0, ChDef.GetLcCh(Ch));
  {for (int ChN=1; ChN<TestLen; ChN++){
    TestChA.PutCh(ChN, ChDef.GetLcCh(GetCh()));}}
  {for (int ChN=1; ChN<TestLen; ChN++){
    PutCh(TestChA[TestLen-ChN-1]);}}
  {for (int ChN=0; ChN<MouldChA.Len(); ChN++){
    if (MouldChA[ChN]=='N'){
      if (!ChDef.IsDigit(TestChA[ChN])){return false;}
    } else {
      if (MouldChA[ChN]!=TestChA[ChN]){return false;}
    }
  }}
  return true;
}
Example #19
0
void PrintLine(void)
{
  CARDINAL i = 0;
  if (!linePrinted) {
    if (TextStart >= maxCols) {
      /*This is the silly line format case*/
      if (linePosition > TextStart) PutLine();
      else Tab(TextStart);
      while (currentLinePointer[i] != CR) PutCh(currentLinePointer[i++]);
    } else {
      /*This is the sensible case*/
      if ((linePosition > TextStart) && (currentLinePointer[i] != Space))
        PutLine();
      do {

        if ((currentLinePointer[i] == CommentSymbol) || (OpcodeStart >= maxCols))
         break;
        /*Write out the label*/
        WriteField(TextStart, FALSE, &i);

        if ((currentLinePointer[i] == CR) || (currentLinePointer[i] == CommentSymbol) || (OperandStart >= maxCols))
         break ;

        /*We have an opcode*/
        if (linePosition >= OpcodeStart) PutLine();
        WriteField(OpcodeStart, FALSE, &i);

        if ((currentLinePointer[i] == CR) || (currentLinePointer[i] == CommentSymbol) || (CommentStart >= maxCols))
         break ;

        /*We have an operand*/
        if (linePosition >= OperandStart) PutLine();
        WriteField(OperandStart, TRUE, &i);
      } while (1);
      if (currentLinePointer[i] != CR) WriteComment(&i);
    }; /* if */
    PutLine();
  }; /* if */
  linePrinted = TRUE;
  linePosition = 0;
  if (PollEscape()) abortFlag = TRUE;
} /* End PrintLine */
Example #20
0
/////////////////////////////////////////////////
// Standard-Output
int TStdOut::PutBf(const void* LBf, const TSize& LBfL){
  int LBfS=0;
  for (TSize LBfC=0; LBfC<LBfL; LBfC++){
    LBfS+=PutCh(((char*)LBf)[LBfC]);}
  return LBfS;
}
Example #21
0
int TSOut::PutDosLn(const int& Lns){
  LnLen=0; int Cs=0;
  for (int LnN=0; LnN<Lns; LnN++){Cs+=PutCh(TCh::CrCh)+PutCh(TCh::LfCh);}
  return Cs;
}
Example #22
0
int TSOut::PutLn(const int& Lns){
  LnLen=0; int Cs=0;
  for (int LnN=0; LnN<Lns; LnN++){Cs+=PutCh('\n');}
  return Cs;
}
Example #23
0
int TSOut::PutIndent(const int& IndentLev){
  return PutCh(' ', IndentLev*2);
}
Example #24
0
static void Tab(CARDINAL position)
{
  while (linePosition < position) PutCh(Space);
} /* End Tab */
Example #25
0
static void PutHexCh(Hex hex)
{
  PutCh((hex >= 10) ? hex - 10 + 'A' : hex + '0');
} /* End PutHexCh */
Example #26
0
void TMOut::MkEolnLn(){
  if (!IsEolnLn()){
    PutCh(TCh::CrCh); PutCh(TCh::LfCh);}
}
Example #27
0
static void PutChs(char *chs)
{
  CARDINAL i,
           j = strlen(chs);
  for (i = 0; i < j; i++) PutCh(chs[i]);
} /* End PutChs */
Example #28
0
TSqlDmLxSym TSqlDmLx::GetSym(const TFSet& Expect){
  if (!PrevSymStStack.Empty()){
    // symbols already on the stack
    PrevSymStStack.Top().Restore(*this); PrevSymStStack.Pop();
  } else {
    // usual symbol
    while (ChDef.IsSpace(Ch)){GetCh();}
    SymLnN=LnN; SymLnChN=LnChN; SymChN=ChN;

    if (ChDef.IsAlpha(Ch)){ // name
      Str.Clr(); UcStr.Clr();
      do {Str.AddCh(Ch); UcStr.AddCh(ChDef.GetUc(Ch));}
      while (ChDef.IsAlNum(GetCh()));
      Sym=TSqlDmLxSymStr::GetRwSym(UcStr);
      if (Sym==dsyUndef){Sym=dsyName;}
    } else
    if (Ch=='['){ // bracketed name
      Str.Clr(); UcStr.Clr(); GetCh();
      while ((Ch!=']')&&(Ch!=TCh::EofCh)){
        Str.AddCh(Ch); UcStr.AddCh(ChDef.GetUc(Ch)); GetCh();}
      if (Ch==TCh::EofCh){Sym=dsyUndef;}
      else {Sym=dsyName; GetCh();}
    } else
    if (Ch=='\''){ // string in single quotes
      Str.Clr(); UcStr.Clr(); GetCh();
      while ((Ch!='\'')&&(Ch!=TCh::EofCh)){
        Str.AddCh(Ch); UcStr.AddCh(ChDef.GetUc(Ch)); GetCh();}
      if (Ch==TCh::EofCh){Sym=dsyUndef;}
      else {Sym=dsyStr; GetCh();}
    } else
    if (ChDef.IsNum(Ch)){ // integer or float
      Str.Clr();
      do {Str.AddCh(Ch);} while (ChDef.IsNum(GetCh()));
      if (Ch=='.'){
        Str.AddCh(Ch);
        while (ChDef.IsNum(GetCh())){Str.AddCh(Ch);}
      }
      if ((Ch=='e')||(Ch=='E')){
        Str.AddCh(Ch); GetCh();
        if ((Ch=='+')||(Ch=='-')){Str.AddCh(Ch); GetCh();}
        while (ChDef.IsNum(Ch)){Str.AddCh(Ch); GetCh();}
      }
      UcStr=Str;
      if (Expect.In(syFlt)){Sym=dsyFlt; Flt=atof(Str.CStr());}
      else {Sym=dsyInt; Int=atoi(Str.CStr());}
    } else
    if (Ch=='/'){ // slash or // commenatry or /* */ commentary
      GetCh();
      if (Ch=='/'){
        do {GetCh();} while (!ChDef.IsEof(Ch));
        if (Ch==TCh::CrCh){
          if (GetCh()==TCh::LfCh){GetCh();}
        } else
        if (Ch==TCh::LfCh){
          if (GetCh()==TCh::CrCh){GetCh();}
        }
        GetSym(Expect);
      } else
      if (Ch=='*'){
        do {while (GetCh()!='*'){}} while (GetCh()!='/');
        GetCh(); GetSym(Expect);
      } else {
        Sym=dsySlash;
      }
    } else
    if (Ch=='-'){ // minus or -- commenatry
      GetCh();
      if (Ch=='-'){
        do {GetCh();} while (!ChDef.IsEof(Ch));
        if (Ch==TCh::CrCh){
          if (GetCh()==TCh::LfCh){GetCh();}
        } else
        if (Ch==TCh::LfCh){
          if (GetCh()==TCh::CrCh){GetCh();}
        }
        GetSym(Expect);
      } else {
        Sym=dsyMinus;
      }
    } else
    if (Ch==TCh::EofCh){ // end-of-file
      Sym=dsyEof;
    } else { // other symbols
      switch (Ch){
        case ',': Sym=dsyComma; GetCh(); break;
        case '.':
          if (ChDef.IsNum(GetCh())){
            PutCh('.'); PutCh('0'); return GetSym(Expect);}
          else {Sym=dsyPeriod;}
          break;
        case ';': Sym=dsySemicolon; GetCh(); break;
        case '<':
          GetCh();
          if (Ch=='='){Sym=dsyLEq; GetCh();}
          else if (Ch=='>'){Sym=dsyNEq; GetCh();}
          else {Sym=dsyLss;} break;
        case '=': Sym=dsyEq; GetCh(); break;
        case '>':
          if (GetCh()=='='){Sym=dsyGEq; GetCh();}
          else {Sym=dsyGtr;} break;
        case '+': Sym=dsyPlus; GetCh(); break;
        case '-': Sym=dsyMinus; GetCh(); break;
        case '*': Sym=dsyAsterisk; GetCh(); break;
        case '/': Sym=dsySlash; GetCh(); break;
        case '(': Sym=dsyLParen; GetCh(); break;
        case ')': Sym=dsyRParen; GetCh(); break;
        case '{': Sym=dsyLBrace; GetCh(); break;
        case '}': Sym=dsyRBrace; GetCh(); break;
        default: Sym=dsyUndef; GetCh(); break;
      }
    }
  }

  if ((!Expect.In(Sym))&&(!Expect.Empty())){
   TStr MsgStr=
    TStr("Unexpected symbol (")+Str+") ["+GetFPosStr()+"]";
   throw TExcept::Throw(MsgStr);
  }
  return Sym;
}
Example #29
0
int TSOut::PutCh(const char& Ch, const int& Chs){
  int Cs=0;
  for (int ChN=0; ChN<Chs; ChN++){Cs+=PutCh(Ch);}
  return Cs;
}
Example #30
0
void PrintAddress(void)
{
  Tab(PCStart);
  PutHexCardinal(programCounter);
  PutCh(Space);
} /* End PrintAddress */