spShareMemoryBase.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. #include "precompile.h"
  2. #include "spShareMemoryBase.h"
  3. #include <strstream>
  4. #include <mutex>
  5. #ifdef RVC_OS_WIN
  6. #include <Shlwapi.h>
  7. #else
  8. #include <sys/types.h>
  9. #include <sys/ipc.h>
  10. #include <sys/shm.h>
  11. #include <sys/user.h>
  12. #endif
  13. #include "sp_dir.h"
  14. #include <winpr/tchar.h>
  15. #include <winpr/synch.h>
  16. #include <winpr/file.h>
  17. #include <winpr/sysinfo.h>
  18. #include <winpr/library.h>
  19. #include "toolkit.h"
  20. #include "fileutil.h"
  21. #define MAX_ENTITY_NUM 20
  22. #define ENTITY_LOCK_NAME "Entity_Connect_Lock"
  23. #define LOG_LOCK_NAME "Entity_Log_Lock"
  24. std::mutex g_mutex_4_connctrl;
  25. std::mutex g_mutex_4_log;
  26. #ifdef RVC_OS_WIN
  27. #pragma data_seg("CONNECT_INFO")
  28. ENTITY_CONNECT_INFO m_connectInfo[MAX_ENTITY_NUM] = { ENTITY_CONNECT_INFO() };
  29. int m_priorLink = -1;
  30. int m_infoInit = 0;
  31. #pragma data_seg()
  32. #pragma comment(linker,"/section:CONNECT_INFO,rws")
  33. #else
  34. static toolkit_once_t once = TOOLKIT_ONCE_INIT;
  35. static char* shm_ptr = NULL;
  36. ENTITY_CONNECT_INFO* m_connectInfo = NULL;
  37. int* m_priorLinkPtr = NULL;
  38. int* m_infoInitPtr = NULL;
  39. #define SHM_SIZE (sizeof(ENTITY_CONNECT_INFO)*MAX_ENTITY_NUM+sizeof(int)+sizeof(int))
  40. #define SHM_MODE 0666
  41. static void share_memory_global_init(void)
  42. {
  43. int shm_id = -1;
  44. key_t key = ftok(".", 20);
  45. shm_id = shmget(key, SHM_SIZE, IPC_CREAT | SHM_MODE);
  46. if (shm_id == -1) {
  47. printf("shmget failed, errorno: %d\n", errno);
  48. }
  49. else {
  50. shm_ptr = (char*)shmat(shm_id, NULL, 0);
  51. if ((void*)shm_ptr == (void*)-1) {
  52. printf("shmat failed, errorno: %d\n", errno);
  53. }
  54. else {
  55. printf("shmat attached from %p\n", (void*)shm_ptr);
  56. m_connectInfo = (ENTITY_CONNECT_INFO*)shm_ptr;
  57. m_priorLinkPtr = (int*)(shm_ptr + sizeof(ENTITY_CONNECT_INFO) * MAX_ENTITY_NUM);
  58. m_infoInitPtr = (int*)(shm_ptr + sizeof(ENTITY_CONNECT_INFO) * MAX_ENTITY_NUM + sizeof(int));
  59. *m_priorLinkPtr = -1;
  60. *m_infoInitPtr = 0;
  61. }
  62. }
  63. }
  64. #endif
  65. CMyLogFile m_log;
  66. BOOL connectControl::Lock(DWORD dwTime)
  67. {
  68. #ifdef RVC_OS_WIN
  69. if (!m_hLock) {
  70. std::string strLockName = ENTITY_LOCK_NAME;
  71. m_hLock = ::CreateMutex(NULL, FALSE, strLockName.c_str());
  72. if (!m_hLock)
  73. return FALSE;
  74. }
  75. // whose priority is higher, when occupies this lock.
  76. DWORD dwRet = ::WaitForSingleObject(m_hLock, dwTime);
  77. return (dwRet == WAIT_OBJECT_0 || dwRet == WAIT_ABANDONED);
  78. #else
  79. g_mutex_4_connctrl.lock();
  80. #endif // RVC_OS_WIN
  81. }
  82. void connectControl::Unlock()
  83. {
  84. #ifdef RVC_OS_WIN
  85. if (m_hLock)
  86. ::ReleaseMutex(m_hLock);
  87. #else
  88. g_mutex_4_connctrl.unlock();
  89. #endif // RVC_OS_WIN
  90. }
  91. connectControl::connectControl()
  92. :m_hLock(NULL)
  93. {
  94. #ifdef RVC_OS_WIN
  95. if (!m_infoInit) {
  96. for (int i = 0; i < MAX_ENTITY_NUM; i++)
  97. m_connectInfo[i].clear();
  98. m_infoInit = 1;
  99. }
  100. #else
  101. if (m_infoInitPtr != NULL && *m_infoInitPtr == 0) {
  102. for (int i = 0; i < MAX_ENTITY_NUM; i++)
  103. m_connectInfo[i].clear();
  104. *m_infoInitPtr = 1;
  105. }
  106. #endif // RVC_OS_WIN
  107. }
  108. connectControl::~connectControl()
  109. {
  110. #ifdef RVC_OS_WIN
  111. if (m_hLock != NULL)
  112. CloseHandle(m_hLock);
  113. #endif // RVC_OS_WIN
  114. }
  115. connectControl* connectControl::getInstance()
  116. {
  117. static connectControl* Instance = NULL;
  118. #ifdef RVC_OS_LINUX
  119. toolkit_once(&once, share_memory_global_init);
  120. #endif
  121. if (NULL == Instance)
  122. Instance = new connectControl();
  123. return Instance;
  124. }
  125. int connectControl::getEntityNum()
  126. {
  127. int entityNum = 0;
  128. #ifdef RVC_OS_LINUX
  129. if (m_connectInfo == NULL)
  130. return 0;
  131. #endif
  132. for (int i = 0; i < MAX_ENTITY_NUM; i++)
  133. {
  134. if (0 != strlen(m_connectInfo[i].m_EntityName))
  135. entityNum++;
  136. else
  137. break;
  138. }
  139. return entityNum;
  140. }
  141. int connectControl::getPriorLink(int lastLink)
  142. {
  143. static int diffTimes = 0;
  144. #ifdef RVC_OS_LINUX
  145. if (m_priorLinkPtr != NULL) {
  146. const int m_priorLink = *m_priorLinkPtr;
  147. #endif
  148. if (-1 == lastLink)
  149. return m_priorLink;
  150. else if (lastLink != m_priorLink) {
  151. int tempLink = (0 == ++diffTimes % 5) ? m_priorLink : lastLink;
  152. m_log.LOGERROR("Try to link to %d", tempLink);
  153. return tempLink;
  154. }
  155. #ifdef RVC_OS_LINUX
  156. }
  157. #endif
  158. return lastLink;
  159. }
  160. void connectControl::setLastLink(int link)
  161. {
  162. #ifdef RVC_OS_WIN
  163. if (-1 == link || -1 == m_priorLink) {
  164. m_priorLink = link;
  165. return;
  166. }
  167. else if (link != m_priorLink) {
  168. int entityNum = getEntityNum();
  169. int diffNum = 0;
  170. for (int i = 0; i < entityNum; i++) {
  171. if (m_priorLink != m_connectInfo[i].m_lastLink)
  172. diffNum++;
  173. }
  174. if (diffNum > (entityNum / 2))
  175. m_priorLink = link;//change prior Link when half of the connection links to another connection
  176. }
  177. #else
  178. if (m_priorLinkPtr != NULL) {
  179. if (-1 == link || -1 == *m_priorLinkPtr) {
  180. *m_priorLinkPtr = link;
  181. return;
  182. }
  183. else if (link != *m_priorLinkPtr) {
  184. int entityNum = getEntityNum();
  185. int diffNum = 0;
  186. for (int i = 0; i < entityNum; i++) {
  187. if (*m_priorLinkPtr != m_connectInfo[i].m_lastLink)
  188. diffNum++;
  189. }
  190. if (diffNum > (entityNum / 2))
  191. *m_priorLinkPtr = link;//change prior Link when half of the connection links to another connection
  192. }
  193. }
  194. #endif
  195. }
  196. bool connectControl::getSuccessDual(ENTITY_CONNECT_INFO *entityInfo)
  197. {
  198. if (NULL == entityInfo)
  199. return false;
  200. #ifdef RVC_OS_LINUX
  201. if (m_connectInfo == NULL)
  202. return false;
  203. #endif
  204. int entityNum = getEntityNum();
  205. for (int i = 0; i < entityNum; i++)
  206. {
  207. if (1 == m_connectInfo[i].m_DualActive && -1 != m_connectInfo[i].m_currentLink)
  208. {
  209. memcpy(entityInfo, &(m_connectInfo[i]), sizeof(ENTITY_CONNECT_INFO));
  210. return true;
  211. }
  212. }
  213. return false;
  214. }
  215. bool connectControl::getEntityInfo(const char *entityName, ENTITY_CONNECT_INFO *entityInfo)
  216. {
  217. #ifdef RVC_OS_LINUX
  218. if (m_connectInfo == NULL)
  219. return false;
  220. #endif
  221. if (NULL == entityName || NULL == entityInfo)
  222. return false;
  223. int entityNum = getEntityNum();
  224. for (int i = 0; i < entityNum; i++)
  225. {
  226. if (!strcmp(entityName, m_connectInfo[i].m_EntityName))
  227. {
  228. memcpy(entityInfo, &(m_connectInfo[i]), sizeof(ENTITY_CONNECT_INFO));
  229. return true;
  230. }
  231. }
  232. return false;
  233. }
  234. bool connectControl::setEntityInfo(const ENTITY_CONNECT_INFO *entityInfo)
  235. {
  236. bool result = false;
  237. if (NULL == entityInfo)
  238. return result;
  239. #ifdef RVC_OS_LINUX
  240. std::lock_guard<std::mutex> guard(g_mutex_4_connctrl);
  241. do
  242. {
  243. if (m_connectInfo == NULL)
  244. break;
  245. int entityNum = getEntityNum();
  246. for (int i = 0; i < entityNum; i++) {
  247. if (!strcmp(entityInfo->m_EntityName, m_connectInfo[i].m_EntityName)) {
  248. m_connectInfo[i].setParam(entityInfo->m_EntityName
  249. , entityInfo->m_ServerIP, entityInfo->m_ServerPort,
  250. entityInfo->m_Server_BackupIP, entityInfo->m_Server_BackupPort,
  251. entityInfo->m_DualActive, entityInfo->m_currentLink);
  252. result = true;
  253. break;
  254. }
  255. }
  256. if (MAX_ENTITY_NUM == entityNum) {
  257. break;
  258. }
  259. m_connectInfo[entityNum].setParam(entityInfo->m_EntityName
  260. , entityInfo->m_ServerIP, entityInfo->m_ServerPort
  261. , entityInfo->m_Server_BackupIP, entityInfo->m_Server_BackupPort
  262. , entityInfo->m_DualActive, entityInfo->m_currentLink);
  263. result = true;
  264. } while (false);
  265. #else
  266. Lock(INFINITE);
  267. __try
  268. {
  269. int entityNum = getEntityNum();
  270. for (int i = 0; i < entityNum; i++)
  271. {
  272. if (!strcmp(entityInfo->m_EntityName, m_connectInfo[i].m_EntityName))
  273. {
  274. m_connectInfo[i].setParam(entityInfo->m_EntityName
  275. , entityInfo->m_ServerIP, entityInfo->m_ServerPort,
  276. entityInfo->m_Server_BackupIP, entityInfo->m_Server_BackupPort,
  277. entityInfo->m_DualActive, entityInfo->m_currentLink);
  278. return true;
  279. }
  280. }
  281. if (MAX_ENTITY_NUM == entityNum)
  282. return false;
  283. m_connectInfo[entityNum].setParam(entityInfo->m_EntityName
  284. , entityInfo->m_ServerIP, entityInfo->m_ServerPort
  285. ,entityInfo->m_Server_BackupIP, entityInfo->m_Server_BackupPort
  286. , entityInfo->m_DualActive, entityInfo->m_currentLink);
  287. return true;
  288. }
  289. __finally
  290. {
  291. Unlock();
  292. }
  293. #endif
  294. return result;
  295. }
  296. CMyLogFile::CMyLogFile()
  297. : m_cOutFile(NULL), m_hLock(nullptr)
  298. {
  299. }
  300. CMyLogFile::~CMyLogFile()
  301. {
  302. }
  303. void CMyLogFile::Output(const TCHAR *data)
  304. {
  305. if (NULL != m_cOutFile)
  306. m_cOutFile->write(data, strlen(data));
  307. }
  308. bool checkDirExist(char *filePath)
  309. {
  310. if (!ExistsDirA(filePath)) {
  311. return CreateDirA(filePath, TRUE);
  312. }
  313. return true;
  314. //bool b = CreateDirectoryA(filePath, NULL);
  315. //if (b || (GetLastError() == ERROR_ALREADY_EXISTS))
  316. // return true;
  317. //return false;
  318. }
  319. void CMyLogFile::Init()
  320. {
  321. if (!m_cOutFile)
  322. {
  323. char m_dirPath[_MAX_PATH] = "", drivePath[_MAX_DRIVE] = "";
  324. sp_dir_get_cur_drive(drivePath);
  325. sprintf_s(m_dirPath, _MAX_PATH, "%s" SPLIT_SLASH_STR "rvc" SPLIT_SLASH_STR "dbg" SPLIT_SLASH_STR "DualActive", drivePath);
  326. if (!checkDirExist(m_dirPath))
  327. return;
  328. SYSTEMTIME cur;
  329. GetSystemTime(&cur);
  330. sprintf(m_dirPath, "%s" SPLIT_SLASH_STR "%4d%.2d%.2d.log", m_dirPath, cur.wYear, cur.wMonth,
  331. cur.wDay);
  332. m_cOutFile = new ofstream(m_dirPath, ios_base::app);
  333. if (m_cOutFile->is_open())
  334. return;
  335. delete m_cOutFile;
  336. m_cOutFile = NULL;
  337. }
  338. }
  339. void CMyLogFile::Release()
  340. {
  341. if (NULL != m_cOutFile)
  342. {
  343. m_cOutFile->close();
  344. delete m_cOutFile;
  345. m_cOutFile = NULL;
  346. }
  347. }
  348. BOOL CMyLogFile::Lock(DWORD dwTime)
  349. {
  350. #ifdef RVC_OS_WIN
  351. if (!m_hLock) {
  352. std::string strLockName = LOG_LOCK_NAME;
  353. m_hLock = ::CreateMutex(NULL, FALSE, strLockName.c_str());
  354. if (!m_hLock)
  355. return FALSE;
  356. }
  357. DWORD dwRet = ::WaitForSingleObject(m_hLock, dwTime);
  358. return (dwRet == WAIT_OBJECT_0 || dwRet == WAIT_ABANDONED);
  359. #else
  360. g_mutex_4_log.lock();
  361. #endif // RVC_OS_WIN
  362. }
  363. void CMyLogFile::Unlock()
  364. {
  365. #ifdef RVC_OS_WIN
  366. if (m_hLock)
  367. ::ReleaseMutex(m_hLock);
  368. #else
  369. g_mutex_4_log.unlock();
  370. #endif
  371. }
  372. bool CMyLogFile::GetRootDir(char *dirPath)
  373. {
  374. char pathbuf[1024] = "";
  375. int pathlen = ::GetModuleFileNameA(NULL, pathbuf, 1024);
  376. int times = 0;
  377. while (pathlen > 0)
  378. {
  379. if (pathbuf[pathlen--] == SPLIT_SLASH)
  380. times++;
  381. if (2 == times)
  382. break;
  383. }
  384. pathbuf[++pathlen] = '\0';
  385. memcpy(dirPath, pathbuf, (pathlen + 1 > 1024 ? 1024 : pathlen + 1));
  386. return pathlen;
  387. }
  388. void CMyLogFile::PrintCurTime()
  389. {
  390. TCHAR dateString[52];
  391. SYSTEMTIME cur;
  392. GetLocalTime(&cur);
  393. sprintf(dateString, "[%4d-%.2d-%.2d,%.2d:%.2d:%.2d] ", cur.wYear, cur.wMonth,
  394. cur.wDay, cur.wHour, cur.wMinute, cur.wSecond);
  395. Output(dateString);
  396. }
  397. CMyLogFile& CMyLogFile::operator <<(unsigned int unVal)
  398. {
  399. strstream tmp;
  400. tmp << unVal;
  401. tmp << '\0';
  402. TCHAR* output = tmp.str();
  403. Output(output);
  404. tmp.freeze(false);
  405. return *this;
  406. }
  407. CMyLogFile& CMyLogFile::operator <<(long lVal)
  408. {
  409. strstream tmp;
  410. tmp << lVal;
  411. tmp << '\0';
  412. TCHAR* output = tmp.str();
  413. Output(output);
  414. tmp.freeze(false);
  415. return *this;
  416. }
  417. CMyLogFile& CMyLogFile::operator <<(const TCHAR* str)
  418. {
  419. Output(str);
  420. return *this;
  421. }
  422. CMyLogFile& CMyLogFile::operator <<(TCHAR tch)
  423. {
  424. TCHAR szCh[2];
  425. szCh[0] = tch;
  426. szCh[1] = '\0';
  427. Output(szCh);
  428. return *this;
  429. }
  430. CMyLogFile& CMyLogFile::operator <<(int nVal)
  431. {
  432. strstream tmp;
  433. tmp << nVal;
  434. tmp << '\0';
  435. TCHAR* output = tmp.str();
  436. Output(output);
  437. tmp.freeze(false);
  438. return *this;
  439. }
  440. CMyLogFile& CMyLogFile::operator <<(unsigned long ulVal)
  441. {
  442. strstream tmp;
  443. tmp << ulVal;
  444. tmp << '\0';
  445. TCHAR* output = tmp.str();
  446. Output(output);
  447. tmp.freeze(false);
  448. return *this;
  449. }
  450. CMyLogFile& CMyLogFile::operator <<(double dVal)
  451. {
  452. strstream tmp;
  453. tmp << dVal;
  454. tmp << '\0';
  455. TCHAR* output = tmp.str();
  456. Output(output);
  457. tmp.freeze(false);
  458. return *this;
  459. }
  460. #ifdef _WIN32
  461. CMyLogFile& CMyLogFile::operator <<(u__int64_t unllVal)
  462. {
  463. strstream tmp;
  464. tmp << unllVal;
  465. tmp << '\0';
  466. TCHAR* output = tmp.str();
  467. Output(output);
  468. tmp.freeze(false);
  469. return *this;
  470. }
  471. #endif
  472. void CMyLogFile::LOGERROR(TCHAR* formatString, ...)
  473. {
  474. #ifdef RVC_OS_WIN
  475. Lock(INFINITE);
  476. Init();
  477. __try {
  478. if (NULL != m_cOutFile && !m_cOutFile->is_open())
  479. return;
  480. /*
  481. ** Insert the current time..
  482. */
  483. PrintCurTime();
  484. /*
  485. ** Parse the format string and write to the file
  486. */
  487. if (formatString == NULL) {
  488. /*
  489. ** No point in continuiing
  490. */
  491. return;
  492. }
  493. va_list argList;
  494. /*
  495. ** Set va_list to the beginning of optional arguments
  496. */
  497. va_start(argList, formatString);
  498. TCHAR* ptr = formatString;
  499. while (*ptr != '\0') {
  500. TCHAR* str = NULL;
  501. int nInteger = 0;
  502. unsigned int unInt = 0;
  503. long lLong = 0;
  504. unsigned long ulLong = 0;
  505. double dDoub = 0;
  506. u__int64_t ullLong = 0;
  507. if (*ptr == '%') {
  508. switch (*(ptr + 1)) {
  509. case 's':
  510. str = va_arg(argList, TCHAR*);
  511. if (NULL == str)
  512. break;
  513. *this << str;
  514. ptr++;
  515. break;
  516. case 'd':
  517. nInteger = va_arg(argList, int);
  518. *this << nInteger;
  519. ptr++;
  520. break;
  521. case 'u':
  522. unInt = va_arg(argList, unsigned int);
  523. *this << unInt;
  524. ptr++;
  525. break;
  526. case 'l':
  527. ptr++;
  528. if (*(ptr + 1) == 'd') {
  529. lLong = va_arg(argList, long);
  530. *this << lLong;
  531. ptr++;
  532. }
  533. else if (*(ptr + 1) == 'u') {
  534. ulLong = va_arg(argList, unsigned long);
  535. *this << ulLong;
  536. ptr++;
  537. }
  538. else if (*(ptr + 1) == 'q') {
  539. ullLong = va_arg(argList, u__int64_t);
  540. *this << ullLong;
  541. ptr++;
  542. }
  543. break;
  544. case 'f':
  545. dDoub = va_arg(argList, double);
  546. *this << dDoub;
  547. ptr++;
  548. break;
  549. default:
  550. *this << *ptr;
  551. }
  552. } // if(*ptr == '%')
  553. else {
  554. *this << *ptr;
  555. }
  556. /*
  557. ** Increment pointer..
  558. */
  559. ptr++;
  560. }
  561. va_end(argList); //va_end missing.
  562. *this << '\n';
  563. }
  564. __finally {
  565. Release();
  566. Unlock();
  567. }
  568. #else
  569. std::lock_guard<std::mutex> guard(g_mutex_4_log);
  570. Init();
  571. do
  572. {
  573. if (NULL != m_cOutFile && !m_cOutFile->is_open())
  574. break;
  575. PrintCurTime();
  576. if (formatString == NULL) {
  577. break;
  578. }
  579. va_list argList;
  580. va_start(argList, formatString);
  581. TCHAR* ptr = formatString;
  582. while (*ptr != '\0') {
  583. TCHAR* str = NULL;
  584. int nInteger = 0;
  585. unsigned int unInt = 0;
  586. long lLong = 0;
  587. unsigned long ulLong = 0;
  588. double dDoub = 0;
  589. u__int64_t ullLong = 0;
  590. if (*ptr == '%') {
  591. switch (*(ptr + 1)) {
  592. case 's':
  593. str = va_arg(argList, TCHAR*);
  594. if (NULL == str)
  595. break;
  596. *this << str;
  597. ptr++;
  598. break;
  599. case 'd':
  600. nInteger = va_arg(argList, int);
  601. *this << nInteger;
  602. ptr++;
  603. break;
  604. case 'u':
  605. unInt = va_arg(argList, unsigned int);
  606. *this << unInt;
  607. ptr++;
  608. break;
  609. case 'l':
  610. ptr++;
  611. if (*(ptr + 1) == 'd') {
  612. lLong = va_arg(argList, long);
  613. *this << lLong;
  614. ptr++;
  615. }
  616. else if (*(ptr + 1) == 'u') {
  617. ulLong = va_arg(argList, unsigned long);
  618. *this << ulLong;
  619. ptr++;
  620. }
  621. else if (*(ptr + 1) == 'q') {
  622. ullLong = va_arg(argList, u__int64_t);
  623. *this << ullLong;
  624. ptr++;
  625. }
  626. break;
  627. case 'f':
  628. dDoub = va_arg(argList, double);
  629. *this << dDoub;
  630. ptr++;
  631. break;
  632. default:
  633. *this << *ptr;
  634. }
  635. } // if(*ptr == '%')
  636. else {
  637. *this << *ptr;
  638. }
  639. /*
  640. ** Increment pointer..
  641. */
  642. ptr++;
  643. }
  644. va_end(argList); //va_end missing.
  645. *this << '\n';
  646. } while (false);
  647. Release();
  648. #endif // RVC_OS_WIN
  649. }