/************************************************************************************************** * @fn HalLcdWriteStringValue * * @brief Write a string followed by a value to the LCD * * @param title - Title that will be displayed before the value * value1 - value #1 * format1 - redix of value #1 * value2 - value #2 * format2 - redix of value #2 * line - line number * * @return None **************************************************************************************************/ void HalLcdWriteStringValueValue( char *title, uint16 value1, uint8 format1, uint16 value2, uint8 format2, uint8 line ) { #if (HAL_LCD == TRUE) uint8 tmpLen; uint8 buf[LCD_MAX_BUF]; uint32 err; tmpLen = (uint8)osal_strlen( (char*)title ); if ( tmpLen ) { osal_memcpy( buf, title, tmpLen ); buf[tmpLen++] = ' '; } err = (uint32)(value1); _ltoa( err, &buf[tmpLen], format1 ); tmpLen = (uint8)osal_strlen( (char*)buf ); buf[tmpLen++] = ','; buf[tmpLen++] = ' '; err = (uint32)(value2); _ltoa( err, &buf[tmpLen], format2 ); HalLcdWriteString( (char *)buf, line ); #endif }
/*--------------------------------------------------------------------------*/ void PegChart::RecalcLayout(BOOL bRedraw /*=TRUE*/) { mChartRegion = mClient; if(mwExStyle & CS_DRAWXTICS) { mChartRegion.wBottom -= mwMajorTicSize; } if(mwExStyle & CS_DRAWYTICS) { mChartRegion.wLeft += mwMajorTicSize; if(mwExStyle & CS_DUALYTICS) { mChartRegion.wRight -= mwMajorTicSize; } } if (mwExStyle & CS_DRAWYLABELS) { SIGNED iSkipHeight = TextHeight(lsTEST, mpFont); iSkipHeight++; iSkipHeight >>= 1; mChartRegion.wTop += iSkipHeight; if(!(mwExStyle & CS_DRAWXLABELS)) { mChartRegion.wBottom -= iSkipHeight; } if(mwYLabelWidth == 0) { PEGCHAR cBuffer[20]; _ltoa(mlMinY, cBuffer, 10); SIGNED iMinWidth = TextWidth(cBuffer, mpFont); //_ltoa(mlMinY,cBuffer,10); _ltoa(mlMaxY, cBuffer, 10); SIGNED iMaxWidth = TextWidth(cBuffer, mpFont); /*_ltoa(mlMinY,cBuffer,10);*/ /*_ltoa(mlMaxY,cBuffer,10);*/ mChartRegion.wLeft += iMinWidth > iMaxWidth ? iMinWidth : iMaxWidth; mChartRegion.wLeft += 2; if(mwExStyle & CS_DUALYLABELS) { mChartRegion.wRight -= iMinWidth > iMaxWidth ? iMinWidth : iMaxWidth; mChartRegion.wRight -= 2; } } else { mChartRegion.wLeft += mwYLabelWidth; } }
// List INI Information for all loaded INI files void INIInfo(HWND hwndDlg) { char str[16]; size_t memused = 0; LVITEM lvi = {0}; WIDATALIST *Item = WIHead; HWND hIniList = GetDlgItem(hwndDlg, IDC_INFOLIST); ListView_DeleteAllItems(hIniList); lvi.mask = LVIF_TEXT; lvi.iItem = 0; while (Item != NULL) { // get the data for the ini file lvi.iSubItem = 0; lvi.pszText = Item->Data.InternalName; ListView_InsertItem(hIniList, &lvi); lvi.iSubItem = 1; lvi.pszText = Item->Data.Author; ListView_SetItem(hIniList, &lvi); lvi.iSubItem = 2; lvi.pszText = Item->Data.Version; ListView_SetItem(hIniList, &lvi); lvi.iSubItem = 3; switch (Item->Data.InternalVer) { case 1: lvi.pszText = "1.0"; break; case 2: lvi.pszText = "1.1"; break; case 3: lvi.pszText = "1.1a"; break; case 4: lvi.pszText = "1.2"; break; case 5: lvi.pszText = "1.3"; break; case 6: lvi.pszText = "1.4"; break; default: lvi.pszText = ""; break; } ListView_SetItem(hIniList, &lvi); lvi.iSubItem = 4; lvi.pszText = _ltoa(Item->Data.UpdateDataCount, str, 10); ListView_SetItem(hIniList, &lvi); lvi.iSubItem = 5; lvi.pszText = Item->Data.DisplayName; ListView_SetItem(hIniList, &lvi); lvi.iSubItem = 6; lvi.pszText = Item->Data.ShortFileName; ListView_SetItem(hIniList, &lvi); memused += Item->Data.MemUsed; Item = Item->next; ++lvi.iItem; } SetDlgItemText(hwndDlg, IDC_INICOUNT, _itoa(lvi.iItem, str, 10)); SetDlgItemText(hwndDlg, IDC_MEMUSED, _ltoa((long)memused, str, 10)); }
int CMaskEdit::SetValue(DWORD dwValue) { char cText[32] = ""; _ltoa(dwValue, cText, 10); SetWindowText(cText); return 0; }
char * SDL_ltoa(long value, char *string, int radix) { #if defined(HAVE__LTOA) return _ltoa(value, string, radix); #else char *bufp = string; if (value < 0) { *bufp++ = '-'; value = -value; } if (value) { while (value > 0) { *bufp++ = ntoa_table[value % radix]; value /= radix; } } else { *bufp++ = '0'; } *bufp = '\0'; /* The numbers went into the string backwards. :) */ if (*string == '-') { SDL_strrev(string + 1); } else { SDL_strrev(string); } return string; #endif /* HAVE__LTOA */ }
/********************************************************************* * _itoa (NTDLL.@) * * Converts an integer to a string. * * RETURNS * str. * * NOTES * - Converts value to a '\0' terminated string which is copied to str. * - The maximum length of the copied str is 33 bytes. If radix * is 10 and value is negative, the value is converted with sign. * - Does not check if radix is in the range of 2 to 36. * - If str is NULL it crashes, as the native function does. */ char * __cdecl _itoa( int value, /* [I] Value to be converted */ char *str, /* [O] Destination for the converted value */ int radix) /* [I] Number base for conversion */ { return _ltoa(value, str, radix); }
/********************************************************************* * @fn glucCollCentralPasscodeCB * * @brief Passcode callback. * * @return none */ static void glucCollCentralPasscodeCB( uint8 *deviceAddr, uint16 connectionHandle, uint8 uiInputs, uint8 uiOutputs ) { #if (HAL_LCD == TRUE) uint32 passcode; uint8 str[7]; // Is the callback to get the passcode from or display it to the user? if ( uiInputs != 0 ) { // Passcode must be entered by the user but use the default passcode for now passcode = DEFAULT_PASSCODE; } else { // Create random passcode LL_Rand( ((uint8 *) &passcode), sizeof( uint32 )); } passcode %= 1000000; // Display passcode to user if ( uiOutputs != 0 ) { LCD_WRITE_STRING( "Passcode:", HAL_LCD_LINE_1 ); LCD_WRITE_STRING( (char *) _ltoa(passcode, str, 10), HAL_LCD_LINE_2 ); } // Send passcode response GAPBondMgr_PasscodeRsp( connectionHandle, SUCCESS, passcode ); #endif }
// ******************************************************************************* // FUNCTION: SetEntryField // // FUNCTION USE: Set entry field text to field value. // // DESCRIPTION: Convert value to a string, moving decimal point for // .01 inch to inch conversion, and set the text of the // entry field // // PARAMETERS: HWND dialog window handle // MPARAM first message parameter // MPARAM second message parameter // // RETURNS: MRESULT Reserved value of zero // // INTERNALS: NONE // // ******************************************************************************* static void SetEntryField( HWND hwnd, ULONG cid, ULONG ulValue, ULONG ulUnits ) { char szText[ 34 ]; char *pszTemp; // -------------------------------------------------------------------------- // Convert the numeric value to a string // -------------------------------------------------------------------------- _ltoa( ulValue, szText, 10 ); if (ulUnits == (ULONG)VSI_INCHES) { // -------------------------------------------------------------------------- // inches units are actually hundredths - so put in the decimal point // -------------------------------------------------------------------------- pszTemp = &szText[ strlen(szText) + 1]; *pszTemp = *(pszTemp-1); pszTemp--; *pszTemp = *(pszTemp-1); pszTemp--; *pszTemp = *(pszTemp-1); pszTemp--; *pszTemp = '.'; } /* endif */ // -------------------------------------------------------------------------- // Set the entry field text // -------------------------------------------------------------------------- WinSetDlgItemText( hwnd, cid, szText ); }
void XmlConfigFile::SetInteger( const std::string& key, long nValue ) { if (key.empty()) { LOGE<<"key is empty."; return; } tinyxml2::XMLNode* pNode = _GetXmlNode(key); if (pNode == nullptr) { LOGE<<"pNode is null."; return ; } tinyxml2::XMLElement* pXmlElement = pNode->ToElement(); if (pXmlElement != NULL) { if (_IsAttribute(key)) { std::string strAttrName = _GetAttributeName(key); pXmlElement->SetAttribute(strAttrName.c_str(), nValue); } else { char buff[32] = {0}; _ltoa(nValue, buff, 10); pXmlElement->SetText(buff); } } }
/* Writes a certificate to a new file. */ int write_cert(X509 *cert) { FILE *fp = NULL; char filename[MAX_PATH], serialstr[20]; long serial = ASN1_INTEGER_get(X509_get_serialNumber(cert)); int ret; /* Create file name from serial number */ strcpy(filename, CA_PATH(caIni.newCertsDir)); strcat(filename, _ltoa(serial, serialstr, 10)); strcat(filename, caIni.newCertsExt); fp = fopen(filename, "w"); if (fp == NULL) return OPENSSLCA_ERR_CERT_OPEN; /* Write certificate text */ if (X509_print_fp(fp, cert) != 1) { ret = OPENSSLCA_ERR_CERT_WRITE; goto err; } /* Write PEM */ if (PEM_write_X509(fp, cert) != 1) { ret = OPENSSLCA_ERR_CERT_WRITE; goto err; } err: if (fp) fclose(fp); return ret; }
void TraceLineI( LPSTR psz1, LONG l ) { char szL[ 10 ]; _ltoa( l, szL, 10 ); TraceLineS( psz1, szL ); }
void NumToString (const long x, Str255 s) { char c[33] = ""; s [ (s[0]=0)+1 ] = 0; _ltoa(x, c, 10); AppendString(s, (const unsigned char*)&c, 0, (short)strlen(c)); }
String::String( const long value, const int base ) { char buf[33]; _ltoa(value, buf, base); getBuffer( _length = strlen(buf) ); if ( _buffer != NULL ) strcpy( _buffer, buf ); }
// Member function to update the static timer comtrol. void BoidsWin::updateTimer( ) { // Set the text of the static control to show the current time. // Update the runTime. clock_t time; // Local variable used to hold the time. if ( stopped == false ) { time = clock( ) - stopTime; runTime = time; } else // The simulation is stopped so just display the current run time. { time = runTime; } CString timeText( "Time: " ); char buffer[ 50 ]; // Temporary buffer for string conversion. long minutes = ( time / CLOCKS_PER_SEC ) / 60; long seconds = ( time / CLOCKS_PER_SEC ) % 60; long hundreds = ( time / ( CLOCKS_PER_SEC / 100 ) ) % 100; timeText += _ltoa( minutes, buffer, 10 ); if ( seconds < 10 ) { timeText += ".0"; } else { timeText += "."; } timeText += _ltoa( seconds, buffer, 10 ); if ( hundreds < 10 ) { timeText += ".0"; } else { timeText += "."; } timeText += _ltoa( hundreds, buffer, 10 ); staticTime.SetWindowText( timeText ); }
/************************************************************************************************** * @fn HalLcdWriteValue * * @brief Write a value to the LCD * * @param value - value that will be displayed * radix - 8, 10, 16 * option - display options * * @return None **************************************************************************************************/ void HalLcdWriteValue ( uint32 value, const uint8 radix, uint8 option) { #if (HAL_LCD == TRUE) uint8 buf[LCD_MAX_BUF]; _ltoa( value, &buf[0], radix ); HalLcdWriteString( (char*)buf, option ); #endif }
char* FdoCommonOSUtil::ltoa(long value, char* buffer) { #ifdef _WIN32 return _ltoa(value, buffer, 10); // radix is always 10 #else sprintf(buffer, "%ld", value); return buffer; #endif }
CString LongToStr(long lVal) { CString strRet; char buff[20]; _ltoa(lVal, buff, 10); strRet = buff; return strRet; }
void MimeHeaders::addLong(const char* name, long lValue, unsigned flags) { MimeHeader& H = mVals[allocSlot()]; H.name = name; char szBuffer[20]; _ltoa(lValue, szBuffer, 10); H.value = mir_strdup(szBuffer); H.flags = 2 | flags; }
void zb_ReceiveDataIndication( uint16 source, uint16 command, uint16 len, uint8 *pData ) { uint8 buf[32]; uint8 *pBuf; uint8 tmpLen; uint8 sensorReading; if (command == SENSOR_REPORT_CMD_ID) { // Received report from a sensor sensorReading = pData[1]; // If tool available, write to serial port tmpLen = (uint8)osal_strlen( (char*)strDevice ); pBuf = osal_memcpy( buf, strDevice, tmpLen ); _ltoa( source, pBuf, 16 ); pBuf += 4; *pBuf++ = ' '; if ( pData[0] == BATTERY_REPORT ) { tmpLen = (uint8)osal_strlen( (char*)strBattery ); pBuf = osal_memcpy( pBuf, strBattery, tmpLen ); *pBuf++ = (sensorReading / 10 ) + '0'; // convent msb to ascii *pBuf++ = '.'; // decimal point ( battery reading is in units of 0.1 V *pBuf++ = (sensorReading % 10 ) + '0'; // convert lsb to ascii *pBuf++ = ' '; *pBuf++ = 'V'; } else { tmpLen = (uint8)osal_strlen( (char*)strTemp ); pBuf = osal_memcpy( pBuf, strTemp, tmpLen ); *pBuf++ = (sensorReading / 10 ) + '0'; // convent msb to ascii *pBuf++ = (sensorReading % 10 ) + '0'; // convert lsb to ascii *pBuf++ = ' '; *pBuf++ = 'C'; } *pBuf++ = '\r'; *pBuf++ = '\n'; *pBuf = '\0'; #if defined( MT_TASK ) debug_str( (uint8 *)buf ); #endif // can also write directly to uart } }
/** * name: CLineBuffer::operator + * desc: appends the specified double word integer as a string to the class's _pVal member * param: dVal - double word integer whose value to add * * return: length of the string, added **/ size_t CLineBuffer::operator + (const DWORD dVal) { size_t cbLength = 10; if (_resizeBuf(cbLength)) { cbLength = mir_strlen(_ltoa(dVal, (LPSTR)(_pVal + _cbUsed), 10)); _cbUsed += cbLength; return cbLength; } return 0; }
// SignedToRxVariable -- Convert a signed number into a REXX String. // // Return: REXX Variable Pool return code // ULONG SignedToRxVariable( LONG number, PRXSTRING rxName) { UCHAR string[34]; ULONG cc; _ltoa(number, string, 10); cc = StringToRxVariable(string, strlen(string), rxName); return cc; }
// SignedToRxResult -- Convert a numeric code to Result. // // Return: return of 'StringToRxResult' // ULONG SignedToRxResult( LONG number, // Code to convert. PRXSTRING rxResult) // REXX function result. { UCHAR string[34]; ULONG cc; _ltoa(number, string, 10); cc = StringToRxResult(string, strlen(string), rxResult); return cc; }
/* ----------------------------------------------------------- */ void ValueUpdate(PegPrompt* pObject, int iValue) { PEGCHAR tStringToDisplay[5]; long lValue = 0; lValue = iValue; _ltoa(lValue,tStringToDisplay,10); pObject->DataSet(tStringToDisplay); pObject->Invalidate(); pObject->Parent()->Draw(); }
/* 打印指定的格式的数值 参数 title,前缀字符串 value,需要显示的数值 format,需要显示的进制,十进制为10,十六进制为16 */ void NPI_PrintValue(char *title, uint16 value, uint8 format) { uint8 tmpLen; uint8 buf[128]; uint32 err; tmpLen = (uint8)osal_strlen( (char*)title ); osal_memcpy( buf, title, tmpLen ); buf[tmpLen] = ' '; err = (uint32)(value); _ltoa( err, &buf[tmpLen+1], format ); NPI_PrintString(buf); }
void PreciseDecimal::SetMantissa(long M) { if (DecimalState == StringExact) { delete [] NumberData.StringPrecision.Mantissa; //convert the number to a string and then add it long Length = NumberDigits(M); NumberData.StringPrecision.Mantissa = new char[Length + 1]; NumberData.StringPrecision.Mantissa = '\0'; _ltoa(M, NumberData.StringPrecision.Mantissa, 10); } else { NumberData.RealPrecision = ((double)M / (double)NumberDigits(M)) + IntegerPartUnRound(NumberData.RealPrecision); } }
void PreciseDecimal::SetInteger(long I) { if (DecimalState == StringExact) { delete [] NumberData.StringPrecision.Integer; //convert the number to a string and then add it long Length = NumberDigits(I); NumberData.StringPrecision.Integer = new char[Length + 1]; NumberData.StringPrecision.Integer = '\0'; _ltoa(I, NumberData.StringPrecision.Integer, 10); } else { NumberData.RealPrecision = I + DecimalPart(NumberData.RealPrecision); } }
/************************************************************************************************** * @fn HalLcdWriteStringValue * * @brief Write a string followed by a value to the LCD * * @param title - Title that will be displayed before the value * value - value * format - redix * line - line number * * @return None **************************************************************************************************/ void HalLcdWriteStringValue( char *title, uint16 value, uint8 format, uint8 line ) { #if (HAL_LCD == TRUE) uint8 tmpLen; uint8 buf[LCD_MAX_BUF]; uint32 err; tmpLen = (uint8)osal_strlen( (char*)title ); osal_memcpy( buf, title, tmpLen ); buf[tmpLen] = ' '; err = (uint32)(value); _ltoa( err, &buf[tmpLen+1], format ); HalLcdWriteString( (char*)buf, line ); #endif }
void PreciseDecimal::SetRealNumber(const double NewRealNumber) { if (DecimalState == StringExact) { long IntPart = IntegerPartUnRound(NewRealNumber); long IntLen = NumberDigits(IntPart); //now get the mantissa long MantPart = DecimalPart(NewRealNumber) * pow(10.0, 10.0); //lose some precision long MantLen = NumberDigits(MantPart); //convert both to strings and store delete [] NumberData.StringPrecision.Integer; NumberData.StringPrecision.Integer = new char[IntLen + 1]; NumberData.StringPrecision.Integer[IntLen] = 0; _ltoa(IntPart, NumberData.StringPrecision.Integer, 10); delete [] NumberData.StringPrecision.Mantissa; NumberData.StringPrecision.Mantissa = new char[MantLen + 1]; NumberData.StringPrecision.Mantissa[MantLen] = 0; _ltoa(IntPart, NumberData.StringPrecision.Mantissa, 10); } else { NumberData.RealPrecision = NewRealNumber; } }
os_string CArcViewLayer::GetUniqueFieldName (LPCSTR pcName) { // als erstes einfach auf 10 Zeichen verkürzen und Eindeutigkeit prüfen os_string strName (pcName, min(MAX_DBASEFIELDNAME_LEN, strlen(pcName))); int iCurrNumber = 0; while (!IsUniqueName (strName)) { // letzte Zeichen einfach durch hochgezählte Ziffern ersetzen char cbCnt[32]; _ltoa (++iCurrNumber, cbCnt, 10); strName = strName.substr (0, min(MAX_DBASEFIELDNAME_LEN, strName.size()) - (strlen(cbCnt) + 1)) + "_" + cbCnt; } return strName; }
void LogStats(int code,long recv,long send) { char szFileName[MAX_PATH]; char tempchar[128]; HANDLE hFile=NULL; FILE *f; if (GetModuleFileName(NULL, szFileName, MAX_PATH)) { char* p = strrchr(szFileName, '\\'); *p = '\0'; strcat_s (szFileName,MAX_PATH,"\\"); strcat_s (szFileName,MAX_PATH,_itoa(code,tempchar,10)); strcat_s (szFileName,MAX_PATH,".txt"); } if ((f = fopen((LPCSTR)szFileName, "a")) != NULL) { char msg[100]; char buf[5]; SYSTEMTIME st; GetLocalTime(&st); _itoa(st.wYear,buf,10); strcpy(msg,buf); strcat(msg,"/"); _itoa(st.wMonth,buf,10); strcat(msg,buf); strcat(msg,"/"); _itoa(st.wDay,buf,10); strcat(msg,buf); strcat(msg," "); _itoa(st.wHour,buf,10); strcat(msg,buf); strcat(msg,":"); _itoa(st.wMinute,buf,10); strcat(msg,buf); strcat(msg,":"); _itoa(st.wSecond,buf,10); strcat(msg,buf); strcat(msg," "); strcat(msg,"Transmitted: "); strcat(msg,_ltoa((send+recv)/512,tempchar,10)); strcat(msg,"k \n"); fprintf(f,msg); fclose(f); } }