Ejemplo n.º 1
0
void q330DestroyCfg(Q330_CFG *cfg)
{
int i;

    if (cfg == NULL) return;
    ClearCfg(cfg);
    free(cfg);
}
Ejemplo n.º 2
0
/*
** 读取语言配置文件
** 配置文件格式: 语言ID=字库名称,字符集名称,语言包名称,语言后缀,语言名称
*/
int CLang::ReadCfg( char *cfgFile )
{
	int nRet = -1;
	char *pCfgBuf = NULL;
     
	int len = ReadFile( &pCfgBuf, cfgFile );
	if ( len > 0 && pCfgBuf != NULL )
    {
    	int lineCnt = 0;

        // 计算配置文件行数
    	for( char *pCfgTmp = pCfgBuf; pCfgTmp != NULL; pCfgTmp++ )
        {
        	pCfgTmp = strchr( pCfgTmp, '\n' );
        	if ( pCfgTmp != NULL ) lineCnt++;
        	else break;
        }

    	if ( lineCnt > 0 )
        {
        	if ( m_ppLangCfg ) ClearCfg( m_ppLangCfg );
        	m_ppLangCfg = ( LP_LANGCFG * )Malloc( lineCnt * sizeof(LP_LANGCFG) );
        	if ( m_ppLangCfg )
            {
            	for ( int i = 0; i < lineCnt; i++ ) m_ppLangCfg[i] = NULL;

            	char *pCfg = pCfgBuf;
            	char *pLine = NULL;
            	int langCnt = 0;
            	while ( (langCnt < lineCnt) && (pLine = GetLine( &pCfg )) )
                {
                	m_ppLangCfg[langCnt] = GetLangCfg( pLine );
                	if ( m_ppLangCfg[langCnt] != NULL ) langCnt++;
                	Free( pLine );
                }
                
            	if ( langCnt > 0 ) // 读取配置文件成功
                {
                	m_nLangNum = langCnt;
                	nRet = 0;
                	FiPrint( "Load language config file success !\r\n" );                    
                }
            }
        	else
            {
            	FiPrint( "Load language config file error: Malloc memory failed !\r\n" );                
            }
        }
    }
	else
    {
    	if ( len == 0 )
        	FiPrint( "Load language config file error: Empty file !\r\n" );
    	else if ( len == -1 )
        	FiPrint( "Load language config file error: Read file error !\r\n" );
    	else
        	FiPrint( "Load language config file error: Malloc memory failed !\r\n" );
    }
    
	Free( pCfgBuf );
	return nRet;
}