更新格式

main
BlueMatthew 2 years ago
parent e77b423326
commit 21ab76b9ea

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

Loading…
Cancel
Save