Exemplo n.º 1
0
static void TextHnd(void *userData, const char *s, int len)
{
    wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
    char *buf = new char[len + 1];

    buf[len] = '\0';
    memcpy(buf, s, (size_t)len);

    if (ctx->lastAsText)
    {
        ctx->lastAsText->SetContent(ctx->lastAsText->GetContent() +
                                    CharToString(ctx->conv, buf));
    }
    else
    {
        bool whiteOnly = true;
        for (char *c = buf; *c != '\0'; c++)
            if (*c != ' ' && *c != '\t' && *c != '\n' && *c != '\r')
            {
                whiteOnly = false;
                break;
            }
        if (!whiteOnly)
        {
            ctx->lastAsText = new wxXmlNode(wxXML_TEXT_NODE, wxT("text"),
                                            CharToString(ctx->conv, buf));
            ctx->node->AddChild(ctx->lastAsText);
        }
    }

    delete[] buf;
}
Exemplo n.º 2
0
static void StartElementHnd(void *userData, const char *name, const char **atts)
{
    wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
    wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, CharToString(ctx->conv, name));
    const char **a = atts;
    while (*a)
    {
        node->AddProperty(CharToString(ctx->conv, a[0]), CharToString(ctx->conv, a[1]));
        a += 2;
    }
    if (ctx->root == NULL)
    {
        ctx->root = node;
    }
    else
    {
        ASSERT_LAST_CHILD_OK(ctx);
        ctx->node->InsertChildAfter(node, ctx->lastChild);
    }

    ctx->lastAsText = NULL;
    ctx->lastChild = NULL; // our new node "node" has no children yet

    ctx->node = node;
}
Exemplo n.º 3
0
static void PIHnd(void *userData, const char *target, const char *data)
{
    wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;

    wxXmlNode *pinode =
        new wxXmlNode(wxXML_PI_NODE, CharToString(ctx->conv, target),
                      CharToString(ctx->conv, data),
                      XML_GetCurrentLineNumber(ctx->parser));

    ASSERT_LAST_CHILD_OK(ctx);
    ctx->node->InsertChildAfter(pinode, ctx->lastChild);
    ctx->lastChild = pinode;
    ctx->lastAsText = NULL;
}
Exemplo n.º 4
0
static void TextHnd(void *userData, const char *s, int len)
{
    wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
    wxString str = CharToString(ctx->conv, s, len);

    if (ctx->lastAsText)
    {
        ctx->lastAsText->SetContent(ctx->lastAsText->GetContent() + str);
    }
    else
    {
        bool whiteOnly = false;
        if (ctx->removeWhiteOnlyNodes)
            whiteOnly = wxIsWhiteOnly(str);

        if (!whiteOnly)
        {
            wxXmlNode *textnode =
                new wxXmlNode(wxXML_TEXT_NODE, wxT("text"), str);

            ASSERT_LAST_CHILD_OK(ctx);
            ctx->node->InsertChildAfter(textnode, ctx->lastChild);
            ctx->lastChild= ctx->lastAsText = textnode;
        }
    }
}
Exemplo n.º 5
0
inline std::string Tile::WriteTileDataToXML(XMLNode& xmlNode){
	UNUSED(xmlNode);
	std::string tileDetailString;
	tileDetailString += CharToString(GetTileDetailsForTileType());

	return tileDetailString;
}
Exemplo n.º 6
0
static void StartElementHnd(void *userData, const char *name, const char **atts) {

    XmlParsingContext *ctx = (XmlParsingContext*)userData;
    CXmlNode *node = new CXmlNode(XML_ELEMENT_NODE, CharToString(name));
    const char **a = atts;
    while (*a) {
        node->AddProperty(CharToString(a[0]), CharToString(a[1]));
        a += 2;
    }
    if (ctx->root == NULL)
        ctx->root = node;
    else
        ctx->node->AddChild(node);
    ctx->node = node;
    ctx->lastAsText = NULL;
}
Exemplo n.º 7
0
inline std::string Tile::WriteTileStateDataToXML(XMLNode& xmlNode){
	UNUSED(xmlNode);
	std::string tileDetailString;
	if (m_tileState.visibility.m_hasBeenSeen)
		tileDetailString = CharToString(GetTileDetailsForTileType());
	else
		tileDetailString = "?";

	return tileDetailString;
}
Exemplo n.º 8
0
static void CommentHnd(void *userData, const char *data)
{
    XmlParsingContext *ctx = (XmlParsingContext*)userData;
#if 0

    if (ctx->node) {
        ctx->node->AddChild(new CXmlNode(XML_COMMENT_NODE,
                            "comment", CharToString(data)));
    }
#endif 
    ctx->lastAsText = NULL;
}
Exemplo n.º 9
0
static void CommentHnd(void *userData, const char *data)
{
    wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;

    wxXmlNode *commentnode =
        new wxXmlNode(wxXML_COMMENT_NODE,
                      wxS("comment"), CharToString(ctx->conv, data),
                      XML_GetCurrentLineNumber(ctx->parser));

    ASSERT_LAST_CHILD_OK(ctx);
    ctx->node->InsertChildAfter(commentnode, ctx->lastChild);
    ctx->lastChild = commentnode;
    ctx->lastAsText = NULL;
}
Exemplo n.º 10
0
static void StartElementHnd(void *userData, const char *name, const char **atts)
{
    wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;
    wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE,
                                    CharToString(ctx->conv, name),
                                    wxEmptyString,
                                    XML_GetCurrentLineNumber(ctx->parser));
    const char **a = atts;

    // add node attributes
    while (*a)
    {
        node->AddAttribute(CharToString(ctx->conv, a[0]), CharToString(ctx->conv, a[1]));
        a += 2;
    }

    ASSERT_LAST_CHILD_OK(ctx);
    ctx->node->InsertChildAfter(node, ctx->lastChild);
    ctx->lastAsText = NULL;
    ctx->lastChild = NULL; // our new node "node" has no children yet

    ctx->node = node;
}
Exemplo n.º 11
0
static void CommentHnd(void *userData, const char *data)
{
    wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;

    if (ctx->node)
    {
        // VS: ctx->node == NULL happens if there is a comment before
        //     the root element (e.g. wxDesigner's output). We ignore such
        //     comments, no big deal...
        ctx->node->AddChild(new wxXmlNode(wxXML_COMMENT_NODE,
                            wxT("comment"), CharToString(ctx->conv, data)));
    }
    ctx->lastAsText = NULL;
}
Exemplo n.º 12
0
CSocket* Connect(CSocket* socket,CDlgMain* dlg,char* buffer,bool auth,CDlgSettings* dlg2)
{
	if(socket)
	{
		dlg->console+=_T("\r\nDisconnecting...");
		dlg->UpdateData(FALSE);
		ScrollToBottom(dlg);

		Send(socket,dlg,"QUIT");
		Receive(socket,dlg,buffer);
		delete socket;
		socket = NULL;
	}

	dlg->console+=_T("\r\nConnecting...");
	dlg->UpdateData(FALSE);
	ScrollToBottom(dlg);

	socket = new CSocket;
	//dlg->socket = socket;
	socket->Create();
	if(socket->Connect(dlg2->set_serveraddress,25))
	{
		dlg->console+=_T("OK");
		dlg->UpdateData(FALSE);
		ScrollToBottom(dlg);
		Receive(socket,dlg,buffer);

		int pos1 = FindStr(buffer," ",1);
		int pos2 = FindStr(buffer," ",pos1+1);
		
		if((pos1!=-1)&&(pos2!=-1))
			dlg->res_domain = CharToString(MidStr(buffer,pos1+1,pos2));
		else
			dlg->res_domain = dlg2->set_serveraddress;

		//dlg->MessageBox(dlg->res_domain);
	}
	else
	{
		dlg->console+=_T("ERROR!");
		ShowError(socket,dlg);
		delete socket;
		socket = NULL;
	}

	return socket;
}
Exemplo n.º 13
0
static void DefaultHnd(void *userData, const char *s, int len)
{
    // XML header:
    if (len > 6 && memcmp(s, "<?xml ", 6) == 0)
    {
        wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;

        wxString buf = CharToString(ctx->conv, s, (size_t)len);
        int pos;
        pos = buf.Find(wxT("encoding="));
        if (pos != wxNOT_FOUND)
            ctx->encoding = buf.Mid(pos + 10).BeforeFirst(buf[(size_t)pos+9]);
        pos = buf.Find(wxT("version="));
        if (pos != wxNOT_FOUND)
            ctx->version = buf.Mid(pos + 9).BeforeFirst(buf[(size_t)pos+8]);
    }
}
Exemplo n.º 14
0
static void CommentHnd(void *userData, const char *data)
{
    wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData;

    if (ctx->node)
    {
        // VS: ctx->node == NULL happens if there is a comment before
        //     the root element (e.g. wxDesigner's output). We ignore such
        //     comments, no big deal...
        wxXmlNode *commentnode =
            new wxXmlNode(wxXML_COMMENT_NODE,
                          wxT("comment"), CharToString(ctx->conv, data));
        ASSERT_LAST_CHILD_OK(ctx);
        ctx->node->InsertChildAfter(commentnode, ctx->lastChild);
        ctx->lastChild = commentnode;
    }
    ctx->lastAsText = NULL;
}
Exemplo n.º 15
0
string GetNextToken(void)
	{
	char ch;
	int start;
	string result;
	
	/* Check for error condition: */
	if(cpos >= buflen)
		Error("No more tokens");
	
	/* Depending on the package mode, we have to skip
	   whitespace characters: */
	skipWhitespaceCharacters();

	/* Retrieve the next character: */
	ch = IthChar(buffer, cpos);
	
	/* Based on that character, either scan a string or return the character: */
	if(isalnum(ch)) /* Character is alphanumeric: */
		{
		/* Remember the start of the string: */
		start = cpos;
		
		/* Iterate until a non-alphanumeric character is encountered: */
		while(cpos < buflen && isalnum(IthChar(buffer, cpos)))
			++cpos;
		
		/* Return the substring from start to the current character position: */
		result = SubString(buffer, start, cpos - 1);
		}
	else /* Character is not alphanumeric: */
		{
		++cpos;
		result = CharToString(ch);
		}
	
	/* Depending on the package mode, we have to skip
	   whitespace characters again: */
	skipWhitespaceCharacters();

	return result;
	}
void CArecsDlg::OnBnClickedButton3()
{
	// TODO: Add your control notification handler code here
	CString filters = _T("Text files (*.txt)|*.txt|All Files (*.*)|*.*||");

	CFileDialog fileDlg(TRUE,_T("Text files (*.txt)"), _T("*.txt"),
		OFN_FILEMUSTEXIST| OFN_HIDEREADONLY,filters,this);

    if(fileDlg.DoModal()==IDOK)
    {
	    CString path = fileDlg.GetPathName();

		dict.RemoveAll();
   
		int i;
		FILE * pFile;
		char* result;
		char line[1024+1];
		pFile = fopen(StringToChar(path), "r");
		if(pFile!=NULL)
		{
			while(true)
			{
				result = fgets(line,1024,pFile);
				i=0;
				while((line[i]!='\0')&&(line[i]!='\r')&&(line[i]!='\n'))
					i++;

				line[i] = '\0';

				dict.AddTail(CharToString(line));

				if (feof(pFile))
					break;
			}
			fclose(pFile);
		}
    }

}
Exemplo n.º 17
0
bool BlacklistTest(CDlgMain* dlg,CURL* curl,thread_status* this_struct)
{
	dlg->console+=_T("\r\n*Retrieving Blacklist record.");
	dlg->UpdateData(FALSE);
	ScrollToBottom(dlg);

	CURLcode result; 

	CString temp = _T("q=");
	CString temp2;
	temp+=dlg->res_domain;//GetDomain(dlg->settings->server_address);
	//temp+=_T("&check=check");

	SetCurlUrl(curl,"http://www.blacklistalert.org/");
	CleanData(this_struct);
	result = curl_easy_perform(curl);
//<input type=hidden name="PHPSESSID" value="1885fc88a84fee781f38ef97da59386f">
	int af = FindStr(this_struct->data,"name=\"PHPSESSID\" value=\"",0);
	int af2 = FindStr(this_struct->data,"\">",af);
	CString sess = CharToString(MidStr(this_struct->data,af+24,af2));
	temp+=_T("&PHPSESSID=")+sess;

	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, StringToChar(temp));
	
	SetCurlUrl(curl,"http://www.blacklistalert.org/");

	CleanData(this_struct);
	result = curl_easy_perform(curl);

	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "");

	if((this_struct->data==NULL))
	{
		//dlg->MessageBox(_T("Unable to retrieve blacklist records"));
		dlg->result_blacklistednum = _T("?");
		dlg->console+=_T("\r\nUnable to get Blacklist record.");
		dlg->UpdateData(FALSE);
		ScrollToBottom(dlg);
	}
	else
	{
		int pos1 = FindStr(this_struct->data,"(Alphabetic order):</b><br>",0);
		int pos1end = FindStr(this_struct->data,"<hr>",pos1+10);
		int pos2 = FindStr(this_struct->data,"(Alphabetic order)</b><br>",pos1end);
		int pos2end = FindStr(this_struct->data,"<hr>",pos2+10);

		if((pos1==-1)||(pos1end==-1)||(pos2==-1)||(pos2end==-1))
		{
			dlg->result_blacklistednum = _T("?");
			dlg->result_blacklist = _T("?");
			dlg->console+=_T("\r\nUnable to get Blacklist record.");
			dlg->UpdateData(FALSE);
			ScrollToBottom(dlg);
		}
		else
		{
			
			int pos4 = 0, pos5 = 0, pos6 = pos1+26, pos7 = 0, pos8 = 0, pos9 = 0;

			bool ok;
			bool no_result;

			int c_ok = 0;
			int c_listed = 0;
			int count = 0;

			int index = 0;

			while((pos4!=-1)&&(pos6<pos2end)) // < !!!!!!!!!!!!!!!!!!!
			{
				pos4 = FindStr(this_struct->data,"<br>",pos6);
				if(pos4==pos1end-4)
					pos4 = FindStr(this_struct->data,"<br>",pos2+26);
				else if(pos4==pos2end-4)
					break;
				pos5 = FindStr(this_struct->data,"<font color=",pos4);
				temp = MidStr(this_struct->data,pos4+4,pos5-1);
				index = dlg->blacklist.InsertItem(dlg->blacklist.GetItemCount(),temp);
				pos6 = FindStr(this_struct->data,">",pos5+5);
				pos7 = FindStr(this_struct->data,"</em>",pos6);
				pos8 = FindStr(this_struct->data,"href=\"",pos6);
				pos9 = FindStr(this_struct->data,"\">",pos8);
				// is blacklsited or not
				ok = (strcmp((const char*)MidStr(this_struct->data,pos5+12,pos6),"green")==0);
				no_result = (strcmp((const char*)MidStr(this_struct->data,pos5+12,pos6),"magenta")==0);

				if(ok)
				{
					dlg->blacklist.SetItemText(index,1,_T("OK"));
					c_ok++;
				}
				else if(no_result)
				{
					dlg->blacklist.SetItemText(index,1,_T("NO RESULT"));
				}
				else
				{
					dlg->blacklist.SetItemText(index,1,_T("LISTED"));
					c_listed++;

					if(pos8<pos7)
					{
						CString temp3(MidStr(this_struct->data,pos8+6,pos9));
						dlg->blacklist.SetItemText(index,2,temp3);
					}
				}

				count++;

				temp.Format(_T("%d"),c_listed);
				temp2.Format(_T("%d"),count);
				temp+=_T("/");
				temp+=temp2;

				dlg->result_blacklistednum = temp;
				dlg->UpdateData(FALSE);
			}

			if(c_listed)
				dlg->result_blacklist = _T("YES");
			else
				dlg->result_blacklist = _T("NO");

			dlg->console+=_T("\r\nSuccess.");

			dlg->UpdateData(FALSE);
			ScrollToBottom(dlg);
		}
	}

	return true;
}
Exemplo n.º 18
0
void CStringVariable::SetChar(const char Value)
{
 m_Value = CharToString(Value);
}
Exemplo n.º 19
0
DWORD WINAPI RunTests(LPVOID lpParam)
{
	thread_data* data = (thread_data*)lpParam;
	CDlgMain* dlg = data->Dlgmain;
	CDlgSettings* dlg2 = data->Dlgsettings;
	//CResultsDlg* dlg = data->result_dlg;
	char buffer[SOCK_BUFFER+1];
	CString msg;

	dlg->console+=_T("\r\nTest started.");
	dlg->UpdateData(FALSE);
	ScrollToBottom(dlg);
	AfxSocketInit();
	CSocket* socket = NULL;

	curl_global_init(CURL_GLOBAL_ALL);
	CURL* curl = curl_easy_init();

	thread_status* this_struct = new thread_status;

	this_struct->bufferlen = 0;
	this_struct->initialized = false;
	this_struct->data = NULL;
	this_struct->writepos = 0;

	curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);  
	curl_easy_setopt(curl,
      CURLOPT_WRITEFUNCTION, writefunction);
    curl_easy_setopt(curl,CURLOPT_WRITEDATA, (void *) &this_struct);
    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT,25);
    curl_easy_setopt(curl, CURLOPT_TIMEOUT,30);

    CString cookie = _T("cookie/cookie");
	CString cookie2;
	CString cookie3 = _T(".txt");
	int cookie4 = int(time(NULL));
	cookie2.Format(_T("%d"),cookie4);
	cookie = cookie+cookie2+cookie3;
	char* cookie_file = StringToChar(cookie);
	//MessageBox(cookie);

	curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookie_file);
	curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookie_file);
	curl_easy_setopt(curl, CURLOPT_COOKIESESSION, true);

	for(int GG=0;GG<1;GG++) // to make cancel possible
	{

	if(socket = Connect(socket,dlg,buffer,false,dlg2))
	{
		dlg->result_1ismailserver = _T("YES");
		
		int pos1 = FindStr(buffer,"Version",0);
		int pos2;
		if(pos1!=-1)
		{
			pos2 = FindStr(buffer," ",pos1+7+2);
			if(pos2==-1)
				pos2 = FindStr(buffer,"\r",pos1+7+2);

			dlg->result_2version = CharToString(MidStr(buffer,pos1+7+1,pos2));
		}

		dlg->UpdateData(FALSE);
		ScrollToBottom(dlg);

		if(CheckIfCancelled(dlg))
			break;

		// OPEN RELAY
		if(dlg->test_openrelay)
		{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------ Open Relay Test ------------------");
			socket = Connect(socket,dlg,buffer,false,dlg2);
			RelayTest(socket,dlg,buffer,dlg2);
		}

		if(CheckIfCancelled(dlg))
			break;

		/// VERIFY COMMAND TEST
		if(dlg->test_verify)
		{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------   Verify Test   ------------------");
			socket = Connect(socket,dlg,buffer,false,dlg2);
			VerifyTest(socket,dlg,buffer,dlg2);
		}

		if(CheckIfCancelled(dlg))
			break;

		/// POSTMAN/ABUSE TEST
		if(dlg->test_postmaster)
		{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------   Postman Test  ------------------");
			socket = Connect(socket,dlg,buffer,false,dlg2);
			PostAbuseTest(socket,dlg,buffer,dlg2,0);
		}

		if(CheckIfCancelled(dlg))
			break;

		if(dlg->test_abuse)
		{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------   Abuse Test    ------------------");
			socket = Connect(socket,dlg,buffer,false,dlg2);
			PostAbuseTest(socket,dlg,buffer,dlg2,1);
		}

		if(CheckIfCancelled(dlg))
			break;

		/// ATTACHMENT TEST // (with server change)
		if(dlg->test_attachments)
		{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------ Attachment Test ------------------");
			CString temp = dlg2->set_serveraddress;
			dlg2->set_serveraddress = dlg2->set_authserver;
			socket = Connect(socket,dlg,buffer,false,dlg2);
			dlg2->set_serveraddress = temp;
			AttachmentTest(socket,dlg,buffer,dlg2);
		}

		if(CheckIfCancelled(dlg))
			break;

		/// SPOOFING TEST
		if(dlg->test_spoofing1)
		{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------ Spoofing 1 Test ------------------");
			socket = Connect(socket,dlg,buffer,false,dlg2);
			SpoofingTest(socket,dlg,buffer,1,dlg2);
		}

		if(CheckIfCancelled(dlg))
			break;
		
		/// SPOOFING TEST 2  // (with server change)
		if(dlg->test_spoofing2)
		{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------ Spoofing 2 Test ------------------");
			CString temp = dlg2->set_serveraddress;
			dlg2->set_serveraddress = dlg2->set_authserver;
			socket = Connect(socket,dlg,buffer,false,dlg2);
			dlg2->set_serveraddress = temp;
			SpoofingTest(socket,dlg,buffer,2,dlg2);
		}

		if(CheckIfCancelled(dlg))
			break;

		/// HELP TEST
		if(dlg->test_help)
		{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------    Help Test    ------------------");
			socket = Connect(socket,dlg,buffer,false,dlg2);
			HelpTest(socket,dlg,buffer);
		}

		if(CheckIfCancelled(dlg))
			break;

		/// ENCRYPTED AUTH
		if(dlg->test_encauth)
		{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------ Encry.Auth Test ------------------");
			socket = Connect(socket,dlg,buffer,false,dlg2);
			EhloTest(socket,dlg,buffer,1);
		}

		if(CheckIfCancelled(dlg))
			break;

		/// CLEARTEXT
		if(dlg->test_cleartext)
		{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------ Cleartext Test  ------------------");
			socket = Connect(socket,dlg,buffer,false,dlg2);
			EhloTest(socket,dlg,buffer,2);
		}

		if(CheckIfCancelled(dlg))
			break;

		/// SASL
		if(dlg->test_sasl)
		{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------    SASL Test    ------------------");
			socket = Connect(socket,dlg,buffer,false,dlg2);
			EhloTest(socket,dlg,buffer,3);
		}

		if(CheckIfCancelled(dlg))
			break;

		/// AUTH
		if(dlg->test_auth)
		{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------    Auth. Test   ------------------");
			socket = Connect(socket,dlg,buffer,false,dlg2);
			EhloTest(socket,dlg,buffer,4);
		}

		if(CheckIfCancelled(dlg))
			break;

	}
	else
	{
		dlg->result_1ismailserver = _T("NO");
		dlg->UpdateData(FALSE);
		ScrollToBottom(dlg);
	}

	if(dlg->test_spf)
	{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------     SPF Test    ------------------");
		SpfTest(dlg,curl,this_struct);
	}

	if(dlg->test_blacklist)
	{
			dlg->console+=_T("\r\n-----------------------------------------------------");
			dlg->console+=_T("\r\n------------------  Blacklist Test ------------------");
		BlacklistTest(dlg,curl,this_struct);
	}

	} // end GG

	delete socket;

			dlg->console+=_T("\r\n-----------------------------------------------------");
	dlg->console+=_T("\r\nTEST COMPLETED.");

	dlg->GetDlgItem(IDC_BUTTON7)->EnableWindow(TRUE);
	dlg->GetDlgItem(IDC_BUTTON8)->EnableWindow(TRUE);
	dlg->GetDlgItem(IDC_BUTTON3)->SetWindowTextW(_T("Run"));
	dlg->GetDlgItem(IDC_BUTTON3)->EnableWindow(TRUE);
	dlg->running = FALSE;
	dlg->want_cancel = FALSE;

	dlg->UpdateData(FALSE);
	ScrollToBottom(dlg);

	return 0;
}
Exemplo n.º 20
0
bool EhloTest(CSocket* socket,CDlgMain* dlg,char* buffer,int subtype)
{
	CString name[4];
	name[0] = _T("Encrypted authentication");
	name[1] = _T("Cleartext login");
	name[2] = _T("SASL Login methods");
	name[3] = _T("Authentication");

	dlg->console+=(_T("\r\n*Starting ")+name[subtype-1]+_T(" Test."));
	dlg->UpdateData(FALSE);
	ScrollToBottom(dlg);

	Send(socket,dlg,"EHLO mozilla");
	Receive(socket,dlg,buffer);

	bool result = false;

	result = (strcmp((const char*)MidStr(buffer,0,3),"250")==0);

	int pos1, pos2;

	if(result)
	{
		switch(subtype)
		{
			case 1: // ENCR
				result = FindStr(buffer,"STARTTLS",0)!=-1;
				dlg->result_encauth = result?_T("YES"):_T("NO");
				break;
			case 2: // CLEARTEXT
				result = FindStr(buffer,"PLAIN",0)!=-1;
				dlg->result_cleartext = result?_T("YES"):_T("NO");
				break;
			case 3: // SASL
				pos1 = FindStr(buffer,"AUTH",0);
				if(pos1!=-1)
				{
					pos2 = FindStr(buffer,"\r",pos1);
					dlg->result_sasl = CharToString(MidStr(buffer,pos1+5,pos2));
					dlg->result_sasl.Replace(_T("LOGIN"),_T(""));
				}
				else
				{
					dlg->result_sasl = _T("-");
				}
				break;
			case 4: // AUTH
				result = ((FindStr(buffer,"AUTH",0)!=-1)||(FindStr(buffer,"STARTTLS",0)!=-1));
				dlg->result_auth = result?_T("YES"):_T("NO");
				break;
		}
	}
	else
	{
		dlg->console+=_T("\r\n[ERROR] Server extensions not obtained.");
		dlg->UpdateData(FALSE);
		ScrollToBottom(dlg);
	}

	return true;
}