/*------------------------------------------------------------------------------
// gotoSection: move file position to start line of a section
//------------------------------------------------------------------------------*/
static int gotoSection( FILE *is, const char *section )
{
  char line[256];
  while( fgets( line, 256, is) )
    if( containTitle( line, section ) )
      return True;
  return False;
}
//----------------------------------------------------------------------------
// gotoSection: move file position to start line of a section
//----------------------------------------------------------------------------
NABoolean UdrCfgParser::gotoSection( FILE *is, const char *section
                                    , NAString &errorText)
{
   char line[BUFFMAX+1];
   while( fgets( line, sizeof(line), is) )
      if( containTitle( line, section ) )
         return TRUE;

   if (ferror(is)) {
      errorText += "*** ERROR: UdrCfgParser(): fgets failed on config file ";
      errorText += cfgFileName;
      errorText += " due to an I/O error: ";
      errorText += strerror(errno);
      errorText += ".\n";

   }

   return FALSE;
}
Ejemplo n.º 3
0
bool ConfigFile::gotoSection(const char *section )
{
/*
	功能:移动文件指针到指定section的开始处
	参数:
		section[IN]:要查找的section
	返回值:
		找到并定位返回true
		否则返回false
*/
	char line[1024];
   fseek(fin,0,SEEK_SET);

	while( FGetS(line,1024,fin)!=NULL)
   {
	   if( containTitle( line, section ) )
		   return true;
   }
	return false;
}