int DBF::putNumber ( int nth, double val ) { char *p = fieldPtr(nth) ; int l = fieldLength(nth) ; if ( fieldType(nth) != 'N' ) { _errNo = DB_FIELD_TYPE_MISSING ; return -1 ; } modify() ; char s[32] ; sprintf(s,"%*.*f",fieldLength(nth),fieldDecimal(nth),val) ; if ( strlen(s) != fieldLength(nth) ) { /* overflow */ memset(p,'*',l) ; _errNo = DB_FIELD_OVERFLOW ; return -1 ; } memcpy(p,s,fieldLength(nth)) ; return 0 ; }
void eap_am_type_securid_symbian_c::type_configure_readL( eap_config_string field, const u32_t field_length, eap_variable_data_c * const data) { EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::type_configure_readL(): m_index_type=%d, m_index=%d, m_tunneling_type=0xfe%06x%08x\n"), m_index_type, m_index, m_tunneling_type.get_vendor_id(), m_tunneling_type.get_vendor_type())); EAP_UNREFERENCED_PARAMETER(field_length); // Create a buffer for the ascii strings - initialised with the argument HBufC16* unicodeBuf = HBufC16::NewLC(KMaxDBFieldNameLength); TPtr16 unicodeString = unicodeBuf->Des(); TPtrC8 fieldPtr(reinterpret_cast<const TUint8 *> (field), field_length); unicodeString.Copy(fieldPtr); // Now do the database query HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); TPtr sqlStatement = buf->Des(); _LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); if (m_eap_type == eap_type_securid) { sqlStatement.Format( KSQLQueryRow, &unicodeString, &KSecurIDTableName, &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingTypeVendorId, m_tunneling_type.get_vendor_id(), &KTunnelingType, m_tunneling_type.get_vendor_type()); } else { sqlStatement.Format( KSQLQueryRow, &unicodeString, &KGtcTableName, &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingTypeVendorId, m_tunneling_type.get_vendor_id(), &KTunnelingType, m_tunneling_type.get_vendor_type()); } RDbView view; User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); CleanupClosePushL(view); User::LeaveIfError(view.EvaluateAll()); if (view.FirstL()) { eap_status_e status = eap_status_ok; view.GetL(); switch (view.ColType(KDefaultColumnInView_One)) { case EDbColText: { if (view.ColLength(KDefaultColumnInView_One) > 0) { TPtrC16 value = view.ColDes16(KDefaultColumnInView_One); eap_variable_data_c string_unicode(m_am_tools); status = string_unicode.set_copy_of_buffer(value.Ptr(), value.Size()); if (status != eap_status_ok) { User::Leave( m_am_tools->convert_eapol_error_to_am_error( EAP_STATUS_RETURN(m_am_tools, status))); } status = m_am_tools->convert_unicode_to_utf8( *data, string_unicode); if (status != eap_status_ok) { User::Leave( m_am_tools->convert_eapol_error_to_am_error( EAP_STATUS_RETURN(m_am_tools, status))); } } else { data->reset(); status = data->set_copy_of_buffer("", 0); if (status != eap_status_ok) { User::Leave( m_am_tools->convert_eapol_error_to_am_error( EAP_STATUS_RETURN(m_am_tools, status))); } } } break; case EDbColUint32: { TUint value = view.ColUint32(KDefaultColumnInView_One); status = data->set_copy_of_buffer(reinterpret_cast<unsigned char *> (&value), sizeof(value)); if (status != eap_status_ok) { User::Leave( m_am_tools->convert_eapol_error_to_am_error( EAP_STATUS_RETURN(m_am_tools, status))); } } break; default: EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("type_configure_readL: Unexpected column type.\n"))); User::Leave(KErrGeneral); break; } } else { // Could not find parameter EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("type_configure_readL: Could not find configuration parameter.\n"))); User::Leave(KErrArgument); } CleanupStack::PopAndDestroy(3); // Close view, 2 x buf EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); }