📄 rcstrtbl.c
字号:
/***************************************************************************** ------------ 子系统名称: 界面资源管理器* RCSTRTBL.H* ------------ 模块名称 : 字符串表资源****************************************************************************/#include "rc.h"#include "strtbl.h"typedef struct tagSTRTBLSTRING{ short nID; char *pBuf; void *pNext;} STRTBLSTRING;#define PSTRTBLSTRING STRTBLSTRING *PSTRTBLSTRING pStrTblHead = (PSTRTBLSTRING)NULL;PSTRTBLSTRING pStrTblTail = (PSTRTBLSTRING)NULL;short AppendString ( PSTRTBL pStrTbl, short nID, char *pBuf ){ PSTRTBLSTRING pStrTblTemp; if ( ( pStrTblTemp = (PSTRTBLSTRING)malloc ( sizeof ( STRTBLSTRING ) ) ) == (PSTRTBLSTRING)NULL ) return ( ERR_NOMEMORY ); pStrTblTemp->nID = nID; if ( ( pStrTblTemp->pBuf = (char*)malloc ( strlen ( pBuf ) + 1 ) ) == (char*)NULL ) return ( ERR_NOMEMORY ); strcpy ( pStrTblTemp->pBuf, pBuf ); pStrTblTemp->pNext = NULL; if ( pStrTbl->nCount == 0 ) pStrTblHead = pStrTblTail = pStrTblTemp; else pStrTblTail = pStrTblTail->pNext = (void*)pStrTblTemp; pStrTbl->nCount ++; pStrTbl->nBufSize += strlen ( pBuf ); return ( OK );}/***************************************************************************** 函数原型: CompileStrTbl ( char **ppRESBuf, char *pWord, void **ppStrTbl )** 功 能: 编译窗口资源** 编程人员: Zhu haibin** 编码时间: 1994/10/05** 修改时间:** 入口参数: char **ppRESBuf 资源文本缓冲区* char *pWord 单词缓冲区* void ppwWindow 字符串表资源指针** 出口参数: =0 编译成功* <0 编译失败** 实现算法:** 上层调用: CompileResource** 下层调用: GetWord* WordToInt* CheckKeyWord****************************************************************************/short CompileStrTbl ( char **ppRESBuf, char *pWord, void **ppStrTbl ){ short nStrTblID; short nID; unsigned short nOffset; short i; char *pTemp; PSTRTBLSTRING pStrTblTemp; /* 取字符串表资源标识号 */ if ( ( GetWord ( ppRESBuf, pWord ) < OK ) || ( WordToInt ( &nStrTblID, pWord ) < OK ) ) return ( ERR_RES_SYNTAX ); /* 取关键字 BEGIN */ if ( ( GetWord ( ppRESBuf, pWord ) < OK ) || ( CheckKeyWord ( pWord ) != ID_BEGIN ) ) return ( ERR_RES_SYNTAX ); if ( NewStringTable ( (PSTRTBL*)ppStrTbl ) < OK ) return ( ERR_NOMEMORY ); while ( 1 ) { if ( GetWord ( ppRESBuf, pWord ) < OK ) return ( ERR_RES_SYNTAX ); if ( CheckKeyWord ( pWord ) == ID_END ) break; if ( WordToInt ( &nID, pWord ) < OK ) return ( ERR_RES_SYNTAX ); if ( GetWord ( ppRESBuf, pWord ) < OK ) return ( ERR_RES_SYNTAX ); if ( AppendString ( *ppStrTbl, nID, pWord ) < OK ) return ( ERR_NOMEMORY ); } if ( ((PSTRTBL)(*ppStrTbl))->nCount > 0 ) { if ( ( ((PSTRTBL)(*ppStrTbl))->pStrTblIndex = (PSTRTBLINDEX)malloc ( ((PSTRTBL)(*ppStrTbl))->nCount * sizeof ( STRTBLINDEX ) ) ) == (PSTRTBLINDEX)NULL ) return ( ERR_NOMEMORY ); if ( ( ((PSTRTBL)(*ppStrTbl))->pBuf = (char*)malloc ( ((PSTRTBL)(*ppStrTbl))->nBufSize ) ) == (char*)NULL ) return ( ERR_NOMEMORY ); nOffset = 0; pTemp = ((PSTRTBL)(*ppStrTbl))->pBuf; pStrTblTemp = pStrTblHead; for ( i = 0; i < ((PSTRTBL)(*ppStrTbl))->nCount; i++ ) { ((PSTRTBL)(*ppStrTbl))->pStrTblIndex[i].nID = pStrTblTemp->nID; ((PSTRTBL)(*ppStrTbl))->pStrTblIndex[i].nOffset = nOffset; ((PSTRTBL)(*ppStrTbl))->pStrTblIndex[i].nLen = strlen ( pStrTblTemp->pBuf ); memcpy ( pTemp, pStrTblTemp->pBuf, ((PSTRTBL)(*ppStrTbl))->pStrTblIndex[i].nLen ); pTemp += ((PSTRTBL)(*ppStrTbl))->pStrTblIndex[i].nLen; nOffset += ((PSTRTBL)(*ppStrTbl))->pStrTblIndex[i].nLen; pStrTblTemp = pStrTblTemp->pNext; free ( pStrTblHead->pBuf ); free ( pStrTblHead ); pStrTblHead = pStrTblTemp; } } return ( nStrTblID );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -