Example #1
0
void CStoreGroupData::operator () (SGroupData* pGroupData)
{
	ASSERT(pGroupData);
	ASSERT(pGroupData->data_vect);

	++ m_nProgressCurrent;

	m_file.WriteString("**********\n");
	m_file.WriteString(FormatStr("%d\n", m_nProgressCurrent));
	m_file.WriteString(pGroupData->time + "\n");
	m_file.WriteString(pGroupData->user + "\n");

	for (SDataVect::iterator it = pGroupData->data_vect->begin(); pGroupData->data_vect->end() != it; ++ it)
	{
		SData *&data = (*it);
		m_file.WriteString(FormatStr("%s\n%d\n", data->file, data->version));
	}

	m_file.WriteString("\n");

	if (0 == m_nProgressCurrent % 1000)
	{
		printf("\r>> %d%%", 100 * m_nProgressCurrent / m_nProgressSize);
	}
}
Example #2
0
void			TMDIChild::SetSelectDetail()
{
    //详细信息显示在右边
    memWatch->Lines->Clear();

    tagSelRect	selRect;
    if(GetTreeSelRect(selRect) == false)
        return;

    String info = FormatStr("偏移 : %d", selRect.SelStart);
    memWatch->Lines->Add(info);

    info = FormatStr("长度 : %d", selRect.SelLength);
    memWatch->Lines->Add(info);

    info = "";

    ParseTreeNode * curNode = (ParseTreeNode * )tvParseTree->Selected->Data;
    if(curNode)
    {
        if(curNode->GetClassMember()->GetType() == "char" && curNode->GetClassMember()->GetArrayVar() != "")
        {
            info = curNode->GetParseResult();
        }
    }

    info = FormatStr("信息 : %s", info);
    memWatch->Lines->Add(info);
}
Example #3
0
void			TMDIChild::RefreshStateBar()
{
    String	modeName;
    if(m_HexEditor->InsertMode)
        modeName = "插入";
    else
        modeName = "覆盖";
    sbState->Panels->Items[0]->Text = FormatStr("模式:%s", modeName);

    int iValue = m_HexEditor->SelStart;
    String hexValue = GetHexAndIntString(iValue);
    sbState->Panels->Items[1]->Text = FormatStr("偏移:%s", hexValue, iValue);


    iValue = m_HexEditor->SelCount;
    hexValue = GetHexAndIntString(iValue);
    sbState->Panels->Items[2]->Text = FormatStr("选定大小:%s", hexValue, iValue);

    hexValue = GetHexAndIntString(m_HexEditor->DataSize);
    sbState->Panels->Items[3]->Text = FormatStr("文件大小:%s", hexValue);

    iValue = 0;
    tagSelRect selRect;
    if(GetTreeSelRect(selRect))
    {
        iValue = selRect.SelLength;
    }
    hexValue = GetHexAndIntString(iValue);
    sbState->Panels->Items[4]->Text = FormatStr("选定类型长度:%s", hexValue, iValue);
}
Example #4
0
int DoHTTPProxyTunnel(STREAM *S, char *Host, int Port, int Flags)
{
char *Tempstr=NULL, *Token=NULL, *ptr=NULL;
int result=FALSE;

	if (Flags & CONNECT_SSL) Tempstr=FormatStr(Tempstr,"CONNECT https://%s:%d HTTP/1.1\r\n\r\n",Host,Port);
	else Tempstr=FormatStr(Tempstr,"CONNECT http://%s:%d HTTP/1.1\r\n\r\n",Host,Port);
	STREAMWriteLine(Tempstr,S);
	STREAMFlush(S);
	
	Tempstr=STREAMReadLine(Tempstr,S);
	StripTrailingWhitespace(Tempstr);

	ptr=GetToken(Tempstr," ",&Token,0);
	ptr=GetToken(ptr," ",&Token,0);

	if (*Token==2) result=TRUE;
	while (StrLen(Tempstr))
	{
		Tempstr=STREAMReadLine(Tempstr,S);
		StripTrailingWhitespace(Tempstr);
	}

DestroyString(Tempstr);
DestroyString(Token);

return(result);
}
bool			AuthClientUser::SendLogMessage(AnsiString msg)
{
	String warnMsg = FormatStr("%s(%s) : %s", m_UserName, m_ClientIP, String(msg));
	GetLog()->Warn(warnMsg);
	GetThreadManager()->AddGUIMessage(warnMsg);

	AnsiString sendMsg = msg;
	sendMsg.Unique();
	if(!this->SocketSendBYTE(PT_MSG))
		return false;

	if(!this->SocketSendWORD(sendMsg.Length()))
		return false;

	if(!this->SocketSendBuff(sendMsg.c_str(), sendMsg.Length()))
		return false;

	if(m_ADOQuery)
	{
		m_ADOQuery->SQL->Text = FormatStr("INSERT user_error_msg (accid, cur_time, build, ip, msg) VALUES ('%s', '%s', %d, '%s', '%s')",
										m_UserName, DateTimeToStr(Now()), m_Build, m_ClientIP, String(msg));
		ExecSQL(m_ADOQuery);
	}
//	Sleep(1000);
	return true;
}
Example #6
0
//---------------------------------------------------------------------
void			TMDIChild::SetFileDescribe(FileStruct * curFile)
{
    memInfo->Lines->Clear();
    memInfo->Lines->Add(FormatStr("描述 : %s", curFile->GetDescribe()));
    String key_str = IntToStr(int(curFile->GetKey()));
    memInfo->Lines->Add(FormatStr("Key : %s", key_str));
    memInfo->Lines->Add(FormatStr("时间 : %s", curFile->GetDateTime()));
    memInfo->Lines->Add(FormatStr("详情 : %s", curFile->GetRemark()));
}
Example #7
0
char *HTTPHeadersAppendAuth(char *RetStr, char *AuthHeader, HTTPInfoStruct *Info, HTTPAuthStruct *AuthInfo)
{
char *SendStr=NULL, *Tempstr=NULL;
char *HA1=NULL, *HA2=NULL, *ClientNonce=NULL, *Digest=NULL;
int i, AuthCounter;

if (! AuthInfo) return(RetStr);

SendStr=CatStr(RetStr,"");

	//Authentication by an opaque authentication token that is handled 
	//elsewhere, and is set as the 'Password'
  if (AuthInfo->Flags & HTTP_AUTH_TOKEN)
	{
    SendStr=MCatStr(SendStr,AuthHeader,": ",AuthInfo->Password,"\r\n",NULL);
    AuthInfo->Flags |= HTTP_SENT_AUTH;
	}
  else if (AuthInfo->Flags & HTTP_AUTH_DIGEST)
  {
    AuthCounter++;
    Tempstr=FormatStr(Tempstr,"%s:%s:%s",AuthInfo->Logon,AuthInfo->AuthRealm,AuthInfo->Password);
    HashBytes(&HA1,"md5",Tempstr,StrLen(Tempstr),0);
    Tempstr=FormatStr(Tempstr,"%s:%s",Info->Method,Info->Doc);
    HashBytes(&HA2,"md5",Tempstr,StrLen(Tempstr),0);

    for (i=0; i < 10; i++)
    {
			Tempstr=FormatStr(Tempstr,"%x",rand() % 255);
			ClientNonce=CatStr(ClientNonce,Tempstr);
    }

    Tempstr=FormatStr(Tempstr,"%s:%s:%08d:%s:auth:%s",HA1,AuthInfo->AuthNonce,AuthCounter,ClientNonce,HA2);
    HashBytes(&Digest,"md5",Tempstr,StrLen(Tempstr),0);
    Tempstr=FormatStr(Tempstr,"%s: Digest username=\"%s\",realm=\"%s\",nonce=\"%s\",uri=\"%s\",qop=auth,nc=%08d,cnonce=\"%s\",response=\"%s\"\r\n",AuthHeader,AuthInfo->Logon,AuthInfo->AuthRealm,AuthInfo->AuthNonce,Info->Doc,AuthCounter,ClientNonce,Digest);
    SendStr=CatStr(SendStr,Tempstr);
    AuthInfo->Flags |= HTTP_SENT_AUTH;
  }
  else 
  {
    Tempstr=CopyStr(Tempstr,AuthInfo->Logon);
    Tempstr=CatStr(Tempstr,":");
    Tempstr=CatStr(Tempstr,AuthInfo->Password);
    Digest=SetStrLen(Digest,StrLen(Tempstr) *2);
    to64frombits(Digest,Tempstr,strlen(Tempstr));
    SendStr=MCatStr(SendStr,AuthHeader,": Basic ",Digest,"\r\n",NULL);
    AuthInfo->Flags |= HTTP_SENT_AUTH;
  }

DestroyString(HA1);
DestroyString(HA2);
DestroyString(ClientNonce);
DestroyString(Digest);
DestroyString(Tempstr);

return(SendStr);
}
Example #8
0
STREAM *IDriveOpenFile(TFileStore *FS, TFileInfo *FI, int Flags)
{
char *URL=NULL, *Tempstr=NULL, *Boundary=NULL, *FullPath=NULL, *ptr;
HTTPInfoStruct *Info;
TFileInfo *tmpFI;

  if (Flags & OPEN_WRITE)
	{
  URL=MCopyStr(URL,"https://",FS->Host,"/evs/uploadFile",NULL);
	Info=HTTPInfoFromURL("POST",URL);
	
	Boundary=FormatStr(Boundary,"%x-%x-%x",getpid(),time(NULL),rand());
	Info->PostContentType=MCopyStr(Info->ContentType,"multipart/form-data; boundary=",Boundary,NULL);

	Tempstr=MCopyStr(Tempstr,"--",Boundary,"\r\n","Content-disposition: form-data; name=uid\r\n\r\n",FS->Logon,"\r\n",NULL);
	Tempstr=MCatStr(Tempstr,"--",Boundary,"\r\n","Content-disposition: form-data; name=pwd\r\n\r\n",FS->Passwd,"\r\n",NULL);
	Tempstr=MCatStr(Tempstr,"--",Boundary,"\r\n","Content-disposition: form-data; name=p\r\n\r\n",FS->CurrDir,"\r\n",NULL);
	//Tempstr=MCatStr(Tempstr,"--",Boundary,"\r\n","Content-disposition: form-data; name=myfiles\r\n\r\n",Path,"\r\n",NULL);
	Tempstr=MCatStr(Tempstr,"--",Boundary,"\r\n","Content-disposition: form-data; charset=UTF-8; name=definition; filename=",FI->Path,"\r\nContent-type: image/jpeg\r\n\r\n",NULL);

	Info->PostContentLength=FI->Size+StrLen(Tempstr)+StrLen(Boundary)+8;
	FS->S=HTTPTransact(Info);
	FS->Extra=Info;

	STREAMWriteLine(Tempstr,FS->S);
	STREAMSetValue(FS->S,"Boundary",Boundary);
	Tempstr=FormatStr(Tempstr,"%d",FI->Size);
	STREAMSetValue(FS->S,"Transfer-Size",Tempstr);
	}
	else
	{
			if (*FI->Path=='/') FullPath=CopyStr(FullPath,FI->Path);
			else FullPath=MCopyStr(FullPath,FS->CurrDir,FI->Path,NULL);

			Tempstr=HTTPQuote(Tempstr,FullPath);

//		if (OpenFI->Version) FI=OpenFI;
//		else FI=FileStoreGetFileInfo(FS, FI->Path);

		  URL=FormatStr(URL,"https://%s/evs/downloadFile?uid=%s&pwd=%s&p=%s&version=%d",FS->Host,FS->Logon,FS->Passwd,Tempstr,FI->Version);
			FS->S=HTTPMethod("POST",URL,"","","","",0);
			FS->Extra=NULL;
//		if (FI != OpenFI) FileInfoDestroy(FI);
	}

	DestroyString(URL);
	DestroyString(FullPath);
	DestroyString(Tempstr);
	DestroyString(Boundary);

   return(FS->S);
}
	pplx::task<http::http_response> RealSteamDataConnection::GetMessages(int baseMessage, const wchar_t * pwzSteamID, bool fSecure)
	{
		std::string strPostData;

		if (fSecure)
			strPostData = FormatStr(STEAM_CHAT_POLL_POST_DATA_FMT_SZ, GetAccessToken(), pwzSteamID, GetUMQID(), baseMessage);
		else
			strPostData = FormatStr(STEAM_CHAT_POLLSTATUS_POST_DATA_FMT_SZ, pwzSteamID, GetUMQID(), baseMessage);

		http::client::http_client  client(fSecure ? STEAM_POST_OAUTH_POLL_URI : STEAM_POST_OAUTH_POLLSTATUS_URI);
		http::http_request         request = CreateHttpPostRequest(strPostData);

		return client.request(request);
	}
