Exemplo n.º 1
0
void CS34XML::CleanInput(char *pBuffer)
{
	if (pBuffer==NULL)
		return;
	StripChars(pBuffer);
	StripLeadingSpaces(pBuffer);
	StripTrailingSpaces(pBuffer);
	StripBeginningAndEndingQoutes(pBuffer);
}
Exemplo n.º 2
0
static void ParseLine(char *line, char *var, char *data)
{
      int len = 0;

      line = StripLeadingSpaces(line);
      strcpy(var, line);
      strcpy(data, "");

      while (*line)
      {
            char *ptr;

            if (/*isspace(*line) || */ ('=' == *line))
            {
                  var[len] = 0;
                  var  = StripTrailingSpaces(var);
                  line = StripLeadingSpaces(line+1);

                  /* Remove a possible '=' */
                  /* This could allow var==string in some cases. No big deal*/

                  while (line && '=' == *line)
                        line = StripLeadingSpaces(line+1);
                  if (line)
                  {
                        strcpy(data, line);
                        if (NULL != (ptr = strrchr(data, ';')) &&
                            NULL == strchr(ptr, '\"'))
                        {
                              *ptr = NUL;
                        }
                        StripTrailingSpaces(data);
                  }
                  return;
            }
            else
            {
                  line++;
                  len++;
            }
      }
}
Exemplo n.º 3
0
//************************************************************************
void CBelongsScene::OnDestroy(HWND hWnd)
//************************************************************************
{
	STRING szString;
	GetDlgItemText(hWnd, IDC_EDIT, szString, sizeof(szString));
	StripLeadingSpaces(szString);
	GetApp()->WriteSettingString("Name", szString, FALSE);
	CGBScene::OnDestroy(hWnd);
	if (m_hSound)
	{
		MCIStop(m_hSound,YES);
		MCIClose(m_hSound);
		m_hSound = NULL;
	}
}
Exemplo n.º 4
0
static enum LineTypes SectionLine(char *line,
                                  char *SectionWanted,
                                  char *CurrentSection)
{
      enum LineTypes linetype;

      line = StripLeadingSpaces(line);
      if (!line || NUL == *line)
            return EmptyLine;

      /*
      ** Comments are started with a "%", ";" or "#"
      */

      if (';' == *line)
            return CommentLine;
      if ('%' == *line)
            return CommentLine;
      if ('#' == *line)
            return CommentLine;

      if ('[' == line[0])  /* Section Header */
      {
            linetype = NewSection;
            if (StrEq(CurrentSection, SectionWanted))
                  linetype = LeavingSection;

            strcpy(CurrentSection, line);
            if (StrEq(line, SectionWanted))
                  linetype = FoundSection;
      }
      else
      {            /* Just a regular line */
            linetype = NotInSection;
            if (StrEq(CurrentSection, SectionWanted))
                  linetype = InSection;
      }

      return linetype;
}
Exemplo n.º 5
0
//************************************************************************
void CBelongsScene::PlayBelongsTo(BOOL fNameOnly)
//************************************************************************
{
	STRING szName;
	FNAME szNameWave;
	FNAME szFileName;
	BOOL fGotName = FALSE;

	GetDlgItemText(m_hWnd, IDC_EDIT, szName, sizeof(szName));
	StripLeadingSpaces(szName);
	if (!lstrlen(szName))
		return;

	// See if the name is in the table (for names longer than 8)
	STRING szTheName;
	int len = lstrlen(szName);
	for (int n = 0; n <= len; ++n)
	{
		if (isspace(szName[n]))
			szTheName[n] = '-';
		else
			szTheName[n] = szName[n];
	}

	for (int i = 0; i < m_nNames; ++i)
	{
		if (!lstrcmpi(m_pNames[i].m_szName, szTheName))
		{ // found it, now play the wav
			GetPathName(szNameWave, m_pNames[i].m_szFileName);
			fGotName = FileExistsExpand(szNameWave, NULL);
			break;
		}
	}

	// See if file for this name exists
	// in normal content directory
	if (!fGotName)
	{
		GetPathName(szNameWave, szName);
		lstrcat(szNameWave, ".wav");
		fGotName = FileExistsExpand(szNameWave, NULL);
	}
			
	// Try the windows directory for a custom name
	if (!fGotName)
	{
		GetWindowsDirectory(szNameWave, sizeof(szNameWave));
		FixPath(szNameWave);
		lstrcat(szNameWave, szName);
		lstrcat(szNameWave, ".wav");
		fGotName = FileExistsExpand(szNameWave, NULL);
	}

	if (fNameOnly && !fGotName)
		return;

	if (m_hSound)
	{
		MCIStop(m_hSound,YES);
		MCIClose(m_hSound);
		m_hSound = NULL;
	}

	if (!fNameOnly)
	{
		GetPathName(szFileName, BELONGS_TO_WAVE);
		if ( m_hSound = MCIOpen(GetApp()->m_hDeviceWAV, szFileName, NULL) )
		{
			MCIPlay(m_hSound, NULL);
			MCIClose(m_hSound);
			m_hSound = NULL;
		}
	}

	if (fGotName)
	{	// If we have a name play it
		if ( m_hSound = MCIOpen(GetApp()->m_hDeviceWAV, szNameWave, NULL) )
		{
			MCIPlay(m_hSound, NULL);
			MCIClose(m_hSound);
			m_hSound = NULL;
		}
	}
	else
	{	// Otherwise, play it letter by letter
		STRING szName;
		GetDlgItemText(m_hWnd, IDC_EDIT, szName, sizeof(szName));
		StripLeadingSpaces(szName);

		STRING szLetter;
		FNAME szFileName;
		BOOL fExists = FALSE;
		int i = 0;
		char c;
		while ( c = szName[i++] )
		{
			szLetter[0] = c;
			szLetter[1] = '\0';
			lstrcat(szLetter, ".wav");
			GetPathName(szFileName, szLetter);
			if ( !FileExistsExpand(szFileName, NULL) )
				continue;
			if ( m_hSound = MCIOpen(GetApp()->m_hDeviceWAV, szFileName, NULL) )
			{
				MCIPlay(m_hSound, NULL);
				MCIClose(m_hSound);
				m_hSound = NULL;
			}
		}
	}
}