コード例 #1
0
ファイル: 36.c プロジェクト: leolas95/c
char *eliminar(char *cadena, char *subcadena)
{
	int i, j, k, t;

	for (i = 0; i < strlen(cadena); i++) {
		if (cadena[i] == subcadena[0]) {
			t = i;
			for (j = 0, k = i; cadena[k] == subcadena[j] && subcadena[j+1]; j++, k++)
				cadena[k] = ' ';
			cadena[k] = ' ';
			/*printf("j vale %d, k vale %d, t vale %d\n", j, k, t);
			if (subcadena[j+1] == '\0') {
				rodar_izquierda(cadena, t, k);
			}*/
		}
	}
	trimall(cadena);
}
コード例 #2
0
void RunPackage::sendOutput()
{

  ifstream in(arcer->getFileName());
  in.seekg(pos);

  char theline[1000]; 
  while (!in.eof()){
    readline(in,theline,999);
    pos = in.tellg();

    
    
    if (strlen(theline) > 0 ){
      char* tok = strtok(theline, "{");
      char trimtok[1000];
      strcpy(trimtok, tok);
      trimall(trimtok);
      
      if ( !actionParser(trimtok) )  {

	//  all output goes into a file link

	if (!started){
	  
	  LogMessage msg1;
	  msg1 << Link(Chars( "Click here to see the details from ") + packageName,
		       "Package",
		       file.getFileName(), true );
	  msg1.send();
	  started = true;
	  useGlobalLink = true;
	}
	file << theline << endl;
	
      }
    }
  }
  in.close();
}
コード例 #3
0
ファイル: ConfigFileParser.cpp プロジェクト: hezhihua/stabird
int  CConfigFileParser::ParseLine(char* line)
{

	if (NULL==line)
	{
		return -1;
	}
	
	char * pstart=trimall(line);
	if (NULL==pstart)
	{
		return -1;
	}

	char* pSecStart = strchr(pstart, '[');
	if (NULL!=pSecStart)
	{
	    if ('['!=pstart[0])
	    {
		   return -1;
	    }

		char* pSecEnd = strchr(pstart, ']');
		if (NULL==pSecEnd || pSecEnd==pSecStart+1 )
		{
			return -1;
		}

		int len=pSecEnd-pSecStart-1;

		if (len<=0)
		{
			return -1;
		}
		char secName[256]={0};
		strncpy(secName,pSecStart+1,len);

		m_sCurrentSectionName=secName;

	}
	

	char* pKey= strchr(pstart, '=');

	if (NULL!=pKey)
	{
		
		char key[100]={0};
		char value[100]={0};
		strncpy(key,pstart,pKey-pstart);

		//char *pk=TrimSpace(pKey+1);
		strncpy(value,pKey+1,strlen(pKey+1));

		SectionMap::iterator it=m_mapFileSection.find(m_sCurrentSectionName);
		if (it!=m_mapFileSection.end())
		{
			(*(it->second))[string(key)]=string(value);
		}
		else
		{
			map<string ,string > *mapKeyValue =new map<string ,string > ;
			(*mapKeyValue)[string(key)]=string(value);

			m_mapFileSection.insert(make_pair(m_sCurrentSectionName,mapKeyValue));
		}
		
		
	}
		
	return 0;
}