void DisplayTransferStatus(char *Line, unsigned int transferred, unsigned int total, unsigned int *percent, unsigned int secs,int CmdFlags, int Throttle)
{
int result=0, cols=80, bps=0;
char *Tempstr=NULL, *TimeStr=NULL, *ptr=NULL;
static int ThrotCount=0;
struct winsize w;


	if (Settings.Flags & FLAG_QUIET) return;
	if (CmdFlags & FLAG_QUIET) return;
	if (! isatty(1)) return;

	ptr=getenv("COLUMNS");
	if (ptr) cols=atoi(ptr);
	printf("\r");
	if (total==0) Tempstr=FormatStr(Tempstr,"%s bytes sent ",GetHumanReadableDataQty(transferred,0));
	else
	{
	result=(transferred * 100) / total;
//	if (result != *percent)
	{
		Tempstr=FormatStr(Tempstr,"%d%% %s of ",result,GetHumanReadableDataQty(transferred,0));
		Tempstr=CatStr(Tempstr,GetHumanReadableDataQty(total,0));
	}
	*percent=result;
	}

bps=transferred / secs;
TimeStr=FormatStr(TimeStr," in %d secs %s Bps ",secs,GetHumanReadableDataQty(bps,0) );

if ((Throttle > 0) && (bps > Throttle)) 
{
	ThrotCount++;
	usleep(ThrotCount * 250000);
}
else if (ThrotCount > 0) ThrotCount--;

if (ThrotCount > 0) Tempstr=MCatStr(Tempstr,TimeStr, Line, " (throttling)      ",NULL);
else Tempstr=MCatStr(Tempstr,TimeStr, Line, "           ",NULL);


ioctl(0, TIOCGWINSZ, &w);
if (StrLen(Tempstr) > w.ws_col) Tempstr[w.ws_col]='\0';

printf("%s",Tempstr);
fflush(NULL);

DestroyString(TimeStr);
DestroyString(Tempstr);
}
Example #11
0
main()
{
char *Tempstr=NULL;
ListNode *Vars, *Streams;
STREAM *S;
int i;
char *IP[]={"217.33.140.70","8.8.8.8","4.2.2.1","88.198.48.36",NULL};

Vars=ListCreate();
Streams=ListCreate();
MessageBusRegister("proc:tester.test.func", 4, 10, Tester);
MessageBusRegister("http://freegeoip.net/xml/", 4, 10, NULL);

printf("PARENT: %d\n",getpid());
for (i=0; i < 4; i++)
{
Tempstr=FormatStr(Tempstr,"string=hello&integer=%d",i);
MessageBusWrite("proc:tester.test.func", Tempstr);
MessageBusWrite("http://freegeoip.net/xml/", IP[i]);

MessageQueueAddToSelect(Streams);
S=STREAMSelect(Streams, NULL);
if (S) 
{
	MessageBusRecv(S, &Tempstr, Vars);
	DumpVars(Vars);
}
else printf("NO ACTIVITY!\n");
sleep(1);
}


}
Example #12
0
const char *OpenSSLQueryCipher(STREAM *S)
{
void *ptr;

if (! S) return(NULL);
ptr=STREAMGetItem(S,"LIBUSEFUL-SSL-CTX");
if (! ptr) return(NULL);

#ifdef HAVE_LIBSSL
const SSL_CIPHER *Cipher;
char *Tempstr=NULL;

Cipher=SSL_get_current_cipher((const SSL *) ptr);

if (Cipher)
{
Tempstr=FormatStr(Tempstr,"%d bit %s",SSL_CIPHER_get_bits(Cipher,NULL), SSL_CIPHER_get_name(Cipher));
STREAMSetValue(S,"SSL-Cipher",Tempstr);

Tempstr=SetStrLen(Tempstr,1024);
Tempstr=SSL_CIPHER_description(Cipher, Tempstr, 1024);


STREAMSetValue(S,"SSL-Cipher-Details",Tempstr);
}

DestroyString(Tempstr);
return(STREAMGetValue(S,"SSL-Cipher"));

#else
return(NULL);
#endif
}
Example #13
0
int DoHTTPProxyTunnel(STREAM *S, const char *Host, int Port, const char *Destination, int Flags)
{
char *Tempstr=NULL, *Token=NULL;
const char *ptr=NULL;
int result=FALSE;

	S->in_fd=ConnectToHost(Host,Port,0); 
	S->out_fd=S->in_fd;
	if (S->in_fd == -1) return(FALSE);

	ptr=Destination;
	if (strncmp(ptr,"tcp:",4)==0) ptr+=4;
	Tempstr=FormatStr(Tempstr,"CONNECT %s HTTP/1.1\r\n\r\n",ptr);

	STREAMWriteLine(Tempstr,S);
	STREAMFlush(S);
	
	Tempstr=STREAMReadLine(Tempstr,S);
	StripTrailingWhitespace(Tempstr);

	ptr=GetToken(Tempstr," ",&Token,0);
	ptr=GetToken(ptr," ",&Token,0);

	if (*Token=='2') result=TRUE;
	while (StrLen(Tempstr))
	{
		Tempstr=STREAMReadLine(Tempstr,S);
		StripTrailingWhitespace(Tempstr);
	}

DestroyString(Tempstr);
DestroyString(Token);

return(result);
}
Example #14
0
STREAM *STREAMSpawnFunction(BASIC_FUNC Func, void *Data, const char *Config)
{
    int to_fd, from_fd, *iptr;
    pid_t pid=0;
    STREAM *S=NULL;
    char *Tempstr=NULL;
    int Flags=0;

    Flags=TTYParseConfig(Config, NULL);
    if (Flags & TTYFLAG_PTY)
    {
        pid=PseudoTTYSpawnFunction(&to_fd, Func, Data, Flags, Config);
        from_fd=to_fd;
    }
    else
    {
        iptr=NULL;
        //if (Flags & COMMS_COMBINE_STDERR) iptr=(int *) COMMS_COMBINE_STDERR;
        pid=PipeSpawnFunction(&to_fd, &from_fd, iptr, Func, Data, Config);
    }

    if (pid > 0) S=STREAMFromDualFD(from_fd, to_fd);
    if (S)
    {
        STREAMSetFlushType(S,FLUSH_LINE,0,0);
        Tempstr=FormatStr(Tempstr,"%d",pid);
        STREAMSetValue(S,"PeerPID",Tempstr);
        S->Type=STREAM_TYPE_PIPE;
    }

    DestroyString(Tempstr);
    return(S);
}
Example #15
0
void __fastcall TDesignFrm::btStartNewClick(TObject *Sender)
{
    if(SourceGenDesignFrm->StartDesign() == false)
        return;

    String  fileName, head, subHead;
    m_WorkSpaceManager->BeginUpdate();
    for(int i=0; i<SourceGenDesignFrm->GetHeadCount(); i++)
    {
        for(int j=0; j<SourceGenDesignFrm->GetSubHeadCount(); j++)
        {
            head = IntToHex(i+1, 2);
            subHead = IntToHex(j+1, 2);
            fileName = FormatStr("Pack_%s_%s.eggxp", head, subHead);
            WorkSpace	*  selWorkSpace = m_WorkSpaceManager->CreateNewWorkSpace();
            selWorkSpace->InitWorkSpace(m_WorkSpaceManager->GetFilePath(),
						fileName, head + " " + subHead);

			selWorkSpace->GetFileManager()->CreateNew();
            selWorkSpace->SaveToFile();            
        }
    }

    m_WorkSpaceManager->ReloadWorkSpacePack();
    WorkspaceToGUI();
    m_WorkSpaceManager->EndUpdate();
}
Example #16
0
char *FinalizeDirListHTML(char *Buffer, HTTPSession *Session, const char *Path, const char *DirItemsHtml, const char *MimeIconsURL, int Flags)
{
char *HTML=NULL;

	HTML=FormatStr(Buffer,"<html>\r\n<head><title>/%s%s</title></head>\r\n<body>\r\n",Session->Host, Session->URL);

	if ((Flags & DIR_FANCY))
	{
		if (Flags & DIR_INTERACTIVE) HTML=CatStr(HTML,"<form>\r\n");

		HTML=CatStr(HTML,"<table align=center border=0><tr>\n");
		if (Settings.Flags & FLAG_SSL) HTML=MCatStr(HTML,"<td><font color=green size=-1>SECURE<br/>",Session->Cipher,"</font></td>\n",NULL);
		else HTML=MCatStr(HTML,"<td><font color=red size=-1>Unencrypted<br/>Connection</font></td>\n",NULL);

		HTML=MCatStr(HTML,"<td><b>",Session->URL,"</b> at ",Session->Host, " <i>",GetDateStrFromSecs("%Y/%m/%d %H:%M:%S",Now,NULL),"</i><br/>",NULL);

		HTML=DisplayDirActions(HTML,Session,Flags);
		HTML=CatStr(HTML,"</td>\n");


		HTML=MCatStr(HTML,"<td>User: "******"<br/>",NULL);
		if (Settings.Flags & FLAG_LOGOUT_AVAILABLE) HTML=MCatStr(HTML,"<a href=\"",GetLogoutPath(),"\">( Logout )</a>",NULL);
		HTML=CatStr(HTML,"</td></tr></table>\n");
	}
	HTML=MCatStr(HTML,DirItemsHtml,"<br />&nbsp;<br />",NULL);
	if (Flags & DIR_INTERACTIVE) HTML=CatStr(HTML,"</form>\r\n");
	HTML=CatStr(HTML,"</body></html>\r\n");

return(HTML);
}
Example #17
0
void __fastcall TDesignFrm::btDeleteSubHeadClick(TObject *Sender)
{
    String fileName = vleSubHeadDef->Keys[vleSubHeadDef->Row];

    int result = Application->MessageBox(FormatStr(L"当真要删除文件 : %s(此操作不可恢复)", fileName).c_str(),L"删除询问",MB_OKCANCEL);
    if(result == IDCANCEL)
    {
        return;
    }

    WorkPackHead * curWorkPackHead = m_WorkSpaceManager->GetWorkSpacePacks()->FindWorkPack(vleHeadDef->Keys[vleHeadDef->Row]);

    if(curWorkPackHead == NULL)
        return;

    WorkSpace	*  selWorkSpace;
    for(int i=0; i<curWorkPackHead->m_Files.Count(); i++)
    {
        if(curWorkPackHead->m_Files[i]->GetFileName() == fileName)
        {
            selWorkSpace = curWorkPackHead->m_Files[i];
            break;
        }
    }
    m_WorkSpaceManager->DeleteWorkSpace(selWorkSpace);
    m_WorkSpaceManager->ReloadWorkSpacePack();
    WorkspaceToGUI();
}
Example #18
0
void __fastcall TDesignFrm::btClearHeadDefClick(TObject *Sender)
{
    int result = Application->MessageBox(L"这个清空动作会清空所有文件!  是否继续?",L"删除询问",MB_OKCANCEL);
    if(result == IDCANCEL)
    {
        return;
    }

    m_WorkSpaceManager->BeginUpdate();
    for(int i=m_WorkSpaceManager->GetWorkSpaceCount()-1; i>=0; i--)
    {
        m_WorkSpaceManager->DeleteWorkSpace(i);
    }


    //添加一条新数据
    String  head = IntToHex(0, 2);
    String  subHead = IntToHex(0, 2);
    String  fileName = FormatStr("Pack_%s_%s.eggxp", head, subHead);
    WorkSpace	*  selWorkSpace = m_WorkSpaceManager->CreateNewWorkSpace();
    selWorkSpace->InitWorkSpace(m_WorkSpaceManager->GetFilePath(),
				fileName, head);

	selWorkSpace->GetFileManager()->CreateNew();
	selWorkSpace->SaveToFile();

	m_WorkSpaceManager->ReloadWorkSpacePack();

	WorkspaceToGUI();
	m_WorkSpaceManager->EndUpdate();
}
Example #19
0
HTTPSession *FileSendCreateSession(char *Path, HTTPSession *Request, ListNode *Vars, int ICYInterval)
{
	HTTPSession *Session;
	char *Tempstr=NULL;

	Session=HTTPSessionResponse(Request);
	Session->ResponseCode=CopyStr(Session->ResponseCode,"200 OK");
	Session->ContentType=CopyStr(Session->ContentType,GetVar(Vars,"ContentType"));
	Session->LastModified=atoi(GetVar(Vars,"MTime-secs"));
	Session->ContentSize=atoi(GetVar(Vars,"FileSize"));

	if (Session->Flags & SESSION_ICECAST) 
	{
		Session->Flags |= SESSION_ICECAST;
		Session->Protocol=CopyStr(Session->Protocol,"ICY");
		Tempstr=FormatStr(Tempstr,"%d",ICYInterval);
		SetVar(Session->Headers,"icy-metaint",Tempstr);
	}
	else if (HTTPServerDecideToCompress(Request,Path))
	{
		Session->ContentSize=0;
		Session->Flags |= SESSION_ENCODE_GZIP;
	}

	DestroyString(Tempstr);
	return(Session);
}
Example #20
0
char *HTTPQuoteChars(char *RetBuff, char *Str, char *CharList)
{
char *RetStr=NULL, *Token=NULL, *ptr;
int olen=0, ilen;

RetStr=CopyStr(RetStr,"");
ilen=StrLen(Str);

for (ptr=Str; ptr < (Str+ilen); ptr++)
{
if (strchr(CharList,*ptr))
{
		Token=FormatStr(Token,"%%%02X",*ptr); 
		RetStr=CatStr(RetStr,Token);
		olen+=StrLen(Token);
}
else
{
		 RetStr=AddCharToBuffer(RetStr,olen,*ptr); 
		 olen++;
}
}


RetStr[olen]='\0';
DestroyString(Token);
return(RetStr);
}
Example #21
0
void __fastcall 	TMDIChild::FastParseExecute(TObject *Sender)
{
    TMenuItem * selMenu = (TMenuItem * )Sender;
    String typeName = selMenu->Caption;

    //修正typeName
    if(selMenu->Caption == "-")
        return;

    if(typeName.Pos("["))
        typeName = LeftString(typeName, "[");

    ClassData * curClass = GetCurParseClass();

//	bool	haveResult = false;
    String 	defaultName;
    if(curClass == NULL)
    {
        //当前无结构体, 新建结构体
        int classCount = m_WorkSpace->GetClassManager()->GetClassCount();
        defaultName = FormatStr("tagUnNamedStruct%d", classCount);

        curClass = m_WorkSpace->GetClassManager()->AddClass();
        curClass->Init(defaultName, "");
        RefreshAllClassView();
    }

    String arrayVar;
    if(selMenu->Tag == 0)
        arrayVar = "";
    else
        arrayVar = IntToStr(selMenu->Tag);

    ClassMember * curMember = curClass->AddMember();
    defaultName = FormatStr("UnKnown%d", m_ParseTree->GetSize() + m_FastParsePos);

    curMember->Init(typeName, defaultName, "", arrayVar);

    m_ParseTree->BindClass(curClass);
    ExpandFirstNode();
    ParseData(false);

    tagSelRect	selRect;
    if(GetTreeSelRect(selRect) == false)
        return;
    GotoPosition(selRect.SelStart + selRect.SelLength);
}
Example #22
0
main()
{
char *Tempstr=NULL;

Tempstr=FormatStr(Tempstr,"%s %n","test",100);
printf("%s\n",Tempstr);

}
Example #23
0
void __fastcall TMDIChild::actCopyAsListExecute(TObject *Sender)
{
    char	*pointer = m_HexEditor->GetFastPointer(0, m_HexEditor->DataSize);
    int selStart = m_HexEditor->SelStart;
    int selLength = m_HexEditor->SelCount;

    String	arrayStr;
    for(int i=0; i<selLength; i++)
    {
        if(i != selLength - 1)
            arrayStr += FormatStr("0x%s, ", BinToStr(pointer + selStart + i, 1));
        else
            arrayStr += FormatStr("0x%s", BinToStr(pointer + selStart + i, 1));
    }
    String result = FormatStr("char arrayData[%d] = {\r\n\t%s};", selLength, arrayStr);
    Clipboard()->AsText = result;
}
Example #24
0
void HandleCompareResult(TFileInfo *FI, int CmdFlags, int CompareLevel, char *Hook, int result)
{
char *ResultStr=NULL, *Tempstr=NULL;

	if (result >= CompareLevel) 
	{
		if (CmdFlags & FLAG_CMD_QUIET) /*Do nothing in quiet mode */  ; 
		else if (result==CMP_DIR)  /*Do nothing with dirs */ ;
		else ResultStr=CopyStr(ResultStr,"MATCHES");
	}
	else switch (result)
	{
		case CMP_FAIL:
			ResultStr=CopyStr(ResultStr,"LOCAL ONLY");
		break;

		case CMP_REMOTE:
			ResultStr=CopyStr(ResultStr,"REMOTE ONLY");
		break;

		case CMP_DIR:
		break;

		case CMP_EXISTS:
			ResultStr=CopyStr(ResultStr,"DIFFERS");
		break;

		case CMP_SIZE:
			ResultStr=CopyStr(ResultStr,"Size Matches");
		break;

		case CMP_SIZE_TIME:
			ResultStr=CopyStr(ResultStr,"Size + Time Matches");
		break;

		case CMP_MD5:
			ResultStr=CopyStr(ResultStr,"MD5 Hash Matches");
		break;

		case CMP_SHA1:
			ResultStr=CopyStr(ResultStr,"SHA1 Hash Matches");
		break;

	}

if (StrLen(ResultStr))
{
	printf("%s: %s\n",ResultStr,FI->Path);
	if (StrLen(Hook)) 
	{
		Tempstr=FormatStr(Tempstr,"%s '%s' '%s'",Hook,FI->Path,ResultStr);
		system(Tempstr);
	}
}

DestroyString(Tempstr);
DestroyString(ResultStr);
}
Example #25
0
	pplx::task<http::http_response> RealSteamDataConnection::ChatLogin()
	{
		std::string strPostData = FormatStr(STEAM_CHAT_LOGIN_POST_DATA_FMT_SZ, GetAccessToken(), GetUMQID());

		http::client::http_client  client(STEAM_POST_OAUTH_CHAT_LOGON_URI);
		http::http_request         request = CreateHttpPostRequest(strPostData);

		return client.request(request);
	}
