Пример #1
0
bool XML_StringSetParser::HandleAttribute(const char *Tag, const char *Value)
{
  if (StringsEqual(Tag,"index")) {
    short ID;
    if (ReadInt16Value(Value,ID)) {
      CurrStringSet = FindStringSet(ID);
      return true;
    }
    else{ return false; }
  }
  UnrecognizedTag();
  return false;
}
// ZZZ: Set up a C-string in the repository; a repeated call will replace an old string
void TS_PutCString(short ID, short Index, const char *String)
{
	// Search for string set: (FindStringSet() creates a new one if necessary)
	StringSet *CurrStringSet = FindStringSet(ID);
        
        // Create a PString of the incoming CString, truncate to fit
        unsigned char	thePStringStagingBuffer[256];

        size_t theStringLength = strlen(String);

        if(theStringLength > 255)
            theStringLength = 255;

        // Fill in the string length.
        thePStringStagingBuffer[0] = (char)theStringLength;
        
        // Copy exactly the string bytes (no termination etc.)
        memcpy(&(thePStringStagingBuffer[1]), String, theStringLength);
        
        // Add() copies the string, so using the stack here is OK.
	CurrStringSet->Add(Index,thePStringStagingBuffer);
}
// Set up a string in the repository; a repeated call will replace an old string
void TS_PutString(short ID, short Index, unsigned char *String)
{
	// Search for string set:
	StringSet *CurrStringSet = FindStringSet(ID);
	CurrStringSet->Add(Index,String);
}