bool Process::BuildYourValueSet(){ int temp; m_name = GetName(); m_canAbort = GetCanAbort(); m_canStart = GetCanStart(); m_canPause = GetCanPause(); m_ownerId = GetOwnerId(); m_ownerManagerClassType = GetOwnerManegerClassType(); ManagedObject::BuildYourValueSet(); temp = m_canStart? 1 : 0; AddInt( temp, SSAPI_PROCESS_FID_CAN_START ); temp = m_canAbort? 1 : 0; AddInt( temp, SSAPI_PROCESS_FID_CAN_ABORT ); temp = m_canPause? 1 : 0; AddInt( temp, SSAPI_PROCESS_FID_CAN_PAUSE ); AddU32( m_percentComplete, SSAPI_PROCESS_FID_PERCENT_COMPLETE ); AddU32( m_priority, SSAPI_PROCESS_FID_PRIORITY ); AddInt64( m_timeStarted, SSAPI_PROCESS_FID_TIME_STARTED ); AddU32( m_state, SSAPI_PROCESS_FID_STATE ); AddU32( m_name, SSAPI_PROCESS_FID_NAME ); AddU32( m_ownerManagerClassType, SSAPI_PROCESS_FID_OWNER_MANAGER_CLASS_TYPE); AddGenericValue( (char *)&m_ownerId, sizeof(m_ownerId), SSAPI_PROCESS_FID_OWNER_ID ); return true; }
void UITextView::ConvertStaticMappings(NIBWriter *writer, XIBObject *obj) { if ( _shadowOffset.width != 0.0 || _shadowOffset.height != 0.0 ) obj->AddSize(writer, "UIShadowOffset", _shadowOffset); if ( _text ) obj->AddString(writer, "UIText", _text); if ( !_editable ) AddBool(writer, "UIEditable", _editable); if ( _dataDetectorTypes ) AddInt(writer, "UIDataDetectorTypes", _dataDetectorTypes); if ( _autoCorrectionType ) AddInt(writer, "UIAutocorrectionType", _autoCorrectionType); if ( _returnKeyType ) AddInt(writer, "UIReturnKeyType", _returnKeyType); if ( _textColor && !_textColor->isNil() ) { obj->AddOutputMember(writer, "UITextColor", _textColor); } else { UIColor *color = new UIColor(4, 4, 0.0f, 0.0f, 0.0f, 1.0f, "whiteColor"); obj->AddOutputMember(writer, "UITextColor", color->CreateObject(writer)); } if ( _font ) obj->AddOutputMember(writer, "UIFont", _font); AddOutputMember(writer, "UIMinimumScaleFactor", new XIBObjectFloat(1.0f)); CGSize size; size.width = getFrame().width; size.height = getFrame().height; AddSize(writer, "UIContentSize", size); AddInt(writer, "UITextAlignment", _textAlignment); if ( !_subviews ) { _subviews = new XIBArray(); _subviews->_className = "NSMutableArray"; } Map(writer, obj, propertyMappings, numPropertyMappings); UIScrollView::ConvertStaticMappings(writer, obj); }
void UILabel::ConvertStaticMappings(NIBWriter *writer, XIBObject *obj) { if ( _shadowOffset.width != 0.0 || _shadowOffset.height != 0.0 ) obj->AddSize(writer, "UIShadowOffset", _shadowOffset); if ( _text ) obj->AddString(writer, "UIText", _text); if ( _textColor ) { obj->AddOutputMember(writer, "UITextColor", _textColor); } else { UIColor *color = new UIColor(4, 4, 0.0f, 0.0f, 0.0f, 1.0f, "whiteColor"); obj->AddOutputMember(writer, "UITextColor", color->CreateObject(writer)); } if ( _highlightedColor ) { obj->AddOutputMember(writer, "UIHighlightedColor", _textColor); } AddOutputMember(writer, "UIMinimumScaleFactor", new XIBObjectFloat(1.0f)); if ( _textAlignment != 0 ) AddInt(writer, "UITextAlignment", _textAlignment); if ( _numberOfLines != 1 ) AddInt(writer, "UINumberOfLines", _numberOfLines); if ( _baselineAdjustment != 0 ) AddInt(writer, "UIBaselineAdjustment", _baselineAdjustment); if ( _numberOfLines == 1 ) { if ( _adjustsFontSizeToFit ) AddBool(writer, "UIAdjustsFontSizeToFit", _adjustsFontSizeToFit); if ( _minimumFontSize != -1.0f ) AddOutputMember(writer, "UIMinimumFontSize", new XIBObjectFloat(_minimumFontSize)); } if ( _font ) AddOutputMember(writer, "UIFont", _font); Map(writer, obj, propertyMappings, numPropertyMappings); UIView::ConvertStaticMappings(writer, obj); }
void UIControl::ConvertStaticMappings(NIBWriter* writer, XIBObject* obj) { UIView::ConvertStaticMappings(writer, obj); if (_contentVerticalAlignment != UIControlContentVerticalAlignmentTop) AddInt(writer, "UIContentVerticalAlignment", _contentVerticalAlignment); if (_contentHorizontalAlignment != UIControlContentHorizontalAlignmentLeft) AddInt(writer, "UIContentHorizontalAlignment", _contentHorizontalAlignment); }
IndexException::IndexException(int i, int j, const GeneralMatrix& A) : Logic_error() { Select = BaseException::Select; AddMessage("detected by Newmat: index error: requested indices = "); AddInt(i); AddMessage(", "); AddInt(j); AddMessage("\n\n"); MatrixDetails(A); Tracer::AddTrace(); }
void UITapGestureRecognizer::ConvertStaticMappings(NIBWriter* writer, XIBObject* obj) { UIGestureRecognizer::ConvertStaticMappings(writer, obj); if (_numberOfTapsRequired != g_defaultNumberOfTapsRequired) { AddInt(writer, "UITapGestureRecognizer.numberOfTapsRequired", _numberOfTapsRequired); } if (_numberOfTouchesRequired != g_defaultNumberOfTouchesRequired) { AddInt(writer, "UITapGestureRecognizer.numberOfTouchesRequired", _numberOfTouchesRequired); } }
CWizKMDataUploadParam(const QString& strToken, const QString& strBookGUID, const QString& strObjectGUID, const QString& strObjectType, const QString& strObjectMD5, int allSize, int partCount, int partIndex, const QByteArray& stream) : CWizKMTokenOnlyParam(strToken, strBookGUID) { AddString(_T("obj_guid"), strObjectGUID); AddString(_T("obj_type"), strObjectType); AddString(_T("obj_md5"), strObjectMD5); AddInt(_T("part_count"), partCount); AddInt(_T("part_sn"), partIndex); AddInt64(_T("part_size"), stream.size()); AddString(_T("part_md5"), ::WizMd5StringNoSpaceJava(stream)); AddBase64(_T("data"), stream); }
bool PHSData::BuildYourValueSet(){ ManagedObject::BuildYourValueSet(); if( m_hasSampleRate ) AddInt64( m_sampleRate, SSAPI_PHS_FID_SAMPLE_RATE ); AddInt( m_valueType, SSAPI_PHS_FID_VALUE_TYPE ); AddInt(m_name, SSAPI_PHS_FID_NAME ); AddInt64( m_collectionTimestamp, SSAPI_PHS_FID_COLLECTION_TIMESTAMP ); return true; }
bool Board::BuildYourValueSet(){ Device::BuildYourValueSet(); AddInt(m_slotNumber, SSAPI_BOARD_FID_SLOT ); AddInt(m_slotName, SSAPI_BOARD_FID_SLOT_NAME ); int i = m_isLocked? 1 : 0; AddInt(m_isLocked, SSAPI_OBJECT_FID_IS_LOCKED ); return true; }
void UITextField::ConvertStaticMappings(NIBWriter* writer, XIBObject* obj) { if (_shadowOffset.width != 0.0 || _shadowOffset.height != 0.0) { obj->AddSize(writer, "UIShadowOffset", _shadowOffset); } if (_text) { obj->AddString(writer, "UIText", _text); } if (_placeholder) { obj->AddString(writer, "UIPlaceholder", _placeholder); } if (_borderStyle != 0) { obj->AddInt(writer, "UIBorderStyle", _borderStyle); } if (_font) { AddOutputMember(writer, "UIFont", _font); } if (_textColor && !_textColor->isNil()) { obj->AddOutputMember(writer, "UITextColor", _textColor); } else { UIColor* color = new UIColor(4, 4, 0.0f, 0.0f, 0.0f, 1.0f, "whiteColor"); obj->AddOutputMember(writer, "UITextColor", color->CreateObject(writer)); } if (_autoCorrectionType) { AddInt(writer, "UIAutocorrectionType", _autoCorrectionType); } if (_returnKeyType) { AddInt(writer, "UIReturnKeyType", _returnKeyType); } if (_clearsOnBeginEditing) { AddBool(writer, "UIClearsOnBeginEditing", _clearsOnBeginEditing); } if (_clearButtonOffset.width != 0.0f || _clearButtonOffset.height != 0.0f) { AddSize(writer, "UIClearButtonOffset", _clearButtonOffset); } AddOutputMember(writer, "UIMinimumScaleFactor", new XIBObjectFloat(1.0f)); Map(writer, obj, propertyMappings, numPropertyMappings); UIControl::ConvertStaticMappings(writer, obj); }
void XElement::AddIntList(CTSTR lpName, List<int> &IntList) { assert(lpName); for(DWORD i=0; i<IntList.Num(); i++) AddInt(lpName, IntList[i]); }
void UIActivityIndicatorView::ConvertStaticMappings(NIBWriter *writer, XIBObject *obj) { UIView::ConvertStaticMappings(writer, obj); if ( _style ) AddInt(writer, "UIActivityIndicatorViewStyle", _style); if ( _animating ) AddBool(writer, "UIAnimating", _animating); if ( _tintColor ) AddOutputMember(writer, "UITintColor", _tintColor); }
void UIButton::ConvertStaticMappings(NIBWriter *writer, XIBObject *obj) { Map(writer, obj, propertyMappings, numPropertyMappings); if ( _buttonType != 0 ) AddInt(writer, "UIButtonType", _buttonType); if ( _font ) obj->AddOutputMember(writer, "UIFont", _font); if ( _connections ) { for ( int i = 0; i < _connections->count(); i ++ ) { XIBObject *curObj = _connections->objectAtIndex(i); if ( strcmp(curObj->_className, "segue") == 0 ) { UIStoryboardSegue *segue = (UIStoryboardSegue *) curObj; UIRuntimeEventConnection *newEvent = new UIRuntimeEventConnection(); newEvent->_label = "perform:"; newEvent->_source = this; newEvent->_destination = segue; newEvent->_eventMask = 0x40; writer->_connections->AddMember(NULL, newEvent); writer->AddOutputObject(newEvent); } } } if ( !_isStory ) { WriteStatefulContent(writer, this); } UIControl::ConvertStaticMappings(writer, obj); }
void ConfigFile::SetIntList(CTSTR lpSection, CTSTR lpKey, List<int> &IntList) { while(HasKey(lpSection, lpKey)) Remove(lpSection, lpKey); for(unsigned int i=0; i<IntList.Num(); i++) AddInt(lpSection, lpKey, IntList[i]); }
void UIRuntimeEventConnection::ConvertStaticMappings(NIBWriter *writer, XIBObject *obj) { ObjectConverter::ConvertStaticMappings(writer, obj); if ( _label ) AddString(writer, "UILabel", _label); AddOutputMember(writer, "UISource", _source); AddOutputMember(writer, "UIDestination", _destination); if ( _eventMask != -1 ) AddInt(writer, "UIEventMask", _eventMask); }
IndexException::IndexException(int i, const GeneralMatrix& A, bool) : Logic_error() { Select = BaseException::Select; AddMessage("detected by Newmat: element error: requested index (wrt 0) = "); AddInt(i); AddMessage("\n\n"); MatrixDetails(A); Tracer::AddTrace(); }
void UITabBarItem::ConvertStaticMappings(NIBWriter* writer, XIBObject* obj) { ObjectConverterSwapper::ConvertStaticMappings(writer, obj); AddBool(writer, "UIEnabled", _enabled); if (_title) AddString(writer, "UITitle", _title); if (_image) AddOutputMember(writer, "UIImage", _image); if (_tag != -1) AddInt(writer, "UITag", _tag); }
bool Iop::BuildYourValueSet(){ int temp; Board::BuildYourValueSet(); AddInt(m_redundantSlotNumber, SSAPI_IOP_FID_REDUNDANT_SLOT ); AddString( &m_manufacturer, SSAPI_IOP_FID_MANUFACTURER ); AddString( &m_hardwareVersion, SSAPI_IOP_FID_HW_VERSION ); AddString( &m_serialNumber, SSAPI_IOP_FID_SERIAL_NUMBER ); temp = m_isPowered? 1 : 0; AddInt(temp, SSAPI_OBJECT_FID_IS_POWERED ); AddInt(m_serviceState, SSAPI_OBJECT_FID_SERVICE_STATE ); m_assetInfo.BuildYourValueSet( *this ); return true; }
void UIView::ConvertStaticMappings(NIBWriter *writer, XIBObject *obj) { if ( !_ignoreUIObject ) writer->_allUIObjects->AddMember(NULL, this); if ( _subviews->count() > 0 ) { int count = _subviews->count(); for ( int i = 0; i < count; i ++ ) { XIBObject *curObj = _subviews->objectAtIndex(i); if ( !curObj->_ignoreUIObject ) writer->_allUIObjects->AddMember(NULL, curObj); } } AddRect(writer, "UIBounds", _bounds); AddPoint(writer, "UICenter", _center); if ( _contentStretch.x != 0.0f || _contentStretch.y != 0.0f || _contentStretch.width != 0.0f || _contentStretch.height != 0.0f ) { AddRect(writer, "UIContentStretch", _contentStretch); } Map(writer, obj, propertyMappings, numPropertyMappings); if ( _subviews->count() > 0 ) AddOutputMember(writer, "UISubviews", _subviews); if ( _constraints->count() > 0) AddOutputMember(writer, "UIViewAutolayoutConstraints", _constraints); if ( _autoresizeSubviews ) AddBool(writer, "UIAutoresizeSubviews", _autoresizeSubviews); if ( _autoresizingMask ) AddInt(writer, "UIAutoresizingMask", _autoresizingMask); if ( _clipsToBounds ) AddBool(writer, "UIClipsToBounds", _clipsToBounds); if ( _backgroundColor ) AddOutputMember(writer, "UIBackgroundColor", _backgroundColor); if ( _contentMode ) AddInt(writer, "UIContentMode", _contentMode); if ( _userInteractionDisabled ) AddBool(writer, "UIUserInteractionDisabled", _userInteractionDisabled); if ( _hidden ) AddBool(writer, "UIHidden", _hidden); if ( !_enabled ) AddBool(writer, "UIDisabled", true); if ( _multipleTouchEnabled ) AddBool(writer, "UIMultipleTouchEnabled", _multipleTouchEnabled); if ( !_clearsContextBeforeDrawing ) AddBool(writer, "UIClearsContextBeforeDrawing", _clearsContextBeforeDrawing); // Metadata if ( !_translatesAutoresizeToConstraints || !obj->GetBool("IBViewMetadataTranslatesAutoresizingMaskIntoConstraints", true) ) AddBool(writer, "UIViewDoesNotTranslateAutoresizingMaskIntoConstraints", true); if ( _opaque ) obj->AddBool(writer, "UIOpaque", _opaque); ObjectConverterSwapper::ConvertStaticMappings(writer, obj); }
void SSAPIEvent::BuildYourValueSet(){ AddInt(m_eventType, SSAPI_EVENT_FID_EVENT_TYPE ); AddInt64(m_timeStamp, SSAPI_EVENT_FID_TIMESTAMP ); AddGenericValue( (char *)&m_parentId, sizeof(m_parentId), SSAPI_EVENT_FID_PARENT_ID ); if( m_pManagedObject ){ m_pManagedObject->BuildYourValueSet(); AddValue( m_pManagedObject, SSAPI_EVENT_FID_MANAGED_OBJECT ); m_pManagedObject->Clear(); } }
bool SoftwareDescriptor::BuildYourValueSet(){ ManagedObject::BuildYourValueSet(); AddU32( m_majorVersion, SSAPI_IOP_SW_IMAGE_DESCRIPTOR_FID_MAJOR_VERSION ); AddU32( m_minorVersion, SSAPI_IOP_SW_IMAGE_DESCRIPTOR_FID_MINOR_VERSION ); AddU32( m_referenceCount, SSAPI_IOP_SW_IMAGE_DESCRIPTOR_FID_REFERENCE_COUNT ); AddInt64( m_loadedOn, SSAPI_IOP_SW_IMAGE_DESCRIPTOR_FID_LOADED_ON ); AddInt( m_isDefault? 1 : 0, SSAPI_IOP_SW_IMAGE_DESCRIPTOR_FID_IS_DEFAULT ); return true; }
void UIBarButtonItem::ConvertStaticMappings(NIBWriter *writer, XIBObject *obj) { AddOutputMember(writer, "UIEnabled", new XIBObjectBool(true)); if ( _systemItem != -1 ) { AddInt(writer, "UISystemItem", _systemItem); AddBool(writer, "UIIsSystemItem", true); } if ( _title ) AddString(writer, "UITitle", _title); if ( !_customView ) { if ( _style ) AddInt(writer, "UIStyle", _style); if ( _width != -1.0f ) { AddOutputMember(writer, "UIWidth", new XIBObjectFloat(_width)); } } if ( _customView ) { AddOutputMember(writer, "UICustomView", _customView); } if ( _connections ) { for ( int i = 0; i < _connections->count(); i ++ ) { XIBObject *curObj = _connections->objectAtIndex(i); if ( strcmp(curObj->_className, "segue") == 0 ) { UIStoryboardSegue *segue = (UIStoryboardSegue *) curObj; UIRuntimeEventConnection *newEvent = new UIRuntimeEventConnection(); newEvent->_label = "perform:"; newEvent->_source = this; newEvent->_destination = segue; writer->_connections->AddMember(NULL, newEvent); writer->AddOutputObject(newEvent); //AddOutputMember(writer, "UIOutlet", refObj); } } } ObjectConverterSwapper::ConvertStaticMappings(writer, obj); }
bool User::BuildYourValueSet(){ ManagedObject::BuildYourValueSet(); AddValue( &m_userName , SSAPI_USER_FID_USERNAME ); AddValue( &m_password , SSAPI_USER_FID_PASSWORD ); AddValue( &m_firstName , SSAPI_USER_FID_FIRST_NAME ); AddValue( &m_lastName , SSAPI_USER_FID_LAST_NAME ); AddValue( &m_description , SSAPI_USER_FID_DESCRIPTION ); AddValue( &m_email , SSAPI_USER_FID_EMAIL ); AddValue( &m_phoneNumber1 , SSAPI_USER_FID_PHONE_1 ); AddValue( &m_phoneNumber2 , SSAPI_USER_FID_PHONE_2 ); AddValue( &m_department , SSAPI_USER_FID_DEPARTMENT); AddInt(m_language, SSAPI_USER_FID_LANGUAGE ); return true; }
bool StorageElementArray::BuildYourValueSet(){ int temp; StorageElement::BuildYourValueSet(); AddInt64( m_memberCapacity, SSAPI_STORAGE_ELEMENT_ARRAY_FID_MEMBER_CAPACITY ); AddInt64( m_dataBlockSize, SSAPI_STORAGE_ELEMENT_ARRAY_FID_DATA_BLOCK_SIZE ); AddInt64( m_parityBlockSize, SSAPI_STORAGE_ELEMENT_ARRAY_FID_PARITY_BLOCK_SIZE ); AddU32( m_peckingOrder, SSAPI_STORAGE_ELEMENT_ARRAY_FID_PECKING_ORDER ); temp = m_isInited? 1 : 0; AddInt( temp, SSAPI_STORAGE_ELEMENT_ARRAY_FID_IS_INITED ); AddU32( m_serialNumber, SSAPI_STORAGE_ELEMENT_ARRAY_FID_SERIAL_NUMBER ); AddGenericValue( (char *)&m_hostSparePoolId, sizeof(m_hostSparePoolId), SSAPI_STORAGE_ELEMENT_ARRAY_FID_HOST_SPAREPOOL_ID ); AddInt64( m_creationTime, SSAPI_STORAGE_ELEMENT_ARRAY_FID_CREATION_TIME ); return true; }
bool LogMessage::BuildYourValueSet(){ ManagedObject::BuildYourValueSet(); AddU32( m_sequenceNumber, SSAPI_LOG_MESSAGE_FID_SEQ_NUMBER ); AddInt64( m_timeStamp, SSAPI_LOG_MESSAGE_FID_TIME_STAMP ); AddInt( m_ec, SSAPI_LOG_MESSAGE_FID_EVENT_CODE ); AddInt( m_slot, SSAPI_LOG_MESSAGE_FID_SLOT ); AddInt( m_facility, SSAPI_LOG_MESSAGE_FID_FACILITY ); AddInt( m_severity, SSAPI_LOG_MESSAGE_FID_SEVERITY ); AddInt( m_did, SSAPI_LOG_MESSAGE_FID_DID ); AddInt( m_vdn, SSAPI_LOG_MESSAGE_FID_VDN ); AddValue( m_pParmVector, SSAPI_LOG_MESSAGE_FID_PARAMETER_VECTOR ); return true; }
void cPlugDetailOsdMenu::SetDetail() { SetPluginMenu(meDetail, libvdrskinservice::mtText); Clear(); ClearValues(); SetText("Text to be displayed if skin doesn't know anything about this plugin"); AddInt("menuitem", element); AddString("tabtext", "String value to be displayed if skin doesn't know anything about this plugin"); //Loop Token Example for (int row = 0; row < 25; row++) { libvdrskinservice::cKeyValueList<cString> *loopValues = new libvdrskinservice::cKeyValueList<cString>(); for (int col = 0; col < 10; col++) { cString key = cString::sprintf("loop1[col%d]", col); cString *value = new cString(cString::sprintf("row%d-col%d", row, col)); loopValues->AddKeyValue(*key, value); } AddLoopValues("loop1", loopValues); } Display(); }
void number_to_str(float number, char *str, int afterdecimal){ int ipart = (int)number; double dpart = number - ipart; for (int i = 0; i < afterdecimal; i++){ dpart *= 10; } // check neg int dintpart = (int)dpart; int nop = -1; if (number < 0) { nop = 1; dintpart = -dintpart; } else nop = 0; int intlength = AddInt(ipart, str, nop); if (dintpart != 0){ str[intlength++] = '.'; int decilength = AddDecimal(dintpart, str, intlength); } }
size_t atcprintf(char *buffer, size_t maxlen, const char *format, IPluginContext *pCtx, const cell_t *params, int *param) { if (!buffer || !maxlen) { return 0; } int arg; int args = params[0]; char *buf_p; char ch; int flags; int width; int prec; int n; char sign; const char *fmt; size_t llen = maxlen - 1; buf_p = buffer; arg = *param; fmt = format; while (true) { // run through the format string until we hit a '%' or '\0' for (ch = *fmt; llen && ((ch = *fmt) != '\0') && (ch != '%'); fmt++) { *buf_p++ = ch; llen--; } if ((ch == '\0') || (llen <= 0)) { goto done; } // skip over the '%' fmt++; // reset formatting state flags = 0; width = 0; prec = -1; sign = '\0'; rflag: ch = *fmt++; reswitch: switch(ch) { case '-': { flags |= LADJUST; goto rflag; } case '.': { n = 0; while(is_digit((ch = *fmt++))) { n = 10 * n + (ch - '0'); } prec = (n < 0) ? -1 : n; goto reswitch; } case '0': { flags |= ZEROPAD; goto rflag; } case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { n = 0; do { n = 10 * n + (ch - '0'); ch = *fmt++; } while(is_digit(ch)); width = n; goto reswitch; } case 'c': { CHECK_ARGS(0); if (!llen) { goto done; } char *c; pCtx->LocalToString(params[arg], &c); *buf_p++ = *c; llen--; arg++; break; } case 'b': { CHECK_ARGS(0); cell_t *value; pCtx->LocalToPhysAddr(params[arg], &value); AddBinary(&buf_p, llen, *value, width, flags); arg++; break; } case 'd': case 'i': { CHECK_ARGS(0); cell_t *value; pCtx->LocalToPhysAddr(params[arg], &value); AddInt(&buf_p, llen, static_cast<int>(*value), width, flags); arg++; break; } case 'u': { CHECK_ARGS(0); cell_t *value; pCtx->LocalToPhysAddr(params[arg], &value); AddUInt(&buf_p, llen, static_cast<unsigned int>(*value), width, flags); arg++; break; } case 'f': { CHECK_ARGS(0); cell_t *value; pCtx->LocalToPhysAddr(params[arg], &value); AddFloat(&buf_p, llen, sp_ctof(*value), width, prec, flags); arg++; break; } case 'L': { CHECK_ARGS(0); cell_t *value; pCtx->LocalToPhysAddr(params[arg], &value); char buffer[255]; if (*value) { CPlayer *player = g_Players.GetPlayerByIndex(*value); if (!player || !player->IsConnected()) { return pCtx->ThrowNativeError("Client index %d is invalid", *value); } const char *auth = player->GetAuthString(); if (!auth || auth[0] == '\0') { auth = "STEAM_ID_PENDING"; } int userid = engine->GetPlayerUserId(player->GetEdict()); UTIL_Format(buffer, sizeof(buffer), "%s<%d><%s><>", player->GetName(), userid, auth); } else { UTIL_Format(buffer, sizeof(buffer), "Console<0><Console><Console>"); } AddString(&buf_p, llen, buffer, width, prec); arg++; break; } case 'N': { CHECK_ARGS(0); cell_t *value; pCtx->LocalToPhysAddr(params[arg], &value); const char *name = "Console"; if (*value) { CPlayer *player = g_Players.GetPlayerByIndex(*value); if (!player || !player->IsConnected()) { return pCtx->ThrowNativeError("Client index %d is invalid", *value); } name = player->GetName(); } AddString(&buf_p, llen, name, width, prec); arg++; break; } case 's': { CHECK_ARGS(0); char *str; int err; if ((err=pCtx->LocalToString(params[arg], &str)) != SP_ERROR_NONE) { pCtx->ThrowNativeErrorEx(err, "Could not deference string"); return 0; } AddString(&buf_p, llen, str, width, prec); arg++; break; } case 'T': { CHECK_ARGS(1); char *key; bool error; size_t res; cell_t *target; pCtx->LocalToString(params[arg++], &key); pCtx->LocalToPhysAddr(params[arg++], &target); res = Translate(buf_p, llen, pCtx, key, *target, params, &arg, &error); if (error) { return 0; } buf_p += res; llen -= res; break; } case 't': { CHECK_ARGS(0); char *key; bool error; size_t res; cell_t target = g_SourceMod.GetGlobalTarget(); pCtx->LocalToString(params[arg++], &key); res = Translate(buf_p, llen, pCtx, key, target, params, &arg, &error); if (error) { return 0; } buf_p += res; llen -= res; break; } case 'X': { CHECK_ARGS(0); cell_t *value; pCtx->LocalToPhysAddr(params[arg], &value); flags |= UPPERDIGITS; AddHex(&buf_p, llen, static_cast<unsigned int>(*value), width, flags); arg++; break; } case 'x': { CHECK_ARGS(0); cell_t *value; pCtx->LocalToPhysAddr(params[arg], &value); AddHex(&buf_p, llen, static_cast<unsigned int>(*value), width, flags); arg++; break; } case '%': { if (!llen) { goto done; } *buf_p++ = ch; llen--; break; } case '\0': { if (!llen) { goto done; } *buf_p++ = '%'; llen--; goto done; } default: { if (!llen) { goto done; } *buf_p++ = ch; llen--; break; } } } done: *buf_p = '\0'; *param = arg; return (maxlen - llen - 1); }
size_t gnprintf(char *buffer, size_t maxlen, const char *format, void **args) { if (!buffer || !maxlen) { return 0; } int arg = 0; char *buf_p; char ch; int flags; int width; int prec; int n; char sign; const char *fmt; size_t llen = maxlen - 1; buf_p = buffer; fmt = format; while (true) { // run through the format string until we hit a '%' or '\0' for (ch = *fmt; llen && ((ch = *fmt) != '\0') && (ch != '%'); fmt++) { *buf_p++ = ch; llen--; } if ((ch == '\0') || (llen <= 0)) { goto done; } // skip over the '%' fmt++; // reset formatting state flags = 0; width = 0; prec = -1; sign = '\0'; rflag: ch = *fmt++; reswitch: switch(ch) { case '-': { flags |= LADJUST; goto rflag; } case '.': { n = 0; while(is_digit((ch = *fmt++))) { n = 10 * n + (ch - '0'); } prec = (n < 0) ? -1 : n; goto reswitch; } case '0': { flags |= ZEROPAD; goto rflag; } case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { n = 0; do { n = 10 * n + (ch - '0'); ch = *fmt++; } while(is_digit(ch)); width = n; goto reswitch; } case 'c': { if (!llen) { goto done; } char *c = (char *)args[arg]; *buf_p++ = *c; llen--; arg++; break; } case 'b': { int *value = (int *)args[arg]; AddBinary(&buf_p, llen, *value, width, flags); arg++; break; } case 'd': case 'i': { int *value = (int *)args[arg]; AddInt(&buf_p, llen, *value, width, flags); arg++; break; } case 'u': { unsigned int *value = (unsigned int *)args[arg]; AddUInt(&buf_p, llen, *value, width, flags); arg++; break; } case 'f': { float *value = (float *)args[arg]; AddFloat(&buf_p, llen, *value, width, prec, flags); arg++; break; } case 's': { const char *str = (const char *)args[arg]; AddString(&buf_p, llen, str, width, prec); arg++; break; } case 'X': { unsigned int *value = (unsigned int *)args[arg]; flags |= UPPERDIGITS; AddHex(&buf_p, llen, *value, width, flags); arg++; break; } case 'x': { unsigned int *value = (unsigned int *)args[arg]; AddHex(&buf_p, llen, *value, width, flags); arg++; break; } case '%': { if (!llen) { goto done; } *buf_p++ = ch; llen--; break; } case '\0': { if (!llen) { goto done; } *buf_p++ = '%'; llen--; goto done; } default: { if (!llen) { goto done; } *buf_p++ = ch; llen--; break; } } } done: *buf_p = '\0'; return (maxlen - llen - 1); }
/* vsprintf I'm not going to support a bunch of the more arcane stuff in here just to keep it simpler. For example, the '*' and '$' are not currently supported. I've tried to make it so that it will just parse and ignore formats we don't support. */ int vsprintf( char *buffer, const char *fmt, va_list argptr ) { int *arg; char *buf_p; char ch; int flags; int width; int prec; int n; char sign; buf_p = buffer; arg = (int *)argptr; while( qtrue ) { // run through the format string until we hit a '%' or '\0' for ( ch = *fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++ ) { *buf_p++ = ch; } if ( ch == '\0' ) { goto done; } // skip over the '%' fmt++; // reset formatting state flags = 0; width = 0; prec = -1; sign = '\0'; rflag: ch = *fmt++; reswitch: switch( ch ) { case '-': flags |= LADJUST; goto rflag; case '.': n = 0; while( is_digit( ( ch = *fmt++ ) ) ) { n = 10 * n + ( ch - '0' ); } prec = n < 0 ? -1 : n; goto reswitch; case '0': flags |= ZEROPAD; goto rflag; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': n = 0; do { n = 10 * n + ( ch - '0' ); ch = *fmt++; } while( is_digit( ch ) ); width = n; goto reswitch; case 'c': *buf_p++ = (char)*arg; arg++; break; case 'd': case 'i': AddInt( &buf_p, *arg, width, flags ); arg++; break; case 'f': AddFloat( &buf_p, *(lfixed *)arg, width, prec ); #ifdef __LCC__ arg += 1; // everything is 32 bit in my compiler #else arg += 2; #endif break; case 's': AddString( &buf_p, (char *)*arg, width, prec ); arg++; break; case '%': *buf_p++ = ch; break; default: *buf_p++ = (char)*arg; arg++; break; } } done: *buf_p = 0; return buf_p - buffer; }