|
From: <at...@us...> - 2007-09-03 03:44:27
|
Revision: 504
http://cadcdev.svn.sourceforge.net/cadcdev/?rev=504&view=rev
Author: atani
Date: 2007-09-02 20:44:24 -0700 (Sun, 02 Sep 2007)
Log Message:
-----------
* increased the buffer for printf (16kb on all plats except nds which is 1k)
* added tinyxml to the include path
* implemented CookieJar::loadFromXML(), CookieJar::saveToXML()
* added dswifi7 lib to arm7_template
* added Socket::send(string), Socket::recv(string)
* modified httpclient to use a TextConsole
Modified Paths:
--------------
tiki/examples/net/httpclient/src/main.cpp
tiki/include/Tiki/net/http/cookie.h
tiki/include/Tiki/net/socket.h
tiki/include/Tiki/net/tcpsocket.h
tiki/include/Tiki/net/util/base64.h
tiki/nds/Makefile.rules
tiki/nds/arm7_template/Makefile
tiki/sdl/Makefile
tiki/src/base/debug.cpp
tiki/src/gl/drawables/console.cpp
tiki/src/net/http/cookiejar.cpp
tiki/src/net/http/useragent.cpp
tiki/src/net/tcpsocket.cpp
tiki/src/net/util/base64.cpp
tiki/win32/include/Tiki/platnet.h
tiki/win32/src/platnet.cpp
tiki/win32/tiki.vcproj
Added Paths:
-----------
tiki/examples/net/httpclient/resources/
tiki/examples/net/httpclient/resources/pc-ascii.png
Added: tiki/examples/net/httpclient/resources/pc-ascii.png
===================================================================
(Binary files differ)
Property changes on: tiki/examples/net/httpclient/resources/pc-ascii.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: tiki/examples/net/httpclient/src/main.cpp
===================================================================
--- tiki/examples/net/httpclient/src/main.cpp 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/examples/net/httpclient/src/main.cpp 2007-09-03 03:44:24 UTC (rev 504)
@@ -14,16 +14,22 @@
#include <Tiki/net/http/useragent.h>
#include <Tiki/net/http/request.h>
+#include <Tiki/drawables/console.h>
+
using namespace Tiki;
using namespace Tiki::Debug;
using namespace Tiki::Net;
using namespace Tiki::Net::Http;
+using namespace Tiki::GL;
volatile bool g_quitting = false;
void tkCallback( const Hid::Event & evt, void * data ) {
if ( evt.type == Hid::Event::EvtQuit ) {
g_quitting = true;
}
+ else if (evt.type == Hid::Event::EvtKeypress && evt.key == Hid::Event::KeyEsc) {
+ g_quitting = true;
+ }
}
extern "C" int tiki_main( int argc, char **argv) {
@@ -32,51 +38,75 @@
Hid::callbackReg( tkCallback, NULL );
HttpUserAgent *useragent = new HttpUserAgent();
+ useragent->setCookieJar(new CookieJar());
useragent->setIgnoreCookies(false);
+ useragent->getCookieJar()->loadFromXML("cookies.xml");
//useragent->setProxyHost("proxy.example.com");
//useragent->setProxyPort(80);
Request *request = new Request();
request->setUrl("http://www.google.com/");
- useragent->setCookieJar(new CookieJar());
- useragent->setIgnoreCookies(false);
+
- for(int reqCount = 0; reqCount < 10; reqCount++) {
- Response *response = useragent->get(request);
- Tiki::Debug::printf("response code: %d\n", response->getResultCode());
- std::list<Cookie *> cookies = useragent->getCookieJar()->getCookies();
- for(std::list<Cookie *>::iterator iter = cookies.begin();
- iter != cookies.end();
- ++iter) {
- Cookie *cookie = (*iter);
- if(cookie->isSecure()) {
- Tiki::Debug::printf("COOKIE: %s (version->%s,path->%s,max-age->%d,domain->%s,secure->%s)\n",
- cookie->getName().c_str(), cookie->getVersion().c_str(), cookie->getPath().c_str(), cookie->getMaxAge(),
- cookie->getDomain().c_str(), cookie->isSecure() ? "true" : "false");
- }
- else {
- Tiki::Debug::printf("COOKIE: %s (version->%s,value->%s,path->%s,max-age->%d,domain->%s,secure->%s)\n",
- cookie->getName().c_str(), cookie->getVersion().c_str(), cookie->getValue().c_str(), cookie->getPath().c_str(), cookie->getMaxAge(),
- cookie->getDomain().c_str(), cookie->isSecure() ? "true" : "false");
- }
- }
+#if TIKI_PLAT == TIKI_DC
+ RefPtr<Texture> cf = new Texture("/rd/pc-ascii.png", true);
+#else
+ RefPtr<Texture> cf = new Texture("resources/pc-ascii.png", true);
+#endif
+ ConsoleText *console = new ConsoleText(80, 25, cf);
+ console->setSize(640, 480);
+ console->setTranslate( Vector( 320, 240, 0 ) );
+ console->setAutoWrap( true );
+ console->setAutoScroll( true );
- std::list<std::string> content = response->getContentPartNames();
- for(std::list<std::string>::iterator iter = content.begin();
- iter != content.end();
- ++iter)
- {
- Buffer *responseBuf = response->getContentPart(*iter);
- Tiki::Debug::printf("Content Part: %s [%u bytes]\n", (*iter).c_str(), responseBuf->getUsedDataLen());
- //Tiki::Debug::printf("%s\n", responseBuf->getData());
- }
+ console->printf("Sending request: %s\n", request->getUrl().c_str());
+ Response *response = useragent->get(request);
+
+ console->printf("response code: %d\n", response->getResultCode());
+ std::list<Cookie *> cookies = useragent->getCookieJar()->getCookies();
+ for(std::list<Cookie *>::iterator iter = cookies.begin();
+ iter != cookies.end();
+ ++iter) {
+ Cookie *cookie = (*iter);
+ if(cookie->isSecure()) {
+ console->printf("COOKIE: %s (version->%s,path->%s,max-age->%d,domain->%s,secure->%s)\n",
+ cookie->getName().c_str(), cookie->getVersion().c_str(), cookie->getPath().c_str(), cookie->getMaxAge(),
+ cookie->getDomain().c_str(), cookie->isSecure() ? "true" : "false");
+ }
+ else {
+ console->printf("COOKIE: %s (version->%s,value->%s,path->%s,max-age->%d,domain->%s,secure->%s)\n",
+ cookie->getName().c_str(), cookie->getVersion().c_str(), cookie->getValue().c_str(), cookie->getPath().c_str(), cookie->getMaxAge(),
+ cookie->getDomain().c_str(), cookie->isSecure() ? "true" : "false");
+ }
+ }
- delete response;
+ std::list<std::string> content = response->getContentPartNames();
+ for(std::list<std::string>::iterator iter = content.begin();
+ iter != content.end();
+ ++iter)
+ {
+ Buffer *responseBuf = response->getContentPart(*iter);
+ console->printf("Content Part: %s [%u bytes]\n", (*iter).c_str(), responseBuf->getUsedDataLen());
+ console->printf((char *)responseBuf->getData());
}
+
+ while(!g_quitting) {
+ Frame::begin();
+ console->draw(Drawable::Opaque);
+ Frame::transEnable();
+ console->draw(Drawable::Trans);
+ Frame::finish();
+ }
+
+ useragent->getCookieJar()->saveToXML("cookies.xml");
+
+ delete response;
delete request;
delete useragent;
Tiki::Net::shutdown();
+ Tiki::shutdown();
+
return 0;
}
Modified: tiki/include/Tiki/net/http/cookie.h
===================================================================
--- tiki/include/Tiki/net/http/cookie.h 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/include/Tiki/net/http/cookie.h 2007-09-03 03:44:24 UTC (rev 504)
@@ -85,6 +85,9 @@
uint64 getCreateTime() const {
return m_createTime;
}
+ void setCreateTime(uint64 time) {
+ m_createTime = time;
+ }
private:
string m_name;
string m_value;
Modified: tiki/include/Tiki/net/socket.h
===================================================================
--- tiki/include/Tiki/net/socket.h 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/include/Tiki/net/socket.h 2007-09-03 03:44:24 UTC (rev 504)
@@ -65,8 +65,12 @@
virtual void send(Buffer *data) = 0;
+ virtual void send(string &data) = 0;
+
virtual void recv(Buffer *data) = 0;
+ virtual void recv(string &data) = 0;
+
virtual void open() = 0;
virtual void close() = 0;
Modified: tiki/include/Tiki/net/tcpsocket.h
===================================================================
--- tiki/include/Tiki/net/tcpsocket.h 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/include/Tiki/net/tcpsocket.h 2007-09-03 03:44:24 UTC (rev 504)
@@ -42,8 +42,10 @@
virtual ~TCPSocket() {}
virtual void send(Buffer *data);
+ virtual void send(string &data);
virtual void recv(Buffer *data);
+ virtual void recv(string &data);
virtual bool isOpen() {
return m_open;
Modified: tiki/include/Tiki/net/util/base64.h
===================================================================
--- tiki/include/Tiki/net/util/base64.h 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/include/Tiki/net/util/base64.h 2007-09-03 03:44:24 UTC (rev 504)
@@ -9,6 +9,8 @@
#ifndef __TIKI_BASE64_H
#define __TIKI_BASE64_H
+#include "Tiki/net/buffer.h"
+
namespace Tiki {
namespace Net {
namespace Util {
Modified: tiki/nds/Makefile.rules
===================================================================
--- tiki/nds/Makefile.rules 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/nds/Makefile.rules 2007-09-03 03:44:24 UTC (rev 504)
@@ -24,6 +24,7 @@
CXXFLAGS+=-I$(TIKI_DIR)/3rdparty/libogg/include
CXXFLAGS+=-I$(TIKI_DIR)/3rdparty/libvorbis/include
CXXFLAGS+=-I$(TIKI_DIR)/3rdparty/libvorbis/lib
+CXXFLAGS+=-I$(TIKI_DIR)/3rdparty/tinyxml
CXXFLAGS+=-DARM9
CXXFLAGS+=-march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork -O2
CFLAGS=$(CXXFLAGS)
Modified: tiki/nds/arm7_template/Makefile
===================================================================
--- tiki/nds/arm7_template/Makefile 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/nds/arm7_template/Makefile 2007-09-03 03:44:24 UTC (rev 504)
@@ -37,7 +37,7 @@
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*).map
-LIBS := -lnds7
+LIBS := -lnds7 -ldswifi7
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
Modified: tiki/sdl/Makefile
===================================================================
--- tiki/sdl/Makefile 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/sdl/Makefile 2007-09-03 03:44:24 UTC (rev 504)
@@ -48,7 +48,7 @@
THIRD_PARTY_OBJS = $(JPEG_OBJ) $(OGG_OBJ) $(VORBIS_OBJ) $(PNG_OBJ) $(ZLIB_OBJ) $(TINYXML_OBJ)
CFLAGS=-I../include -I$(CURDIR)/include -g
-CFLAGS+=-I../3rdparty/libogg/include -I../3rdparty/libvorbis/include -I../3rdparty/libvorbis/lib
+CFLAGS+=-I../3rdparty/libogg/include -I../3rdparty/libvorbis/include -I../3rdparty/libvorbis/lib -I../3rdparty/tinyxml
SUBDIRS=src
Modified: tiki/src/base/debug.cpp
===================================================================
--- tiki/src/base/debug.cpp 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/src/base/debug.cpp 2007-09-03 03:44:24 UTC (rev 504)
@@ -19,7 +19,7 @@
// console output in a GUI app.
#if TIKI_PLAT == TIKI_WIN32
va_list args;
- char buffer[ 4096 ];
+ char buffer[ 16 * 1024 ];
va_start( args, fmt );
int i = vsprintf( buffer, fmt, args );
va_end( args );
Modified: tiki/src/gl/drawables/console.cpp
===================================================================
--- tiki/src/gl/drawables/console.cpp 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/src/gl/drawables/console.cpp 2007-09-03 03:44:24 UTC (rev 504)
@@ -137,7 +137,11 @@
void ConsoleText::printf( const char *fmt, ... )
{
+#if TIKI_PLAT == TIKI_NDS
char buf[ 1024 ];
+#else
+ char buf[ 16 * 1024 ];
+#endif
va_list args;
va_start( args, fmt );
Modified: tiki/src/net/http/cookiejar.cpp
===================================================================
--- tiki/src/net/http/cookiejar.cpp 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/src/net/http/cookiejar.cpp 2007-09-03 03:44:24 UTC (rev 504)
@@ -10,8 +10,13 @@
#include "Tiki/tiki.h"
#include "Tiki/tikitime.h"
#include "Tiki/net/http/cookiejar.h"
+#include "Tiki/net/util/base64.h"
#include "Tiki/net/util/date.h"
+#include "tinyxml.h"
+
+#include <fstream>
+
namespace Tiki {
namespace Net {
@@ -19,7 +24,10 @@
namespace Http {
using std::string;
+ using std::endl;
using std::list;
+ using std::ofstream;
+ using Tiki::Net::Util::Base64;
CookieJar::CookieJar() {
}
@@ -186,7 +194,9 @@
}
void CookieJar::expireCookies() {
- if(m_cookies.empty()) return;
+ if(m_cookies.empty()) {
+ return;
+ }
list< list< Cookie * >::iterator > cookiesToExpire;
uint64 now = Tiki::Time::gettime();
for(list<Cookie *>::iterator iter = m_cookies.begin();
@@ -195,7 +205,9 @@
// check if cookie has expired
uint64 create = (*iter)->getCreateTime();
uint64 diff = now - create;
- if(diff < 1) diff = 1;
+ if(diff < 1) {
+ diff = 1;
+ }
// convert the diff from microseconds to milliseconds
diff /= 1000;
// convert the diff from milliseconds to seconds
@@ -206,10 +218,84 @@
}
}
- void loadFromXML(string filename) {
+ void CookieJar::loadFromXML(string filename) {
+ TiXmlDocument doc(filename.c_str());
+ Base64 b64;
+ if(doc.LoadFile()) {
+ for(TiXmlNode *node = doc.FirstChildElement("CookieJar")->FirstChild("Cookie"); node != NULL; node = node->NextSibling()) {
+ Cookie *cookie;
+ string name = node->ToElement()->Attribute("name");
+ TiXmlElement *valueNode = node->FirstChildElement("Value");
+ string valueEncoded(valueNode->GetText());
+ Tiki::Debug::printf(valueNode->GetText());
+ Buffer buf(valueEncoded.length(), (uint8 *)valueEncoded.c_str());
+ Buffer *decoded = b64.decode(&buf);
+ string value = (char *)decoded->getData();
+ delete decoded;
+
+ cookie = new Cookie(name, value);
+ for(TiXmlAttribute *attr = node->ToElement()->FirstAttribute();
+ attr != NULL;
+ attr = attr->Next()) {
+ if(!string(attr->Name()).compare("maxage")) {
+ cookie->setMaxAge(attr->IntValue());
+ }
+ else if(!string(attr->Name()).compare("version")) {
+ cookie->setVersion(attr->Value());
+ }
+ else if(!string(attr->Name()).compare("path")) {
+ cookie->setPath(attr->Value());
+ }
+ else if(!string(attr->Name()).compare("secure")) {
+ if(attr->Value()[0] == 't') {
+ cookie->setSecure(true);
+ }
+ }
+ else if(!string(attr->Name()).compare("domain")) {
+ cookie->setDomain(attr->Value());
+ }
+ else if(!string(attr->Name()).compare("created")) {
+ cookie->setCreateTime(attr->IntValue());
+ }
+ }
+ addCookie(cookie);
+ }
+ }
}
- void saveToXML(string filename) {
+ void CookieJar::saveToXML(string filename) {
+ ofstream stream;
+ stream.open(filename.c_str());
+
+ stream << "<?xml version=\"1.0\" ?>" << endl;
+ stream << "<CookieJar>" << endl;
+ Base64 b64;
+ for(list< Cookie * >::iterator iter = m_cookies.begin();
+ iter != m_cookies.end();
+ ++iter) {
+ stream << " <Cookie name=\""<< (*iter)->getName()
+ << "\" version=\"" << (*iter)->getVersion()
+ << "\" maxage=\"" << (*iter)->getMaxAge()
+ << "\" created=\"" << (*iter)->getCreateTime()
+ << "\" domain=\"" << (*iter)->getDomain()
+ << "\" path=\"" << (*iter)->getPath()
+ << "\" secure=\"" << ((*iter)->isSecure() ? string("true") : string("false"))
+ << "\">" << endl;
+ if(!(*iter)->getComment().empty()) {
+ stream << " <Comment>" << (*iter)->getComment() << "</Comment>" << endl;
+ }
+ stream << " <Value><![CDATA[" << endl;
+ Buffer *buf = b64.encode(new Buffer((*iter)->getValue().length(),
+ (uint8 *)((*iter)->getValue().c_str())));
+ stream << (char *)(buf->getData());
+ delete buf;
+ stream << endl << "]]></Value>" << endl;
+ stream << " </Cookie>" << endl;
+ }
+ stream << "</CookieJar>" << endl;
+
+ stream.flush();
+ stream.close();
}
}; // namespace Http
Modified: tiki/src/net/http/useragent.cpp
===================================================================
--- tiki/src/net/http/useragent.cpp 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/src/net/http/useragent.cpp 2007-09-03 03:44:24 UTC (rev 504)
@@ -28,25 +28,6 @@
using std::istringstream;
using std::ios;
-#define READ_ONE_LINE(res, socket) \
- { \
- Buffer *recvBuf = new Buffer(1); \
- res = ""; \
- while(socket->isOpen()) { \
- recvBuf->reset(); \
- socket->recv(recvBuf); \
- if(recvBuf->getUsedDataLen() > 0) { \
- if(recvBuf->getData()[0] != '\n' && recvBuf->getData()[0] != '\r' ) { \
- res.append((char *)recvBuf->getData()); \
- } \
- else if(recvBuf->getData()[0] != '\r' ) { \
- break; \
- } \
- } \
- } \
- delete recvBuf; \
- }
-
HttpUserAgent::HttpUserAgent() {
#if TIKI_PLAT == TIKI_WIN32
m_userAgentName = "Tiki/1.0 (Windows)";
@@ -100,7 +81,7 @@
Tiki::Debug::printf("Sending request...\n");
Tiki::Debug::printf(requestText.c_str());
- socket->send(new Buffer(requestText.length(), (uint8 *)requestText.c_str()));
+ socket->send(requestText);
readResponse(response, socket);
@@ -144,12 +125,12 @@
}
Tiki::Debug::printf("Sending request...\n");
- socket->send(new Buffer(requestText.length(), (uint8 *)requestText.c_str()));
+ socket->send(requestText);
list<string> content = req->getContentPartNames();
if(content.size() > 1 || req->isForcedMultiPartUpload()) {
string status = "";
- READ_ONE_LINE(status, socket)
+ socket->recv(status);
for(list<string>::iterator iter = content.begin();
iter != content.end();
@@ -168,7 +149,7 @@
temp << "\"; filename=\"" << buf->getFileNameShort() << "\"\r\nContent-Type: " << buf->getContentType() << "\r\n\r\n";
string headerText = temp.str();
//Tiki::Debug::printf("CONTENT_HEADER:\n%s", headerText.c_str());
- socket->send(new Buffer(headerText.length(), (uint8 *)headerText.c_str()));
+ socket->send(headerText);
socket->send(buf);
}
}
@@ -176,7 +157,7 @@
footerText.append(req->getBoundaryMarker());
footerText.append("--\r\n");
//Tiki::Debug::printf("CONTENT_FOOTER:\n%s", footerText.c_str());
- socket->send(new Buffer(footerText.length(), (uint8 *)footerText.c_str()));
+ socket->send(footerText);
}
else if(content.size() == 1) {
Buffer *buf = req->getContentPart(*content.begin());
@@ -303,7 +284,7 @@
parseUrl(response->getUrl(), host, resource, port);
string status = "";
- READ_ONE_LINE(status, socket)
+ socket->recv(status);
Tiki::Debug::printf("%s\n", status.c_str());
@@ -317,7 +298,7 @@
while(1) {
string line = "";
- READ_ONE_LINE(line, socket)
+ socket->recv(line);
if(line.size() == 0) {
// done with headers
break;
@@ -353,7 +334,7 @@
{
sizeDecoded = 0;
string size = "";
- READ_ONE_LINE(size, socket);
+ socket->recv(size);
if(size.empty()) {
sizeDecoded = 1;
continue;
Modified: tiki/src/net/tcpsocket.cpp
===================================================================
--- tiki/src/net/tcpsocket.cpp 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/src/net/tcpsocket.cpp 2007-09-03 03:44:24 UTC (rev 504)
@@ -34,6 +34,22 @@
} while(dataLen > 0 && (len > 0 || errno == EINTR));
}
+void TCPSocket::send(string &buffer) {
+ uint8 *data = (uint8 *)buffer.c_str();
+ size_t dataLen = buffer.length();
+ int len;
+
+ do {
+ //Tiki::Debug::printf("sending %d bytes\n", dataLen);
+ len = ::send(m_socket, (const char *)data, (int)dataLen, 0);
+ if(len > 0) {
+ //Tiki::Debug::printf("sent %d bytes\n", len);
+ dataLen -= len;
+ data += len;
+ }
+ } while(dataLen > 0 && (len > 0 || errno == EINTR));
+}
+
void TCPSocket::recv(Buffer *data) {
size_t maxReadData = data->getDataLen();
#if TIKI_PLAT == TIKI_NDS
@@ -65,6 +81,24 @@
delete [] tmp;
}
+void TCPSocket::recv(string &data) {
+ Buffer *recvBuf = new Buffer(1);
+ data = "";
+ while(isOpen()) {
+ recvBuf->reset();
+ recv(recvBuf);
+ if(recvBuf->getUsedDataLen() > 0) {
+ if(recvBuf->getData()[0] != '\n' && recvBuf->getData()[0] != '\r' ) {
+ data.append((char *)recvBuf->getData());
+ }
+ else if(recvBuf->getData()[0] != '\r' ) {
+ break;
+ }
+ }
+ }
+ delete recvBuf;
+}
+
void TCPSocket::open() {
struct sockaddr_in sock_addr;
m_socket = socket(AF_INET, SOCK_STREAM, 0);
Modified: tiki/src/net/util/base64.cpp
===================================================================
--- tiki/src/net/util/base64.cpp 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/src/net/util/base64.cpp 2007-09-03 03:44:24 UTC (rev 504)
@@ -62,7 +62,7 @@
while (inIndex < source->getUsedDataLen()) {
if (source->getUsedDataLen() - inIndex <= 2) {
quartetsPerLine++;
- encodeTriplet (inputData + inIndex, source->getUsedDataLen() - inIndex, result + outIndex);
+ encodeTriplet (inputData + inIndex, static_cast<uint8>(source->getUsedDataLen() - inIndex), result + outIndex);
break;
} else {
quartetsPerLine++;
@@ -200,14 +200,14 @@
}
size_t Base64::calcEncodeBufferSize(size_t byteCount) {
- div_t result = div (byteCount, 3);
+ div_t result = div (static_cast<int>(byteCount), 3);
size_t bytesNeeded = result.quot * 4;
if (result.rem != 0) {
// pad with 4 extra bytes to ensure room for pad characters;
bytesNeeded += 4;
}
// CRLF -> "\r\n" each 76 characters
- result = div (bytesNeeded, 76);
+ result = div (static_cast<int>(byteCount), 76);
bytesNeeded += result.quot * 2;
// allow room for null terminator
@@ -217,7 +217,7 @@
}
size_t Base64::calcDecodeBufferSize(uint8 *input, size_t inputByteCount) {
- div_t result = div (inputByteCount, 4);
+ div_t result = div (static_cast<int>(inputByteCount), 4);
size_t bytesNeeded = result.quot * 3;
if (input[inputByteCount - 1] == '=') {
Modified: tiki/win32/include/Tiki/platnet.h
===================================================================
--- tiki/win32/include/Tiki/platnet.h 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/win32/include/Tiki/platnet.h 2007-09-03 03:44:24 UTC (rev 504)
@@ -15,5 +15,9 @@
#include <fcntl.h>
#include <winsock2.h>
+#include <wininet.h>
+#pragma comment(lib, "ws2_32.lib")
+#pragma comment(lib, "wininet.lib")
+
#endif // TIKI_PLATFORM_NET_H
Modified: tiki/win32/src/platnet.cpp
===================================================================
--- tiki/win32/src/platnet.cpp 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/win32/src/platnet.cpp 2007-09-03 03:44:24 UTC (rev 504)
@@ -9,11 +9,14 @@
#include "pch.h"
#include "Tiki/tiki.h"
#include "Tiki/net.h"
+#include "Tiki/glhdrs.h"
namespace Tiki {
namespace Net {
+ DWORD connectionFlags;
+
void init()
{
WORD version_wanted = MAKEWORD(1,1);
@@ -34,6 +37,38 @@
}
}
+bool connect()
+{
+ BOOL state = InternetAutodial(0, Tiki::GetWin32Window());
+ return state == TRUE;
+}
+
+bool isConnected()
+{
+ BOOL state = InternetGetConnectedState(&connectionFlags, 0);
+ if(connectionFlags & INTERNET_CONNECTION_CONFIGURED) {
+ Tiki::Debug::printf("INTERNET_CONNECTION_CONFIGURED is set\n");
+ }
+ if(connectionFlags & INTERNET_CONNECTION_LAN) {
+ Tiki::Debug::printf("INTERNET_CONNECTION_LAN is set\n");
+ }
+ if(connectionFlags & INTERNET_CONNECTION_MODEM) {
+ Tiki::Debug::printf("INTERNET_CONNECTION_MODEM is set\n");
+ }
+ if(connectionFlags & INTERNET_CONNECTION_OFFLINE) {
+ Tiki::Debug::printf("INTERNET_CONNECTION_OFFLINE is set\n");
+ }
+ if(connectionFlags & INTERNET_CONNECTION_PROXY) {
+ Tiki::Debug::printf("INTERNET_CONNECTION_PROXY is set\n");
+ }
+ return state == TRUE;
+}
+
+void disconnect()
+{
+ InternetAutodialHangup(0);
+}
+
} // namespace Net
} // namespace Tiki
\ No newline at end of file
Modified: tiki/win32/tiki.vcproj
===================================================================
--- tiki/win32/tiki.vcproj 2007-09-02 23:53:47 UTC (rev 503)
+++ tiki/win32/tiki.vcproj 2007-09-03 03:44:24 UTC (rev 504)
@@ -42,7 +42,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories=""$(ProjectDir)\include";"$(ProjectDir)\..\include";"C:\Program Files\OpenAL 1.1 SDK\include";"$(ProjectDir)\..\3rdparty\libjpeg";"$(ProjectDir)\..\3rdparty\libogg\include";"$(ProjectDir)\..\3rdparty\libpng";"$(ProjectDir)\..\3rdparty\libvorbis\include";"$(ProjectDir)\..\3rdparty\zlib""
+ AdditionalIncludeDirectories=""$(ProjectDir)\include";"$(ProjectDir)\..\include";"C:\Program Files\OpenAL 1.1 SDK\include";"$(ProjectDir)\..\3rdparty\libjpeg";"$(ProjectDir)\..\3rdparty\libogg\include";"$(ProjectDir)\..\3rdparty\libpng";"$(ProjectDir)\..\3rdparty\libvorbis\include";"$(ProjectDir)\..\3rdparty\zlib";"$(ProjectDir)\..\3rdparty\tinyxml""
PreprocessorDefinitions="_WIN32_WINNT=0x0500;_CRT_SECURE_NO_WARNINGS=1"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -108,7 +108,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""$(ProjectDir)\include";"$(ProjectDir)\..\include";"C:\Program Files\OpenAL 1.1 SDK\include";"$(ProjectDir)\..\3rdparty\libjpeg";"$(ProjectDir)\..\3rdparty\libogg\include";"$(ProjectDir)\..\3rdparty\libpng";"$(ProjectDir)\..\3rdparty\libvorbis\include";"$(ProjectDir)\..\3rdparty\zlib""
+ AdditionalIncludeDirectories=""$(ProjectDir)\include";"$(ProjectDir)\..\include";"C:\Program Files\OpenAL 1.1 SDK\include";"$(ProjectDir)\..\3rdparty\libjpeg";"$(ProjectDir)\..\3rdparty\libogg\include";"$(ProjectDir)\..\3rdparty\libpng";"$(ProjectDir)\..\3rdparty\libvorbis\include";"$(ProjectDir)\..\3rdparty\zlib";"$(ProjectDir)\..\3rdparty\tinyxml""
PreprocessorDefinitions="_WIN32_WINNT=0x0500; _CRT_SECURE_NO_WARNINGS=1"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|