Пример #1
0
int PDSDataset::ParseCompressedImage()

{
    CPLString osFileName = GetKeyword( "COMPRESSED_FILE.FILE_NAME", "" );
    CleanString( osFileName );

    CPLString osPath = CPLGetPath(GetDescription());
    CPLString osFullFileName = CPLFormFilename( osPath, osFileName, NULL );
    int iBand;

    poCompressedDS = (GDALDataset*) GDALOpen( osFullFileName, GA_ReadOnly );
    
    if( poCompressedDS == NULL )
        return FALSE;

    nRasterXSize = poCompressedDS->GetRasterXSize();
    nRasterYSize = poCompressedDS->GetRasterYSize();

    for( iBand = 0; iBand < poCompressedDS->GetRasterCount(); iBand++ )
    {
        SetBand( iBand+1, new PDSWrapperRasterBand( poCompressedDS->GetRasterBand( iBand+1 ) ) );
    }
    
    return TRUE;
}
Пример #2
0
//----------------------------------------------------------------------------
// Returns a string keyword if found. Else a default value
//----------------------------------------------------------------------------
const char* CXMLTreeNode::GetPszKeyword (const char* _pszKey, const char* _pszDefault/*=NULL*/) const
{
  const char* pszRet = _pszDefault;

  xmlChar* value = GetKeyword(_pszKey);

  if (value)
  {
    pszRet = (const char*)value;
  }

  return pszRet;
}
Пример #3
0
//----------------------------------------------------------------------------
// Returns a float keyword if found. Else a default value
//----------------------------------------------------------------------------
float CXMLTreeNode::GetFloatKeyword (const char* _pszKey, float _fDefault/*=0.0*/) const
{
  float fRet = _fDefault;

  xmlChar* value = GetKeyword(_pszKey);

  if (value)
  {
    fRet = static_cast<float>(atof((const char*)value));
  }

  return fRet;
}
Пример #4
0
//----------------------------------------------------------------------------
// Returns an integer keyword if found. Else a default value
//----------------------------------------------------------------------------
int CXMLTreeNode::GetIntKeyword (const char* _pszKey, int _iDefault/*=0*/) const
{
  int iRet = _iDefault;

  xmlChar* value = GetKeyword(_pszKey);

  if (value)
  {
    iRet = atoi((const char*)value);
  }

  return iRet;
}
Пример #5
0
//----------------------------------------------------------------------------
// Returns a float vector3 keyword if found. Else a default value
//----------------------------------------------------------------------------
Vect3f CXMLTreeNode::GetVect3fKeyword  ( const char* _pszKey, const Vect3f& _Default, bool warningDefault ) const
{
	xmlChar* value = GetKeyword(_pszKey);
	Vect3f l_V3f = _Default;

	if ( value )
	{
		const char* pszValue = (const char*)value;
		sscanf_s(pszValue,"%f %f %f",&l_V3f.x, &l_V3f.y, &l_V3f.z);    
	}
	else if(warningDefault)
	{
		LOGGER->AddNewLog(ELL_WARNING, "CXMLTreeNode::GetVect3fKeyword se ha utilizado el vector3f por defecto:(%f,%f,%f) para el tag <%s>",_Default.x, _Default.y, _Default.z, _pszKey);
	}

	xmlFree(value);
	return l_V3f;
}
Пример #6
0
//----------------------------------------------------------------------------
// Returns a boolean keyword if found. Else a default value
//----------------------------------------------------------------------------
bool CXMLTreeNode::GetBoolKeyword (const char* _pszKey, bool _bDefault/*=false*/) const
{
  bool bRet = _bDefault;

  xmlChar* value = GetKeyword(_pszKey);

  if (value)
  {
    const char* pszValue = (const char*)value;
    if (strcmp("TRUE", pszValue) == 0 || strcmp("true", pszValue) == 0 || strcmp("True", pszValue) == 0)
    {
      bRet = true;
    }
    else
      bRet = false;
  }

  return bRet;
}
Пример #7
0
bool AsmFile::Read()
{	
    bool rv = true;
    AsmExpr::ReInit();
    parser->Init();
    bigEndian = parser->IsBigEndian();
    FPF::SetBigEndian(bigEndian);
    Instruction::SetBigEndian(bigEndian);
    listing.SetBigEndian(bigEndian);
    while (!lexer.AtEof())
    {
        bool inInstruction = false;
        try
        {
            if (GetKeyword() == Lexer::openbr)
            {
                Directive();
                thisLabel = NULL;
            }
            else if (parser->MatchesOpcode(GetToken()->GetChars()))
            {
                NoAbsolute();
                NeedSection();
                inInstruction = true;
                int lineno = preProcessor.GetMainLineNo();
                Instruction *ins = parser->Parse(lexer.GetRestOfLine(), currentSection->GetPC());
                if (lineno >= 0)
                    listing.Add(ins, lineno, preProcessor.InMacro());
                NextToken();
                currentSection->InsertInstruction(ins);
                thisLabel = NULL;
            }
            else
            {
                int lineno = preProcessor.GetMainLineNo();
                std::string name = GetId();
                DoLabel(name, lineno);
            }
        }
        catch(std::runtime_error *e)
        {
            Errors::Error(e->what());
            delete e;
            rv = false;
            if (inInstruction)
                NextToken();
            else
                lexer.SkipPastEol();
        }
    }
    for (std::map<std::string, std::string>::iterator it = exports.begin(); it != exports.end(); ++it)
    {
        if (labels[it->first] == NULL)
        {
            Errors::Error(std::string("Undefined export symbol '") + it->first + "'");
            rv = false;
        }
        else
        {
            labels[it->first]->SetPublic(true);
        }
    }
    for (std::set<std::string>::iterator it = globals.begin(); it != globals.end(); ++it)
    {
        if (labels[*it] == NULL)
        {
            Errors::Error(std::string("Undefined public '") + *it + "'");
            rv = false;
        }
        else
        {
            labels[*it]->SetPublic(true);
        }
    }
    return rv && !Errors::ErrorCount();
}
Пример #8
0
void AsmFile::DoDB()
{
    char buf[3000];
    int size = 0;
    bool byte = GetKeyword() == Lexer::DB;
    short val = 0;
    std::deque<Fixup *> fixups;
    NeedSection();
    int lineno = preProcessor.GetMainLineNo();
    do
    {
        int errLine = Errors::GetErrorLine();
        std::string errFile = Errors::GetFileName();
        NextToken();
        if (IsString())
        {
            std::wstring str = GetString();
            int len = str.size();
            if (byte)
            {
                for (int i=0; i < len; i++)
                {
                    buf[size++] = str[i];
                }
            }
            else
            {
                char temp[1000];
                int j;
                for (j=0; j < len; j++)
                    temp[j] = str[j];
                temp[j] = 0;
                for (int i=0; i < len;)
                {
                    int v = UTF8::Decode(temp + i);
                    if (v < 0x10000)
                    {
                        (*(short *)(buf + size)) = v;
                        size += 2;
                    }
                    else
                    {
                        v -= 0x10000;
                        int n1 = v >> 10;
                        int n2 = v & 0x3ff;
                        *((short *)(buf+size)) = n1 + 0xd800;
                        *((short *)(buf+size+2)) = n2 + 0xdc00;
                        size += 4;
                                            
                    }
                    i += UTF8::CharSpan(temp + i);
                }
            }
        }
        else
        {
            AsmExprNode *num = GetNumber();
            Fixup *f = new Fixup(num, byte ? 1 : 2, false, 0);
            f->SetInsOffs(size);
            f->SetFileName(errFile);
            f->SetErrorLine(errLine);
            fixups.push_back(f);
            buf[size++] = 0;
            if (!byte)
                buf[size++] = 0;
        }
    } while (GetKeyword() == Lexer::comma);
Пример #9
0
void AsmFile::DoLabel(std::string &name, int lineno)
{
    NeedSection();
    Label *label;
    if (caseInsensitive)
    {
        for (int i=0; i < name.size(); i++)
            name[i] = toupper(name[i]);
    }
    std::string realName = name;
    bool nl = false;
    if (name.size() > 2)
    {
        if (name[0] == '.' && name[1] == '.' && name[2] == '@')
        {
            if (name.size() == 3)
                throw new std::runtime_error("Malformed non-local label");
            nl = true;
        }
    }
    if (!nl && name[0] == '.')
    {
        if (name == "..start")
        {
            if (startupSection)
            {
                throw new std::runtime_error("Multiple start addresses specified");
            }
            label = new Label(name, labels.size(), currentSection->GetSect());
            startupSection = currentSection;
        }
        else
        {
            if (currentLabel)
            {
                realName = currentLabel->GetName() + name;
            }
        }
    } 
    if (labels[realName] != NULL)
    {
        if (realName != "..start")
        {
            throw new std::runtime_error(std::string("Label '") + name + "' already exists.");
        }
    }
    else
    {
        if (inAbsolute)
        {
            label = new Label(realName, labels.size(), 0);
            label->SetOffset(absoluteValue);
            AsmExpr::SetEqu(realName, new AsmExprNode(absoluteValue));
            if (lineno >= 0)
                listing.Add(label, lineno, preProcessor.InMacro());
        }
        else
        {
            label = new Label(realName, labels.size(), currentSection->GetSect()-1);
        }
        if (name[0] != '.')
        {
            currentLabel = label;
            AsmExpr::SetCurrentLabel(label->GetName());
        }
        thisLabel = label;
        labels[realName] = label;
        numericLabels.push_back(label);
        if (!inAbsolute)
            currentSection->InsertLabel(label);
//		if (lineno >= 0)
//			listing.Add(thisLabel, lineno, preProcessor.InMacro());
        if (realName == "..start")
            startupLabel = label;
    }
    if (GetKeyword() == Lexer::colon)
    {
        NextToken();
        thisLabel = NULL;
    }
}
Пример #10
0
int PDSDataset::ParseImage( CPLString osPrefix )
{
/* ------------------------------------------------------------------- */
/*	We assume the user is pointing to the label (ie. .lbl) file.  	   */
/* ------------------------------------------------------------------- */
    // IMAGE can be inline or detached and point to an image name
    // ^IMAGE = 3
    // ^IMAGE             = "GLOBAL_ALBEDO_8PPD.IMG"
    // ^IMAGE             = "MEGT90N000CB.IMG"
    // ^IMAGE		  = ("BLAH.IMG",1)	 -- start at record 1 (1 based)
    // ^IMAGE		  = ("BLAH.IMG")	 -- still start at record 1 (equiv of "BLAH.IMG")
    // ^IMAGE		  = ("BLAH.IMG", 5 <BYTES>) -- start at byte 5 (the fifth byte in the file)
    // ^IMAGE             = 10851 <BYTES>
    // ^SPECTRAL_QUBE = 5  for multi-band images

    CPLString osImageKeyword = osPrefix + "^IMAGE";
    CPLString osQube = GetKeyword( osImageKeyword, "" );
    CPLString osTargetFile = GetDescription();

    if (EQUAL(osQube,"")) {
        osImageKeyword = "^SPECTRAL_QUBE";
        osQube = GetKeyword( osImageKeyword );
    }

    int nQube = atoi(osQube);
    int nDetachedOffset = 0;
    int bDetachedOffsetInBytes = FALSE;

    if( osQube.size() && osQube[0] == '(' )
    {
        osQube = "\"";
        osQube += GetKeywordSub( osImageKeyword, 1 );
        osQube +=  "\"";
        nDetachedOffset = atoi(GetKeywordSub( osImageKeyword, 2, "1")) - 1;

        // If this is not explicitly in bytes, then it is assumed to be in
        // records, and we need to translate to bytes.
        if (strstr(GetKeywordSub(osImageKeyword,2),"<BYTES>") != NULL)
            bDetachedOffsetInBytes = TRUE;
    }

    if( osQube.size() && osQube[0] == '"' )
    {
        CPLString osTPath = CPLGetPath(GetDescription());
        CPLString osFilename = osQube;
        CleanString( osFilename );
        osTargetFile = CPLFormCIFilename( osTPath, osFilename, NULL );
        osExternalCube = osTargetFile;
    }

    GDALDataType eDataType = GDT_Byte;

    
    //image parameters
    int	nRows, nCols, nBands = 1;
    int nSkipBytes = 0;
    int itype;
    int record_bytes;
    char chByteOrder = 'M';  //default to MSB
    double dfNoData = 0.0;
 
    /* -------------------------------------------------------------------- */
    /*      Checks to see if this is raw PDS image not compressed image     */
    /*      so ENCODING_TYPE either does not exist or it equals "N/A".      */
    /*      Compressed types will not be supported in this routine          */
    /* -------------------------------------------------------------------- */
    const char *value;

    CPLString osEncodingType = GetKeyword(osPrefix+"IMAGE.ENCODING_TYPE","N/A");
    CleanString(osEncodingType);
    if ( !EQUAL(osEncodingType.c_str(),"N/A") )
    {
        CPLError( CE_Failure, CPLE_OpenFailed, 
                  "*** PDS image file has an ENCODING_TYPE parameter:\n"
                  "*** gdal pds driver does not support compressed image types\n"
                  "found: (%s)\n\n", osEncodingType.c_str() );
        return FALSE;
    } 
    /**************** end ENCODING_TYPE check ***********************/
    
    
    /***********   Grab layout type (BSQ, BIP, BIL) ************/
    //  AXIS_NAME = (SAMPLE,LINE,BAND)
    /***********   Grab samples lines band        **************/
    /** if AXIS_NAME = "" then Bands=1 and Sample and Lines   **/
    /** are there own keywords  "LINES" and "LINE_SAMPLES"    **/
    /** if not NULL then CORE_ITEMS keyword i.e. (234,322,2)  **/
    /***********************************************************/
    char szLayout[10] = "BSQ"; //default to band seq.
    value = GetKeyword( osPrefix+"IMAGE.AXIS_NAME", "" );
    if (EQUAL(value,"(SAMPLE,LINE,BAND)") ) {
        strcpy(szLayout,"BSQ");
        nCols = atoi(GetKeywordSub(osPrefix+"IMAGE.CORE_ITEMS",1));
        nRows = atoi(GetKeywordSub(osPrefix+"IMAGE.CORE_ITEMS",2));
        nBands = atoi(GetKeywordSub(osPrefix+"IMAGE.CORE_ITEMS",3));
    }
    else if (EQUAL(value,"(BAND,LINE,SAMPLE)") ) {
        strcpy(szLayout,"BIP");
        nBands = atoi(GetKeywordSub(osPrefix+"IMAGE.CORE_ITEMS",1));
        nRows = atoi(GetKeywordSub(osPrefix+"IMAGE.CORE_ITEMS",2));
        nCols = atoi(GetKeywordSub(osPrefix+"IMAGE.CORE_ITEMS",3));
    }
    else if (EQUAL(value,"(SAMPLE,BAND,LINE)") ) {
        strcpy(szLayout,"BIL");
        nCols = atoi(GetKeywordSub(osPrefix+"IMAGE.CORE_ITEMS",1));
        nBands = atoi(GetKeywordSub(osPrefix+"IMAGE.CORE_ITEMS",2));
        nRows = atoi(GetKeywordSub(osPrefix+"IMAGE.CORE_ITEMS",3));
    }
    else if ( EQUAL(value,"") ) {
        strcpy(szLayout,"BSQ");
        nCols = atoi(GetKeyword(osPrefix+"IMAGE.LINE_SAMPLES",""));
        nRows = atoi(GetKeyword(osPrefix+"IMAGE.LINES",""));
        nBands = atoi(GetKeyword(osPrefix+"IMAGE.BANDS","1"));
    }
    else {
        CPLError( CE_Failure, CPLE_OpenFailed, 
                  "%s layout not supported. Abort\n\n", value);
        return FALSE;
    }
    
    /***********   Grab Qube record bytes  **********/
    record_bytes = atoi(GetKeyword(osPrefix+"IMAGE.RECORD_BYTES"));
    if (record_bytes == 0)
        record_bytes = atoi(GetKeyword(osPrefix+"RECORD_BYTES"));

    // this can happen with "record_type = undefined". 
    if( record_bytes == 0 )
        record_bytes = 1;

    if( nQube >0 && osQube.find("<BYTES>") != CPLString::npos )
        nSkipBytes = nQube - 1;
    else if (nQube > 0 )
        nSkipBytes = (nQube - 1) * record_bytes;
    else if( nDetachedOffset > 0 )
    {
        if (bDetachedOffsetInBytes)
            nSkipBytes = nDetachedOffset;
        else
            nSkipBytes = nDetachedOffset * record_bytes;
    }
    else
        nSkipBytes = 0;     

    nSkipBytes += atoi(GetKeyword(osPrefix+"IMAGE.LINE_PREFIX_BYTES",""));
    
    /***********   Grab SAMPLE_TYPE *****************/
    /** if keyword not found leave as "M" or "MSB" **/
    CPLString osST = GetKeyword( osPrefix+"IMAGE.SAMPLE_TYPE" );
    if( osST.size() >= 2 && osST[0] == '"' && osST[osST.size()-1] == '"' )
        osST = osST.substr( 1, osST.size() - 2 );

    if( (EQUAL(osST,"LSB_INTEGER")) || 
        (EQUAL(osST,"LSB")) || // just incase
        (EQUAL(osST,"LSB_UNSIGNED_INTEGER")) || 
        (EQUAL(osST,"LSB_SIGNED_INTEGER")) || 
        (EQUAL(osST,"UNSIGNED_INTEGER")) || 
        (EQUAL(osST,"VAX_REAL")) || 
        (EQUAL(osST,"VAX_INTEGER")) || 
        (EQUAL(osST,"PC_INTEGER")) ||  //just incase 
        (EQUAL(osST,"PC_REAL")) ) {
        chByteOrder = 'I';
    }

    /**** Grab format type - pds supports 1,2,4,8,16,32,64 (in theory) **/
    /**** I have only seen 8, 16, 32 (float) in released datasets      **/
    itype = atoi(GetKeyword(osPrefix+"IMAGE.SAMPLE_BITS",""));
    switch(itype) {
      case 8 :
        eDataType = GDT_Byte;
        dfNoData = NULL1;
        break;
      case 16 :
        if( strstr(osST,"UNSIGNED") != NULL )
            eDataType = GDT_UInt16;
        else
            eDataType = GDT_Int16;
        dfNoData = NULL2;
        break;
      case 32 :
        eDataType = GDT_Float32;
        dfNoData = NULL3;
        break;
      case 64 :
        eDataType = GDT_Float64;
        dfNoData = NULL3;
        break;
      default :
        CPLError( CE_Failure, CPLE_AppDefined,
                  "Sample_bits of %d is not supported in this gdal PDS reader.",
                  itype); 
        return FALSE;
    }

/* -------------------------------------------------------------------- */
/*      Is there a specific nodata value in the file? Either the        */
/*      MISSING or MISSING_CONSTANT keywords are nodata.                */
/* -------------------------------------------------------------------- */
    if( GetKeyword( osPrefix+"IMAGE.MISSING", NULL ) != NULL )
        dfNoData = CPLAtofM( GetKeyword( osPrefix+"IMAGE.MISSING", "" ) );

    if( GetKeyword( osPrefix+"IMAGE.MISSING_CONSTANT", NULL ) != NULL )
        dfNoData = CPLAtofM( GetKeyword( osPrefix+"IMAGE.MISSING_CONSTANT",""));

/* -------------------------------------------------------------------- */
/*      Did we get the required keywords?  If not we return with        */
/*      this never having been considered to be a match. This isn't     */
/*      an error!                                                       */
/* -------------------------------------------------------------------- */
    if( nRows < 1 || nCols < 1 || nBands < 1 )
    {
        CPLError( CE_Failure, CPLE_AppDefined,
                  "File %s appears to be a PDS file, but failed to find some required keywords.", 
                  GetDescription() );
        return FALSE;
    }

/* -------------------------------------------------------------------- */
/*      Capture some information from the file that is of interest.     */
/* -------------------------------------------------------------------- */
    nRasterXSize = nCols;
    nRasterYSize = nRows;

/* -------------------------------------------------------------------- */
/*      Open target binary file.                                        */
/* -------------------------------------------------------------------- */
    
    if( eAccess == GA_ReadOnly )
    {
        fpImage = VSIFOpenL( osTargetFile, "rb" );
        if( fpImage == NULL )
        {
            CPLError( CE_Failure, CPLE_OpenFailed, 
                    "Failed to open %s.\n%s", 
                    osTargetFile.c_str(),
                    VSIStrerror( errno ) );
            return FALSE;
        }
    }
    else
    {
        fpImage = VSIFOpenL( osTargetFile, "r+b" );
        if( fpImage == NULL )
        {
            CPLError( CE_Failure, CPLE_OpenFailed, 
                    "Failed to open %s with write permission.\n%s", 
                    osTargetFile.c_str(),
                    VSIStrerror( errno ) );
            return FALSE;
        }
    }

/* -------------------------------------------------------------------- */
/*      Compute the line offset.                                        */
/* -------------------------------------------------------------------- */
    int     nItemSize = GDALGetDataTypeSize(eDataType)/8;
    int     nLineOffset = record_bytes;
    int	    nPixelOffset, nBandOffset;

    if( EQUAL(szLayout,"BIP") )
    {
        nPixelOffset = nItemSize * nBands;
        nBandOffset = nItemSize;
        nLineOffset = ((nPixelOffset * nCols + record_bytes - 1)/record_bytes)
            * record_bytes;
    }
    else if( EQUAL(szLayout,"BSQ") )
    {
        nPixelOffset = nItemSize;
        nLineOffset = ((nPixelOffset * nCols + record_bytes - 1)/record_bytes)
            * record_bytes;
        nBandOffset = nLineOffset * nRows;
    }
    else /* assume BIL */
    {
        nPixelOffset = nItemSize;
        nBandOffset = nItemSize * nCols;
        nLineOffset = ((nBandOffset * nCols + record_bytes - 1)/record_bytes)
            * record_bytes;
    }
    
/* -------------------------------------------------------------------- */
/*      Create band information objects.                                */
/* -------------------------------------------------------------------- */
    int i;

    for( i = 0; i < nBands; i++ )
    {
        RawRasterBand	*poBand;

        poBand = 
            new RawRasterBand( this, i+1, fpImage,
                               nSkipBytes + nBandOffset * i, 
                               nPixelOffset, nLineOffset, eDataType,
#ifdef CPL_LSB                               
                               chByteOrder == 'I' || chByteOrder == 'L',
#else
                               chByteOrder == 'M',
#endif        
                               TRUE );

        if( nBands == 1 )
        {
            const char* pszMin = GetKeyword(osPrefix+"IMAGE.MINIMUM", NULL);
            const char* pszMax = GetKeyword(osPrefix+"IMAGE.MAXIMUM", NULL);
            const char* pszMean = GetKeyword(osPrefix+"IMAGE.MEAN", NULL);
            const char* pszStdDev= GetKeyword(osPrefix+"IMAGE.STANDARD_DEVIATION", NULL);
            if (pszMin != NULL && pszMax != NULL &&
                pszMean != NULL && pszStdDev != NULL)
            {
                poBand->SetStatistics( CPLAtofM(pszMin),
                                       CPLAtofM(pszMax),
                                       CPLAtofM(pszMean),
                                       CPLAtofM(pszStdDev));
            }
        }
        
        poBand->SetNoDataValue( dfNoData );

        SetBand( i+1, poBand );

        // Set offset/scale values at the PAM level.
        poBand->SetOffset( 
            CPLAtofM(GetKeyword(osPrefix+"IMAGE.OFFSET","0.0")));
        poBand->SetScale( 
            CPLAtofM(GetKeyword(osPrefix+"IMAGE.SCALING_FACTOR","1.0")));
    }

    return TRUE;
}
Пример #11
0
// here for <!ELEMENT blah>
void CMUSHclientDoc::MXP_Element (CString strName, CString strTag)
  {
static CArgumentList ArgumentList;

  // get arguments to !ELEMENT definition
  if (BuildArgumentList (ArgumentList, strTag))
    {
    DELETE_LIST (ArgumentList);
    return;
    }

CElement * pElement;
bool bDelete = GetKeyword (ArgumentList, "delete");

  strName.MakeLower (); // case-insensitive?

  // see if we know of this atom

  CAtomicElement * element_item;

  if (App.m_ElementMap.Lookup (strName, element_item))
    {
    MXP_error (DBG_ERROR, errMXP_CannotRedefineElement,
               TFormat ("Cannot redefine built-in MXP element: <%s>" ,
                        (LPCTSTR) strName));
    return;
    }

// if element already defined, delete old one
  if (m_CustomElementMap.Lookup (strName, pElement))
    {
    if (!bDelete)
      MXP_error (DBG_WARNING, wrnMXP_ReplacingElement, 
                 TFormat ("Replacing previously-defined MXP element: <%s>", 
                (LPCTSTR) strName)); 
    DELETE_LIST (pElement->ElementItemList);
    DELETE_LIST (pElement->AttributeList);
    delete pElement;
    } // end of existing element

  if (bDelete)
    return; // all done!

// add new element to map
m_CustomElementMap.SetAt (strName, pElement = new CElement);

  pElement->strName = strName;

// get keywords first, so we won't mistake them for arguments 
// (eg. so OPEN doesn't become an argument)

  // look for keyword OPEN
  pElement->bOpen = GetKeyword (ArgumentList, "open");

  // look for keyword EMPTY
  pElement->bCommand = GetKeyword (ArgumentList, "empty");

CString strArgument;

  // get definition ( <COLOR &col;> )
  strArgument = GetArgument (ArgumentList, "", 1, false);  // get definition

// add atomic items here  --------------------------

  CString strAtom;

  const char * p = strArgument; 
  const char * pStart; 

  while (*p)
    {
    // check opening <
    if (*p != '<')
      {
      MXP_error (DBG_ERROR, errMXP_NoTagInDefinition,
                TFormat ("No opening \"<\" in MXP element definition \"%s\"", 
                (LPCTSTR) strArgument)); 
      return;
      }
    p++;  // skip <

    pStart = p;   // remember start of tag

    // skip <, look for >
    for (; *p && *p != '>'; p++) // look for closing tag
      {
      if (*p == '<')
        {
        MXP_error (DBG_ERROR, errMXP_UnexpectedDefinitionSymbol,
                  TFormat ("Unexpected \"<\" in MXP element definition \"%s\"", 
                  (LPCTSTR) strArgument)); 
        return;
        }
      if (*p == '\'' || *p == '\"') // quoted string?
        {
        char c = *p;    // remember opening quote
        for (p++; *p && *p != c; p++) // look for closing quote
          ; // just keep looking
        if (*p != c)
          {
          MXP_error (DBG_ERROR, errMXP_NoClosingDefinitionQuote,
                     TFormat ("No closing quote in MXP element definition \"%s\"", 
                    (LPCTSTR) strArgument)); 
          return;
          }
        } // end of quoted string

      } // end of search for closing tag  

    // check closing >
    if (*p != '>')
      {
      MXP_error (DBG_ERROR, errMXP_NoClosingDefinitionTag,
                TFormat ("No closing \">\" in MXP element definition \"%s\"", 
                (LPCTSTR) strArgument)); 
      return;
      }

    strAtom = CString (pStart, p - pStart);   // build tag, excluding < and >

    CString strAtomName;
    
    if (GetWord (strAtomName, strAtom))
      {
      MXP_error (DBG_ERROR, errMXP_NoDefinitionTag,
                TFormat ("No element name in MXP element definition \"<%s>\"", 
                (LPCTSTR) CString (pStart, p - pStart))); 
      return;
      }

    if (strAtomName == "/")
      {
      GetWord (strAtomName, strAtom);   // try to get next word
      strAtomName.MakeLower (); // case insensitive?
      MXP_error (DBG_ERROR, errMXP_DefinitionCannotCloseElement,
                TFormat ("Element definitions cannot close other elements: </%s>" ,
                          (LPCTSTR) strAtomName));
      return;
      }

    if (strAtomName == "!")
      {
      GetWord (strAtomName, strAtom);   // try to get next word
      strAtomName.MakeLower (); // case insensitive?
      MXP_error (DBG_ERROR, errMXP_DefinitionCannotDefineElement,
                TFormat ("Element definitions cannot define other elements: <!%s>" ,
                          (LPCTSTR) strAtomName));
      return;
      }

    strAtomName.MakeLower (); // case insensitive?

    // see if we know of this atom

    CAtomicElement * element_item;
  
    if (!App.m_ElementMap.Lookup (strAtomName, element_item))
      {
      MXP_error (DBG_ERROR, errMXP_NoInbuiltDefinitionTag,
                TFormat ("Unknown MXP element: <%s>" ,
                          (LPCTSTR) strAtomName));
      return;
      }

    // yes?  add to list

    CElementItem * pElementItem = new CElementItem;

    if (BuildArgumentList (pElementItem->ArgumentList, strAtom))  // add arguments
      {     // bad arguments
      DELETE_LIST (pElementItem->ArgumentList);
      delete pElementItem;
      return;
      }

    pElement->ElementItemList.AddTail (pElementItem );
    pElementItem->pAtomicElement = element_item;    // which atomic element

    p++; // skip >


    } // end of processing each atomic item

// end of add atomic items  --------------------------


  // get attributes  (COLOR=RED NAME=FRED)
  if (BuildArgumentList (pElement->AttributeList, GetArgument (ArgumentList, "att", 2, false)))
    {     // bad arguments
    DELETE_LIST (pElement->AttributeList);
    return;
    }


  // get tag (TAG=22)
  strArgument = GetArgument (ArgumentList, "tag", 3, true);  // get tag number

  if (IsNumeric (strArgument))
    {
    int i = atoi (strArgument);
    if (i >= 20 && i <= 99)
       pElement->iTag = i;
    }

  // get tag (FLAG=roomname)
  strArgument = GetArgument (ArgumentList, "flag", 4, true);  // get flag name

  if (!strArgument.IsEmpty ())
    {
/*
//   I won't check names right now ...

   if (strArgument == "roomname" ||
        strArgument == "roomdesc" ||
        strArgument == "roomexit" ||
        strArgument == "roomnum" ||
        strArgument == "prompt")
       pElement->strFlag = strArgument;
    else
*/
    if (strArgument.Left (4) == "set ")
      pElement->strFlag = strArgument.Mid (4);  // what variable to set
    else 
      pElement->strFlag = strArgument;
        
    pElement->strFlag.TrimLeft ();
    pElement->strFlag.TrimRight ();

    // make things a bit easier - let spaces through but change to underscores
    pElement->strFlag.Replace (" ", "_");

    // check variable name is OK
    if (CheckObjectName (pElement->strFlag) != eOK)
      {
      MXP_error (DBG_ERROR, errMXP_BadVariableName,
                 TFormat ("Bad variable name \"%s\" - for MXP FLAG definition", 
                (LPCTSTR) pElement->strFlag)); 
      pElement->strFlag.Empty ();
      }


    } // end of having a flag

  DELETE_LIST (ArgumentList);

  } // end of CMUSHclientDoc::MXP_Element
Пример #12
0
int FitsFile::GetIntKeywordValue(int keywordNumber)
{
	return atoi(GetKeyword(keywordNumber).c_str());
}
Пример #13
0
BOOL CFCView::GetElement(BOOL bWantFileEnd)
{
	BOOL bReportWrongToken=TRUE;//此标记用于避免连续的报告“非法符号”
RestartGetElement:
	int &iCount=m_iCharCount;
	while(1)//跳过空格,tab,回车符,注释
	{
		if(iCount>=m_nSourceLength)//到达源代码尾
		{
			m_element=E_FILEEND;
			if(!bWantFileEnd)//源代码
			{
				ErrorReport(ET_SOURCENOEND);
				return FALSE;
			}
			return TRUE;
		}
		if( m_source[iCount]==' '  || m_source[iCount]=='\t' || //空白字符
			m_source[iCount]=='\r' || m_source[iCount]=='\n')	//换行字符
				iCount++;
		else if(m_source[iCount]=='/' && iCount+1<m_nSourceLength) //可能为注释
		{
			if(m_source[iCount+1]=='/')//单行注释
			{
				m_comment="//";
				for(iCount+=2;iCount<m_nSourceLength && m_source[iCount]!='\n';iCount++)
					m_comment+=m_source[iCount];
				if(iCount!=m_nSourceLength)//并没到达源文件尾
				{
					m_comment+="\n";
					iCount++;
				}
			}
			else if(m_source[iCount+1]=='*')//多行注释
			{
				m_comment="/*";
				iCount+=2;
				while(1)
				{
					if(iCount>=m_nSourceLength)//到达文件尾
					{
						m_element=E_FILEEND;
						if(!bWantFileEnd)//源代码
						{
							ErrorReport(ET_SOURCENOEND);
							return FALSE;
						}
						return TRUE;
					}
					m_comment+=m_source[iCount];
					if(m_source[iCount]=='*' && iCount+1<m_nSourceLength &&
						m_source[iCount+1]=='/') //到达注释尾
					{
						m_comment+="*/";
						iCount+=2;
						break;//多行注释结束
					}
					iCount++;
				}
			}
			else break;//不是注释
		}
		else break;//不是空白字符,且不可能是注释
	}
	if( (m_source[iCount]>='a' && m_source[iCount]<='z') ||
		(m_source[iCount]>='A' && m_source[iCount]<='Z') ||
		m_source[iCount]=='_' )
////标识符、关键字、库函数/////////////////////////////////////////////////////
	{
		m_ident="";
		//获取连续的字母、数字、下划线串
		while(iCount<m_nSourceLength &&
			  ( (m_source[iCount]>='a' && m_source[iCount]<='z') ||
				(m_source[iCount]>='A' && m_source[iCount]<='Z') ||
				(m_source[iCount]>='0' && m_source[iCount]<='9') ||
				m_source[iCount]=='_' ) )
		{
			m_ident+=m_source[iCount];
			iCount++;
		}
		if(m_ident.GetLength()>31) //只保留标识符的前31个字符
			m_ident=m_ident.Left(31);
		if(GetKeyword())
			return TRUE;
		if(GetLibraryFunction())
			return TRUE;
		m_element=E_IDENT;
		return TRUE;
	}
	if(m_source[iCount]>='0' && m_source[iCount]<='9')
////数/////////////////////////////////////////////////////////////////////////
	{
		m_int=0;
		while(iCount<m_nSourceLength && m_source[iCount]>='0' && m_source[iCount]<='9')
		{
			m_int*=10;
			m_int+=m_source[iCount]-'0';
			iCount++;
		}
		if(iCount>=m_nSourceLength || m_source[iCount]!='.')//到达源文件尾或不是小数点,即为整数
		{
			m_element=E_INUMBER;
			return TRUE;
		}
		int l=1;
		m_double=m_int;
		iCount++;//跳过小数点iCount<m_nSourceLength && 
		while(iCount<m_nSourceLength && m_source[iCount]>='0' && m_source[iCount]<='9')
		{
			m_double+=(m_source[iCount]-'0')/pow(10,l);
			l++;
			iCount++;
		}
		m_element=E_DNUMBER;
		return TRUE;
	}
	if(m_source[iCount]=='\'')
////字符///////////////////////////////////////////////////////////////////////
	{
		iCount++;//跳过单引号
		if(iCount>=m_nSourceLength || m_source[iCount]=='\r')//源代码结束或行结束
		{
			if(!ErrorReport(ET_WRONGCHARACTER))
				return FALSE;
			m_element=E_CHARACTER;
			m_char='\0';
			return TRUE;
		}
		if(m_source[iCount]=='\\')
		{
			iCount++;
			if(iCount>=m_nSourceLength || m_source[iCount]=='\r')//源代码结束或行结束
			{
				if(!ErrorReport(ET_WRONGCHARACTER))
					return FALSE;
				m_char='\0';
				return TRUE;
			}
			m_element=E_CHARACTER;
			if(!GetSysChar())
				return FALSE;
		}
		else
		{
			m_element=E_CHARACTER;
			m_char=m_source[iCount];
			iCount++;//跳过字符
		}
		if(iCount>=m_nSourceLength || m_source[iCount]!='\'')//源代码结束或不是单引号
		{
			if(!ErrorReport(ET_WRONGCHARACTER))
				return FALSE;
			m_char='\0';
			return TRUE;
		}
		iCount++;//跳过单引号
		return TRUE;
	}
	if(m_source[iCount]=='\"')
////字符串/////////////////////////////////////////////////////////////////////
	{
		iCount++;//跳过双引号
		m_element=E_STRING;
		m_string="";
		while(iCount<m_nSourceLength && m_source[iCount]!='\"')
		{
			if(m_source[iCount]=='\\')//转义字符
			{
				iCount++;
				if(!GetSysChar())
					return FALSE;
				m_string+=m_char;
			}
			else if(m_source[iCount]=='\r')//行结束
			{
				if(!ErrorReport(ET_STRINGNOEND))
					return FALSE;
				return TRUE;
			}
			else
			{
				m_string+=m_source[iCount];
				iCount++;
			}
		}
		iCount++;//跳过双引号
		return TRUE;
	}
	switch(m_source[iCount])
////运算符/////////////////////////////////////////////////////////////////////
	{
	case '+':
		iCount++;
		if(iCount<m_nSourceLength && m_source[iCount]=='=')
		{
			iCount++;
			m_element=E_PLUSBECOMES;
		}
		else m_element=E_PLUS;
		return TRUE;
	case '-':
		iCount++;
		if(iCount<m_nSourceLength && m_source[iCount]=='=')
		{
			iCount++;
			m_element=E_MINUSBECOMES;
		}
		else m_element=E_MINUS;
		return TRUE;
	case '*':
		iCount++;
		if(iCount<m_nSourceLength && m_source[iCount]=='=')
		{
			iCount++;
			m_element=E_TIMESBECOMES;
		}
		else m_element=E_TIMES;
		return TRUE;
	case '/':
		iCount++;
		if(iCount<m_nSourceLength && m_source[iCount]=='=')
		{
			iCount++;
			m_element=E_SLASHBECOMES;
		}
		else m_element=E_SLASH;
		return TRUE;
	case '%':
		iCount++;
		if(iCount<m_nSourceLength && m_source[iCount]=='=')
		{
			iCount++;
			m_element=E_MODBECOMES;
		}
		else m_element=E_MOD;
		return TRUE;
	case '(':
		iCount++;
		m_element=E_LPAREN;
		return TRUE;
	case ')':
		iCount++;
		m_element=E_RPAREN;
		return TRUE;
	case '[':
		iCount++;
		m_element=E_LSUB;
		return TRUE;
	case ']':
		iCount++;
		m_element=E_RSUB;
		return TRUE;
	case '{':
		iCount++;
		m_element=E_BEGIN;
		return TRUE;
	case '}':
		iCount++;
		m_element=E_END;
		return TRUE;
	case ',':
		iCount++;
		m_element=E_COMMA;
		return TRUE;
	case ':':
		iCount++;
		m_element=E_COLON;
		return TRUE;
	case ';':
		iCount++;
		m_element=E_SEMICOLON;
		return TRUE;
	case '!':
		iCount++;
		if(iCount<m_nSourceLength && m_source[iCount]=='=')
		{
			iCount++;
			m_element=E_NOTEQUAL;
		}
		else m_element=E_NOT;
		return TRUE;
	case '>':
		iCount++;
		if(iCount<m_nSourceLength && m_source[iCount]=='=')
		{
			iCount++;
			m_element=E_GREATEQUAL;
		}
		else m_element=E_GREAT;
		return TRUE;
	case '<':
		iCount++;
		if(iCount<m_nSourceLength && m_source[iCount]=='=')
		{
			iCount++;
			m_element=E_LESSEQUAL;
		}
		else m_element=E_LESS;
		return TRUE;
	case '=':
		iCount++;
		if(iCount<m_nSourceLength && m_source[iCount]=='=')
		{
			iCount++;
			m_element=E_EQUAL;
		}
		else m_element=E_BECOMES;
		return TRUE;
	case '&':
		iCount++;
		if(iCount>=m_nSourceLength || m_source[iCount]!='&')
		{
			if(!ErrorReport(ET_UNKNOWNTOKEN))
				return FALSE;
			m_element=E_AND;
			return TRUE;
		}
		iCount++;
		m_element=E_AND;
		return TRUE;
	case '|':
		iCount++;
		if(iCount>=m_nSourceLength || m_source[iCount]!='|')
		{
			if(!ErrorReport(ET_UNKNOWNTOKEN))
				return FALSE;
			m_element=E_OR;
			return TRUE;
		}
		iCount++;
		m_element=E_OR;
		return TRUE;
	}
	if(bReportWrongToken)
	{
		if(!ErrorReport(ET_UNKNOWNTOKEN))
			return FALSE;
		bReportWrongToken=FALSE;
	}
	//碰到无法识别的符号,跳过之,使用goto语句重新启动本函数
	iCount++;
	goto RestartGetElement;
}
Пример #14
0
// do the action required to open a single atomic tag (iAction)
void CMUSHclientDoc::MXP_OpenAtomicTag (const CString strTag,
                                        int iAction, 
                                        CStyle * pStyle,
                                        CString & strAction,    // new action
                                        CString & strHint,      // new hint
                                        CString & strVariable,   // new variable
                                        CArgumentList & ArgumentList)
  {
CString strArgument;
CString strArgumentName;
bool bIgnoreUnusedArgs = false; // cut down on some spam by setting this
COLORREF colour1,
         colour2;

unsigned short iFlags      = pStyle->iFlags;      
COLORREF       iForeColour = pStyle->iForeColour; 
COLORREF       iBackColour = pStyle->iBackColour; 

  // call script if required
  if (m_dispidOnMXP_OpenTag != DISPID_UNKNOWN || m_bPluginProcessesOpenTag)
    {
    // dummy-up an argument list
    CString strArgument;
    CArgument * pArgument;
    POSITION pos;

    // put the arguments into the array

    for (pos = ArgumentList.GetHeadPosition (); pos; )
      {
      pArgument = ArgumentList.GetNext (pos);
      
      // empty ones we will put there by position
      if (pArgument->strName.IsEmpty ())
        strArgument += CFormat ("'%s'",
                      (LPCTSTR) pArgument->strValue);
      else
        strArgument += CFormat ("%s='%s'",
                      (LPCTSTR) pArgument->strName,
                      (LPCTSTR) pArgument->strValue);

      if (pos)
        strArgument += " ";

      }      // end of looping through each argument

    bool bNotWanted = MXP_StartTagScript (strTag, strArgument, ArgumentList);

    // re-get current style in case the script did a world.note
    pStyle = m_pCurrentLine->styleList.GetTail ();

    // put things backt to how they were
    pStyle->iFlags      = iFlags;      
    pStyle->iForeColour = iForeColour; 
    pStyle->iBackColour = iBackColour; 

    if (bNotWanted)
      return;   // they didn't want to go ahead with this tag

    }


// find current foreground and background RGB values
  GetStyleRGB (pStyle, colour1, colour2);

// special processing for Pueblo
// a tag like this: <A XCH_CMD="examine #1"> 
// will convert to a SEND tag

  if (iAction == MXP_ACTION_HYPERLINK &&
      PUEBLO_ACTIVE)
    {
    strArgument = GetArgument (ArgumentList, "xch_cmd", 0, true);
    if (!strArgument.IsEmpty ())
      {
      m_bPuebloActive = true;  // for correct newline processing
      iAction = MXP_ACTION_SEND;
      }
    }    

  // now take the action 
  switch (iAction)
    {

    // temporarily make headlines the same as bold
    case MXP_ACTION_H1: 
    case MXP_ACTION_H2: 
    case MXP_ACTION_H3: 
    case MXP_ACTION_H4: 
    case MXP_ACTION_H5: 
    case MXP_ACTION_H6: 

    case MXP_ACTION_BOLD: pStyle->iFlags |= HILITE; break;
    case MXP_ACTION_UNDERLINE: pStyle->iFlags |= UNDERLINE; break;
    case MXP_ACTION_ITALIC: pStyle->iFlags |= BLINK; break;

    case MXP_ACTION_COLOR:
         {

         pStyle->iForeColour = colour1;
         pStyle->iBackColour = colour2;
         // convert to RGB colour to start with in case only FORE or BACK supplied
         pStyle->iFlags &= ~COLOURTYPE;  // clear bits, eg. custom
         pStyle->iFlags |= COLOUR_RGB;

         // foreground colour
         strArgument = GetArgument (ArgumentList, "fore", 1, true);  // get foreground colour
         if (!m_bIgnoreMXPcolourChanges)
           if (SetColour (strArgument, pStyle->iForeColour)) 
             MXP_error (DBG_ERROR, errMXP_UnknownColour,
                        TFormat ("Unknown colour: \"%s\"" ,
                                 (LPCTSTR) strArgument));

         // background colour
         strArgument = GetArgument (ArgumentList, "back", 2, true);  // get background colour
         if (!m_bIgnoreMXPcolourChanges)
           if (SetColour (strArgument, pStyle->iBackColour)) 
             MXP_error (DBG_ERROR, errMXP_UnknownColour,
                        TFormat ("Unknown colour: \"%s\"" ,
                                 (LPCTSTR) strArgument));
         }
         break;   // end of COLOR

    case MXP_ACTION_HIGH:
         {
         CColor clr;

         pStyle->iForeColour = colour1;
         pStyle->iBackColour = colour2;
         // convert to RGB colour to start with 
         pStyle->iFlags &= ~COLOURTYPE;  // clear bits, eg. custom
         pStyle->iFlags |= COLOUR_RGB;

         clr.SetColor (colour1);
         float lum = clr.GetLuminance ();
         lum += 0.15f;
         if (lum > 1.0f)
           lum = 1.0f;
         clr.SetLuminance (lum);
         pStyle->iForeColour = clr; 
         
         }
         break;   // end of COLOR

    case MXP_ACTION_SEND: 
          // send to mud hyperlink

          pStyle->iFlags &= ~ACTIONTYPE;   // cancel old actions
          if (GetKeyword (ArgumentList, "prompt"))
            pStyle->iFlags |= ACTION_PROMPT;   // prompt action
          else
            pStyle->iFlags |= ACTION_SEND;   // send-to action

          if (m_bUnderlineHyperlinks)
            pStyle->iFlags |= UNDERLINE;   // underline it

          if (m_bUseCustomLinkColour)
            {
            // find current background RGB value
            pStyle->iForeColour = m_iHyperlinkColour;    // use hyperlink colour
            pStyle->iBackColour = colour2;
            pStyle->iFlags &= ~COLOURTYPE;  // clear bits, eg. custom
            pStyle->iFlags |= COLOUR_RGB;
            }

          strArgument = GetArgument (ArgumentList,"href", 1, false);  // get link
          if (strArgument.IsEmpty ())
            strArgument = GetArgument (ArgumentList,"xch_cmd", 1, false);  // get link
            
          strAction = strArgument;   // hyperlink
         
          strArgument = GetArgument (ArgumentList, "hint", 2, false);  // get hints
          if (strArgument.IsEmpty ())
            strArgument = GetArgument (ArgumentList,"xch_hint", 2, false);  // get hint
          
          strHint = strArgument;     // hints

          break;  // end of MXP_ACTION_SEND

    case MXP_ACTION_HYPERLINK: 
          // hyperlink

          strArgument = GetArgument (ArgumentList,"href", 1, false);  // get link
          strAction = strArgument;   // hyperlink

          pStyle->iFlags &= ~ACTIONTYPE;   // cancel old actions
          pStyle->iFlags |= ACTION_HYPERLINK | UNDERLINE;   // send-to action

          if (m_bUseCustomLinkColour)
            {
            pStyle->iForeColour = m_iHyperlinkColour;    // use hyperlink colour
            pStyle->iBackColour = colour2;
            pStyle->iFlags &= ~COLOURTYPE;  // clear bits, eg. custom
            pStyle->iFlags |= COLOUR_RGB;
            }

          break;  // end of MXP_ACTION_HYPERLINK

    case MXP_ACTION_FONT:
          {
          pStyle->iForeColour = colour1;
          pStyle->iBackColour = colour2;
          // convert to RGB colour to start with in case only FORE or BACK supplied
          pStyle->iFlags &= ~COLOURTYPE;  // clear bits, eg. custom
          pStyle->iFlags |= COLOUR_RGB;

          // eg. <FONT COLOR=Red,Blink>
          CStringList list;

          strArgument = GetArgument (ArgumentList,"color", 1, true);  // get color etc.
          if (strArgument.IsEmpty () && PUEBLO_ACTIVE)
            strArgument = GetArgument (ArgumentList,"fgcolor", 1, true);  // get color
          StringToList (strArgument, ",", list);   // break into components

          for (POSITION pos = list.GetHeadPosition (); pos; )
            {
            CString strItem = list.GetNext (pos); // get action item

            if (strItem == "blink")
               pStyle->iFlags |= BLINK;
            else
            if (strItem == "italic")
               pStyle->iFlags |= BLINK;
            else
            if (strItem == "underline")
               pStyle->iFlags |= UNDERLINE;
            else
            if (strItem == "bold")
               pStyle->iFlags |= HILITE;
            else
            if (strItem == "inverse")
               pStyle->iFlags |= INVERSE;
            else
              {  // must be colour name, yes?

              // foreground colour
              if (!m_bIgnoreMXPcolourChanges)
                if (SetColour (strItem, pStyle->iForeColour)) 
                  MXP_error (DBG_ERROR, errMXP_UnknownColour,
                              TFormat ("Unknown colour: \"%s\"" ,
                                      (LPCTSTR) strItem));
              } // end of colour

            } // end of handling each item in the list
          strArgument = GetArgument (ArgumentList,"back", 2, true);  // get back color
          if (strArgument.IsEmpty () && PUEBLO_ACTIVE)
            strArgument = GetArgument (ArgumentList,"bgcolor", 2, true);  // get back color
          // background colour

          if (!m_bIgnoreMXPcolourChanges)
            if (SetColour (strArgument, pStyle->iBackColour)) 
              MXP_error (DBG_ERROR, errMXP_UnknownColour,
                        TFormat ("Unknown colour: \"%s\"" ,
                                  (LPCTSTR) strArgument));

          // get font size argument to avoid warnings about unused arguments
          strArgument = GetArgument (ArgumentList,"size", 0, true);  // get font size
          }
          break; // end of FONT

    case MXP_ACTION_VERSION:
            {

            CString strVersion = CFormat ("\x1B[1z<VERSION MXP=\"%s\" CLIENT=MUSHclient "
                      "VERSION=\"%s\" REGISTERED=YES>%s",
                     MXP_VERSION,
                     MUSHCLIENT_VERSION,
                     ENDLINE
                     );

            SendPacket (strVersion, strVersion.GetLength ());  // send version info back
            MXP_error (DBG_INFO, infoMXP_VersionSent,
                      TFormat ("Sent version response: %s" ,
                                (LPCTSTR) strVersion.Mid (4)));

            }
          break;  // end of VERSION

    case MXP_ACTION_AFK:
          if (m_bSendMXP_AFK_Response)    // if player wants us to
            {
            strArgument = GetArgument (ArgumentList,"challenge", 1, false);  // get challenge

            // find time since last player input
            CTimeSpan ts = CTime::GetCurrentTime() - m_tLastPlayerInput;
            CString strAFK = CFormat ("\x1B[1z<AFK %ld %s>%s",
                      ts.GetTotalSeconds  (),
                      (LPCTSTR) strArgument,
                      ENDLINE
                     );

            SendPacket (strAFK, strAFK.GetLength ());  // send AFK info back
            MXP_error (DBG_INFO, infoMXP_AFKSent,
                      TFormat ("Sent AFK response: %s" ,
                                (LPCTSTR) strAFK.Mid (4)));
            } // end of AFK
          break;

    case MXP_ACTION_SUPPORT:
            {
            CString strSupports;
            CAtomicElement * pElement;
            CStringList list;
            CString strName;       

            if (ArgumentList.IsEmpty ())
              {
              for (POSITION pos = App.m_ElementMap.GetStartPosition(); pos; ) 
                {                                                
                App.m_ElementMap.GetNextAssoc (pos, strName, pElement);

                if ((pElement->iFlags & TAG_NOT_IMP) == 0)
                  {
                  strSupports += "+";
                  strSupports += pElement->strName;
                  strSupports += " ";

                  // now list the sub-items it supports
                  StringToList (pElement->strArgs, ",", list);   // break into components
                  for (POSITION argpos = list.GetHeadPosition (); argpos; )
                    {
                    CString strItem = list.GetNext (argpos); // get argument item
                    strSupports += "+";
                    strSupports += pElement->strName;
                    strSupports += ".";
                    strSupports += strItem;
                    strSupports += " ";
                    } // end of doing each sub-item
                  } // end of being implemented
                }  // end of looping through all atomic elements
              } // end of wanting complete list
            else
              {
              for (POSITION pos = ArgumentList.GetHeadPosition (); pos; )
                {
                CArgument * pArgument = ArgumentList.GetNext (pos); 
                CStringList questionlist;
                StringToList (pArgument->strValue, ".", questionlist);   // break into components

                // should be one or two words, eg. send.prompt or color
                if (questionlist.GetCount () > 2)
                  {
                  MXP_error (DBG_ERROR, errMXP_InvalidSupportArgument,
                            TFormat ("Invalid <support> argument: %s" ,
                                      (LPCTSTR) pArgument->strValue));
                  return;
                  }
                
                CString strTag =  questionlist.RemoveHead ();
                strTag.MakeLower ();

                // check valid name requested
                if (!IsValidName (strTag))
                  {
                  MXP_error (DBG_ERROR, errMXP_InvalidSupportArgument,
                            TFormat ("Invalid <support> argument: %s" ,
                                      (LPCTSTR) strTag));
                  return;
                  }

                // look up main element name

                if (!App.m_ElementMap.Lookup (strTag, pElement) ||
                   (pElement->iFlags & TAG_NOT_IMP) != 0)
                  {     // not supported
                  strSupports += "-";
                  strSupports += strTag;
                  strSupports += " ";
                  continue;   // all done for this argument
                  }

                // only one word - they aren't looking for a suboption
                if (questionlist.IsEmpty ())
                  {     // supported
                  strSupports += "+";
                  strSupports += strTag;
                  strSupports += " ";
                  continue;   // all done for this argument
                  }
                  
                CString strSubtag =  questionlist.RemoveHead ();
                strSubtag.MakeLower ();

                if (strSubtag == "*")
                  {   // they want list of options for this tag
                  // now list the sub-items it supports
                  StringToList (pElement->strArgs, ",", list);   // break into components
                  for (POSITION argpos = list.GetHeadPosition (); argpos; )
                    {
                    CString strItem = list.GetNext (argpos); // get argument item
                    strSupports += "+";
                    strSupports += pElement->strName;
                    strSupports += ".";
                    strSupports += strItem;
                    strSupports += " ";
                    } // end of doing each sub-item
                  } // end of wildcard
                else
                  {  // not wildcard - must be name
                  // check valid name requested
                  if (!IsValidName (strSubtag))
                    {
                    MXP_error (DBG_ERROR, errMXP_InvalidSupportArgument,
                              TFormat ("Invalid <support> argument: %s" ,
                                        (LPCTSTR) strSubtag));
                    return;
                    }

                  // so, see if that word is in our arguments list
                  StringToList (pElement->strArgs, ",", list);   // break into components
                  if (list.Find (strSubtag))
                    {
                    strSupports += "+";
                    strSupports += pArgument->strValue;
                    strSupports += " ";
                    }
                  else
                    {
                    strSupports += "-";
                    strSupports += pArgument->strValue;
                    strSupports += " ";
                    }
                  }    // end of not looking for wildcard
                } // end of doing each argument

              } // find individual items

            CString strMessage = CFormat ("\x1B[1z<SUPPORTS %s>%s",
                                          (LPCTSTR) strSupports,
                                          ENDLINE);

            SendPacket (strMessage, strMessage.GetLength ());  // send version info back
            MXP_error (DBG_INFO, infoMXP_SupportsSent,
                      TFormat ("Sent supports response: %s" ,
                                (LPCTSTR) strMessage.Mid (4)));

            }
          bIgnoreUnusedArgs = true;

          break;  // end of MXP_ACTION_SUPPORT

    case MXP_ACTION_OPTION:
            {
            CString strOptions;
            CStringList list;
            CString strName;       

            if (ArgumentList.IsEmpty ())
              {

              for (long i = 0; OptionsTable [i].pName; i++)
                {
                char * pName = OptionsTable [i].pName;
                strOptions += CFormat ("%s=%ld ",
                               pName, 
                               (LPCTSTR) GetOptionItem (i));
                }

              } // end of wanting complete list
            else
              {
              for (POSITION pos = ArgumentList.GetHeadPosition (); pos; )
                {
                CArgument * pArgument = ArgumentList.GetNext (pos); 

                strOptions += CFormat ("%s=%ld",
                               (LPCTSTR) pArgument->strValue, 
                               (LPCTSTR) GetOption (pArgument->strValue));

                } // end of doing each argument

              } // find individual items

            CString strMessage = CFormat ("\x1B[1z<OPTIONS %s>%s",
                                          (LPCTSTR) strOptions,
                                          ENDLINE);

            SendPacket (strMessage, strMessage.GetLength ());  // send version info back
            MXP_error (DBG_INFO, infoMXP_OptionsSent,
                      TFormat ("Sent options response: %s" ,
                                (LPCTSTR) strMessage.Mid (4)));

            }
          bIgnoreUnusedArgs = true;

          break;  // end of MXP_ACTION_OPTION

    case MXP_ACTION_RECOMMEND_OPTION:
          if (m_bMudCanChangeOptions)
            {
            CString strOptions;
            CStringList list;
            CString strName;       

            for (POSITION pos = ArgumentList.GetHeadPosition (); pos; )
              {
              CArgument * pArgument = ArgumentList.GetNext (pos); 

              int iItem;
              int iResult = FindBaseOption (pArgument->strName, OptionsTable, iItem);

              if (iResult != eOK)
                MXP_error (DBG_ERROR, errMXP_InvalidOptionArgument,
                          TFormat ("Option named '%s' not known.",
                          (LPCTSTR) pArgument->strName));      
              else if (!(OptionsTable [iItem].iFlags & OPT_SERVER_CAN_WRITE))
                MXP_error (DBG_ERROR, errMXP_CannotChangeOption,
                          TFormat ("Option named '%s' cannot be changed.",
                          (LPCTSTR) pArgument->strName));      
              else
                {
                iResult = SetOptionItem (iItem, atol (pArgument->strValue), true, false);
                if (iResult == eOK)
                  MXP_error (DBG_INFO, infoMXP_OptionChanged,
                            TFormat ("Option named '%s' changed to '%s'.",
                            (LPCTSTR) pArgument->strName,
                            (LPCTSTR) pArgument->strValue)); 
                else
                  MXP_error (DBG_ERROR, errMXP_OptionOutOfRange,
                            TFormat ("Option named '%s' could not be changed to '%s' (out of range).",
                            (LPCTSTR) pArgument->strName,
                            (LPCTSTR) pArgument->strValue));      
                }

              } // end of doing each argument

            }
          bIgnoreUnusedArgs = true;

          break;  // end of MXP_ACTION_RECOMMEND_OPTION


    case MXP_ACTION_USER:
            if (!m_name.IsEmpty () && 
                m_connect_now == eConnectMXP)
              {
              CString strPacket = m_name + ENDLINE;
              SendPacket (strPacket, strPacket.GetLength ());  // send name to MUD
              MXP_error (DBG_INFO, infoMXP_CharacterNameSent,
                          TFormat ("Sent character name: %s" ,
                                  (LPCTSTR) m_name));      
              }
            else if (m_connect_now != eConnectMXP)
              MXP_error (DBG_WARNING, wrnMXP_CharacterNameRequestedButNotDefined,
                        Translate ("Character name requested but auto-connect not set to MXP."));      
            else
              MXP_error (DBG_WARNING, wrnMXP_CharacterNameRequestedButNotDefined,
                        Translate ("Character name requested but none defined."));      
            break;  // end of USER

    case MXP_ACTION_PASSWORD:
            if (m_nTotalLinesSent > 10)     // security check
              MXP_error (DBG_WARNING, wrnMXP_PasswordNotSent,
                        "Too many lines sent to MUD - password not sent.");      
            else
            if (!m_password.IsEmpty () && 
                m_connect_now == eConnectMXP)
              {
              CString strPacket = m_password + ENDLINE;
              SendPacket (strPacket, strPacket.GetLength ());  // send password to MUD
              MXP_error (DBG_INFO, infoMXP_PasswordSent,
                        "Sent password to world.");      
              }
            else if (m_connect_now != eConnectMXP)
              MXP_error (DBG_WARNING, wrnMXP_PasswordRequestedButNotDefined,
                        "Password requested but auto-connect not set to MXP.");      
            else
              MXP_error (DBG_WARNING, wrnMXP_PasswordRequestedButNotDefined,
                        "Password requested but none defined.");      
            break;  // end of PASSWORD

         // new para
    case MXP_ACTION_P:
          // experimental
          m_cLastChar = 0;
          m_bInParagraph = true;      
          break;  // end of MXP_ACTION_P
    
          // new line
    case MXP_ACTION_BR:
          bIgnoreUnusedArgs = true; // don't worry about args for now :)

          StartNewLine (true, 0);
          SetNewLineColour (0);
          break;  // end of MXP_ACTION_BR

          // reset
    case MXP_ACTION_RESET:
          MXP_Off ();
          break;  // end of MXP_ACTION_RESET

          // MXP options  (MXP OFF, MXP DEFAULT_OPEN, MXP DEFAULT_SECURE etc.
    case MXP_ACTION_MXP:
          
          if (GetKeyword (ArgumentList, "off"))
            MXP_Off (true);

          /*
          if (GetKeyword (ArgumentList, "default_open"))
            {
            MXP_error (DBG_INFO, "MXP default mode now OPEN.");
            m_iMXP_defaultMode = eMXP_open;
            }  // end of DEFAULT_OPEN

          if (GetKeyword (ArgumentList, "default_secure"))
            {
            MXP_error (DBG_INFO, "MXP default mode now SECURE.");
            m_iMXP_defaultMode = eMXP_secure;
            }  // end of DEFAULT_SECURE

          if (GetKeyword (ArgumentList, "default_locked"))
            {
            MXP_error (DBG_INFO, "MXP default mode now LOCKED.");
            m_iMXP_defaultMode = eMXP_locked;
            }  // end of DEFAULT_LOCKED


          if (GetKeyword (ArgumentList, "use_newlines"))
            {
            MXP_error (DBG_INFO, "Now interpreting newlines as normal.");
            m_bInParagraph = false;      
            }   // end of USE_NEWLINES

          if (GetKeyword (ArgumentList, "ignore_newlines"))
            {
            MXP_error (DBG_INFO, "Now ignoring newlines.");
            m_bInParagraph = true;      
            }   // end of IGNORE_NEWLINES

          */

          break;  // end of MXP_ACTION_MXP

    case MXP_ACTION_SCRIPT:
          MXP_error (DBG_INFO, infoMXP_ScriptCollectionStarted,
                      "Script collection mode entered (discarding script).");
          m_bMXP_script = true;
          break;  // end of MXP_ACTION_SCRIPT

    case MXP_ACTION_HR: 

          {
          // wrap up previous line if necessary
          if (m_pCurrentLine->len > 0)
             StartNewLine (true, 0);

          /*
          CString strLine;
          char * p = strLine.GetBuffer (m_nWrapColumn);
          memset (p, 175, m_nWrapColumn);
          strLine.ReleaseBuffer (m_nWrapColumn);
          AddToLine (strLine, 0);
          */
          // mark line as HR line
          m_pCurrentLine->flags = HORIZ_RULE;
          
          StartNewLine (true, 0); // now finish this line
          }
          break;  // end of MXP_ACTION_HR

    case MXP_ACTION_PRE: 
          m_bPreMode = true;
          break;  // end of MXP_ACTION_PRE

     case MXP_ACTION_UL:   
          m_iListMode = eUnorderedList;
          m_iListCount = 0;
          break;  // end of MXP_ACTION_UL
     case MXP_ACTION_OL:   
          m_iListMode = eOrderedList;
          m_iListCount = 0;
          break;  // end of MXP_ACTION_OL
     case MXP_ACTION_LI:   
         {
          // wrap up previous line if necessary
          if (m_pCurrentLine->len > 0)
             StartNewLine (true, 0);
          CString strListItem = " * ";
          if (m_iListMode == eOrderedList)
            strListItem.Format (" %i. ", ++m_iListCount);
          AddToLine (strListItem, 0);
          }
          break;  // end of MXP_ACTION_LI

    // pueblo tags we put here so we don't get warnings

      case MXP_ACTION_BODY : bIgnoreUnusedArgs = true; break; // just ignore it
      case MXP_ACTION_HEAD : bIgnoreUnusedArgs = true; break; // just ignore it
      case MXP_ACTION_HTML : bIgnoreUnusedArgs = true; break; // just ignore it
      case MXP_ACTION_TITLE: bIgnoreUnusedArgs = true; break; // just ignore it
      case MXP_ACTION_SAMP : bIgnoreUnusedArgs = true; break; // just ignore it
      case MXP_ACTION_CENTER : bIgnoreUnusedArgs = true; break; // just ignore it
      case MXP_ACTION_XCH_PANE : bIgnoreUnusedArgs = true; break; // just ignore it

      case MXP_ACTION_IMG  : 
      case MXP_ACTION_IMAGE:

        {
          GetKeyword (ArgumentList, "ismap"); // make sure we realise it is a keyword

          // detect newline treatment
          strArgument = GetArgument (ArgumentList,"xch_mode", 0, false);  // get mode
          if (!strArgument.IsEmpty ())
            {
            m_bPuebloActive = true;  // for correct newline processing
            if (strArgument.CompareNoCase ("purehtml") == 0)
               m_bSuppressNewline = true;
            else
            if (strArgument.CompareNoCase ("html") == 0)
               m_bSuppressNewline = false;
            } // end of some sort of Pueblo

          strArgument = GetArgument (ArgumentList,"url", 0, false);  // get link
          if (strArgument.IsEmpty () && PUEBLO_ACTIVE)   
            strArgument = GetArgument (ArgumentList,"src", 0, false);  // get link

          CString strFilename = GetArgument (ArgumentList,"fname", 0, false); // and file name

          if (!strArgument.IsEmpty ())
            {

            CString strOldAction = strAction;
            int iFlags = pStyle->iFlags;
            COLORREF iForeColour = pStyle->iForeColour;
            COLORREF iBackColour = pStyle->iBackColour;

            // ensure on new line
            if (m_pCurrentLine->len > 0)
               StartNewLine (true, 0);

            // starting a new line may have deleted pStyle

            pStyle = m_pCurrentLine->styleList.GetTail ();

            if (m_bUseCustomLinkColour)
              {
              pStyle->iForeColour = m_iHyperlinkColour;    // use hyperlink colour
              pStyle->iBackColour = colour2;
              pStyle->iFlags &= ~COLOURTYPE;  // clear bits, eg. custom
              pStyle->iFlags |= COLOUR_RGB;
              }

            strArgument += strFilename;   // append filename to URL
            strAction = strArgument;   // hyperlink
            pStyle->iFlags &= ~ACTIONTYPE;   // cancel old actions
            pStyle->iFlags |= ACTION_HYPERLINK;   // send-to action

            if (m_bUnderlineHyperlinks)
              pStyle->iFlags |= UNDERLINE;   // send-to action

            AddToLine ("[", 0);          
            AddToLine (strArgument, 0);
            AddToLine ("]", 0);

            // have to add the action now, before we start a new line
            pStyle->pAction = GetAction (strAction, strHint, strVariable);
            strAction.Empty ();

            StartNewLine (true, 0);   // new line after image tag
            // go back to old style (ie. lose the underlining)
            AddStyle (iFlags, 
                     iForeColour, 
                     iBackColour, 
                     0, 
                     strOldAction);

            }
        }
        break; // end of MXP_ACTION_IMG

    case MXP_ACTION_XCH_PAGE:
         bIgnoreUnusedArgs = true;
         m_bPuebloActive = true;  // for correct newline processing
         MXP_Off ();    // same as <reset>?
      break;  // end of MXP_ACTION_XCH_PAGE

    case MXP_ACTION_VAR: 
          // set variable

          strVariable = GetArgument (ArgumentList,"", 1, false);  // get name

          // case insensitive
          strVariable.MakeLower ();

          if (!IsValidName (strVariable))
            {
            MXP_error (DBG_ERROR, errMXP_InvalidDefinition,
                      TFormat ("Invalid MXP entity name: <!%s>", 
                      (LPCTSTR) strVariable)); 
            strVariable.Empty ();
            return;
            }

            { // protect local variable
            CString strEntityContents;

            if (App.m_EntityMap.Lookup (strVariable, strEntityContents))
              {
              MXP_error (DBG_ERROR, errMXP_CannotRedefineEntity,
                        TFormat ("Cannot redefine entity: &%s;", 
                        (LPCTSTR) strVariable)); 
              strVariable.Empty ();
              return;
              }
              }

          break;  // end of MXP_ACTION_VAR


    default:
          {
          // warn them it is not implemented
          MXP_error (DBG_WARNING, wrnMXP_TagNotImplemented,
                     TFormat ("MXP tag <%s> is not implemented" ,
                             (LPCTSTR) strTag));
          }   // end of default

    } // end of switch on iAction

  if (!bIgnoreUnusedArgs)
    CheckArgumentsUsed (strTag, ArgumentList);

  } // end of CMUSHclientDoc::MXP_OpenAtomicTag
static HPDF_STATUS
LoadAfm (HPDF_FontDef  fontdef,
         HPDF_Stream   stream)
{
    HPDF_Type1FontDefAttr attr = (HPDF_Type1FontDefAttr)fontdef->attr;
    char buf[HPDF_TMP_BUF_SIZ];
    HPDF_CharData* cdata;
    HPDF_STATUS ret;
    HPDF_UINT len;
    char keyword[HPDF_LIMIT_MAX_NAME_LEN + 1];
    HPDF_UINT i;

    HPDF_PTRACE (" LoadAfm\n");

    len = HPDF_TMP_BUF_SIZ;

    /* chaeck AFM header */
    if ((ret = HPDF_Stream_ReadLn (stream, buf, &len)) != HPDF_OK)
         return ret;

    GetKeyword (buf, keyword, HPDF_LIMIT_MAX_NAME_LEN + 1);

    if (HPDF_StrCmp (keyword, "StartFontMetrics") != 0)
        return HPDF_INVALID_AFM_HEADER;

    /* Global Font Information */

    for (;;) {
        const char *s;

        len = HPDF_TMP_BUF_SIZ;
        if ((ret = HPDF_Stream_ReadLn (stream, buf, &len)) != HPDF_OK)
            return ret;

        s = GetKeyword (buf, keyword, HPDF_LIMIT_MAX_NAME_LEN + 1);

        if (HPDF_StrCmp (keyword, "FontName") == 0) {
            HPDF_StrCpy (fontdef->base_font, s,
                    fontdef->base_font + HPDF_LIMIT_MAX_NAME_LEN);
        } else

        if (HPDF_StrCmp (keyword, "Weight") == 0) {
            if (HPDF_StrCmp (s, "Bold") == 0)
                fontdef->flags |= HPDF_FONT_FOURCE_BOLD;
        } else

        if (HPDF_StrCmp (keyword, "IsFixedPitch") == 0) {
            if (HPDF_StrCmp (s, "true") == 0)
               fontdef->flags |= HPDF_FONT_FIXED_WIDTH;
        } else

        if (HPDF_StrCmp (keyword, "ItalicAngle") == 0) {
            fontdef->italic_angle = (HPDF_INT16)HPDF_AToI (s);
            if (fontdef->italic_angle != 0)
                fontdef->flags |= HPDF_FONT_ITALIC;
        } else

        if (HPDF_StrCmp (keyword, "CharacterSet") == 0) {
            HPDF_UINT len = HPDF_StrLen (s, HPDF_LIMIT_MAX_STRING_LEN);

            if (len > 0) {
                attr->char_set = HPDF_GetMem (fontdef->mmgr, len + 1);
                if (!attr->char_set)
                    return HPDF_Error_GetCode (fontdef->error);

                HPDF_StrCpy (attr->char_set, s, attr->char_set + len);
            }
        } else
        if (HPDF_StrCmp (keyword, "FontBBox") == 0) {
            char buf[HPDF_INT_LEN + 1];

            s = GetKeyword (s, buf, HPDF_INT_LEN + 1);
            fontdef->font_bbox.left = (HPDF_REAL)HPDF_AToI (buf);

            s = GetKeyword (s, buf, HPDF_INT_LEN + 1);
            fontdef->font_bbox.bottom = (HPDF_REAL)HPDF_AToI (buf);

            s = GetKeyword (s, buf, HPDF_INT_LEN + 1);
            fontdef->font_bbox.right = (HPDF_REAL)HPDF_AToI (buf);

            GetKeyword (s, buf, HPDF_INT_LEN + 1);
            fontdef->font_bbox.top = (HPDF_REAL)HPDF_AToI (buf);
        } else
        if (HPDF_StrCmp (keyword, "EncodingScheme") == 0) {
            HPDF_StrCpy (attr->encoding_scheme, s,
                    attr->encoding_scheme + HPDF_LIMIT_MAX_NAME_LEN);
        } else
        if (HPDF_StrCmp (keyword, "CapHeight") == 0) {
            fontdef->cap_height = (HPDF_UINT16)HPDF_AToI (s);
        } else
        if (HPDF_StrCmp (keyword, "Ascender") == 0) {
            fontdef->ascent = (HPDF_INT16)HPDF_AToI (s);
        } else
        if (HPDF_StrCmp (keyword, "Descender") == 0) {
            fontdef->descent = (HPDF_INT16)HPDF_AToI (s);
        } else
        if (HPDF_StrCmp (keyword, "STDHW") == 0) {
            fontdef->stemh = (HPDF_UINT16)HPDF_AToI (s);
        } else
        if (HPDF_StrCmp (keyword, "STDHV") == 0) {
            fontdef->stemv = (HPDF_UINT16)HPDF_AToI (s);
        } else
        if (HPDF_StrCmp (keyword, "StartCharMetrics") == 0) {
            attr->widths_count = HPDF_AToI (s);
            break;
        }
    }

    cdata = (HPDF_CharData*)HPDF_GetMem (fontdef->mmgr,
            sizeof(HPDF_CharData) * attr->widths_count);
    if (cdata == NULL)
        return HPDF_Error_GetCode (fontdef->error);

    HPDF_MemSet (cdata, 0, sizeof(HPDF_CharData) * attr->widths_count);
    attr->widths = cdata;

    /* load CharMetrics */
    for (i = 0; i < attr->widths_count; i++, cdata++) {
        const char *s;
        char buf2[HPDF_LIMIT_MAX_NAME_LEN + 1];

        len = HPDF_TMP_BUF_SIZ;
        if ((ret = HPDF_Stream_ReadLn (stream, buf, &len)) != HPDF_OK)
            return ret;

        /* C default character code. */
        s = GetKeyword (buf, buf2, HPDF_LIMIT_MAX_NAME_LEN + 1);
        if (HPDF_StrCmp (buf2, "CX") == 0) {
            /* not suppoted yet. */
            return HPDF_SetError (fontdef->error,
                    HPDF_INVALID_CHAR_MATRICS_DATA, 0);
        } else
        if (HPDF_StrCmp (buf2, "C") == 0) {
            s += 2;

            s = GetKeyword (s, buf2, HPDF_LIMIT_MAX_NAME_LEN + 1);
              HPDF_AToI (buf2);

            cdata->char_cd = (HPDF_INT16)HPDF_AToI (buf2);

        } else
            return HPDF_SetError (fontdef->error,
                    HPDF_INVALID_CHAR_MATRICS_DATA, 0);

        /* WX Character width */
        s = HPDF_StrStr (s, "WX ", 0);
        if (!s)
            return HPDF_SetError (fontdef->error, HPDF_INVALID_WX_DATA, 0);

        s += 3;

        s = GetKeyword (s, buf2, HPDF_LIMIT_MAX_NAME_LEN + 1);
        if (buf2[0] == 0)
            return HPDF_SetError (fontdef->error, HPDF_INVALID_WX_DATA, 0);

        cdata->width = (HPDF_INT16)HPDF_AToI (buf2);

        /* N PostScript language character name */
        s = HPDF_StrStr (s, "N ", 0);
        if (!s)
            return HPDF_SetError (fontdef->error, HPDF_INVALID_N_DATA, 0);

        s += 2;

        GetKeyword (s, buf2, HPDF_LIMIT_MAX_NAME_LEN + 1);

        cdata->unicode = HPDF_GryphNameToUnicode (buf2);

    }

    return HPDF_OK;
}
Пример #16
0
struct bwb_line *
bwb_OPEN(struct bwb_line * l)
{
   /* OPEN filename [FOR mode] AS filenumber [LEN reclen] */
   char            filename[BasicStringLengthMax + 1];
   char            mode[BasicStringLengthMax + 1];
   char            filenumber[BasicStringLengthMax + 1];
   char            reclen[BasicStringLengthMax + 1];
   char            OutputBuffer[BasicStringLengthMax + 1];
   int             p;

   bwx_DEBUG(__FUNCTION__);

   /* OPEN filename [FOR mode] AS */
   if (GetKeyword(l, filename, " FOR "))
   {
      /* OPEN filename FOR */
      if (GetKeyword(l, mode, " AS "))
      {
         /* FOR mode AS */
      }
      else
      {
         bwb_error("syntax error");
      }
   }
   else
   if (GetKeyword(l, filename, " AS "))
   {
      /* OPEN filename AS */
      strcpy(mode, "BINARY"); /* default for structured OPEN */
   }
   else
   {
      bwb_error("syntax error");
   }

   /* AS filenumber [LEN reclen] */
   if (GetKeyword(l, filenumber, " LEN "))
   {
      /* AS filenumber LEN reclen */
      GetRestOfLine(l, reclen);
   }
   else
   {
      /* AS filenumber */
      GetRestOfLine(l, filenumber);
      strcpy(reclen, "128");  /* default for structured OPEN */
   }

   OutputBuffer[0] = '\0';
   strcat(OutputBuffer, "OPEN(");
   strcat(OutputBuffer, "\"");
   strcat(OutputBuffer, mode);
   strcat(OutputBuffer, "\"");
   strcat(OutputBuffer, ",");
   strcat(OutputBuffer, filenumber);
   strcat(OutputBuffer, ",");
   strcat(OutputBuffer, filename);
   strcat(OutputBuffer, ",");
   strcat(OutputBuffer, reclen);
   strcat(OutputBuffer, ")");


   p = 0;
   bwb_exp(OutputBuffer, FALSE, &p);
   if (ERROR_PENDING)
   {
      /* oops */
   }
   return bwb_zline(l);
}
Пример #17
0
void PDSDataset::ParseSRS()

{
    const char *pszFilename = GetDescription();

/* ==================================================================== */
/*      Get the geotransform.                                           */
/* ==================================================================== */
    /***********   Grab Cellsize ************/
    //example:
    //MAP_SCALE   = 14.818 <KM/PIXEL>
    //added search for unit (only checks for CM, KM - defaults to Meters)
    const char *value;
    //Georef parameters
    double dfULXMap=0.5;
    double dfULYMap = 0.5;
    double dfXDim = 1.0;
    double dfYDim = 1.0;
    double xulcenter = 0.0;
    double yulcenter = 0.0;

    value = GetKeyword("IMAGE_MAP_PROJECTION.MAP_SCALE");
    if (strlen(value) > 0 ) {
        dfXDim = atof(value);
        dfYDim = atof(value) * -1;
        
        CPLString unit = GetKeywordUnit("IMAGE_MAP_PROJECTION.MAP_SCALE",2); //KM
        //value = GetKeywordUnit("IMAGE_MAP_PROJECTION.MAP_SCALE",3); //PIXEL
        if((EQUAL(unit,"M"))  || (EQUAL(unit,"METER")) || (EQUAL(unit,"METERS"))) {
            // do nothing
        }
        else if (EQUAL(unit,"CM")) {
            // convert from cm to m
            dfXDim = dfXDim / 100.0;
            dfYDim = dfYDim / 100.0;
        } else {
            //defaults to convert km to m
            dfXDim = dfXDim * 1000.0;
            dfYDim = dfYDim * 1000.0;
        }            
    }
    
/* -------------------------------------------------------------------- */
/*      Calculate upper left corner of pixel in meters from the         */
/*      upper  left center pixel sample/line offsets.  It doesn't       */
/*      mean the defaults will work for every PDS image, as these       */
/*      values are used inconsistantly.  Thus we have included          */
/*      conversion options to allow the user to override the            */
/*      documented PDS3 default. Jan. 2011, for known mapping issues    */
/*      see GDAL PDS page or mapping within ISIS3 source (USGS)         */
/*      $ISIS3DATA/base/translations/pdsProjectionLineSampToXY.def      */
/* -------------------------------------------------------------------- */
   
    // defaults should be correct for what is documented in the PDS3 standard
    double   dfSampleOffset_Shift;
    double   dfLineOffset_Shift;
    double   dfSampleOffset_Mult;
    double   dfLineOffset_Mult;

    dfSampleOffset_Shift = 
        atof(CPLGetConfigOption( "PDS_SampleProjOffset_Shift", "-0.5" ));
    
    dfLineOffset_Shift = 
        atof(CPLGetConfigOption( "PDS_LineProjOffset_Shift", "-0.5" ));

    dfSampleOffset_Mult =
        atof(CPLGetConfigOption( "PDS_SampleProjOffset_Mult", "-1.0") );

    dfLineOffset_Mult = 
        atof( CPLGetConfigOption( "PDS_LineProjOffset_Mult", "1.0") );

    /***********   Grab LINE_PROJECTION_OFFSET ************/
    value = GetKeyword("IMAGE_MAP_PROJECTION.LINE_PROJECTION_OFFSET");
    if (strlen(value) > 0) {
        yulcenter = atof(value);
        dfULYMap = ((yulcenter + dfLineOffset_Shift) * -dfYDim * dfLineOffset_Mult);
        //notice dfYDim is negative here which is why it is again negated here
    }
    /***********   Grab SAMPLE_PROJECTION_OFFSET ************/
    value = GetKeyword("IMAGE_MAP_PROJECTION.SAMPLE_PROJECTION_OFFSET");
    if( strlen(value) > 0 ) {
        xulcenter = atof(value);
        dfULXMap = ((xulcenter + dfSampleOffset_Shift) * dfXDim * dfSampleOffset_Mult);
    }

/* ==================================================================== */
/*      Get the coordinate system.                                      */
/* ==================================================================== */
    int	bProjectionSet = TRUE;
    double semi_major = 0.0;
    double semi_minor = 0.0;
    double iflattening = 0.0;
    double center_lat = 0.0;
    double center_lon = 0.0;
    double first_std_parallel = 0.0;
    double second_std_parallel = 0.0;
    OGRSpatialReference oSRS;

    /***********  Grab TARGET_NAME  ************/
    /**** This is the planets name i.e. MARS ***/
    CPLString target_name = GetKeyword("TARGET_NAME");
    CleanString( target_name );
     
    /**********   Grab MAP_PROJECTION_TYPE *****/
    CPLString map_proj_name = 
        GetKeyword( "IMAGE_MAP_PROJECTION.MAP_PROJECTION_TYPE");
    CleanString( map_proj_name );
     
    /******  Grab semi_major & convert to KM ******/
    semi_major = 
        atof(GetKeyword( "IMAGE_MAP_PROJECTION.A_AXIS_RADIUS")) * 1000.0;
    
    /******  Grab semi-minor & convert to KM ******/
    semi_minor = 
        atof(GetKeyword( "IMAGE_MAP_PROJECTION.C_AXIS_RADIUS")) * 1000.0;

    /***********   Grab CENTER_LAT ************/
    center_lat = 
        atof(GetKeyword( "IMAGE_MAP_PROJECTION.CENTER_LATITUDE"));

    /***********   Grab CENTER_LON ************/
    center_lon = 
        atof(GetKeyword( "IMAGE_MAP_PROJECTION.CENTER_LONGITUDE"));

    /**********   Grab 1st std parallel *******/
    first_std_parallel = 
        atof(GetKeyword( "IMAGE_MAP_PROJECTION.FIRST_STANDARD_PARALLEL"));

    /**********   Grab 2nd std parallel *******/
    second_std_parallel = 
        atof(GetKeyword( "IMAGE_MAP_PROJECTION.SECOND_STANDARD_PARALLEL"));
     
    /*** grab  PROJECTION_LATITUDE_TYPE = "PLANETOCENTRIC" ****/
    // Need to further study how ocentric/ographic will effect the gdal library.
    // So far we will use this fact to define a sphere or ellipse for some projections
    // Frank - may need to talk this over
    char bIsGeographic = TRUE;
    value = GetKeyword("IMAGE_MAP_PROJECTION.COORDINATE_SYSTEM_NAME");
    if (EQUAL( value, "PLANETOCENTRIC" ))
        bIsGeographic = FALSE; 

/**   Set oSRS projection and parameters --- all PDS supported types added if apparently supported in oSRS
      "AITOFF",  ** Not supported in GDAL??
      "ALBERS", 
      "BONNE",
      "BRIESEMEISTER",   ** Not supported in GDAL??
      "CYLINDRICAL EQUAL AREA",
      "EQUIDISTANT",
      "EQUIRECTANGULAR",
      "GNOMONIC",
      "HAMMER",    ** Not supported in GDAL??
      "HENDU",     ** Not supported in GDAL??
      "LAMBERT AZIMUTHAL EQUAL AREA",
      "LAMBERT CONFORMAL",
      "MERCATOR",
      "MOLLWEIDE",
      "OBLIQUE CYLINDRICAL",
      "ORTHOGRAPHIC",
      "SIMPLE CYLINDRICAL",
      "SINUSOIDAL",
      "STEREOGRAPHIC",
      "TRANSVERSE MERCATOR",
      "VAN DER GRINTEN",     ** Not supported in GDAL??
      "WERNER"     ** Not supported in GDAL?? 
**/ 
    CPLDebug( "PDS","using projection %s\n\n", map_proj_name.c_str());

    if ((EQUAL( map_proj_name, "EQUIRECTANGULAR" )) ||
        (EQUAL( map_proj_name, "SIMPLE_CYLINDRICAL" )) ||
        (EQUAL( map_proj_name, "EQUIDISTANT" )) )  {
        oSRS.SetEquirectangular2 ( 0.0, center_lon, center_lat, 0, 0 );
    } else if (EQUAL( map_proj_name, "ORTHOGRAPHIC" )) {
        oSRS.SetOrthographic ( center_lat, center_lon, 0, 0 );
    } else if (EQUAL( map_proj_name, "SINUSOIDAL" )) {
        oSRS.SetSinusoidal ( center_lon, 0, 0 );
    } else if (EQUAL( map_proj_name, "MERCATOR" )) {
        oSRS.SetMercator ( center_lat, center_lon, 1, 0, 0 );
    } else if (EQUAL( map_proj_name, "STEREOGRAPHIC" )) {
        oSRS.SetStereographic ( center_lat, center_lon, 1, 0, 0 );
    } else if (EQUAL( map_proj_name, "POLAR_STEREOGRAPHIC")) {
        oSRS.SetPS ( center_lat, center_lon, 1, 0, 0 );
    } else if (EQUAL( map_proj_name, "TRANSVERSE_MERCATOR" )) {
        oSRS.SetTM ( center_lat, center_lon, 1, 0, 0 );
    } else if (EQUAL( map_proj_name, "LAMBERT_CONFORMAL_CONIC" )) {
        oSRS.SetLCC ( first_std_parallel, second_std_parallel, 
                      center_lat, center_lon, 0, 0 );
    } else if (EQUAL( map_proj_name, "LAMBERT_AZIMUTHAL_EQUAL_AREA" )) {
        oSRS.SetLAEA( center_lat, center_lon, 0, 0 );
    } else if (EQUAL( map_proj_name, "CYLINDRICAL_EQUAL_AREA" )) {
        oSRS.SetCEA  ( first_std_parallel, center_lon, 0, 0 );
    } else if (EQUAL( map_proj_name, "MOLLWEIDE" )) {
        oSRS.SetMollweide ( center_lon, 0, 0 );
    } else if (EQUAL( map_proj_name, "ALBERS" )) {
        oSRS.SetACEA ( first_std_parallel, second_std_parallel, 
                       center_lat, center_lon, 0, 0 );
    } else if (EQUAL( map_proj_name, "BONNE" )) {
        oSRS.SetBonne ( first_std_parallel, center_lon, 0, 0 );
    } else if (EQUAL( map_proj_name, "GNOMONIC" )) {
        oSRS.SetGnomonic ( center_lat, center_lon, 0, 0 );
    } else if (EQUAL( map_proj_name, "OBLIQUE_CYLINDRICAL" )) { 
        // hope Swiss Oblique Cylindrical is the same
        oSRS.SetSOC ( center_lat, center_lon, 0, 0 );
    } else {
        CPLDebug( "PDS",
                  "Dataset projection %s is not supported. Continuing...",
                  map_proj_name.c_str() );
        bProjectionSet = FALSE;
    }

    if (bProjectionSet) {
        //Create projection name, i.e. MERCATOR MARS and set as ProjCS keyword
        CPLString proj_target_name = map_proj_name + " " + target_name;
        oSRS.SetProjCS(proj_target_name); //set ProjCS keyword
     
        //The geographic/geocentric name will be the same basic name as the body name
        //'GCS' = Geographic/Geocentric Coordinate System
        CPLString geog_name = "GCS_" + target_name;
        
        //The datum and sphere names will be the same basic name aas the planet
        CPLString datum_name = "D_" + target_name;
        CPLString sphere_name = target_name; // + "_IAU_IAG");  //Might not be IAU defined so don't add
          
        //calculate inverse flattening from major and minor axis: 1/f = a/(a-b)
        if ((semi_major - semi_minor) < 0.0000001) 
            iflattening = 0;
        else
            iflattening = semi_major / (semi_major - semi_minor);
     
        //Set the body size but take into consideration which proj is being used to help w/ compatibility
        //Notice that most PDS projections are spherical based on the fact that ISIS/PICS are spherical 
        //Set the body size but take into consideration which proj is being used to help w/ proj4 compatibility
        //The use of a Sphere, polar radius or ellipse here is based on how ISIS does it internally
        if ( ( (EQUAL( map_proj_name, "STEREOGRAPHIC" ) && (fabs(center_lat) == 90)) ) || 
             (EQUAL( map_proj_name, "POLAR_STEREOGRAPHIC" )))  
        {
            if (bIsGeographic) { 
                //Geograpraphic, so set an ellipse
                oSRS.SetGeogCS( geog_name, datum_name, sphere_name,
                                semi_major, iflattening, 
                                "Reference_Meridian", 0.0 );
            } else {
                //Geocentric, so force a sphere using the semi-minor axis. I hope... 
                sphere_name += "_polarRadius";
                oSRS.SetGeogCS( geog_name, datum_name, sphere_name,
                                semi_minor, 0.0, 
                                "Reference_Meridian", 0.0 );
            }
        }
        else if ( (EQUAL( map_proj_name, "SIMPLE_CYLINDRICAL" )) || 
                  (EQUAL( map_proj_name, "EQUIDISTANT" )) || 
                  (EQUAL( map_proj_name, "ORTHOGRAPHIC" )) || 
                  (EQUAL( map_proj_name, "STEREOGRAPHIC" )) || 
                  (EQUAL( map_proj_name, "SINUSOIDAL" )) ) {
            //isis uses the spherical equation for these projections so force a sphere
            oSRS.SetGeogCS( geog_name, datum_name, sphere_name,
                            semi_major, 0.0, 
                            "Reference_Meridian", 0.0 );
        } 
        else if (EQUAL( map_proj_name, "EQUIRECTANGULAR" )) { 
            //isis uses local radius as a sphere, which is pre-calculated in the PDS label as the semi-major
            sphere_name += "_localRadius";
            oSRS.SetGeogCS( geog_name, datum_name, sphere_name,
                            semi_major, 0.0, 
                            "Reference_Meridian", 0.0 );
        } 
        else { 
            //All other projections: Mercator, Transverse Mercator, Lambert Conformal, etc.
            //Geographic, so set an ellipse
            if (bIsGeographic) {
                oSRS.SetGeogCS( geog_name, datum_name, sphere_name,
                                semi_major, iflattening, 
                                "Reference_Meridian", 0.0 );
            } else { 
                //Geocentric, so force a sphere. I hope... 
                oSRS.SetGeogCS( geog_name, datum_name, sphere_name,
                                semi_major, 0.0, 
                                "Reference_Meridian", 0.0 );
            }
        }

        // translate back into a projection string.
        char *pszResult = NULL;
        oSRS.exportToWkt( &pszResult );
        osProjection = pszResult;
        CPLFree( pszResult );
    }

/* ==================================================================== */
/*      Check for a .prj and world file to override the georeferencing. */
/* ==================================================================== */
    {
        CPLString osPath, osName;
        VSILFILE *fp;

        osPath = CPLGetPath( pszFilename );
        osName = CPLGetBasename(pszFilename);
        const char  *pszPrjFile = CPLFormCIFilename( osPath, osName, "prj" );

        fp = VSIFOpenL( pszPrjFile, "r" );
        if( fp != NULL )
        {
            char	**papszLines;
            OGRSpatialReference oSRS;

            VSIFCloseL( fp );
        
            papszLines = CSLLoad( pszPrjFile );

            if( oSRS.importFromESRI( papszLines ) == OGRERR_NONE )
            {
                char *pszResult = NULL;
                oSRS.exportToWkt( &pszResult );
                osProjection = pszResult;
                CPLFree( pszResult );
            }

            CSLDestroy( papszLines );
        }
    }
    
    if( dfULYMap != 0.5 || dfULYMap != 0.5 || dfXDim != 1.0 || dfYDim != 1.0 )
    {
        bGotTransform = TRUE;
        adfGeoTransform[0] = dfULXMap;
        adfGeoTransform[1] = dfXDim;
        adfGeoTransform[2] = 0.0;
        adfGeoTransform[3] = dfULYMap;
        adfGeoTransform[4] = 0.0;
        adfGeoTransform[5] = dfYDim;
    }
    
    if( !bGotTransform )
        bGotTransform = 
            GDALReadWorldFile( pszFilename, "psw", 
                               adfGeoTransform );

    if( !bGotTransform )
        bGotTransform = 
            GDALReadWorldFile( pszFilename, "wld", 
                               adfGeoTransform );

}
Пример #18
0
double FitsFile::GetDoubleKeywordValue(int keywordNumber)
{
	return atof(GetKeyword(keywordNumber).c_str());
}
Пример #19
0
static CJcToken* NextToken(CJcScanner* scanner){
	jc_int state;
	while (scanner->ch == ' ' ||
			scanner->ch >= 9 && scanner->ch <= 10 || scanner->ch == 13
	) NextCh(scanner);

	scanner->t = CreateToken(scanner);
	scanner->t->fcol = GetCol(scanner->buffer);
	scanner->t->fline = GetLine(scanner->buffer);
	scanner->t->fname = GetFileName(scanner->buffer);
	scanner->t->pos = scanner->pos;
	scanner->t->col = scanner->col;
	scanner->t->line = scanner->line;
	state = GetStartState(&scanner->start, scanner->ch);
	scanner->tlen = 0;
	AddCh(scanner);

	switch (state){
	case -1:
		scanner->t->kind = scanner->eofSym;
		break;
	case 0:
		scanner->t->kind = scanner->noSym;
		break;
		case 1:
			case_1:
			if (scanner->ch >= '0' && scanner->ch <= '9' || scanner->ch >= 'A' && scanner->ch <= 'Z' || scanner->ch == '_' || scanner->ch >= 'a' && scanner->ch <= 'z') {AddCh(scanner); goto case_1;}
			else {scanner->t->kind = 1; {char *literal = jcc_string_create(scanner->tval, 0, scanner->tlen); scanner->t->kind = GetKeyword(&scanner->keywords, literal, scanner->t->kind); free(literal); break;}}
		case 2:
			if (scanner->ch <= 9 || scanner->ch >= 11 && scanner->ch <= 12 || scanner->ch >= 14 && scanner->ch <= '&' || scanner->ch >= '(' && scanner->ch <= '[' || scanner->ch >= ']' && scanner->ch <= 65535) {AddCh(scanner); goto case_4;}
			else if (scanner->ch == 92) {AddCh(scanner); goto case_3;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 3:
			case_3:
			if (scanner->ch == '"' || scanner->ch == 39 || scanner->ch == '?' || scanner->ch == 92 || scanner->ch >= 'a' && scanner->ch <= 'b' || scanner->ch == 'f' || scanner->ch == 'n' || scanner->ch == 'r' || scanner->ch == 't' || scanner->ch == 'v') {AddCh(scanner); goto case_4;}
			else if (scanner->ch >= '0' && scanner->ch <= '7') {AddCh(scanner); goto case_5;}
			else if (scanner->ch == 'X' || scanner->ch == 'x') {AddCh(scanner); goto case_6;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 4:
			case_4:
			if (scanner->ch == 39) {AddCh(scanner); goto case_8;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 5:
			case_5:
			if (scanner->ch >= '0' && scanner->ch <= '7') {AddCh(scanner); goto case_87;}
			else if (scanner->ch == 39) {AddCh(scanner); goto case_8;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 6:
			case_6:
			if (scanner->ch >= '0' && scanner->ch <= '9' || scanner->ch >= 'A' && scanner->ch <= 'F' || scanner->ch >= 'a' && scanner->ch <= 'f') {AddCh(scanner); goto case_7;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 7:
			case_7:
			if (scanner->ch >= '0' && scanner->ch <= '9' || scanner->ch >= 'A' && scanner->ch <= 'F' || scanner->ch >= 'a' && scanner->ch <= 'f') {AddCh(scanner); goto case_4;}
			else if (scanner->ch == 39) {AddCh(scanner); goto case_8;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 8:
			case_8:
			{scanner->t->kind = 2; break;}
		case 9:
			case_9:
			if (scanner->ch <= 9 || scanner->ch >= 11 && scanner->ch <= 12 || scanner->ch >= 14 && scanner->ch <= '!' || scanner->ch >= '#' && scanner->ch <= '[' || scanner->ch >= ']' && scanner->ch <= 65535) {AddCh(scanner); goto case_9;}
			else if (scanner->ch == '"') {AddCh(scanner); goto case_14;}
			else if (scanner->ch == 92) {AddCh(scanner); goto case_10;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 10:
			case_10:
			if (scanner->ch == '"' || scanner->ch == 39 || scanner->ch == '?' || scanner->ch == 92 || scanner->ch >= 'a' && scanner->ch <= 'b' || scanner->ch == 'f' || scanner->ch == 'n' || scanner->ch == 'r' || scanner->ch == 't' || scanner->ch == 'v') {AddCh(scanner); goto case_9;}
			else if (scanner->ch >= '0' && scanner->ch <= '7') {AddCh(scanner); goto case_11;}
			else if (scanner->ch == 'X' || scanner->ch == 'x') {AddCh(scanner); goto case_12;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 11:
			case_11:
			if (scanner->ch <= 9 || scanner->ch >= 11 && scanner->ch <= 12 || scanner->ch >= 14 && scanner->ch <= '!' || scanner->ch >= '#' && scanner->ch <= '/' || scanner->ch >= '8' && scanner->ch <= '[' || scanner->ch >= ']' && scanner->ch <= 65535) {AddCh(scanner); goto case_9;}
			else if (scanner->ch >= '0' && scanner->ch <= '7') {AddCh(scanner); goto case_88;}
			else if (scanner->ch == '"') {AddCh(scanner); goto case_14;}
			else if (scanner->ch == 92) {AddCh(scanner); goto case_10;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 12:
			case_12:
			if (scanner->ch >= '0' && scanner->ch <= '9' || scanner->ch >= 'A' && scanner->ch <= 'F' || scanner->ch >= 'a' && scanner->ch <= 'f') {AddCh(scanner); goto case_13;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 13:
			case_13:
			if (scanner->ch <= 9 || scanner->ch >= 11 && scanner->ch <= 12 || scanner->ch >= 14 && scanner->ch <= '!' || scanner->ch >= '#' && scanner->ch <= '[' || scanner->ch >= ']' && scanner->ch <= 65535) {AddCh(scanner); goto case_9;}
			else if (scanner->ch == '"') {AddCh(scanner); goto case_14;}
			else if (scanner->ch == 92) {AddCh(scanner); goto case_10;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 14:
			case_14:
			{scanner->t->kind = 3; break;}
		case 15:
			case_15:
			if (scanner->ch == '8' || scanner->ch == 'L' || scanner->ch == 'l') {AddCh(scanner); goto case_25;}
			else if (scanner->ch == '1') {AddCh(scanner); goto case_16;}
			else if (scanner->ch == '3') {AddCh(scanner); goto case_17;}
			else if (scanner->ch == '6') {AddCh(scanner); goto case_18;}
			else {scanner->t->kind = 4; break;}
		case 16:
			case_16:
			if (scanner->ch == '6') {AddCh(scanner); goto case_25;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 17:
			case_17:
			if (scanner->ch == '2') {AddCh(scanner); goto case_25;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 18:
			case_18:
			if (scanner->ch == '4') {AddCh(scanner); goto case_25;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 19:
			case_19:
			if (scanner->ch == '8') {AddCh(scanner); goto case_25;}
			else if (scanner->ch == '1') {AddCh(scanner); goto case_20;}
			else if (scanner->ch == '3') {AddCh(scanner); goto case_21;}
			else if (scanner->ch == '6') {AddCh(scanner); goto case_22;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 20:
			case_20:
			if (scanner->ch == '6') {AddCh(scanner); goto case_25;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 21:
			case_21:
			if (scanner->ch == '2') {AddCh(scanner); goto case_25;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 22:
			case_22:
			if (scanner->ch == '4') {AddCh(scanner); goto case_25;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 23:
			case_23:
			if (scanner->ch >= '0' && scanner->ch <= '9' || scanner->ch >= 'A' && scanner->ch <= 'F' || scanner->ch >= 'a' && scanner->ch <= 'f') {AddCh(scanner); goto case_24;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 24:
			case_24:
			if (scanner->ch >= '0' && scanner->ch <= '9' || scanner->ch >= 'A' && scanner->ch <= 'F' || scanner->ch >= 'a' && scanner->ch <= 'f') {AddCh(scanner); goto case_24;}
			else if (scanner->ch == 'U' || scanner->ch == 'u') {AddCh(scanner); goto case_15;}
			else if (scanner->ch == 'I' || scanner->ch == 'i') {AddCh(scanner); goto case_19;}
			else {scanner->t->kind = 4; break;}
		case 25:
			case_25:
			{scanner->t->kind = 4; break;}
		case 26:
			case_26:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_26;}
			else if (scanner->ch == 'F' || scanner->ch == 'f') {AddCh(scanner); goto case_39;}
			else if (scanner->ch == 'E' || scanner->ch == 'e') {AddCh(scanner); goto case_27;}
			else {scanner->t->kind = 5; break;}
		case 27:
			case_27:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_29;}
			else if (scanner->ch == '+' || scanner->ch == '-') {AddCh(scanner); goto case_28;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 28:
			case_28:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_29;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 29:
			case_29:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_29;}
			else if (scanner->ch == 'F' || scanner->ch == 'f') {AddCh(scanner); goto case_39;}
			else {scanner->t->kind = 5; break;}
		case 30:
			case_30:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_30;}
			else if (scanner->ch == '.') {AddCh(scanner); goto case_31;}
			else if (scanner->ch == 'E' || scanner->ch == 'e') {AddCh(scanner); goto case_36;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 31:
			case_31:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_35;}
			else if (scanner->ch == 'F' || scanner->ch == 'f') {AddCh(scanner); goto case_39;}
			else if (scanner->ch == 'E' || scanner->ch == 'e') {AddCh(scanner); goto case_32;}
			else {scanner->t->kind = 5; break;}
		case 32:
			case_32:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_34;}
			else if (scanner->ch == '+' || scanner->ch == '-') {AddCh(scanner); goto case_33;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 33:
			case_33:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_34;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 34:
			case_34:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_34;}
			else if (scanner->ch == 'F' || scanner->ch == 'f') {AddCh(scanner); goto case_39;}
			else {scanner->t->kind = 5; break;}
		case 35:
			case_35:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_35;}
			else if (scanner->ch == 'F' || scanner->ch == 'f') {AddCh(scanner); goto case_39;}
			else if (scanner->ch == 'E' || scanner->ch == 'e') {AddCh(scanner); goto case_32;}
			else {scanner->t->kind = 5; break;}
		case 36:
			case_36:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_38;}
			else if (scanner->ch == '+' || scanner->ch == '-') {AddCh(scanner); goto case_37;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 37:
			case_37:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_38;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 38:
			case_38:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_38;}
			else if (scanner->ch == 'F' || scanner->ch == 'f') {AddCh(scanner); goto case_39;}
			else {scanner->t->kind = 5; break;}
		case 39:
			case_39:
			{scanner->t->kind = 5; break;}
		case 40:
			case_40:
			if (scanner->ch == '.') {AddCh(scanner); goto case_41;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 41:
			case_41:
			{scanner->t->kind = 40; break;}
		case 42:
			case_42:
			{scanner->t->kind = 41; break;}
		case 43:
			case_43:
			{scanner->t->kind = 42; break;}
		case 44:
			case_44:
			{scanner->t->kind = 43; break;}
		case 45:
			case_45:
			{scanner->t->kind = 44; break;}
		case 46:
			case_46:
			{scanner->t->kind = 45; break;}
		case 47:
			case_47:
			{scanner->t->kind = 46; break;}
		case 48:
			case_48:
			{scanner->t->kind = 47; break;}
		case 49:
			case_49:
			{scanner->t->kind = 48; break;}
		case 50:
			case_50:
			{scanner->t->kind = 49; break;}
		case 51:
			case_51:
			{scanner->t->kind = 50; break;}
		case 52:
			case_52:
			{scanner->t->kind = 51; break;}
		case 53:
			case_53:
			{scanner->t->kind = 52; break;}
		case 54:
			case_54:
			{scanner->t->kind = 53; break;}
		case 55:
			case_55:
			{scanner->t->kind = 54; break;}
		case 56:
			case_56:
			{scanner->t->kind = 57; break;}
		case 57:
			case_57:
			{scanner->t->kind = 58; break;}
		case 58:
			case_58:
			{scanner->t->kind = 59; break;}
		case 59:
			case_59:
			{scanner->t->kind = 60; break;}
		case 60:
			case_60:
			{scanner->t->kind = 61; break;}
		case 61:
			{scanner->t->kind = 62; break;}
		case 62:
			{scanner->t->kind = 68; break;}
		case 63:
			{scanner->t->kind = 69; break;}
		case 64:
			case_64:
			{scanner->t->kind = 73; break;}
		case 65:
			case_65:
			{scanner->t->kind = 74; break;}
		case 66:
			case_66:
			{scanner->t->kind = 75; break;}
		case 67:
			case_67:
			{scanner->t->kind = 76; break;}
		case 68:
			{scanner->t->kind = 79; break;}
		case 69:
			{scanner->t->kind = 82; break;}
		case 70:
			{scanner->t->kind = 84; break;}
		case 71:
			case_71:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_71;}
			else if (scanner->ch == 'U' || scanner->ch == 'u') {AddCh(scanner); goto case_15;}
			else if (scanner->ch == 'I' || scanner->ch == 'i') {AddCh(scanner); goto case_19;}
			else if (scanner->ch == '.') {AddCh(scanner); goto case_31;}
			else if (scanner->ch == 'E' || scanner->ch == 'e') {AddCh(scanner); goto case_36;}
			else {scanner->t->kind = 4; break;}
		case 72:
			case_72:
			if (scanner->ch >= '0' && scanner->ch <= '7') {AddCh(scanner); goto case_72;}
			else if (scanner->ch >= '8' && scanner->ch <= '9') {AddCh(scanner); goto case_30;}
			else if (scanner->ch == 'X' || scanner->ch == 'x') {AddCh(scanner); goto case_23;}
			else if (scanner->ch == 'U' || scanner->ch == 'u') {AddCh(scanner); goto case_15;}
			else if (scanner->ch == 'I' || scanner->ch == 'i') {AddCh(scanner); goto case_19;}
			else if (scanner->ch == '.') {AddCh(scanner); goto case_31;}
			else if (scanner->ch == 'E' || scanner->ch == 'e') {AddCh(scanner); goto case_36;}
			else {scanner->t->kind = 4; break;}
		case 73:
			if (scanner->ch >= '0' && scanner->ch <= '9') {AddCh(scanner); goto case_26;}
			else if (scanner->ch == '.') {AddCh(scanner); goto case_40;}
			else {scanner->t->kind = 83; break;}
		case 74:
			if (scanner->ch == '>') {AddCh(scanner); goto case_89;}
			else if (scanner->ch == '=') {AddCh(scanner); goto case_53;}
			else {scanner->t->kind = 81; break;}
		case 75:
			if (scanner->ch == '<') {AddCh(scanner); goto case_90;}
			else if (scanner->ch == '=') {AddCh(scanner); goto case_54;}
			else if (scanner->ch == '%') {AddCh(scanner); goto case_64;}
			else if (scanner->ch == ':') {AddCh(scanner); goto case_66;}
			else {scanner->t->kind = 80; break;}
		case 76:
			if (scanner->ch == '=') {AddCh(scanner); goto case_44;}
			else {scanner->t->kind = 63; break;}
		case 77:
			if (scanner->ch == '=') {AddCh(scanner); goto case_45;}
			else if (scanner->ch == '>') {AddCh(scanner); goto case_65;}
			else {scanner->t->kind = 64; break;}
		case 78:
			if (scanner->ch == '=') {AddCh(scanner); goto case_46;}
			else {scanner->t->kind = 65; break;}
		case 79:
			if (scanner->ch == '=') {AddCh(scanner); goto case_47;}
			else if (scanner->ch == '&') {AddCh(scanner); goto case_56;}
			else {scanner->t->kind = 66; break;}
		case 80:
			if (scanner->ch == '=') {AddCh(scanner); goto case_48;}
			else {scanner->t->kind = 67; break;}
		case 81:
			if (scanner->ch == '=') {AddCh(scanner); goto case_49;}
			else if (scanner->ch == '>') {AddCh(scanner); goto case_58;}
			else if (scanner->ch == '-') {AddCh(scanner); goto case_60;}
			else {scanner->t->kind = 70; break;}
		case 82:
			if (scanner->ch == '=') {AddCh(scanner); goto case_50;}
			else if (scanner->ch == '+') {AddCh(scanner); goto case_59;}
			else {scanner->t->kind = 71; break;}
		case 83:
			if (scanner->ch == '=') {AddCh(scanner); goto case_51;}
			else if (scanner->ch == '|') {AddCh(scanner); goto case_57;}
			else {scanner->t->kind = 77; break;}
		case 84:
			if (scanner->ch == '=') {AddCh(scanner); goto case_52;}
			else {scanner->t->kind = 85; break;}
		case 85:
			if (scanner->ch == '=') {AddCh(scanner); goto case_55;}
			else {scanner->t->kind = 72; break;}
		case 86:
			if (scanner->ch == '>') {AddCh(scanner); goto case_67;}
			else {scanner->t->kind = 78; break;}
		case 87:
			case_87:
			if (scanner->ch >= '0' && scanner->ch <= '7') {AddCh(scanner); goto case_4;}
			else if (scanner->ch == 39) {AddCh(scanner); goto case_8;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 88:
			case_88:
			if (scanner->ch <= 9 || scanner->ch >= 11 && scanner->ch <= 12 || scanner->ch >= 14 && scanner->ch <= '!' || scanner->ch >= '#' && scanner->ch <= '[' || scanner->ch >= ']' && scanner->ch <= 65535) {AddCh(scanner); goto case_9;}
			else if (scanner->ch == '"') {AddCh(scanner); goto case_14;}
			else if (scanner->ch == 92) {AddCh(scanner); goto case_10;}
			else {scanner->t->kind = scanner->noSym; break;}
		case 89:
			case_89:
			if (scanner->ch == '=') {AddCh(scanner); goto case_42;}
			else {scanner->t->kind = 56; break;}
		case 90:
			case_90:
			if (scanner->ch == '=') {AddCh(scanner); goto case_43;}
			else {scanner->t->kind = 55; break;}

	}
	AppendVal(scanner, scanner->t);
	return scanner->t;
}