Example #26
0
void __fastcall TWOWFisherMain::lvFishResultData(TObject *Sender, TListItem *Item)
{
	shared_ptr<DataObject> curObj = GetGameWorld()->GetDataByKey("fish_results")->GetAt(Item->Index);
	DWORD itemID = curObj->GetKeyName().ToIntDef(0);
	DWORD cnt = curObj->AsInt();
	Item->Caption = GetGameWorld()->GetItemNameByID(itemID);
	Item->SubItems->Add(cnt);
	Item->SubItems->Add(FormatStr("%s%%", curObj->GetDataObject("percent")->AsString()));
}
Example #27
0
void __fastcall TWOWFisherMain::btAuthClick(TObject *Sender)
{
	memLog->Lines->Clear();
	DWORD addr = 0;
	DWORD offset = 0;
	String username = "******";
	LogMsg(FormatStr("验证:用户名(%s)", username));
	if(!GetClientAuth()->BeginAuth(username, 11159, &addr, &offset))
	{
		LogMsg("验证失败了");
		return;
	}

	GetSharedMemInfo()->FindSelf()->BaseAddr = addr;
	GetSharedMemInfo()->FindSelf()->BaseAddrOffset = offset;
//	proxy->ServerAuthOKBeginProxy();
	LogMsg(FormatStr("验证成功addr:0x%x, offset:0x%x", addr, offset));
}
Example #28
0
int ProxyControlConnect(TSession *Session, char *Host, int Port)
{
char *Tempstr=NULL;
int fd, result=FALSE;

if (StrLen(Host)==0) 
{
	SendLoggedLine(Session,"421 ERROR: Proxy cannot connect. No destination host.");
}
else 
{
Tempstr=IPCRequest(Tempstr, Session, "GetIP", Host);

   if (strcmp(Tempstr,"DENIED")==0)
   {
      Tempstr=FormatStr(Tempstr,"421 ERROR: Proxy connection denied for host %s:%d",Host,Port);
      SendLoggedLine(Session,Tempstr);

   }
   else
  {
      fd=ConnectToHost(Tempstr,Port,FALSE);
      if (fd==-1)
      {
      	Tempstr=FormatStr(Tempstr,"421 ERROR: Proxy cannot connect to host %s:%d",Host,Port);
        SendLoggedLine(Session,Tempstr);
      }
			else
			{
     	 Session->ProxySock=STREAMFromFD(fd);
     	 result=TRUE;
     	 do
     	 {
     	  Tempstr=STREAMReadLine(Tempstr,Session->ProxySock);
     	  STREAMWriteLine(Tempstr,Session->ClientSock);
     	 } while ( (Tempstr[3]=='-') || (isspace(Tempstr[0])) );
			STREAMFlush(Session->ClientSock);
			}
  }
}

DestroyString(Tempstr);
return(result);
}
Example #29
0
int GrabPseudoTTY(int *pty, int *tty)
{
char c1,c2;
char *Buffer=NULL;

//first try unix98 style
*pty=open("/dev/ptmx",O_RDWR);
if (*pty > -1)
{
	grantpt(*pty);
	unlockpt(*pty);
	if ( (*tty=open((char *) ptsname(*pty),O_RDWR)) >-1)
	{
		InitTTY(*tty,0,0);
		return(1);
	}
	
}

//if unix98 fails, try old BSD style

for (c1='p'; c1 < 's'; c1++)
{
  for (c2='5'; c2 <='9'; c2++)
  {
   Buffer=FormatStr(Buffer,"/dev/pty%c%c",c1,c2);
   if ( (*pty=open(Buffer,O_RDWR)) >-1)
   {
      Buffer=FormatStr(Buffer,"/dev/tty%c%c",c1,c2);
      if ( (*tty=OpenTTY(Buffer,0,0)) >-1)
      {
				DestroyString(Buffer);
        return(1);
      }
      else close(*pty);
   }

  }

}

DestroyString(Buffer);
return(0);
}
String			GetFileNameByDate(String name, String ext)
{
	String curTime = Now();
    TReplaceFlags   flag;
    flag << rfReplaceAll;
	curTime = StringReplace(curTime, "/", "_", flag);
	curTime = StringReplace(curTime, ":", "_", flag);
	curTime = StringReplace(curTime, " ", "_", flag);
	return	FormatStr("%s_%s.%s", name, curTime, ext);
}