static ssize_t data_file_t_convert_from(data_t *data, fastcall_convert_from *fargs){ // {{{ ssize_t ret; if(fargs->src == NULL) return -EINVAL; switch(fargs->format){ case FORMAT(config):; case FORMAT(human):; case FORMAT(native):; request_t r_config[] = { { HK(filename), *fargs->src }, hash_end }; return file_new((file_t **)&data->ptr, r_config); case FORMAT(hash):; hash_t *config; data_get(ret, TYPE_HASHT, config, fargs->src); if(ret != 0) return -EINVAL; return file_new((file_t **)&data->ptr, config); default: break; }; return -ENOSYS; } // }}}
static ssize_t data_length_t_convert_from(data_t *dst, fastcall_convert_from *fargs){ // {{{ ssize_t ret; length_t *fdata; if(dst->ptr != NULL) return -EINVAL; switch(fargs->format){ case FORMAT(hash):; hash_t *config; data_get(ret, TYPE_HASHT, config, fargs->src); if(ret != 0) return ret; if( (fdata = malloc(sizeof(length_t))) == NULL) return -ENOMEM; hash_holder_consume(ret, fdata->data, config, HK(data)); if(ret != 0){ free(fdata); return -EINVAL; } fdata->format = FORMAT(clean); hash_data_get(ret, TYPE_FORMATT, fdata->format, config, HK(format)); dst->ptr = fdata; return 0; default: break; } return -ENOSYS; } // }}}
/*static ssize_t data_env_t_copy(data_t *src, fastcall_copy *fargs){ // {{{ env_t *fdata = (env_t *)src->ptr; env_t *new_fdata = NULL; if(fargs->dest == NULL) return -EINVAL; if(fdata){ if( (new_fdata = malloc(sizeof(env_t))) == NULL) return -EINVAL; new_fdata->key = fdata->key; } fargs->dest->type = src->type; fargs->dest->ptr = new_fdata; return 0; } // }}}*/ static ssize_t data_env_t_convert_from(data_t *dst, fastcall_convert_from *fargs){ // {{{ ssize_t ret; env_t *fdata; if(dst->ptr != NULL) return data_env_t_handler(dst, (fastcall_header *)fargs); // already inited - pass to underlying data if(fargs->src == NULL) return -EINVAL; if( (ret = data_env_t_alloc(dst, NULL)) != 0) return ret; fdata = (env_t *)dst->ptr; switch(fargs->format){ case FORMAT(config):; case FORMAT(human):; data_t hkey = DATA_PTR_HASHKEYT(&fdata->key); fastcall_convert_from r_convert = { { 4, ACTION_CONVERT_FROM }, fargs->src, fargs->format }; return data_query(&hkey, &r_convert); default: break; } return -ENOSYS; } // }}}
String Object::getString() const { switch (this->getNativeType()) { default: throw ObjectConversionException(FORMAT("Unknown DataType %u", this->getNativeType())); case NIL: return ""; case BOOLEAN: return this->data.boolean ? "true" : "false"; case NUMBER: return FORMAT("%f", this->data.number); case ADDRESS: return FORMAT("%u", this->data.address); case STRING: return this->data.string; case USERDATA: { std::stringstream ss; ss << this->data.userdata; return ss.str(); } } }
static ssize_t data_timestamp_t_convert_from(data_t *dst, fastcall_convert_from *fargs){ // {{{ char buffer[DEF_BUFFER_SIZE] = { 0 }; timestamp_t *fdata; if(fargs->src == NULL) return -EINVAL; if(dst->ptr == NULL){ // no buffer, alloc new if(data_timestamp_t_alloc(dst, NULL) != 0) return -ENOMEM; } fdata = (timestamp_t *)dst->ptr; switch( fargs->format ){ case FORMAT(config):; case FORMAT(human):; fastcall_read r_read_str = { { 5, ACTION_READ }, 0, &buffer, sizeof(buffer) - 1 }; if(data_query(fargs->src, &r_read_str) != 0) return -EFAULT; return timestamp_from_string(&fdata->time, buffer, r_read_str.buffer_size); case FORMAT(clean):; case FORMAT(binary):; fastcall_read r_read = { { 5, ACTION_READ }, 0, &fdata->time, sizeof(fdata->time) }; return data_query(fargs->src, &r_read); default: break; }; return -ENOSYS; } // }}}
void TOptions::LogOptions(TLogOptionEvent OnLogOption) { for (size_t Index = 0; Index < FOriginalOptions.size(); ++Index) { const TOption & Option = FOriginalOptions[Index]; UnicodeString LogStr; switch (Option.Type) { case otParam: LogStr = FORMAT(L"Parameter: %s", Option.Value.c_str()); assert(Option.Name.IsEmpty()); break; case otSwitch: LogStr = FORMAT(L"Switch: %c%s%s%s", FSwitchMarks[1], Option.Name.c_str(), (Option.Value.IsEmpty() ? UnicodeString() : FSwitchValueDelimiters.SubString(1, 1)).c_str(), Option.Value.c_str()); break; default: FAIL; break; } OnLogOption(LogStr); } }
UnicodeString TCopyParamType::GetLogStr() const { wchar_t CaseC[] = L"NULFS"; wchar_t ModeC[] = L"BAM"; wchar_t ResumeC[] = L"YSN"; // OpenArray (ARRAYOFCONST) supports only up to 19 arguments, so we had to split it return FORMAT( L" PrTime: %s%s; PrRO: %s; Rght: %s; PrR: %s (%s); FnCs: %c; RIC: %c; " L"Resume: %c (%d); CalcS: %s; Mask: %s\n", BooleanToEngStr(GetPreserveTime()).c_str(), UnicodeString(GetPreserveTime() && GetPreserveTimeDirs() ? L"+Dirs" : L"").c_str(), BooleanToEngStr(GetPreserveReadOnly()).c_str(), GetRights().GetText().c_str(), BooleanToEngStr(GetPreserveRights()).c_str(), BooleanToEngStr(GetIgnorePermErrors()).c_str(), CaseC[GetFileNameCase()], CharToHex(GetInvalidCharsReplacement()).c_str(), ResumeC[GetResumeSupport()], (int)GetResumeThreshold(), BooleanToEngStr(GetCalculateSize()).c_str(), GetFileMask().c_str()) + FORMAT( L" TM: %c; ClAr: %s; RemEOF: %s; RemBOM: %s; CPS: %u; NewerOnly: %s; InclM: %s; ResumeL: %d\n" L" AscM: %s\n", ModeC[GetTransferMode()], BooleanToEngStr(GetClearArchive()).c_str(), BooleanToEngStr(GetRemoveCtrlZ()).c_str(), BooleanToEngStr(GetRemoveBOM()).c_str(), int(GetCPSLimit()), BooleanToEngStr(GetNewerOnly()).c_str(), GetIncludeFileMask().GetMasks().c_str(), ((FTransferSkipList.get() != nullptr) ? FTransferSkipList->GetCount() : 0) + (!FTransferResumeFile.IsEmpty() ? 1 : 0), GetAsciiFileMask().GetMasks().c_str()); }
static ssize_t timestamp_to_string(time_t time, char *string, size_t *string_size, format_t format){ // {{{ ssize_t ret; intmax_t time_format = -1; struct tm timetm; if(gmtime_r(&time, &timetm) == NULL) return -EINVAL; switch(format){ case FORMAT(human): case FORMAT(time_rfc2822): if(time_format == -1) time_format = 0; case FORMAT(time_rfc3339): if(time_format == -1) time_format = 1; case FORMAT(time_slash_dmyhms): if(time_format == -1) time_format = 2; case FORMAT(time_slash_dmyhm): if(time_format == -1) time_format = 3; case FORMAT(time_slash_dmy): if(time_format == -1) time_format = 4; case FORMAT(time_dot_dmyhms): if(time_format == -1) time_format = 5; case FORMAT(time_dot_dmyhm): if(time_format == -1) time_format = 6; case FORMAT(time_dot_dmy): if(time_format == -1) time_format = 7; case FORMAT(time_unix): if(time_format == -1) time_format = 8; default: if(time_format == -1) break; if( (ret = strftime(string, *string_size, time_formats[time_format], &timetm)) == 0) return -EFAULT; *string_size = ret; return 0; } return -ENOSYS; } // }}}
static ssize_t data_timestamp_t_convert_to(data_t *src, fastcall_convert_to *fargs){ // {{{ ssize_t ret; char buffer[DEF_BUFFER_SIZE]; uintmax_t buffer_size = sizeof(buffer); uintmax_t transfered = 0; timestamp_t *fdata = (timestamp_t *)src->ptr; time_t time_val = timestamp_gettime(fdata); if(fargs->dest == NULL || fdata == NULL) return -EINVAL; switch( fargs->format ){ case FORMAT(native):; case FORMAT(packed):; fastcall_write r_write = { { 5, ACTION_WRITE }, 0, &time_val, sizeof(time_val) }; ret = data_query(fargs->dest, &r_write); transfered = r_write.buffer_size; break; default: if( (ret = timestamp_to_string(time_val, buffer, &buffer_size, fargs->format)) != 0) return ret; fastcall_write r_write2 = { { 5, ACTION_WRITE }, 0, &buffer, buffer_size }; ret = data_query(fargs->dest, &r_write2); transfered = r_write.buffer_size; break; } if(fargs->header.nargs >= 5) fargs->transfered = transfered; return ret; } // }}}
//--------------------------------------------------------------------------- UnicodeString __fastcall TPropertiesDialog::LoadRemoteToken( const TRemoteToken & Token) { UnicodeString Result; if (FUserGroupByID) { if (Token.IDValid) { if (Token.NameValid) { Result = FORMAT(L"%s [%d]", (Token.Name, int(Token.ID))); } else { Result = FORMAT(L"[%d]", (int(Token.ID))); } } else { // be it valid or not Result = Token.Name; } } else { // what if name is not filled in? Result = Token.Name; } return Result; }
//--------------------------------------------------------------------- void __fastcall TFileSystemInfoDialog::ClipboardAddItem(TControl * Control, int Label, UnicodeString Value) { if (Control->Enabled && !Value.IsEmpty()) { if (FLastFeededControl != Control) { if (FLastFeededControl != NULL) { FClipboard += UnicodeString::StringOfChar(L'-', 60) + L"\r\n"; } FLastFeededControl = Control; } if (dynamic_cast<TListView *>(Control) == NULL) { TGroupBox * Group = dynamic_cast<TGroupBox *>(Control->Parent); assert(Group != NULL); if ((Value.Length() >= 2) && (Value.SubString(Value.Length() - 1, 2) == L"\r\n")) { Value.SetLength(Value.Length() - 2); } FClipboard += FORMAT(L"%s\r\n%s\r\n", (Group->Caption, Value)); } else { assert(dynamic_cast<TListView *>(Control) != NULL); FClipboard += FORMAT(L"%s = %s\r\n", (LoadStr(Label), Value)); } } }
//--------------------------------------------------------------------------- static bool __fastcall GetResource( const UnicodeString ResName, void *& Content, unsigned long & Size) { HRSRC Resource = FindResourceEx(HInstance, RT_RCDATA, ResName.c_str(), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)); bool Result = (Resource != NULL); if (Result) { Size = SizeofResource(HInstance, Resource); if (!Size) { throw Exception(FORMAT(L"Cannot get size of resource %s", (ResName))); } Content = LoadResource(HInstance, Resource); if (!Content) { throw Exception(FORMAT(L"Cannot read resource %s", (ResName))); } Content = LockResource(Content); if (!Content) { throw Exception(FORMAT(L"Cannot lock resource %s", (ResName))); } } return Result; }
std::string Media::mimetype(Format f) const{ if(f == Track::Vorbis) return "audio/ogg"; if(f == Track::MP3) return "audio/mpeg"; FORMAT(".aiff", "audio/aiff") FORMAT(".flac", "audio/flac") FORMAT(".wav", "audio/wav") return "application/octet-stream"; }
static ssize_t data_list_t_convert_to(data_t *src, fastcall_convert_to *fargs){ // {{{ ssize_t ret = 0; ssize_t qret; list_chunk_t *chunk; list_t *fdata = (list_t *)src->ptr; data_t sl_output = DATA_SLIDERT(fargs->dest, 0); switch(fargs->format){ case FORMAT(packed):; for(chunk = fdata->head; chunk; chunk = chunk->cnext){ // remove ref_t from top hash_t r_key[] = { { 0, DATA_HASHKEYT(HK(data)) }, hash_end }; data_t d_key = DATA_PTR_HASHT(r_key); fastcall_control r_control = { { 5, ACTION_CONTROL }, HK(data), &d_key, NULL }; if( (ret = data_query(&chunk->data, &r_control)) < 0) break; data_t d_data = DATA_PTR_DATAT(r_control.value); fastcall_convert_to r_convert = { { 5, ACTION_CONVERT_TO }, &sl_output, FORMAT(packed) }; ret = data_query(&d_data, &r_convert); data_slider_t_set_offset(&sl_output, r_convert.transfered, SEEK_CUR); if(ret < 0) break; } // terminate list data_t terminator = { TYPE_LISTENDT, NULL }; data_t d_data = DATA_PTR_DATAT(&terminator); fastcall_convert_to r_convert = { { 5, ACTION_CONVERT_TO }, &sl_output, FORMAT(packed) }; qret = data_query(&d_data, &r_convert); data_slider_t_set_offset(&sl_output, r_convert.transfered, SEEK_CUR); if(qret < 0) ret = qret; break; default: return -ENOSYS; } if(fargs->header.nargs >= 5) fargs->transfered = data_slider_t_get_offset(&sl_output); return ret; } // }}}
const NAString QualifiedName::getQualifiedNameAsAnsiNTFilenameString() const { // Preallocate a result buffer that'll be big enough most of the time // (so += won't reallocate+copy most of the time). NAString result((NASize_T)40, CmpCommon::statementHeap()); NAString catName(CmpCommon::statementHeap()); NAString schName(CmpCommon::statementHeap()); NAString objName(CmpCommon::statementHeap()); formatAsAnsiIdentifier = TRUE; // put quotes on delimited identifiers if ( NOT getCatalogName().isNull() ) { catName = FORMAT(getCatalogName()); makeSafeFilenamePart(catName, "SQLMX_DEFAULT_CATALOG_"); } if ( NOT getSchemaName().isNull() ) { schName = FORMAT(getSchemaName()); makeSafeFilenamePart(schName, "SQLMX_DEFAULT_SCHEMA_"); } if ( NOT getObjectName().isNull() ) { objName = FORMAT(getObjectName()); } makeSafeFilenamePart(objName, "SQLMX_DEFAULT_FILE_"); formatAsAnsiIdentifier = FALSE; // reset to initial value size_t totlen = catName.length() + schName.length() + objName.length() + 2; if ( totlen > 255 ) { // need to truncate // +1 so round off doesn't give us less than what we need to chop size_t chopLen = totlen - 255 + 1; if ( catName.length() - chopLen/2 <= 0 ) // cat too short schName.remove( schName.length() - chopLen ); else if ( schName.length() - chopLen/2 <= 0 ) // sch too short catName.remove( catName.length() - chopLen ); else { // chop from both // remember position starts at 0 and length is 1 more chopLen /= 2; catName.remove( catName.length() - chopLen - 1 ); schName.remove( schName.length() - chopLen - 1 ); } } if (NOT catName.isNull()) { result = catName; result += "."; } if (NOT schName.isNull()) { result += schName; result += "."; } result += objName; return result; }
inline int __checkString (const wchar_t* __str) { wchar_t* __charIterator; for (__charIterator = (wchar_t*)__str; *__charIterator; __charIterator++) { if (FORMAT(*__charIterator) < START_SYMBOL || FORMAT(*__charIterator) > STOP_SYMBOL) return 0; } return 1; }
static ssize_t data_uint16_t_convert_from(data_t *dst, fastcall_convert_from *fargs){ // {{{ ssize_t ret; char *endptr; char buffer[DEF_BUFFER_SIZE]; uintmax_t transfered = 0; if(fargs->src == NULL) return -EINVAL; #ifndef OPTIMIZE_UINT if(dst->ptr == NULL){ // no buffer, alloc new if( (dst->ptr = malloc(sizeof(uint16_t))) == NULL) return -ENOMEM; } #endif switch( fargs->format ){ case FORMAT(config):; case FORMAT(human):; // TODO fix it for slider_t fastcall_read r_read_str = { { 5, ACTION_READ }, 0, &buffer, sizeof(buffer) - 1 }; if( (ret = data_query(fargs->src, &r_read_str)) < 0){ // TODO memleak return ret; } buffer[r_read_str.buffer_size] = '\0'; SET_TYPE_UINT16T(dst) = (void *)((uintmax_t)((uint16_t )strtoul(buffer, &endptr, 10))); transfered = (endptr - buffer); break; case FORMAT(native):; case FORMAT(packed):; if(fargs->src->type == dst->type){ SET_TYPE_UINT16T(dst) = (void *)((uintmax_t) DEREF_TYPE_UINT16T(fargs->src)); ret = 0; }else{ fastcall_read r_read = { { 5, ACTION_READ }, 0, &buffer, sizeof(uint16_t) }; if( (ret = data_query(fargs->src, &r_read)) < 0){ // TODO memleak return ret; } SET_TYPE_UINT16T(dst) = (void *)((uintmax_t)(*((uint16_t *)buffer))); } transfered = sizeof(uint16_t); break; default: return -ENOSYS; }; if(fargs->header.nargs >= 5) fargs->transfered = transfered; return 0; } // }}}
/////////////////////////////////////add//////////////////// void add(unsigned char Data2,unsigned char Data1,volatile unsigned short Ident) { volatile unsigned short dat=0; Cdata1=FORMAT(Data1); Cdata2=FORMAT(Data2); dat=Ident*8-Startcharlen*8+1;//4*8-1 if(Cdat1_0>Cdat2_0&&!find(rdata3,dat+0)) {rdata3[Quest_len_int(rdata3)]=dat+0; } if(Cdat1_1>Cdat2_1&&!find(rdata3,dat+1)) {rdata3[Quest_len_int(rdata3)]=dat+1; //if(find(rdata2,(dat+6))&&(!find(rdata4,(dat+6))))addto4_last(dat+6); } if(Cdat1_2>Cdat2_2&&!find(rdata3,dat+2)) {rdata3[Quest_len_int(rdata3)]=dat+2; } if(Cdat1_3>Cdat2_3&&!find(rdata3,dat+3)) {rdata3[Quest_len_int(rdata3)]=dat+3; //if(find(rdata2,(dat+4))&&(!find(rdata4,(dat+4))))addto4_last(dat+4); } if(Cdat1_4>Cdat2_4&&!find(rdata3,dat+4)) {rdata3[Quest_len_int(rdata3)]=dat+4; } if(Cdat1_5>Cdat2_5&&!find(rdata3,dat+5)) {rdata3[Quest_len_int(rdata3)]=dat+5; //if(find(rdata2,(dat+2))&&(!find(rdata4,(dat+2))))addto4_last(dat+2); } if(Cdat1_6>Cdat2_6&&!find(rdata3,dat+6)) {rdata3[Quest_len_int(rdata3)]=dat+6; } if(Cdat1_7>Cdat2_7&&!find(rdata3,dat+7)) {rdata3[Quest_len_int(rdata3)]=dat+7; //if(find(rdata2,(dat+0))&&(!find(rdata4,(dat+0))))addto4_last(dat+0); } /*if(Cdat1_0<Cdat2_0&&Cdat1_0==0){cut((dat+0));} if(Cdat1_1<Cdat2_1&&Cdat1_1==0){cut((dat+1));} if(Cdat1_2<Cdat2_2&&Cdat1_2==0){cut((dat+2));} if(Cdat1_3<Cdat2_3&&Cdat1_3==0){cut((dat+3));} if(Cdat1_4<Cdat2_4&&Cdat1_4==0){cut((dat+4));} if(Cdat1_5<Cdat2_5&&Cdat1_5==0){Z//76666666 cut((dat+6));} if(Cdat1_7<Cdat2_7&&Cdat1_7==0){cut((dat+7));}*/ }
static void *thread_get_geoloc(void *vargs) { struct cb_args *a = (struct cb_args *) vargs; struct geoip *g = geoip_get_info(a->ip, 0); enum e_status i_status = a->status; const char *s_status = a->status & STATUS_AFK ? "AFK" : i_status & STATUS_PLAYING ? "playing" : i_status & STATUS_SHOP ? "in shop" : i_status & STATUS_INVENTORY ? "in inventory" : i_status & STATUS_ROOM ? "in a room" : i_status & STATUS_LOBBY ? "in lobby" : i_status & STATUS_ONLINE ? "connecting" : "offline"; /* wut ? impossible !§§!§ */ if (a->nick_to == NULL || a->jid_to == NULL) { if (g == NULL) printf("ip:%s is %s\n", a->ip, s_status); else { printf("ip:%s (%s) is %s\n", a->ip, g->country_name, s_status); geoip_free(g); } } else { int r = time(NULL) % 3; const char *format = r == 0 ? "He's from %s... currently %s" : r == 1 ? "That's a guy from %s. He is %s" : "I met him in %s but now he's %s"; char *message; if (g == NULL) FORMAT(message, "He's %s", s_status); else { FORMAT(message, format, g->country_name, s_status); geoip_free(g); } xmpp_send_message(a->nick_to, a->jid_to, message); free(message); } free(a->ip); free(a->nick_to); free(a->jid_to); free(a); pthread_exit(NULL); }
void ResourceManager::reloadResource(Ogre::ResourceManager* resMgr, const std::string& resourceName, const std::string& resourceGroup) { Ogre::ResourcePtr rPtr = resMgr->load(resourceName, resourceGroup); if (rPtr.isNull()) LOG_META(FORMAT("The resource '%1%' no longer exists!", resourceName)); rPtr->reload(); if (rPtr->isLoaded()) LOG_META(FORMAT("The resource '%1%' wasn`t unloaded!", resourceName)); else LOG_META(FORMAT("The resource '%1%' was unloaded!", resourceName)); }
ssize_t data_default_convert_from (data_t *dest, fastcall_convert_from *fargs){ // {{{ switch(fargs->format){ case FORMAT(native):; fastcall_convert_to r_convert = { { 3, ACTION_CONVERT_TO }, dest, FORMAT(native) }; return data_query(fargs->src, &r_convert); default: break; } return -ENOSYS; } // }}}
static ssize_t data_action_t_len(data_t *data, fastcall_length *fargs){ // {{{ switch(fargs->format){ case FORMAT(binary): case FORMAT(clean): fargs->length = sizeof(action_t); return 0; default: break; } return -ENOSYS; } // }}}
void TraceDumpToFile() { if (TraceFile != nullptr) { TGuard Guard(TracingCriticalSection); DWORD Written; TDateTime N = Now(); #ifdef TRACE_IN_MEMORY_NO_FORMATTING DWORD Ticks = GetTickCount(); #endif const UnicodeString TimestampFormat = L"hh:mm:ss.zzz"; UnicodeString TimeString = FormatDateTime(TimestampFormat, N); UTF8String Buffer = UTF8String( FORMAT("[%s] Dumping in-memory tracing =================================\n", (TimeString))); WriteFile(TraceFile, Buffer.c_str(), Buffer.Length(), &Written, nullptr); TTracesInMemory::const_iterator i = TracesInMemory.begin(); while (i != TracesInMemory.end()) { #ifdef TRACE_IN_MEMORY_NO_FORMATTING const wchar_t * SourceFile = i->SourceFile; const wchar_t * Slash = wcsrchr(SourceFile, L'\\'); if (Slash != nullptr) { SourceFile = Slash + 1; } TimeString = FormatDateTime(TimestampFormat, IncMilliSecond(N, -static_cast<int>(Ticks - i->Ticks))); Buffer = UTF8String(FORMAT(L"[%s] [%.4X] [%s:%d:%s] %s\n", (TimeString, int(i->Thread), SourceFile, i->Line, i->Func, i->Message))); WriteFile(TraceFile, Buffer.c_str(), Buffer.Length(), &Written, nullptr); #else WriteFile(TraceFile, i->Message.c_str(), i->Message.Length(), &Written, nullptr); #endif ++i; } TracesInMemory.clear(); TimeString = FormatDateTime(TimestampFormat, Now()); Buffer = UTF8String( FORMAT("[%s] Done in-memory tracing =================================\n", (TimeString))); WriteFile(TraceFile, Buffer.c_str(), Buffer.Length(), &Written, nullptr); } }
static ssize_t allocator_new(allocator_fixed_t **pfdata, hash_t *config){ // {{{ ssize_t ret; data_t *sample; allocator_fixed_t *fdata; if((fdata = calloc(1, sizeof(allocator_fixed_t))) == NULL) return error("calloc failed"); pthread_rwlock_init(&fdata->rwlock, NULL); // get removed items tracker hash_holder_consume(ret, fdata->removed_items, config, HK(removed_items)); hash_holder_consume(ret, fdata->storage, config, HK(storage)); if(ret != 0){ ret = error("invalid storage supplied"); goto error; } hash_data_get(ret, TYPE_UINTT, fdata->item_size, config, HK(item_size)); if(ret != 0){ if( (sample = hash_data_find(config, HK(item_sample))) == NULL){ ret = error("no item_size nor item_sample supplied"); goto error; } fastcall_length r_len = { { 4, ACTION_LENGTH }, 0, FORMAT(binary) }; if( data_query(sample, &r_len) != 0 ){ ret = error("bad item_sample"); goto error; } fdata->item_size = r_len.length; } if(fdata->item_size == 0){ ret = error("bad item size"); goto error; } // get last id fastcall_length r_len = { { 4, ACTION_LENGTH }, 0, FORMAT(clean) }; if( data_query(&fdata->storage, &r_len) != 0){ ret = error("bad underlying storage"); goto error; } fdata->last_id = r_len.length / fdata->item_size; *pfdata = fdata; return 0; error: allocator_destroy(fdata); return ret; } // }}}
void xmpp_iq_broadcast_session_result_cb ( const char *msg_id, const char *msg, void *args ) { /* <iq from='k01.warface' to='22910345@warface/GameClient' type='get' id='1343823563'><query xmlns='urn:cryonline:k01'><data query_name='broadcast_session_result' compressedData='...' originalSize='4185'/></query></iq> */ /* <broadcast_session_result bcast_receivers='20511692@warface/GameClient,22910345@warface/GameClient,22061196@warface/GameClient,22911131@warface/GameClient,22911515@warface/GameClient'><player_result nickname='Tastan' experience='3900' pvp_rating_points='0' money='1800' gained_crown_money='0' no_crown_rewards='1' sponsor_points='0' bonus_experience='0' bonus_money='0' bonus_sponsor_points='0' experience_boost='0' money_boost='0' sponsor_points_boost='0' experience_boost_percent='0' money_boost_percent='0' sponsor_points_boost_percent='0' completed_stages='13' is_vip='0' score='44277' dynamic_multipliers_info='' dynamic_crown_multiplier='1'><profile_progression_update profile_id='1597755' mission_unlocked='none,trainingmission,easymission,normalmission,hardmission,survivalmission,zombieeasy,zombienormal,zombiehard,campaignsections,campaignsection1,campaignsection2,campaignsection3,volcanoeasy,volcanonormal,volcanohard,all' tutorial_unlocked='7' class_unlocked='29'/></player_result><player_result nickname='DevilsBitch6' experience='3900' pvp_rating_points='0' money='1800' gained_crown_money='0' no_crown_rewards='1' sponsor_points='0' bonus_experience='0' bonus_money='0' bonus_sponsor_points='0' experience_boost='0' money_boost='0' sponsor_points_boost='0' experience_boost_percent='0' money_boost_percent='0' sponsor_points_boost_percent='0' completed_stages='13' is_vip='0' score='44277' dynamic_multipliers_info='' dynamic_crown_multiplier='1'><profile_progression_update profile_id='2383428' mission_unlocked='none,trainingmission,easymission,normalmission,hardmission,survivalmission,zombieeasy,zombienormal,campaignsections,campaignsection1,campaignsection2,campaignsection3,volcanoeasy,volcanonormal,volcanohard,all' tutorial_unlocked='7' class_unlocked='5'/></player_result><player_result nickname='Nebel.' experience='3900' pvp_rating_points='0' money='2070' gained_crown_money='0' no_crown_rewards='1' sponsor_points='0' bonus_experience='0' bonus_money='0' bonus_sponsor_points='0' experience_boost='0' money_boost='270' sponsor_points_boost='0' experience_boost_percent='0' money_boost_percent='0.15' sponsor_points_boost_percent='0' completed_stages='13' is_vip='0' score='44277' dynamic_multipliers_info='' dynamic_crown_multiplier='1'><profile_progression_update profile_id='2108267' mission_unlocked='none,trainingmission,easymission,normalmission,hardmission,survivalmission,zombieeasy,zombienormal,zombiehard,campaignsections,campaignsection1,campaignsection2,campaignsection3,volcanoeasy,volcanonormal,volcanohard,all' tutorial_unlocked='7' tutorial_passed='7' class_unlocked='29'/></player_result><player_result nickname='DevilsBitch7' experience='3900' pvp_rating_points='0' money='1800' gained_crown_money='0' no_crown_rewards='1' sponsor_points='0' bonus_experience='0' bonus_money='0' bonus_sponsor_points='0' experience_boost='0' money_boost='0' sponsor_points_boost='0' experience_boost_percent='0' money_boost_percent='0' sponsor_points_boost_percent='0' completed_stages='13' is_vip='0' score='44277' dynamic_multipliers_info='' dynamic_crown_multiplier='1'><profile_progression_update profile_id='2383432' mission_unlocked='none,trainingmission,easymission,normalmission,hardmission,survivalmission,zombieeasy,zombienormal,campaignsections,campaignsection1,campaignsection2,campaignsection3,volcanoeasy,volcanonormal,volcanohard,all' tutorial_unlocked='7' class_unlocked='5'/></player_result><player_result nickname='DevilsBitch8' experience='3900' pvp_rating_points='0' money='1800' gained_crown_money='0' no_crown_rewards='1' sponsor_points='3000' bonus_experience='0' bonus_money='0' bonus_sponsor_points='0' experience_boost='0' money_boost='0' sponsor_points_boost='0' experience_boost_percent='0' money_boost_percent='0' sponsor_points_boost_percent='0' completed_stages='13' is_vip='0' score='44277' dynamic_multipliers_info='' dynamic_crown_multiplier='1'><profile_progression_update profile_id='2383439' mission_unlocked='none,trainingmission,easymission,normalmission,hardmission,zombieeasy,zombienormal,volcanoeasy,volcanonormal,volcanohard,all' tutorial_unlocked='7' class_unlocked='5'/></player_result></broadcast_session_result> */ char *data = wf_get_query_content ( msg ); char *begin; FORMAT ( begin, "player_result nickname='%s'", session.profile.nickname ); char *content = get_info ( data, begin, "</player_result>", NULL ); int xp_gained = get_info_int ( content, "experience='", "'", NULL ); int money_earned = get_info_int ( content, "money='", "'", NULL ); int crowns_earned = get_info_int ( content, "gained_crown_money='", "'", NULL ); int no_crowns = get_info_int ( content, "no_crown_rewards='", "'", NULL ); int vp_gained = get_info_int ( content, "sponsor_points='", "'", NULL ); int score = get_info_int ( content, "score='", "'", NULL ); session.profile.experience += xp_gained; session.profile.money.game += money_earned; session.profile.money.crown += crowns_earned; char *rewards; FORMAT ( rewards, "SCORE = %-8d XP = %-6d MONEY = %-6d", score, xp_gained, money_earned ); if ( vp_gained ) { char *old_rewards = strdup ( rewards ); FORMAT ( rewards, "%s VP = %-6d", old_rewards, vp_gained ); free ( old_rewards ); } if ( !no_crowns ) { char *old_rewards = strdup ( rewards ); FORMAT ( rewards, "%s CROWNS = %-6d", old_rewards, crowns_earned ); free ( old_rewards ); } LOGPRINT ( "%-20s " BOLD "%s\n", "GAME REWARDS", rewards ); LOGPRINT ( "%-20s " BOLD "%d\n", "EXPERIENCE", session.profile.experience ); LOGPRINT ( "%-20s " BOLD "%d\n", "MONEY", session.profile.money ); free ( data ); free ( content ); }
static ssize_t data_fastcall_t_convert_to(data_t *src, fastcall_convert_to *fargs){ // {{{ fastcall_t *fdata = (fastcall_t *)src->ptr; switch(fargs->format){ case FORMAT(input):; return api_convert_fastcall_to_request(fargs->dest, fdata->hargs, (f_fast_to_hash)api_pack_fastcall_callback); case FORMAT(output):; return api_convert_fastcall_to_request(fargs->dest, fdata->hargs, (f_fast_to_hash)api_pack_fastcall_callback); } return -ENOSYS; } // }}}
//--------------------------------------------------------------------- void __fastcall TFileSystemInfoDialog::Feed(TFeedFileSystemData AddItem) { AddItem(ServerView, FSINFO_REMOTE_SYSTEM, FFileSystemInfo.RemoteSystem); AddItem(ServerView, FSINFO_FS_PROTOCOL, FFileSystemInfo.ProtocolName); AddItem(ServerView, FSINFO_CRYPTOGRAPHIC_PROTOCOL, FSessionInfo.SecurityProtocolName); AddItem(ServerView, FSINFO_SSH_IMPLEMENTATION, FSessionInfo.SshImplementation); UnicodeString Str = FSessionInfo.CSCipher; if (FSessionInfo.CSCipher != FSessionInfo.SCCipher) { Str += FORMAT(L"/%s", (FSessionInfo.SCCipher)); } AddItem(ServerView, FSINFO_CIPHER, Str); Str = DefaultStr(FSessionInfo.CSCompression, LoadStr(NO_STR)); if (FSessionInfo.CSCompression != FSessionInfo.SCCompression) { Str += FORMAT(L"/%s", (DefaultStr(FSessionInfo.SCCompression, LoadStr(NO_STR)))); } AddItem(ServerView, FSINFO_COMPRESSION, Str); AddItem(HostKeyFingerprintEdit, 0, FSessionInfo.HostKeyFingerprint); AddItem(CertificateFingerprintEdit, 0, FSessionInfo.CertificateFingerprint); AddItem(ProtocolView, FSINFO_MODE_CHANGING, CapabilityStr(fcModeChanging)); AddItem(ProtocolView, FSINFO_OWNER_GROUP_CHANGING, CapabilityStr(fcGroupChanging)); UnicodeString AnyCommand; if (!FFileSystemInfo.IsCapable[fcShellAnyCommand] && FFileSystemInfo.IsCapable[fcAnyCommand]) { AnyCommand = LoadStr(FSINFO_PROTOCOL_ANY_COMMAND); } else { AnyCommand = CapabilityStr(fcAnyCommand); } AddItem(ProtocolView, FSINFO_ANY_COMMAND, AnyCommand); AddItem(ProtocolView, FSINFO_SYMBOLIC_HARD_LINK, CapabilityStr(fcSymbolicLink, fcHardLink)); AddItem(ProtocolView, FSINFO_USER_GROUP_LISTING, CapabilityStr(fcUserGroupListing)); AddItem(ProtocolView, FSINFO_REMOTE_COPY, CapabilityStr(fcRemoteCopy)); AddItem(ProtocolView, FSINFO_CHECKING_SPACE_AVAILABLE, CapabilityStr(fcCheckingSpaceAvailable)); AddItem(ProtocolView, FSINFO_CALCULATING_CHECKSUM, CapabilityStr(fcCalculatingChecksum)); AddItem(ProtocolView, FSINFO_NATIVE_TEXT_MODE, CapabilityStr(fcNativeTextMode)); AddItem(InfoMemo, 0, FFileSystemInfo.AdditionalInfo); AddItem(SpaceAvailableView, FSINFO_BYTES_ON_DEVICE, SpaceStr(FSpaceAvailable.BytesOnDevice)); AddItem(SpaceAvailableView, FSINFO_UNUSED_BYTES_ON_DEVICE, SpaceStr(FSpaceAvailable.UnusedBytesOnDevice)); AddItem(SpaceAvailableView, FSINFO_BYTES_AVAILABLE_TO_USER, SpaceStr(FSpaceAvailable.BytesAvailableToUser)); AddItem(SpaceAvailableView, FSINFO_UNUSED_BYTES_AVAILABLE_TO_USER, SpaceStr(FSpaceAvailable.UnusedBytesAvailableToUser)); AddItem(SpaceAvailableView, FSINFO_BYTES_PER_ALLOCATION_UNIT, SpaceStr(FSpaceAvailable.BytesPerAllocationUnit)); }
static ssize_t data_format_t_convert_to(data_t *src, fastcall_convert_to *fargs){ // {{{ ssize_t ret; format_t value; uintmax_t transfered; keypair_t *kp; void *iter = NULL; char *string = "(unknown)"; if(fargs->dest == NULL || src->ptr == NULL) return -EINVAL; value = *(format_t *)src->ptr; switch(fargs->format){ case FORMAT(config):; case FORMAT(clean):; case FORMAT(human):; // find in static keys first for(kp = &formats[0]; kp->key_str != NULL; kp++){ if(kp->key_val == value){ string = kp->key_str; goto found; } } #ifdef RESOLVE_DYNAMIC_KEYS // find in dynamic keys list_rdlock(&dynamic_formats); while( (kp = list_iter_next(&dynamic_formats, &iter)) != NULL){ if(kp->key_val == value){ string = kp->key_str; list_unlock(&dynamic_formats); goto found; } } list_unlock(&dynamic_formats); #endif found:; fastcall_write r_write = { { 5, ACTION_WRITE }, 0, string, strlen(string) }; ret = data_query(fargs->dest, &r_write); transfered = r_write.buffer_size; break; default: return -ENOSYS; } if(fargs->header.nargs >= 5) fargs->transfered = transfered; return ret; } // }}}
RenderPassDesc Driver::getRenderPassDesc() { auto desc = RenderPassDesc {}; auto cb_target_mask = getRegister<latte::CB_TARGET_MASK>(latte::Register::CB_TARGET_MASK); for (auto i = 0u; i < latte::MaxRenderTargets; ++i) { auto targetMask = (cb_target_mask.value >> (i * 4)) & 0xF; auto cb_color_base = getRegister<latte::CB_COLORN_BASE>(latte::Register::CB_COLOR0_BASE + i * 4); auto cb_color_info = getRegister<latte::CB_COLORN_INFO>(latte::Register::CB_COLOR0_INFO + i * 4); if (!!targetMask && cb_color_base.BASE_256B() != 0) { desc.colorTargets[i] = RenderPassDesc::ColorTarget { true, cb_color_info.FORMAT(), cb_color_info.NUMBER_TYPE(), 1 }; } else { desc.colorTargets[i] = RenderPassDesc::ColorTarget { false, latte::CB_FORMAT::COLOR_INVALID, latte::CB_NUMBER_TYPE::UNORM, 0 }; } } auto db_depth_control = getRegister<latte::DB_DEPTH_CONTROL>(latte::Register::DB_DEPTH_CONTROL); auto zEnable = db_depth_control.Z_ENABLE(); auto stencilEnable = db_depth_control.STENCIL_ENABLE(); auto depthEnabled = zEnable || stencilEnable; auto db_depth_base = getRegister<latte::DB_DEPTH_BASE>(latte::Register::DB_DEPTH_BASE); auto db_depth_info = getRegister<latte::DB_DEPTH_INFO>(latte::Register::DB_DEPTH_INFO); if (depthEnabled && db_depth_base.BASE_256B() != 0) { desc.depthTarget = RenderPassDesc::DepthStencilTarget { true, db_depth_info.FORMAT() }; } else { desc.depthTarget = { false, latte::DB_FORMAT::DEPTH_INVALID }; } return desc; }
static ssize_t data_fastcall_t_convert_from(data_t *dst, fastcall_convert_from *fargs){ // {{{ fastcall_t *fdata = (fastcall_t *)dst->ptr; switch(fargs->format){ case FORMAT(input):; return api_unpack_fastcall(fargs->src, fdata); case FORMAT(output):; return api_unpack_fastcall_output(fargs->src, fdata); } return 0; } // }}}