|
|
|
@ -102,7 +102,7 @@
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#include <io.h>
|
|
|
|
|
#else
|
|
|
|
|
//#include <curses.h>
|
|
|
|
|
//#include <curses.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
//#include <global_errno.h>
|
|
|
|
|
// #include <sys/uswitch.h>
|
|
|
|
@ -124,7 +124,7 @@ static PGCBOOL g_bHandleInit = PGCFALSE;
|
|
|
|
|
|
|
|
|
|
//定义行注释符
|
|
|
|
|
#define MARK_pgcchar_NUM 2
|
|
|
|
|
static pgcchar gs_szMarkpgcchar[MARK_pgcchar_NUM] = {';', '#'};
|
|
|
|
|
static pgcchar gs_szMarkpgcchar[MARK_pgcchar_NUM] = { ';', '#' };
|
|
|
|
|
|
|
|
|
|
//行结尾字符为\n,不包括\r
|
|
|
|
|
//#define LINE_EXCLUDE_0A
|
|
|
|
@ -144,7 +144,7 @@ pgcchar* UpperCase(pgcchar *szSource)
|
|
|
|
|
while (*pcTemp != '\0')
|
|
|
|
|
{
|
|
|
|
|
if ((*pcTemp >= 'a') && (*pcTemp <= 'z'))
|
|
|
|
|
*pcTemp = (pgcchar)(*pcTemp - ('a' - 'A')) ;
|
|
|
|
|
*pcTemp = (pgcchar)(*pcTemp - ('a' - 'A'));
|
|
|
|
|
pcTemp++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -182,9 +182,9 @@ static int fnhash_compare(const void * pKey1, const void * pKey2);
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#define INDEX_HASH_TABLE_SIZE_FACTOR 20
|
|
|
|
|
pgc32 profile_build_hash_index ( SItemInCache * pindex,
|
|
|
|
|
pgc32 profile_build_hash_index(SItemInCache * pindex,
|
|
|
|
|
pgc32 count,
|
|
|
|
|
TChainHash<SItemInCache> ** pphash_of_index )
|
|
|
|
|
TChainHash<SItemInCache> ** pphash_of_index)
|
|
|
|
|
{
|
|
|
|
|
pgc32 i = 0;
|
|
|
|
|
TChainHash<SItemInCache> * phash_table = NULL;
|
|
|
|
@ -201,7 +201,7 @@ pgc32 profile_build_hash_index ( SItemInCache * pindex,
|
|
|
|
|
if (phash_table == NULL)
|
|
|
|
|
return ERROR_MEMORY_ALLOC;
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
phash_table->insertItem(pindex + i);
|
|
|
|
|
|
|
|
|
|
*pphash_of_index = phash_table;
|
|
|
|
@ -224,7 +224,7 @@ pgc32 profile_build_hash_index ( SItemInCache * pindex,
|
|
|
|
|
* 索引在索引数组中的序号 -- 成功的查找到指定的配置项目的索引
|
|
|
|
|
* -1 -- 失败
|
|
|
|
|
*/
|
|
|
|
|
pgc32 profile_search_sequence ( SItemInCache **pindex_base,
|
|
|
|
|
pgc32 profile_search_sequence(SItemInCache **pindex_base,
|
|
|
|
|
TChainHash<SItemInCache> *phash_of_index,
|
|
|
|
|
const pgcchar *szSecName,
|
|
|
|
|
const pgcchar *szItemName)
|
|
|
|
@ -254,7 +254,7 @@ pgc32 profile_search_sequence ( SItemInCache **pindex_base,
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
p = phash_of_index->searchItem((void *)&index);
|
|
|
|
|
if(NULL == p)
|
|
|
|
|
if (NULL == p)
|
|
|
|
|
return -1;
|
|
|
|
|
*pindex_base = p;
|
|
|
|
|
return 0;
|
|
|
|
@ -294,7 +294,7 @@ static u32 fnhash_index_of(const void * pKey, u32 hash_size)
|
|
|
|
|
iX = iX % MAX_SEC_NUM;
|
|
|
|
|
|
|
|
|
|
pbString = (u_char*)sindex.szItemName;
|
|
|
|
|
for ( i = 0; i < MAX_CHAR_LINE; i++)
|
|
|
|
|
for (i = 0; i < MAX_CHAR_LINE; i++)
|
|
|
|
|
{
|
|
|
|
|
iY = iY + pbString[i];
|
|
|
|
|
}
|
|
|
|
@ -323,7 +323,7 @@ static int fnhash_compare(const void * pKey1, const void * pKey2)
|
|
|
|
|
|
|
|
|
|
if (pKey1 == NULL)
|
|
|
|
|
return 1;
|
|
|
|
|
//#ifdef OS_WINDOWS
|
|
|
|
|
//#ifdef OS_WINDOWS
|
|
|
|
|
if (pKey2 == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (_stricmp(pindex1->szSecName, pindex2->szSecName) == 0)
|
|
|
|
@ -339,7 +339,7 @@ static int fnhash_compare(const void * pKey1, const void * pKey2)
|
|
|
|
|
else
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
/*#else
|
|
|
|
|
/*#else
|
|
|
|
|
if (pKey2 == NULL)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -356,7 +356,7 @@ static int fnhash_compare(const void * pKey1, const void * pKey2)
|
|
|
|
|
else
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
#endif*/
|
|
|
|
|
#endif*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -397,7 +397,7 @@ pgcchar* FindSecTail(pgcchar *szString)
|
|
|
|
|
{
|
|
|
|
|
if (*szTemp == ']')
|
|
|
|
|
return szStart;
|
|
|
|
|
szTemp ++;
|
|
|
|
|
szTemp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -422,7 +422,7 @@ PGCBOOL DigSecName(const pgcchar *szString, pgcchar *szRevBuffer, pgc32 iBufferL
|
|
|
|
|
bSecNameExist = PGCTRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
szTemp ++;
|
|
|
|
|
szTemp++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bSecNameExist)
|
|
|
|
@ -448,7 +448,7 @@ PGCBOOL DigSecName(const pgcchar *szString, pgcchar *szRevBuffer, pgc32 iBufferL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//提取项目名及项目值
|
|
|
|
|
PGCBOOL DigItemContent( pgcchar *szString, pgcchar *szItemName, pgcchar *szItemVal, pgc32 iBufferLength)
|
|
|
|
|
PGCBOOL DigItemContent(pgcchar *szString, pgcchar *szItemName, pgcchar *szItemVal, pgc32 iBufferLength)
|
|
|
|
|
{
|
|
|
|
|
pgcchar *pcBeval = NULL, *pcTemp = NULL, szTemp[MAX_CHAR_LINE];
|
|
|
|
|
pgc32 iCount = 0, i = 0;
|
|
|
|
@ -468,7 +468,7 @@ PGCBOOL DigItemContent( pgcchar *szString, pgcchar *szItemName, pgcchar *szItemV
|
|
|
|
|
szTemp[iCount] = '\0';
|
|
|
|
|
|
|
|
|
|
//删除前面多余空格
|
|
|
|
|
for ( i = 0; i < MAX_CHAR_LINE; i++)
|
|
|
|
|
for (i = 0; i < MAX_CHAR_LINE; i++)
|
|
|
|
|
{
|
|
|
|
|
if (szTemp[i] != ' ')
|
|
|
|
|
{
|
|
|
|
@ -499,7 +499,7 @@ PGCBOOL DigItemContent( pgcchar *szString, pgcchar *szItemName, pgcchar *szItemV
|
|
|
|
|
#ifdef OS_WINDOWS
|
|
|
|
|
lstrcpyn((LPWSTR)szTemp, (LPCWSTR)pcBeval + 1, MAX_CHAR_LINE);
|
|
|
|
|
#else
|
|
|
|
|
strncpy(szTemp ,pcBeval + 1, MAX_CHAR_LINE - 1);
|
|
|
|
|
strncpy(szTemp, pcBeval + 1, MAX_CHAR_LINE - 1);
|
|
|
|
|
#endif
|
|
|
|
|
//删除前面多余空格
|
|
|
|
|
for (i = 0; i < MAX_CHAR_LINE; i++)
|
|
|
|
@ -515,7 +515,7 @@ PGCBOOL DigItemContent( pgcchar *szString, pgcchar *szItemName, pgcchar *szItemV
|
|
|
|
|
}// end for
|
|
|
|
|
|
|
|
|
|
//删除后面多余空格
|
|
|
|
|
for ( i = (pgc32)strlen(szTemp) - 1 ; i >= 0; i--)
|
|
|
|
|
for (i = (pgc32)strlen(szTemp) - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
if (szTemp[i] != ' ')
|
|
|
|
|
break;
|
|
|
|
@ -562,7 +562,7 @@ PGCBOOL InsertNode(SItemSequence * &psHead, pgc32 iPos, SItemInCache *psCacheEnt
|
|
|
|
|
return PGCTRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
delete []psNewNode;
|
|
|
|
|
delete[]psNewNode;
|
|
|
|
|
return PGCFALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -638,7 +638,7 @@ void ReleaseProfileCache(HPROFILE hProfile)
|
|
|
|
|
SMemoChain *psMemo = NULL, *psMemoPrior = NULL;
|
|
|
|
|
pgc32 iCurItemCount = 0;
|
|
|
|
|
|
|
|
|
|
fstream = g_pHandleIndex[hProfile].fstream ;
|
|
|
|
|
fstream = g_pHandleIndex[hProfile].fstream;
|
|
|
|
|
if (fstream != NULL)
|
|
|
|
|
fclose(fstream);
|
|
|
|
|
|
|
|
|
@ -652,7 +652,7 @@ void ReleaseProfileCache(HPROFILE hProfile)
|
|
|
|
|
{
|
|
|
|
|
psPrior = pSequence;
|
|
|
|
|
pSequence = pSequence->NextNode;
|
|
|
|
|
delete []psPrior;
|
|
|
|
|
delete[]psPrior;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -668,8 +668,8 @@ void ReleaseProfileCache(HPROFILE hProfile)
|
|
|
|
|
{
|
|
|
|
|
psMemoPrior = psMemo;
|
|
|
|
|
psMemo = psMemo->NextNode;
|
|
|
|
|
delete []psMemoPrior->szMemo;
|
|
|
|
|
delete []psMemoPrior;
|
|
|
|
|
delete[]psMemoPrior->szMemo;
|
|
|
|
|
delete[]psMemoPrior;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free(psCacheEntry);
|
|
|
|
@ -686,7 +686,7 @@ pgcu32 AdjustCache(HPROFILE hCacher, pgc32 iNewItem)
|
|
|
|
|
pgc32 iOldUse = g_pHandleIndex[hCacher].CurUseItems;
|
|
|
|
|
SItemInCache *pCacheEntry = NULL;
|
|
|
|
|
|
|
|
|
|
if ((g_pHandleIndex[hCacher].CurUseItems + iNewItem ) >= iOldSize)
|
|
|
|
|
if ((g_pHandleIndex[hCacher].CurUseItems + iNewItem) >= iOldSize)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
iNewSize = iOldSize + RESIZE_ITEM_NUM;
|
|
|
|
@ -724,7 +724,7 @@ pgc32 get_file_lastMTime(char * pszfname, timeval *pt)
|
|
|
|
|
memset((void *)&buf, 0, sizeof(buf));
|
|
|
|
|
|
|
|
|
|
ret = stat(pszfname, &buf);
|
|
|
|
|
if(-1 == ret)
|
|
|
|
|
if (-1 == ret)
|
|
|
|
|
return ERROR_FAIL;
|
|
|
|
|
|
|
|
|
|
pt->tv_sec = buf.st_mtime;
|
|
|
|
@ -741,13 +741,13 @@ pgc32 ReWriteProfile(HPROFILE hProfile)
|
|
|
|
|
pgcchar *pcFileBuffer = NULL, *pcTemp = NULL;
|
|
|
|
|
pgcchar *pcHead = NULL;
|
|
|
|
|
PGCBOOL bSecExist = PGCFALSE;
|
|
|
|
|
SItemSequence * psSeq = g_pHandleIndex[hProfile].pSequence ;
|
|
|
|
|
SItemSequence * psSeq = g_pHandleIndex[hProfile].pSequence;
|
|
|
|
|
SItemInCache *psCacheEntry = g_pHandleIndex[hProfile].pCacheEntry, *psTemp = NULL;
|
|
|
|
|
SMemoChain *psMemo = NULL;
|
|
|
|
|
FILE *stream = /*g_pHandleIndex[hProfile].fstream*/0;
|
|
|
|
|
iSize = (g_pHandleIndex[hProfile].CurLines + 2) * (MAX_CHAR_LINE + 2);
|
|
|
|
|
|
|
|
|
|
if (( pcHead = (pgcchar*)malloc(iSize)) != NULL)
|
|
|
|
|
if ((pcHead = (pgcchar*)malloc(iSize)) != NULL)
|
|
|
|
|
{
|
|
|
|
|
pcFileBuffer = pcHead;
|
|
|
|
|
memset(pcFileBuffer, 0, iSize);
|
|
|
|
@ -849,9 +849,9 @@ pgc32 ReWriteProfile(HPROFILE hProfile)
|
|
|
|
|
|
|
|
|
|
//2002/03/05 杨小波++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
#if 0
|
|
|
|
|
pgcu32 numwritten = (pgcu32)pcFileBuffer - (pgcu32)pcHead ;
|
|
|
|
|
pgcu32 numwritten = (pgcu32)pcFileBuffer - (pgcu32)pcHead;
|
|
|
|
|
#endif
|
|
|
|
|
pgcu32 numwritten = (pgcu32)(pcFileBuffer - pcHead) ;
|
|
|
|
|
pgcu32 numwritten = (pgcu32)(pcFileBuffer - pcHead);
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -887,7 +887,7 @@ pgc32 ReWriteProfile(HPROFILE hProfile)
|
|
|
|
|
|
|
|
|
|
fseek(stream, 0, SEEK_SET);
|
|
|
|
|
//函数fwrite在写数据到文件时,如遇字符NULL,会产生错误,从而使文件无法定位结尾
|
|
|
|
|
pgc32 numwritted = (pgc32)fwrite(pcHead, sizeof( pgcchar ), numwritten , stream );
|
|
|
|
|
pgc32 numwritted = (pgc32)fwrite(pcHead, sizeof(pgcchar), numwritten, stream);
|
|
|
|
|
free(pcHead);
|
|
|
|
|
fclose(stream);
|
|
|
|
|
//记录下修改文件的时间
|
|
|
|
@ -939,7 +939,7 @@ void ReCreateCache(HPROFILE hProfile)
|
|
|
|
|
pgc32 ProcessCreateCache(HPROFILE hProfile)
|
|
|
|
|
{
|
|
|
|
|
pgcchar *pcFileBuffer = NULL, *pcTemp = NULL, *pcStart = NULL, *pcEnd = NULL;
|
|
|
|
|
pgcchar *pcNextLine = NULL, *pcTemp1 = NULL ;
|
|
|
|
|
pgcchar *pcNextLine = NULL, *pcTemp1 = NULL;
|
|
|
|
|
pgcchar szSecName[MAX_CHAR_LINE], CurItemName[MAX_CHAR_LINE], CurItemVal[MAX_CHAR_LINE];
|
|
|
|
|
SItemInCache *psTemp = NULL;
|
|
|
|
|
SMemoChain *psMemoTep = NULL, *psMemo = NULL;
|
|
|
|
@ -962,13 +962,13 @@ pgc32 ProcessCreateCache(HPROFILE hProfile)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
memset(&g_pHandleIndex[hProfile], 0, sizeof(SProfileHanleInfo));
|
|
|
|
|
//#ifdef OS_WINDOWS
|
|
|
|
|
//#ifdef OS_WINDOWS
|
|
|
|
|
//windows下打开文件
|
|
|
|
|
if ((fstream = fopen(szProfileName, "r+b")) == NULL)
|
|
|
|
|
{
|
|
|
|
|
return ERROR_FOPEN;
|
|
|
|
|
}
|
|
|
|
|
/*#else
|
|
|
|
|
/*#else
|
|
|
|
|
//unix下打开文件
|
|
|
|
|
PGCBOOL bOpenOK = PGCFALSE;
|
|
|
|
|
do
|
|
|
|
@ -984,7 +984,7 @@ pgc32 ProcessCreateCache(HPROFILE hProfile)
|
|
|
|
|
|
|
|
|
|
if (!bOpenOK)
|
|
|
|
|
return ERROR_FOPEN;
|
|
|
|
|
#endif*/
|
|
|
|
|
#endif*/
|
|
|
|
|
|
|
|
|
|
if (fseek(fstream, 0, SEEK_END) != 0)
|
|
|
|
|
{
|
|
|
|
@ -1007,7 +1007,7 @@ pgc32 ProcessCreateCache(HPROFILE hProfile)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
//将文件读入缓冲
|
|
|
|
|
if ((iCount = (pgc32)fread(pcTemp, sizeof( pgcchar ), lFileLength, fstream)) != lFileLength)
|
|
|
|
|
if ((iCount = (pgc32)fread(pcTemp, sizeof(pgcchar), lFileLength, fstream)) != lFileLength)
|
|
|
|
|
{
|
|
|
|
|
fclose(fstream);
|
|
|
|
|
return ERROR_FREAD;
|
|
|
|
@ -1023,16 +1023,16 @@ pgc32 ProcessCreateCache(HPROFILE hProfile)
|
|
|
|
|
if (*pcStart == ' ')
|
|
|
|
|
{
|
|
|
|
|
*pcStart = 0;
|
|
|
|
|
pcStart ++;
|
|
|
|
|
pcStart++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (*pcStart == '\n')
|
|
|
|
|
pcStart ++;
|
|
|
|
|
pcStart++;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ((pcStart = strchr(pcStart, '\n')) == NULL) break;
|
|
|
|
|
pcStart ++;
|
|
|
|
|
pcStart++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}// end while
|
|
|
|
@ -1046,7 +1046,7 @@ pgc32 ProcessCreateCache(HPROFILE hProfile)
|
|
|
|
|
if ((*pcStart == '\r') && (*(pcStart + 1) == '\n'))
|
|
|
|
|
{
|
|
|
|
|
*pcStart = 0;
|
|
|
|
|
pcStart +=2;
|
|
|
|
|
pcStart += 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
pcStart++;
|
|
|
|
@ -1070,7 +1070,7 @@ pgc32 ProcessCreateCache(HPROFILE hProfile)
|
|
|
|
|
//重建文件缓冲
|
|
|
|
|
pcFileBuffer = new pgcchar[iCount + 1];
|
|
|
|
|
memset(pcFileBuffer, 0, iCount + 1);
|
|
|
|
|
for ( i = 0; i < iCount; i++)
|
|
|
|
|
for (i = 0; i < iCount; i++)
|
|
|
|
|
{
|
|
|
|
|
if (pcTemp[i] != 0)
|
|
|
|
|
{
|
|
|
|
@ -1078,7 +1078,7 @@ pgc32 ProcessCreateCache(HPROFILE hProfile)
|
|
|
|
|
iPos++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
delete []pcTemp;
|
|
|
|
|
delete[]pcTemp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1087,7 +1087,7 @@ pgc32 ProcessCreateCache(HPROFILE hProfile)
|
|
|
|
|
if (psCacheEntry == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (pcFileBuffer != NULL)
|
|
|
|
|
delete []pcFileBuffer;
|
|
|
|
|
delete[]pcFileBuffer;
|
|
|
|
|
fclose(fstream);
|
|
|
|
|
return ERROR_MEMORY_ALLOC;
|
|
|
|
|
}
|
|
|
|
@ -1136,7 +1136,7 @@ pgc32 ProcessCreateCache(HPROFILE hProfile)
|
|
|
|
|
pcTemp = strchr(pcStart, '[');
|
|
|
|
|
pcTemp1 = strchr(pcStart, ']');
|
|
|
|
|
//如果当前行是段名,则提取段名
|
|
|
|
|
if ( pcTemp && pcTemp1 && (pcTemp1 > pcTemp))
|
|
|
|
|
if (pcTemp && pcTemp1 && (pcTemp1 > pcTemp))
|
|
|
|
|
{
|
|
|
|
|
DigSecName(pcStart, szSecName, MAX_CHAR_LINE);
|
|
|
|
|
iCurLineType = 2;
|
|
|
|
@ -1226,7 +1226,7 @@ pgc32 ProcessCreateCache(HPROFILE hProfile)
|
|
|
|
|
|
|
|
|
|
AddNode(g_pHandleIndex[hProfile].pSequence, g_pHandleIndex[hProfile].pCurSeq, iCurItem);
|
|
|
|
|
bSecNameExist = PGCTRUE;
|
|
|
|
|
iCurItem ++;
|
|
|
|
|
iCurItem++;
|
|
|
|
|
psMemo = NULL;
|
|
|
|
|
break;
|
|
|
|
|
//如果是项目赋值
|
|
|
|
@ -1242,7 +1242,7 @@ pgc32 ProcessCreateCache(HPROFILE hProfile)
|
|
|
|
|
psTemp->memo = psMemo;
|
|
|
|
|
|
|
|
|
|
AddNode(g_pHandleIndex[hProfile].pSequence, g_pHandleIndex[hProfile].pCurSeq, iCurItem);
|
|
|
|
|
iCurItem ++;
|
|
|
|
|
iCurItem++;
|
|
|
|
|
psMemo = NULL;
|
|
|
|
|
}//end if
|
|
|
|
|
break;
|
|
|
|
@ -1276,20 +1276,20 @@ pgc32 ProcessCreateCache(HPROFILE hProfile)
|
|
|
|
|
}// end while
|
|
|
|
|
|
|
|
|
|
if (pcFileBuffer != NULL)
|
|
|
|
|
delete []pcFileBuffer;
|
|
|
|
|
delete[]pcFileBuffer;
|
|
|
|
|
|
|
|
|
|
pgc32 iRev = -1;
|
|
|
|
|
|
|
|
|
|
//创建哈希表
|
|
|
|
|
iRev = profile_build_hash_index(psCacheEntry, iCurItem , &phash_table);
|
|
|
|
|
iRev = profile_build_hash_index(psCacheEntry, iCurItem, &phash_table);
|
|
|
|
|
if (iRev != SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
ReleaseProfileCache(hProfile);
|
|
|
|
|
return ERROR_CONF_CREATEHASH ;
|
|
|
|
|
return ERROR_CONF_CREATEHASH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_pHandleIndex[hProfile].pHashTable = phash_table;
|
|
|
|
|
g_pHandleIndex[hProfile].CurUseItems = iCurItem ;
|
|
|
|
|
g_pHandleIndex[hProfile].CurUseItems = iCurItem;
|
|
|
|
|
g_pHandleIndex[hProfile].CurSecNum = iCurSec;
|
|
|
|
|
|
|
|
|
|
fstream = g_pHandleIndex[hProfile].fstream;
|
|
|
|
@ -1334,7 +1334,7 @@ int create_profile_cache(pgcchar *szProfileName, int *phfile)
|
|
|
|
|
HPROFILE hCurCacher = 0;
|
|
|
|
|
|
|
|
|
|
if (szProfileName == NULL)
|
|
|
|
|
return ERROR_FOPEN ;
|
|
|
|
|
return ERROR_FOPEN;
|
|
|
|
|
|
|
|
|
|
if (phfile == NULL)
|
|
|
|
|
return ERROR_CONF_NULL_HANDEPTR;
|
|
|
|
@ -1354,7 +1354,7 @@ int create_profile_cache(pgcchar *szProfileName, int *phfile)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( hCurCacher < 1)
|
|
|
|
|
if (hCurCacher < 1)
|
|
|
|
|
{
|
|
|
|
|
return ERROR_CONF_NOHANDLE;
|
|
|
|
|
}
|
|
|
|
@ -1443,7 +1443,7 @@ int get_pgcprofile_string(
|
|
|
|
|
pgcchar * lpReturnedString, // point to destination buffer
|
|
|
|
|
pgcu32 * pdwSize, // point to size of destination buffer
|
|
|
|
|
HPROFILE hProfile // point to initialization filename
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
SItemInCache *psTemp = NULL;
|
|
|
|
|
TChainHash<SItemInCache> *phash_table = NULL;
|
|
|
|
@ -1454,7 +1454,7 @@ int get_pgcprofile_string(
|
|
|
|
|
if ((hProfile < 1) || (hProfile >= MAX_PROFILEHANDLE_NUM))
|
|
|
|
|
return ERROR_CONF_INVALIDHANDLE;
|
|
|
|
|
|
|
|
|
|
if ((lpAppName == NULL) || ( lpKeyName == NULL))
|
|
|
|
|
if ((lpAppName == NULL) || (lpKeyName == NULL))
|
|
|
|
|
return ERROR_FAIL;
|
|
|
|
|
|
|
|
|
|
ReCreateCache(hProfile);
|
|
|
|
@ -1553,20 +1553,20 @@ int write_pgcprofile_string(
|
|
|
|
|
const pgcchar * lpString, // point to string to add
|
|
|
|
|
HPROFILE hProfile, // handle to Profile Cache
|
|
|
|
|
PGCBOOL bInsertItem
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
SItemInCache *psTemp = NULL, *psCacheEntry = NULL, *psSec = NULL;
|
|
|
|
|
TChainHash<SItemInCache> *phash_table = NULL;
|
|
|
|
|
pgc32 iBuffer = 0, iCurItem = 0, iSecPos = 0, i = 0, iWriteSuccess = 0;
|
|
|
|
|
PGCBOOL bSecExist = PGCFALSE;
|
|
|
|
|
PGCBOOL bTrunc = PGCFALSE ;/*写入的字符串是否被截断*/
|
|
|
|
|
PGCBOOL bTrunc = PGCFALSE;/*写入的字符串是否被截断*/
|
|
|
|
|
|
|
|
|
|
//输入句柄合法性检查
|
|
|
|
|
if ((hProfile < 1) || (hProfile >= MAX_PROFILEHANDLE_NUM))
|
|
|
|
|
return ERROR_CONF_INVALIDHANDLE;
|
|
|
|
|
|
|
|
|
|
//输入段名及项目名合法性检查
|
|
|
|
|
if ((lpAppName == NULL) || ( lpKeyName == NULL))
|
|
|
|
|
if ((lpAppName == NULL) || (lpKeyName == NULL))
|
|
|
|
|
return ERROR_FAIL;
|
|
|
|
|
|
|
|
|
|
//判断输入字符串是否超长
|
|
|
|
@ -1574,7 +1574,7 @@ int write_pgcprofile_string(
|
|
|
|
|
bTrunc = PGCTRUE;
|
|
|
|
|
if (strlen(lpKeyName) >= MAX_CHAR_LINE)
|
|
|
|
|
bTrunc = PGCTRUE;
|
|
|
|
|
if ( (lpString != NULL) && (strlen(lpString) >= MAX_CHAR_LINE))
|
|
|
|
|
if ((lpString != NULL) && (strlen(lpString) >= MAX_CHAR_LINE))
|
|
|
|
|
bTrunc = PGCTRUE;
|
|
|
|
|
if (bTrunc)
|
|
|
|
|
return ERROR_CONF_INPUTSTRING_TOOLARGE;
|
|
|
|
@ -1706,13 +1706,13 @@ int write_pgcprofile_string(
|
|
|
|
|
// 参数说明 : pgcu32 *pdwSize -- [in][out]写入缓冲区的按字节长度
|
|
|
|
|
// 参数说明 : pgcu32 *nSecNum --[out]将获取的段总数写入该地址
|
|
|
|
|
// 参数说明 : hProfile-- [in] handle to Profile Cache
|
|
|
|
|
int get_pgcprofile_secnames( pgcchar * lpszReturnBuffer, // address of return buffer
|
|
|
|
|
int get_pgcprofile_secnames(pgcchar * lpszReturnBuffer, // address of return buffer
|
|
|
|
|
pgcu32 * pdwSize, // size of return buffer
|
|
|
|
|
pgcu32 *nSecNum,
|
|
|
|
|
HPROFILE hProfile // handle to Profile Cache
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
pgc32 iCount = g_pHandleIndex[hProfile].CurUseItems , iSecNum = 0, i = -1;
|
|
|
|
|
pgc32 iCount = g_pHandleIndex[hProfile].CurUseItems, iSecNum = 0, i = -1;
|
|
|
|
|
pgcu32 dwWrite = 0, dwSize = 0, dwNeed = 0;
|
|
|
|
|
SItemInCache *psCacheEntry = g_pHandleIndex[hProfile].pCacheEntry;
|
|
|
|
|
pgcchar *szSec = NULL;
|
|
|
|
@ -1734,7 +1734,7 @@ int get_pgcprofile_secnames( pgcchar * lpszReturnBuffer, // address of return
|
|
|
|
|
szSec = psCacheEntry[i].szSecName;
|
|
|
|
|
dwNeed = dwNeed + (pgcu32)strlen(szSec) + 1;
|
|
|
|
|
iSecNum++;
|
|
|
|
|
while ((dwWrite < dwSize ) && (*szSec != '\0'))
|
|
|
|
|
while ((dwWrite < dwSize) && (*szSec != '\0'))
|
|
|
|
|
{
|
|
|
|
|
*lpszReturnBuffer = *szSec;
|
|
|
|
|
dwWrite++;
|
|
|
|
@ -1781,10 +1781,10 @@ int get_pgcprofile_secnames( pgcchar * lpszReturnBuffer, // address of return
|
|
|
|
|
// 参数说明 : lpAppName --[in] 段名
|
|
|
|
|
// 参数说明 : lpKeyName -- [in]项目名
|
|
|
|
|
// 参数说明 : HPROFILE hProfile --[in]配置文件的缓冲句柄
|
|
|
|
|
int del_pgcprofile_key( const pgcchar * lpAppName, // point to section name
|
|
|
|
|
int del_pgcprofile_key(const pgcchar * lpAppName, // point to section name
|
|
|
|
|
const pgcchar * lpKeyName, // point to key name
|
|
|
|
|
HPROFILE hProfile // point to initialization filename
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
SItemInCache *psTemp = NULL;
|
|
|
|
|
TChainHash<SItemInCache> *phash_table = NULL;
|
|
|
|
@ -1793,7 +1793,7 @@ int del_pgcprofile_key( const pgcchar * lpAppName, // point to section name
|
|
|
|
|
if ((hProfile < 1) || (hProfile >= MAX_PROFILEHANDLE_NUM))
|
|
|
|
|
return ERROR_CONF_INVALIDHANDLE;
|
|
|
|
|
|
|
|
|
|
if ((lpAppName == NULL) || ( lpKeyName == NULL))
|
|
|
|
|
if ((lpAppName == NULL) || (lpKeyName == NULL))
|
|
|
|
|
return ERROR_FAIL;
|
|
|
|
|
|
|
|
|
|
ReCreateCache(hProfile);
|
|
|
|
@ -1824,9 +1824,9 @@ int del_pgcprofile_key( const pgcchar * lpAppName, // point to section name
|
|
|
|
|
// 返回值说明 : int -- 成功则返回SUCCESS,失败则返回具体的执行失败的代码
|
|
|
|
|
// 参数说明 : lpAppName --[in] 段名
|
|
|
|
|
// 参数说明 : HPROFILE hProfile --[in]配置文件的缓冲句柄
|
|
|
|
|
int del_pgcprofile_sec( const pgcchar * lpAppName,
|
|
|
|
|
int del_pgcprofile_sec(const pgcchar * lpAppName,
|
|
|
|
|
HPROFILE hProfile
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
SItemInCache *psSec = NULL, *psCacheEntry = NULL;
|
|
|
|
|
TChainHash<SItemInCache> *phash_table = NULL;
|
|
|
|
|