Exemple #1
0
/* read Blocks of the form
** [BLOCKID]
** identifier   ... anything ...
** identifier   ... anything ...
*/
static Bool TXTfindSection(struct TXTFILE *TXT,Bool Match)
{ Int16 c=0,val=0,n;
  char buffer[8];
  while(1)
  { if(TXTskipComment(TXT)!=TRUE) return FALSE;
    if(TXTgetc(TXT,&c,&val)!=TRUE)return FALSE;
    if(c=='[')
    { for(n=0;n<256;n++)
      { if(TXTgetc(TXT,&c,&val)!=TRUE) return FALSE;
	if(c==']')
	{ if(n<8)buffer[n]='\0';
	  if(Match==FALSE) return TRUE;/*any section is ok*/
	  Normalise(buffer,buffer);        /*the right section?*/
	  if(strncmp(buffer,TXT->Section,8)==0) return TRUE;
	  break; 			   /*not the right section*/
	}
	if(!(val & (NAME|NUMBER))) break;  /*not a section*/
	if(n<8) buffer[n]=c;
      }
    }
    while(1) /*look for end of line*/
    { if(TXTgetc(TXT,&c,&val)!=TRUE)return FALSE;
      if(val & NEWLINE) break;
    }
  }
}
Exemple #2
0
/*return FALSE if read End*/
Bool TXTreadTexDef(struct TXTFILE *TXT,char name[8],Int16 *szx,Int16 *szy)
{ if(TXTok!=TRUE) Bug("TR71", "TxtTxd");
  if(TXTskipComment(TXT)==FALSE) return FALSE; /*End*/
  if(TXTread(TXT,name,NAME|NUMBER)!=TRUE)
    ProgError("TR73", "%s(%ld): expecting identifier",
	fname (TXT->pathname), (long) TXT->Lines);
  Normalise(name,name);
  *szx=TXTreadShort(TXT);
  *szy=TXTreadShort(TXT);
  return TRUE;
}
Exemple #3
0
/*read a patch def.  Return FALSE if could not find '*' */
Bool TXTreadPatchDef(struct TXTFILE *TXT,char name[8],Int16 *ofsx,Int16 *ofsy)
{ if(TXTok!=TRUE) Bug("TR81", "TxtRpd");
  if(TXTskipComment(TXT)==FALSE) return FALSE;
  if(TXTcheckStartPatch(TXT)!=TRUE) return FALSE; /*not a patch line*/
  if(TXTread(TXT,name,NAME|NUMBER)!=TRUE)
	   ProgError("TR83", "%s(%ld): expecting identifier",
	       fname (TXT->pathname), (long) TXT->Lines);
  Normalise(name,name);
  *ofsx=TXTreadShort(TXT);
  *ofsy=TXTreadShort(TXT);
  return TRUE;
}
Exemple #4
0
static Bool TXTreadIdent(struct TXTFILE *TXT,char name[8])
{ if(TXTok!=TRUE) Bug("TR21", "%s: TxtRid", fname (TXT->pathname));
  if(TXTskipComment(TXT)==FALSE) return FALSE;
  /*check end of section*/
  if((TXT->Lines)>(TXT->SectionEnd))
  { if(TXTboundSection(TXT)==FALSE)
      return FALSE;   /*no other section*/
  }
  if(TXTread(TXT,name,NAME|NUMBER)!=TRUE)
    ProgError("TR23", "%s(%ld): expected identifier or \"END:\"",
	TXT->pathname, (long) TXT->Lines);
  Normalise(name,name);
  return TRUE;
}
Exemple #5
0
/*return false if read End*/
bool TXTreadTexDef(struct TXTFILE * TXT, char name[8], int16_t * szx,
                   int16_t * szy)
{
    if (!TXTok)
        Bug("TR71", "TxtTxd");
    if (!TXTskipComment(TXT))
        return false;           /*End */
    if (!TXTread(TXT, name, NAME | NUMBER))
        ProgError("TR73", "%s(%ld): expecting identifier",
                  fname(TXT->pathname), (long) TXT->Lines);
    Normalise(name, name);
    *szx = TXTreadShort(TXT);
    *szy = TXTreadShort(TXT);
    return true;
}
Exemple #6
0
/*read a patch def.  Return false if could not find '*' */
bool TXTreadPatchDef(struct TXTFILE * TXT, char name[8], int16_t * ofsx,
                     int16_t * ofsy)
{
    if (!TXTok)
        Bug("TR81", "TxtRpd");
    if (!TXTskipComment(TXT))
        return false;
    if (!TXTcheckStartPatch(TXT))
        return false;           /*not a patch line */
    if (!TXTread(TXT, name, NAME | NUMBER))
        ProgError("TR83", "%s(%ld): expecting identifier",
                  fname(TXT->pathname), (long) TXT->Lines);
    Normalise(name, name);
    *ofsx = TXTreadShort(TXT);
    *ofsy = TXTreadShort(TXT);
    return true;
}
Exemple #7
0
/* read Blocks of the form
** [BLOCKID]
** identifier   ... anything ...
** identifier   ... anything ...
*/
static bool TXTfindSection(struct TXTFILE *TXT, bool Match)
{
    int16_t c = 0, val = 0, n;
    char buffer[8];
    while (1) {
        if (!TXTskipComment(TXT))
            return false;
        if (!TXTgetc(TXT, &c, &val))
            return false;
        if (c == '[') {
            for (n = 0; n < 256; n++) {
                if (!TXTgetc(TXT, &c, &val))
                    return false;
                if (c == ']') {
                    if (n < 8)
                        buffer[n] = '\0';
                    if (!Match)
                        return true;    /*any section is ok */
                    Normalise(buffer, buffer);  /*the right section? */
                    if (strncmp(buffer, TXT->Section, 8) == 0)
                        return true;
                    break;      /*not the right section */
                }
                if (!(val & (NAME | NUMBER)))
                    break;      /*not a section */
                if (n < 8)
                    buffer[n] = c;
            }
        }
        while (1) {             /*look for end of line */
            if (!TXTgetc(TXT, &c, &val))
                return false;
            if (val & NEWLINE)
                break;
        }
    }
}