void IN_NetgameDrawer(void) { int i; if(earlyexit == true) for (i = 0; i < MAXPLAYERS; i++) { killvalue[i] = pstats[i].killpercent; itemvalue[i] = pstats[i].itempercent; secretvalue[i] = pstats[i].secretpercent; fragvalue[i] = players[i].frags; } if (statsdrawn == false) { if (netgame == gt_deathmatch) { print(30 , FVALY, "Your Frags"); print(54 , FVALY + 40, "His Frags"); IN_DrawValue(FVALX, FVALY, fragvalue[consoleplayer]); IN_DrawValue(FVALX, FVALY + 40, fragvalue[!consoleplayer]); } else { print (28, 50, "Player"); print (KVALX - 18, 50, "1"); print (KVALX + 66, 50, "2"); DrawJagobj(i_kills, 57, 80); DrawJagobj(i_items, 51, 110); DrawJagobj(i_secret, 13, 140); } } if (netgame == gt_deathmatch) { EraseBlock(30 + (mystrlen("Your Frags") * 15), FVALY, 80, 80); IN_DrawValue(FVALX, FVALY, fragvalue[consoleplayer]); IN_DrawValue(FVALX, FVALY + 40, fragvalue[!consoleplayer]); } else { EraseBlock(57 + (mystrlen("Kills") * 15), KVALY, 100, 100); IN_DrawValue(KVALX, KVALY, killvalue[consoleplayer]); IN_DrawValue(KVALX + 80, KVALY, killvalue[!consoleplayer]); IN_DrawValue(IVALX, IVALY, itemvalue[consoleplayer]); IN_DrawValue(IVALX + 80, IVALY, itemvalue[!consoleplayer]); IN_DrawValue(SVALX, SVALY, secretvalue[consoleplayer]); IN_DrawValue(SVALX + 80, SVALY, secretvalue[!consoleplayer]); DrawJagobj(i_percent, KVALX, KVALY); DrawJagobj(i_percent, KVALX + 80, KVALY); DrawJagobj(i_percent, IVALX, IVALY); DrawJagobj(i_percent, IVALX + 80, IVALY); DrawJagobj(i_percent, SVALX, SVALY); DrawJagobj(i_percent, SVALX + 80, SVALY); } }
void IN_SingleDrawer(void) { int length; if(earlyexit == true) { killvalue[0] = pstats[0].killpercent; itemvalue[0] = pstats[0].itempercent; secretvalue[0] = pstats[0].secretpercent; } EraseBlock(71 + (mystrlen("Secrets") * 15), 70, 55, 80); if (statsdrawn == false) { length = mystrlen(mapnames[gamemap - 1]); print( (320 - (length * 14)) >> 1 , 10, mapnames[gamemap - 1]); length = mystrlen("Finished"); print( (320 - (length * 14)) >> 1, 34, "Finished"); if (nextmap != 23) { length = mystrlen("Entering"); print( (320 - (length * 14)) >> 1, 162, "Entering"); length = mystrlen(mapnames[nextmap - 1]); print( (320 - (length*14)) >> 1, 182, mapnames[nextmap - 1]); }
ERROR_CODE EraseFlash(unsigned long ulAddr) { ERROR_CODE ErrorCode = NO_ERR; // tells us if there was an error erasing flash int nBlock = 0; // index for each block to erase #ifdef LOCK_MAC_ADDR_SECTOR // do an erase block here because the MAC address is contained // at address 0x201F8000(0x203F0000 in a memory window) in FLASH for( nBlock = 0; ( nBlock < (gNumSectors - 1) ) && ( ErrorCode == NO_ERR ); nBlock++ ) ErrorCode = EraseBlock( nBlock, ulAddr ); #else // erase contents of Flash WriteFlash( ulAddr + 0x0AAA, 0xaa ); WriteFlash( ulAddr + 0x0554, 0x55 ); WriteFlash( ulAddr + 0x0AAA, 0x80 ); WriteFlash( ulAddr + 0x0AAA, 0xaa ); WriteFlash( ulAddr + 0x0554, 0x55 ); WriteFlash( ulAddr + 0x0AAA, 0x10 ); // poll until the command has completed ErrorCode = PollToggleBit(ulAddr + 0x0000); #endif // erase should be complete return ErrorCode; }
// // Draw control value // void O_DrawControl(void) { EraseBlock(menuitem[controls].x + 40, menuitem[controls].y + 20, 90, 80, NULL); print(menuitem[controls].x + 40, menuitem[controls].y + 20, buttona[controltype]); print(menuitem[controls].x + 40, menuitem[controls].y + 40, buttonb[controltype]); print(menuitem[controls].x + 40, menuitem[controls].y + 60, buttonc[controltype]); O_SetButtonsFromControltype(); }
bool Erase(u32 *addr, u32 len){ u32 *ptr, *end=addr+len/4; // erase block loop. for (ptr=addr; ptr<end; ptr+=FLASH_BLOCK_SIZE/4){ ClearLine(); printf("\tCurrent block address\t: 0x%08lx", (long)ptr); // erase block. if (!EraseBlock(ptr)){ return false; } } printf("\n"); return true; }
void PID_NandSave() { int i; uint8 data[2048]; *(uint8*)(data)=PID_ListLength; for(i=0;i<PID_ListLength;i++) { *(fp64*)(data+24*i+8)=Pid_List[i].PROP; *(fp64*)(data+24*i+16)=Pid_List[i].Ti; *(fp64*)(data+24*i+24)=Pid_List[i].Td; } EraseBlock(PID_NANDPAGE); if(WritePage(PID_NANDPAGE,data)!=1) { Nand_Error=PID_NANDPAGE; } }
void O_Drawer(void) { int i; int offset; // Erase old and Draw new cursor frame EraseBlock(56, 40, o_cursor1->width, 200, NULL); if(cursorframe) DrawJagobj(o_cursor1, 60, menuitem[cursorpos].y - 2, NULL); else DrawJagobj(o_cursor2, 60, menuitem[cursorpos].y - 2, NULL); // Draw menu print(104, 10, "Options"); for(i = 0; i < NUMMENUITEMS; i++) { print(menuitem[i].x, menuitem[i].y, menuitem[i].name); if(menuitem[i].hasslider == true) { DrawJagobj(o_slidertrack , menuitem[i].x + 2, menuitem[i].y + 20, NULL); offset = (slider[i].curval * SLIDEWIDTH) / slider[i].maxval; DrawJagobj(o_slider, menuitem[i].x + 7 + offset, menuitem[i].y + 20, NULL); } } // Draw control info print(menuitem[controls].x + 10, menuitem[controls].y + 20, "A"); print(menuitem[controls].x + 10, menuitem[controls].y + 40, "B"); print(menuitem[controls].x + 10, menuitem[controls].y + 60, "C"); O_DrawControl(); UpdateBuffer(); }
u32 adi_pdd_Control( ADI_DEV_PDD_HANDLE PDDHandle, u32 Command, void *pArg) { ERROR_CODE ErrorCode = NO_ERR; COMMAND_STRUCT *pCmdStruct = (COMMAND_STRUCT *)pArg; // switch on the command switch ( Command ) { // erase all case CNTRL_ERASE_ALL: ErrorCode = EraseFlash(pCmdStruct->SEraseAll.ulFlashStartAddr); break; // erase sector case CNTRL_ERASE_SECT: ErrorCode = EraseBlock( pCmdStruct->SEraseSect.nSectorNum, pCmdStruct->SEraseSect.ulFlashStartAddr ); break; // get manufacturer and device codes case CNTRL_GET_CODES: ErrorCode = GetCodes((int *)pCmdStruct->SGetCodes.pManCode, (int *)pCmdStruct->SGetCodes.pDevCode, (unsigned long)pCmdStruct->SGetCodes.ulFlashStartAddr); break; case CNTRL_GET_DESC: //Filling the contents with data pCmdStruct->SGetDesc.pDesc = pFlashDesc; pCmdStruct->SGetDesc.pFlashCompany = pDeviceCompany; break; // get sector number based on address case CNTRL_GET_SECTNUM: ErrorCode = GetSectorNumber( pCmdStruct->SGetSectNum.ulOffset, (int *)pCmdStruct->SGetSectNum.pSectorNum ); break; // get sector number start and end offset case CNTRL_GET_SECSTARTEND: ErrorCode = GetSectorStartEnd( pCmdStruct->SSectStartEnd.pStartOffset, pCmdStruct->SSectStartEnd.pEndOffset, pCmdStruct->SSectStartEnd.nSectorNum ); break; // get the number of sectors case CNTRL_GETNUM_SECTORS: pCmdStruct->SGetNumSectors.pnNumSectors[0] = gNumSectors; break; // reset case CNTRL_RESET: ErrorCode = ResetFlash(pCmdStruct->SReset.ulFlashStartAddr); break; // turn on dataflow (command required of all device drivers) case ADI_DEV_CMD_SET_DATAFLOW: ErrorCode = NO_ERR; break; case ADI_DEV_CMD_SET_DATAFLOW_METHOD: // Do nothing & simply return back for these commands break; // get peripheral DMA support (command required of all device drivers) case ADI_DEV_CMD_GET_PERIPHERAL_DMA_SUPPORT: (*(u32 *)pArg) = FALSE; // no, this device is not supported by peripheral DMA break; // no command or unknown command do nothing default: // set our error ErrorCode = UNKNOWN_COMMAND; break; } // return return(ErrorCode); }
BOOL SF_BS_Driver::Write(void *context, ByteAddress Address, UINT32 NumBytes, BYTE *pSectorBuff, BOOL ReadModifyWrite ) { NATIVE_PROFILE_PAL_FLASH(); BYTE * pData; BYTE * pBuf = NULL; MEMORY_MAPPED_SERIAL_BLOCK_CONFIG* config = (MEMORY_MAPPED_SERIAL_BLOCK_CONFIG*)context; const BlockDeviceInfo * deviceInfo = config->BlockConfig.BlockDeviceInformation; UINT32 region, range; if(ReadModifyWrite) { BOOL fRet = TRUE; if(!deviceInfo->FindRegionFromAddress(Address, region, range)) return FALSE; UINT32 bytesPerBlock = deviceInfo->Regions[region].BytesPerBlock; UINT32 regionEnd = deviceInfo->Regions[region].Start + deviceInfo->Regions[region].Size(); UINT32 offset = Address % bytesPerBlock; ByteAddress addr = Address; ByteAddress addrEnd = Address + NumBytes; UINT32 index = 0; pBuf = (BYTE*)private_malloc(bytesPerBlock); if(pBuf == NULL) { return FALSE; } while(fRet && addr < addrEnd) { ByteAddress sectAddr = (addr - offset); if(offset == 0 && NumBytes >= bytesPerBlock) { pData = &pSectorBuff[index]; } else { int bytes = __min(bytesPerBlock - offset, NumBytes); //memcpy( &pBuf[0] , (void*)sectAddr , bytesPerBlock ); Read(context, sectAddr, bytesPerBlock, (BYTE *)&pBuf[0]); memcpy( &pBuf[offset], &pSectorBuff[index], bytes ); pData = pBuf; } if(!EraseBlock( context, sectAddr )) { fRet = FALSE; break; } fRet = WriteX(context, sectAddr, bytesPerBlock, pData, ReadModifyWrite, TRUE); NumBytes -= bytesPerBlock - offset; addr += bytesPerBlock - offset; index += bytesPerBlock - offset; offset = 0; if(NumBytes > 0 && addr >= regionEnd) { region++; if(region >= deviceInfo->NumRegions) { fRet = FALSE; } else { regionEnd = deviceInfo->Regions[region].Start + deviceInfo->Regions[region].Size(); bytesPerBlock = deviceInfo->Regions[region].BytesPerBlock; private_free(pBuf); pBuf = (BYTE*)private_malloc(bytesPerBlock); if(pBuf == NULL) { fRet = FALSE; } } } } if(pBuf != NULL) { private_free(pBuf); } return fRet; } else { return WriteX(context, Address, NumBytes, pSectorBuff, ReadModifyWrite, TRUE); } }
u32 adi_pdd_Control( ADI_DEV_PDD_HANDLE PDDHandle, u32 Command, void *pArg) { ERROR_CODE ErrorCode = NO_ERR; COMMAND_STRUCT *pCmdStruct = (COMMAND_STRUCT *)pArg; // switch on the command switch ( Command ) { // erase all case CNTRL_ERASE_ALL: ErrorCode = EraseFlash(pCmdStruct->SEraseAll.ulFlashStartAddr); break; // erase sector case CNTRL_ERASE_SECT: ErrorCode = EraseBlock( pCmdStruct->SEraseSect.nSectorNum, pCmdStruct->SEraseSect.ulFlashStartAddr ); break; // get manufacturer and device codes case CNTRL_GET_CODES: ErrorCode = GetCodes((int *)pCmdStruct->SGetCodes.pManCode, (int *)pCmdStruct->SGetCodes.pDevCode, (unsigned long)pCmdStruct->SGetCodes.ulFlashStartAddr); break; //Filling the contents with data case CNTRL_GET_DESC: pCmdStruct->SGetDesc.pTitle = pEzKitTitle; pCmdStruct->SGetDesc.pDesc = pFlashDesc; pCmdStruct->SGetDesc.pFlashCompany = pDeviceCompany; break; // get sector number based on address case CNTRL_GET_SECTNUM: ErrorCode = GetSectorNumber( pCmdStruct->SGetSectNum.ulOffset, (int *)pCmdStruct->SGetSectNum.pSectorNum ); break; // get sector number start and end offset case CNTRL_GET_SECSTARTEND: ErrorCode = GetSectorStartEnd( pCmdStruct->SSectStartEnd.pStartOffset, pCmdStruct->SSectStartEnd.pEndOffset, pCmdStruct->SSectStartEnd.nSectorNum ); break; // get the number of sectors case CNTRL_GETNUM_SECTORS: pCmdStruct->SGetNumSectors.pnNumSectors[0] = NUM_SECTORS; break; // reset case CNTRL_RESET: ErrorCode = ResetFlash(pCmdStruct->SReset.ulFlashStartAddr); break; // no command or unknown command do nothing default: // set our error ErrorCode = UNKNOWN_COMMAND; break; } // return return(ErrorCode); }
BOOL WriteFlashNK(UINT32 address, UINT32 size) { BOOL rc = FALSE; HANDLE hFMD; FlashInfo flashInfo; SectorInfo sectorInfo; BOOL ok = FALSE; BLOCK_ID block; //ROMHDR *pTOC; UINT32 *pInfo, count, sector; UINT32 blockSize, sectorSize, sectorsPerBlock; UINT8 *pData; OALMSG(OAL_INFO, (L"OEMWriteFlash: Writing NK image to flash\r\n")); // We need to know sector/block size if ((hFMD = FMD_Init(NULL, NULL, NULL)) == NULL) { OALMSG(OAL_ERROR, (L"ERROR: OEMWriteFlash: " L"FMD_Init call failed\r\n" )); goto cleanUp; } // Get flash info if (!FMD_GetInfo(&flashInfo)) { OALMSG(OAL_ERROR, (L"ERROR: EBOOT!OEMWriteFlash: " L"FMD_GetInfo call failed!\r\n" )); FMD_Deinit(hFMD); goto cleanUp; } // We don't need access to FMD library FMD_Deinit(hFMD); OALMSG(OAL_INFO, (L"OEMWriteFlash: " L"Flash has %d blocks, %d bytes/block, %d sectors/block\r\n", flashInfo.dwNumBlocks, flashInfo.dwBytesPerBlock, flashInfo.wSectorsPerBlock )); // Make block & sector size ready blockSize = flashInfo.dwBytesPerBlock; sectorSize = flashInfo.wDataBytesPerSector; sectorsPerBlock = flashInfo.wSectorsPerBlock; // Get data location pData = OEMMapMemAddr(address, address); // Verify that we get CE image. pInfo = (UINT32*)(pData + ROM_SIGNATURE_OFFSET); if (*pInfo++ != ROM_SIGNATURE) { OALMSG(OAL_ERROR, (L"ERROR: OEMWriteFlash: " L"Image Signature not found\r\n" )); goto cleanUp; } pInfo++; // Skip reserved blocks block = 0; while (block < flashInfo.dwNumBlocks) { if ((FMD_GetBlockStatus(block) & BLOCK_STATUS_BAD) != 0) { OALMSG(OAL_WARN, (L"WARN: EBOOT!OEMWriteFlash: " L"Skip bad block %d\r\n", block )); block++; continue; } if ((FMD_GetBlockStatus(block) & BLOCK_STATUS_RESERVED) == 0) break; block++; } OALMSG(OAL_INFO, (L"OEMWriteFlash: " L"NK image starts at block %d\r\n", block )); // Write image count = 0; while (count < size && block < flashInfo.dwNumBlocks) { // If block is bad, we have to offset it if ((FMD_GetBlockStatus(block) & BLOCK_STATUS_BAD) != 0) { block++; OALMSG(OAL_WARN, (L"WARN: EBOOT!OEMWriteFlash: " L"Skip bad block %d\r\n", block )); continue; } // Erase block if (!EraseBlock(block)) { FMD_SetBlockStatus(block, BLOCK_STATUS_BAD); block++; OALMSG(OAL_WARN, (L"WARN: EBOOT!OEMWriteFlash: " L"Block %d erase failed, mark block as bad\r\n", block )); continue; } // Now write sectors sector = 0; while (sector < sectorsPerBlock && count < size) { // Prepare sector info memset(§orInfo, 0xFF, sizeof(sectorInfo)); sectorInfo.dwReserved1 = 0; sectorInfo.wReserved2 = 0; // Write sector if (!(ok = WriteSector( block * sectorsPerBlock + sector, pData + count, §orInfo ))) break; // Move to next sector count += sectorSize; sector++; } // When sector write failed, mark block as bad and move back if (!ok) { OALMSG(OAL_WARN, (L"WARN: EBOOT!OEMWriteFlash: " L"Block %d sector %d write failed, mark block as bad\r\n", block, sector )); // First move back count -= sector * flashInfo.wDataBytesPerSector; // Mark block as bad FMD_SetBlockStatus(block, BLOCK_STATUS_BAD); } // We are done with block block++; } // Erase rest of media while (block < flashInfo.dwNumBlocks) { // If block is bad, we have to offset it if ((FMD_GetBlockStatus(block) & BLOCK_STATUS_BAD) != 0) { block++; OALMSG(OAL_WARN, (L"WARN: EBOOT!OEMWriteFlash: " L"Skip bad block %d\r\n", block )); continue; } // When erase failed, mark block as bad and skip it if (!EraseBlock(block)) { FMD_SetBlockStatus(block, BLOCK_STATUS_BAD); block++; OALMSG(OAL_WARN, (L"WARN: EBOOT!OEMWriteFlash: " L"Block %d erase failed, mark block as bad\r\n", block )); continue; } // Move to next block block++; } // Close FMD driver FMD_Deinit(hFMD); hFMD = NULL; OALMSG(OAL_INFO, (L"OEMWriteFlash: NK written\r\n")); // Done rc = TRUE; cleanUp: if (hFMD != NULL) FMD_Deinit(hFMD); return rc; }
void GetData(HANDLE hContact) { int statpos = 0, dispos = 0, statposend = 0; char*pos; DBVARIANT dbv; char tempstring[300], tempstring2[300]; int MallocSize = 0; int DownloadSuccess = 0; char*raw; char*szInfo; char truncated[MAXSIZE1]; char truncated2[MAXSIZE2]; int trunccount = 0; char url[300]; unsigned long downloadsize = 0; int AmountWspcRem = 0; static char contactname[100]; int TherewasAlert = 0; int PosButnClick = 0; char tstr[128]; static char timestring[128]; int eventIndex = 0; int location = 0; int location2 = 0; if (Startingup) Sleep(2000); HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); Startingup = 0; ZeroMemory(&url, sizeof(url)); ZeroMemory(&contactname, sizeof(contactname)); ZeroMemory(&tempstring, sizeof(tempstring)); ZeroMemory(&tempstring2, sizeof(tempstring2)); ZeroMemory(&szInfo, sizeof(szInfo)); ZeroMemory(&dbv, sizeof(dbv)); ZeroMemory(&tstr, sizeof(tstr)); ZeroMemory(×tring, sizeof(timestring)); db_set_b(hContact, MODULENAME, STOP_KEY, 0); if (db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv)) { if ( !db_get_s(hContact, "CList", "MyHandle", &dbv)) { db_set_s(hContact, MODULENAME, PRESERVE_NAME_KEY, dbv.pszVal); db_free(&dbv); } } if ( !db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv)) { strncpy_s(contactname, SIZEOF(contactname), dbv.pszVal, _TRUNCATE); db_free(&dbv); } url[0] = '\0'; if (!Startingup) db_set_b(NULL, MODULENAME, HAS_CRASHED_KEY, 1); if ( !db_get_s(hContact, MODULENAME, START_STRING_KEY, &dbv)) { strncpy_s(tempstring, SIZEOF(tempstring), dbv.pszVal, _TRUNCATE); db_free(&dbv); } if ( !db_get_s(hContact, MODULENAME, END_STRING_KEY, &dbv)) { strncpy_s(tempstring2, SIZEOF(tempstring2), dbv.pszVal, _TRUNCATE); db_free(&dbv); } if ( !db_get_s(hContact, MODULENAME, URL_KEY, &dbv)) { strncpy_s(url, SIZEOF(url), dbv.pszVal, _TRUNCATE); db_free(&dbv); } if (strlen(url) < 3) WErrorPopup(hContact, TranslateT("URL not supplied")); NETLIBHTTPREQUEST nlhr = { sizeof(nlhr) }; nlhr.requestType = REQUEST_GET; nlhr.flags = NLHRF_DUMPASTEXT; nlhr.szUrl = url; nlhr.headersCount = 2; NETLIBHTTPHEADER headers[2]; headers[0].szName = "User-Agent"; headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Win32)"; headers[1].szName = "Content-Length"; headers[1].szValue = NULL; nlhr.headers = headers; if ( db_get_b(NULL, MODULENAME, NO_PROTECT_KEY, 0)) // disable AlreadyDownloading = 0; // //try site//// if (!AlreadyDownloading) { // not already downloading if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON))) PosButnClick = 0; else PosButnClick = 1; EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 1); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Download in progress, please wait...")); db_set_ts(hContact, "CList", "StatusMsg", TranslateT("Updating...")); db_set_w(hContact, MODULENAME, "Status", ID_STATUS_DND); // download NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) & nlhr); if (nlhrReply) { if (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300) { db_set_w(hContact, MODULENAME, "Status", ID_STATUS_AWAY); TCHAR *statusText = TranslateT("The server replied with a failure code"); HWND hwndDlg = WindowList_Find(hWindowList, hContact); SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText); WErrorPopup(hContact, statusText); db_set_ts(hContact, "CList", "StatusMsg", statusText); } if (nlhrReply->dataLength) { int cbLen = lstrlenA(nlhrReply->pData); szInfo = (char*)malloc(cbLen + 2); lstrcpynA(szInfo, nlhrReply->pData, cbLen); downloadsize = lstrlenA(nlhrReply->pData); trunccount = 0; lstrcpynA(truncated2, szInfo, MAXSIZE2); free(szInfo); //////////////////////////////////////////// sprintf(truncated2, "%s", nlhrReply->pData); AlreadyDownloading = 1; } // END DATELENGTH } // END REPLY if (!nlhrReply) { db_set_w(hContact, MODULENAME, "Status", ID_STATUS_NA); HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); TCHAR *statusText = TranslateT("The server is down or lagging."); SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText); WErrorPopup(hContact, statusText); db_set_ts(hContact, "CList", "StatusMsg", statusText); } if (!(nlhrReply)) DownloadSuccess = 0; if ((nlhrReply) && (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300)) DownloadSuccess = 0; else if (nlhrReply) DownloadSuccess = 1; CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) nlhrReply); if (DownloadSuccess) { HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Download successful; about to process data...")); } ///get data in desired range // download successful if (DownloadSuccess) { // all the site if (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 1) lstrcpynA(truncated, truncated2, MAXSIZE1); else { // use start and end string // putting data into string if (((strstr(truncated2, tempstring)) != 0) && ((strstr(truncated2, tempstring2)) != 0)) { // start string pos = strstr(truncated2, tempstring); statpos = pos - truncated2; ZeroMemory(&pos, sizeof(pos)); // end string pos = strstr(truncated2, tempstring2); statposend = pos - truncated2 + (int)strlen(tempstring2); if (statpos > statposend) { memset(&truncated2, ' ', statpos); ZeroMemory(&pos, sizeof(pos)); pos = strstr(truncated2, tempstring2); statposend = pos - truncated2 + (int)strlen(tempstring2); } if (statpos < statposend) { ZeroMemory(&raw, sizeof(raw)); // get size for malloc MallocSize = statposend - statpos; raw = (char *) malloc(MallocSize + 1); // start string pos = strstr(truncated2, tempstring); statpos = pos - truncated2; // end string pos = strstr(truncated2, tempstring2); statposend = pos - truncated2 + (int)strlen(tempstring2); if (statpos > statposend) { memset(&truncated2, ' ', statpos); ZeroMemory(&pos, sizeof(pos)); pos = strstr(truncated2, tempstring2); statposend = pos - truncated2 + (int)strlen(tempstring2); } dispos = 0; strncpy(raw, &truncated2[statpos], MallocSize); raw[MallocSize] = '\0'; trunccount = 0; lstrcpynA(truncated, raw, MAXSIZE1); free(raw); DownloadSuccess = 1; } else if (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 0) { TCHAR *szStatusText = TranslateT("Invalid search parameters."); WErrorPopup(hContact, szStatusText); HWND hwndDlg = WindowList_Find(hWindowList, hContact); DownloadSuccess = 0; SetDlgItemText(hwndDlg, IDC_STATUSBAR, szStatusText); db_set_w(hContact, MODULENAME, "Status", ID_STATUS_AWAY); } } // end putting data into string } // end use start and end strings } // end download success if (DownloadSuccess) { // download success if (statpos == 0 && statposend == 0) { if (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 0) { TCHAR *statusText = TranslateT("Both search strings not found or strings not set."); WErrorPopup(hContact, statusText); db_set_ts(hContact, "CList", "StatusMsg", statusText); HWND hwndDlg = WindowList_Find(hWindowList, hContact); DownloadSuccess = 0; SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText); TherewasAlert = ProcessAlerts(hContact, _T2A(statusText), contactname, contactname, 1); db_set_w(hContact, MODULENAME, "Status", ID_STATUS_AWAY); } } } // end download success if (DownloadSuccess) { // download success char timeprefix[32]; char temptime1[32]; char timeat[16]; char temptime2[32]; char temptime[128]; time_t ftime; struct tm *nTime; setlocale(LC_ALL, ""); if (!db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv)) { ZeroMemory(&temptime, sizeof(temptime)); ZeroMemory(&tstr, sizeof(tstr)); ftime = time(NULL); nTime = localtime(&ftime); // 12 hour if (db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0) == 0) strftime(temptime, 128, "(%b %d,%I:%M %p)", nTime); // 24 hour if (db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0) == 1) strftime(temptime, 128, "(%b %d,%H:%M:%S)", nTime); if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 1) mir_snprintf(tstr, SIZEOF(tstr), "%s %s", temptime, dbv.pszVal); if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 0) mir_snprintf(tstr, SIZEOF(tstr), "%s %s", dbv.pszVal, temptime); db_free(&dbv); } else { db_get_ts(hContact, "CList", "MyHandle", &dbv); ZeroMemory(&temptime, sizeof(temptime)); ZeroMemory(&tstr, sizeof(tstr)); ftime = time(NULL); nTime = localtime(&ftime); // 12 hour if (db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0) == 0) strftime(temptime, 128, "(%b %d,%I:%M %p)", nTime); // 24 hour if (db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0) == 1) strftime(temptime, 128, "(%b %d,%H:%M:%S)", nTime); db_set_ts(hContact, MODULENAME, PRESERVE_NAME_KEY, dbv.ptszVal); if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 1) mir_snprintf(tstr, SIZEOF(tstr), "%s %s", temptime, dbv.pszVal); if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 0) mir_snprintf(tstr, SIZEOF(tstr), "%s %s", dbv.pszVal, temptime); db_free(&dbv); } ftime = time(NULL); nTime = localtime(&ftime); strncpy_s(timeprefix, SIZEOF(timeprefix), Translate("Last updated on"), _TRUNCATE); strncpy_s(timeat, SIZEOF(timeat), Translate("at the time"), _TRUNCATE); strftime(temptime1, 32, " %a, %b %d, %Y ", nTime); strftime(temptime2, 32, " %I:%M %p.", nTime); mir_snprintf(timestring, SIZEOF(timestring), " %s %s%s%s", timeprefix, temptime1, timeat, temptime2); } // end download success if (DownloadSuccess) { TherewasAlert = ProcessAlerts(hContact, truncated, tstr, contactname, 0); // get range of text to be highlighted when part of change changes if (TherewasAlert) { // //////////////////////// static char buff[MAXSIZE1]; char Alerttempstring[300], Alerttempstring2[300]; eventIndex = db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0); if (eventIndex == 2) { strncpy(buff, truncated, SIZEOF(buff)); Filter(buff); if ( !db_get_s(hContact, MODULENAME, ALRT_S_STRING_KEY, &dbv)) { strncpy_s(Alerttempstring, SIZEOF(Alerttempstring), dbv.pszVal, _TRUNCATE); db_free(&dbv); } if ( !db_get_s(hContact, MODULENAME, ALRT_E_STRING_KEY, &dbv)) { strncpy_s(Alerttempstring2, SIZEOF(Alerttempstring2), dbv.pszVal, _TRUNCATE); db_free(&dbv); } // putting data into string if (((strstr(buff, Alerttempstring)) != 0) && ((strstr(buff, Alerttempstring2)) != 0)) { location = (strstr(buff, Alerttempstring)) - buff; location2 = (strstr(buff, Alerttempstring2)) - buff; } } } if ((((strstr(truncated2, tempstring)) != 0) && ((strstr(truncated2, tempstring2)) != 0) && (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 0)) || (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 1)) { RemoveTabs(truncated); if ( db_get_b(hContact, MODULENAME, CLEAR_DISPLAY_KEY, 0)) { HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 1)")); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) { LBL_Stop: TCHAR *statusText = TranslateT("Processing data stopped by user."); SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText); db_set_b(hContact, MODULENAME, STOP_KEY, 0); db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE); db_set_ts(hContact, "CList", "StatusMsg", statusText); AlreadyDownloading = 0; return; } CodetoSymbol(truncated); Sleep(100); // avoid 100% CPU SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 2)")); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; EraseBlock(truncated); Sleep(100); // avoid 100% CPU SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 3)")); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; FastTagFilter(truncated); Sleep(100); // avoid 100% CPU SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 4)")); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; NumSymbols(truncated); Sleep(100); // avoid 100% CPU SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 5)")); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; EraseSymbols(truncated); Sleep(100); // avoid 100% CPU SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 6)")); AmountWspcRem = db_get_b(hContact, MODULENAME, RWSPACE_KEY, 0); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; RemoveInvis(truncated, AmountWspcRem); Sleep(100); // avoid 100% CPU SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 7)")); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; Removewhitespace(truncated); SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 8)")); //data in popup if (TherewasAlert) if ( db_get_b(NULL, MODULENAME, DATA_POPUP_KEY, 0)) WAlertPopup(hContact, _A2T(truncated)); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; // removed any excess characters at the end. if ((truncated[strlen(truncated) - 1] == truncated[strlen(truncated) - 2]) && (truncated[strlen(truncated) - 2] == truncated[strlen(truncated) - 3])) { int counterx = 0; while (true) { counterx++; if (truncated[strlen(truncated) - counterx] != truncated[strlen(truncated) - 1]) { truncated[(strlen(truncated) - counterx) + 2] = '\0'; break; } } } } } if (TherewasAlert) { db_set_w(hContact, MODULENAME, "Status", ID_STATUS_OCCUPIED); db_set_ts(hContact, "CList", "StatusMsg", TranslateT("Alert!")); } else { db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE); db_set_ts(hContact, "CList", "StatusMsg", TranslateT("Online")); } } if (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 0) { if (statpos > statposend) DownloadSuccess = 0; else if (statpos == 0 && statposend == 0) DownloadSuccess = 0; else DownloadSuccess = 1; } AlreadyDownloading = 0; } // end not already downloading if (AlreadyDownloading) SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("A site is already downloading, try again in a moment.")); if (DownloadSuccess) { // download success char BytesString[128]; HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); // update window if the update only on alert option isn't ticked or // there was an alert or the update button was clicked if ((!(db_get_b(NULL, MODULENAME, UPDATE_ONALERT_KEY, 0))) || (TherewasAlert == 1) || (PosButnClick == 1)) { SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); if (TherewasAlert) { // highlight text when part of change changes if (eventIndex == 2) { CHARRANGE sel2 = {location, location2}; SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_EXSETSEL, 0, (LPARAM) & sel2); SetFocus(GetDlgItem(hwndDlg, IDC_DATA)); DWORD HiBackgoundClr = db_get_dw(NULL, MODULENAME, BG_COLOR_KEY, Def_color_bg); DWORD HiTextClr = db_get_dw(NULL, MODULENAME, TXT_COLOR_KEY, Def_color_txt); CHARFORMAT2 Format; memset(&Format, 0, sizeof(Format)); Format.cbSize = sizeof(Format); Format.dwMask = CFM_BOLD | CFM_COLOR | CFM_BACKCOLOR; Format.dwEffects = CFE_BOLD; Format.crBackColor = ((~HiBackgoundClr) & 0x00ffffff); Format.crTextColor = ((~HiTextClr) & 0x00ffffff); SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) & Format); } } SetDlgItemTextA(hwndDlg, IDC_STATUSBAR, timestring); sprintf(BytesString, "%s: %d | %s: %lu", (Translate("Bytes in display")), (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_DATA))), (Translate("Bytes downloaded")), downloadsize); SendMessage(GetDlgItem(hwndDlg, IDC_STATUSBAR), SB_SETTEXT, 1, (LPARAM) BytesString); } else SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Alert test conditions not met; press the refresh button to view content.")); } EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 1); if (!Startingup) db_set_b(NULL, MODULENAME, HAS_CRASHED_KEY, 0); }