Got rid of WIN32 related source code. Someone, please build.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19024 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer 2006-10-07 18:59:59 +00:00
parent 1781c9776e
commit 926f124731
20 changed files with 1269 additions and 1555 deletions

View File

@ -5,11 +5,7 @@
#include <algorithm>
#include <cstring>
#ifdef WIN32
#include <minmax.h>
#else
#define stricmp strcasecmp
#endif
#include "HttpURLConnection.h"
#include "Socket.h"

View File

@ -4,13 +4,8 @@
#ifndef __HttpURLConnection_H
#define __HttpURLConnection_H
#ifdef WIN32
#include <istream>
#include <ostream>
#else
#include <istream.h>
#include <ostream.h>
#endif
#include <list>
#include <string>

View File

@ -1,9 +1,7 @@
// Sun, 18 Jun 2000
// Y.Takagi
#ifdef WIN32
# include <winsock.h>
#elif defined(__HAIKU__)
#if defined(__HAIKU__)
# include <sys/socket.h>
# include <netinet/in.h>
#else

View File

@ -4,17 +4,12 @@
#ifndef __IppContent_H
#define __IppContent_H
#ifdef WIN32
#include <istream>
#include <ostream>
#else
#include <istream.h>
#include <ostream.h>
#endif
#include <list>
#include <string>
#if (!__MWERKS__ || defined(WIN32))
#if (!__MWERKS__)
using namespace std;
#else
#define std

View File

@ -18,7 +18,7 @@
#include "IppDefs.h"
#include "DbgMsg.h"
#if (!__MWERKS__ || defined(WIN32))
#if (!__MWERKS__)
using namespace std;
#else
#define std

View File

@ -9,7 +9,7 @@
#include <fstream>
#include <string>
#if (!__MWERKS__ || defined(WIN32))
#if (!__MWERKS__)
using namespace std;
#else
#define std

View File

@ -1,11 +1,6 @@
// Sun, 18 Jun 2000
// Y.Takagi
#ifdef WIN32
#include <winsock.h>
#include <ostream>
#include <cstring>
#else
#ifdef __HAIKU__
# include <sys/socket.h>
#else
@ -21,7 +16,6 @@ char *itoa(int i, char *buf, int unit)
}
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif // WIN32
#include <list>
#include "IppURLConnection.h"

View File

@ -6,7 +6,7 @@
#include <string>
#if (!__MWERKS__ || defined(WIN32))
#if (!__MWERKS__)
using namespace std;
#else
#define std

View File

@ -19,7 +19,7 @@
#include "LprDefs.h"
#include "DbgMsg.h"
#if (!__MWERKS__ || defined(WIN32))
#if (!__MWERKS__)
using namespace std;
#else
#define std

View File

@ -9,7 +9,7 @@
#include <fstream>
#include <string>
#if (!__MWERKS__ || defined(WIN32))
#if (!__MWERKS__)
using namespace std;
#else
#define std

View File

@ -1,11 +1,6 @@
// Sun, 18 Jun 2000
// Y.Takagi
#ifdef WIN32
# include <windows.h>
# include <winsock.h>
# include <sstream>
#else
#ifdef __HAIKU__
# include <sys/socket.h>
# include <netdb.h>
@ -15,7 +10,6 @@
#endif
#include <errno.h>
#include "_sstream"
#endif
#include <iomanip>
#include <algorithm>
@ -23,7 +17,7 @@
#include "Socket.h"
//#include "DbgMsg.h"
#if (!__MWERKS__ || defined(WIN32))
#if (!__MWERKS__)
using namespace std;
#else
#define std
@ -51,12 +45,7 @@ using namespace std;
#define INADDR_NONE 0xffffffff
#endif
#ifdef WIN32
#define EADDRINUSE WSAEADDRINUSE
#define ERRNO WSAGetLastError()
#else
#define ERRNO errno
#endif
LpsClient::LpsClient(const char *host)

View File

@ -4,16 +4,11 @@
#ifndef __LPSCLIENT_H
#define __LPSCLIENT_H
#ifdef WIN32
#include <istream>
#include <ostream>
#else
#include <istream.h>
#include <ostream.h>
#endif
#include <string>
#if (!__MWERKS__ || defined(WIN32))
#if (!__MWERKS__)
using namespace std;
#else
#define std

View File

@ -9,8 +9,7 @@ if $(BONE_COMPATIBLE) {
Objects
DbgMsg.cpp
Socket.cpp
SocketStream1.cpp
SocketStream2.cpp
SocketStream.cpp
;

View File

@ -1,9 +1,6 @@
// Sun, 18 Jun 2000
// Y.Takagi
#ifdef WIN32
#include <winsock.h>
#else
#ifdef __HAIKU__
# include <sys/socket.h>
#else
@ -11,7 +8,6 @@
#endif
#include <netdb.h>
#include <arpa/inet.h>
#endif // WIN32
#include <stdio.h>
#include <unistd.h>
@ -23,29 +19,7 @@
#define INADDR_NONE 0xffffffff
#endif
#ifdef WIN32
#define EADDRINUSE WSAEADDRINUSE
#define errno WSAGetLastError()
#else
#include <errno.h>
#endif
#ifdef WIN32
class WIN32SOCKET {
public:
WIN32SOCKET()
{
WSADATA winsockdata;
WSAStartup(MAKEWORD(1,1), &winsockdata);
}
~WIN32SOCKET()
{
WSACleanup();
}
};
WIN32SOCKET win32socket;
#endif
Socket::Socket(const char *host, int port)
: __sock(-1), __is(NULL), __os(NULL), __error(false)

View File

@ -4,17 +4,12 @@
#ifndef __Socket_H
#define __Socket_H
#ifdef WIN32
#include <istream>
#include <ostream>
#else
#include <istream.h>
#include <ostream.h>
#endif // WIN32
#include <string>
#if (!__MWERKS__ || defined(WIN32))
#if (!__MWERKS__)
using namespace std;
#else
#define std

View File

@ -1,7 +1,6 @@
// Sun, 18 Jun 2000
// Y.Takagi
#ifndef WIN32
#ifdef __HAIKU__
# include <sys/socket.h>
#else
@ -127,5 +126,3 @@ osocketstream::~osocketstream()
{
flush();
}
#endif // !WIN32

View File

@ -1,8 +1,60 @@
// Sun, 18 Jun 2000
// Y.Takagi
#ifdef WIN32
#include "SocketStream1.h"
#else
#include "SocketStream2.h"
#endif
#ifndef __SocketStream_H
#define __SocketStream_H
#include <istream.h>
#include <ostream.h>
#include <streambuf.h>
class Socket;
class socketstreambuf : public streambuf {
public:
explicit socketstreambuf(Socket *sock, streamsize n);
~socketstreambuf();
protected:
virtual int underflow();
virtual int overflow(int);
virtual int sync();
private:
Socket *__sock;
streamsize __alsize;
char *__pu;
char *__po;
};
class socketstreambase : public virtual ios {
public:
socketstreambuf *rdbuf();
protected:
socketstreambase(Socket *sock, streamsize n);
~socketstreambase() {}
private:
socketstreambuf buf;
};
inline socketstreambuf *socketstreambase::rdbuf()
{
return &this->buf;
}
class isocketstream : public socketstreambase, public istream {
public:
explicit isocketstream(Socket *sock, streamsize n = 4096);
virtual ~isocketstream();
};
class osocketstream : public socketstreambase, public ostream {
public:
explicit osocketstream(Socket *sock, streamsize n = 4096);
virtual ~osocketstream();
};
#endif // __SocketStream_H

View File

@ -1,124 +0,0 @@
// Sun, 18 Jun 2000
// Y.Takagi
#ifdef WIN32
#include <winsock.h>
#ifdef _DEBUG
#include <iostream>
#include <fstream>
#endif
#include "Socket.h"
#include "SocketStream.h"
namespace std {
/*-----------------------------------------------------------------*/
socketstreambuf::socketstreambuf(Socket *sock, streamsize n)
: basic_streambuf<char_type, traits>(), __alsize(n), __sock(sock), __pu(NULL), __po(NULL)
{
setg(0, 0, 0);
setp(0, 0);
}
socketstreambuf::~socketstreambuf()
{
if (__pu)
delete [] __pu;
if (__po)
delete [] __po;
}
socketstreambuf::int_type socketstreambuf::underflow()
{
// cout << "***** underflow" << endl;
if (__pu == NULL) {
__pu = new char[__alsize];
}
int bytes = __sock->read(__pu, __alsize);
if (bytes > 0) {
#ifdef _DEBUG
ofstream ofs("recv.log", ios::binary | ios::app);
ofs.write(__pu, bytes);
#endif
setg(__pu, __pu, __pu + bytes);
return traits::to_int_type(*gptr());
}
return traits::eof();
}
socketstreambuf::int_type socketstreambuf::overflow(socketstreambuf::int_type c)
{
// cout << "***** overflow" << endl;
if (__po == NULL) {
__po = new char[__alsize];
setp(__po, __po + __alsize);
} else if (sync() != 0) {
return traits::eof();
}
return sputc(c);
}
int socketstreambuf::sync()
{
// cout << "***** sync" << endl;
if (__po) {
int length = pptr() - pbase();
if (length > 0) {
const char *buffer = pbase();
int bytes;
while (length > 0) {
bytes = __sock->write(buffer, length);
if (bytes <= 0) {
return EOF;
}
#ifdef _DEBUG
ofstream ofs("send.log", ios::binary | ios::app);
ofs.write(buffer, bytes);
#endif
length -= bytes;
buffer += bytes;
}
pbump(pbase() - pptr());
}
}
return 0;
}
/*-----------------------------------------------------------------*/
isocketstream::isocketstream(Socket *sock, streamsize n)
: basic_istream<char_type, traits>(&ssb_), ssb_(sock, n)
{
}
isocketstream::~isocketstream()
{
}
/*-----------------------------------------------------------------*/
osocketstream::osocketstream(Socket *sock, streamsize n)
: basic_ostream<char_type, traits>(&ssb_), ssb_(sock, n)
{
}
osocketstream::~osocketstream()
{
flush();
}
/*-----------------------------------------------------------------*/
}
#endif // WIN32

View File

@ -1,81 +0,0 @@
// Sun, 18 Jun 2000
// Y.Takagi
#ifndef __SocketStream1_H
#define __SocketStream1_H
#include <istream>
#include <ostream>
#include <streambuf>
class Socket;
namespace std {
class socketstreambuf : public basic_streambuf< char, char_traits<char> > {
public:
typedef char char_type;
typedef char_traits<char> traits;
typedef traits::int_type int_type;
typedef traits::pos_type pos_type;
typedef traits::off_type off_type;
explicit socketstreambuf(Socket *sock, streamsize n);
virtual ~socketstreambuf();
protected:
virtual int_type underflow();
virtual int_type overflow(int_type c = traits::eof());
virtual int sync();
private:
Socket *__sock;
streamsize __alsize;
char *__pu;
char *__po;
};
class isocketstream : public basic_istream< char, char_traits<char> > {
public:
typedef char char_type;
typedef char_traits<char> traits;
typedef traits::int_type int_type;
typedef traits::pos_type pos_type;
typedef traits::off_type off_type;
explicit isocketstream(Socket *sock, streamsize n = 4096);
virtual ~isocketstream();
socketstreambuf *rdbuf() const
{
return (socketstreambuf *)basic_ios<char_type, traits>::rdbuf();
}
private:
socketstreambuf ssb_;
};
class osocketstream : public basic_ostream< char, char_traits<char> > {
public:
typedef char char_type;
typedef char_traits<char> traits;
typedef traits::int_type int_type;
typedef traits::pos_type pos_type;
typedef traits::off_type off_type;
explicit osocketstream(Socket *sock, streamsize n = 4096);
virtual ~osocketstream();
socketstreambuf *rdbuf() const
{
return (socketstreambuf *)basic_ios<char_type, traits>::rdbuf();
}
private:
socketstreambuf ssb_;
};
}
#endif // __SocketStream1_H

View File

@ -1,60 +0,0 @@
// Sun, 18 Jun 2000
// Y.Takagi
#ifndef __SocketStream2_H
#define __SocketStream2_H
#include <istream.h>
#include <ostream.h>
#include <streambuf.h>
class Socket;
class socketstreambuf : public streambuf {
public:
explicit socketstreambuf(Socket *sock, streamsize n);
~socketstreambuf();
protected:
virtual int underflow();
virtual int overflow(int);
virtual int sync();
private:
Socket *__sock;
streamsize __alsize;
char *__pu;
char *__po;
};
class socketstreambase : public virtual ios {
public:
socketstreambuf *rdbuf();
protected:
socketstreambase(Socket *sock, streamsize n);
~socketstreambase() {}
private:
socketstreambuf buf;
};
inline socketstreambuf *socketstreambase::rdbuf()
{
return &this->buf;
}
class isocketstream : public socketstreambase, public istream {
public:
explicit isocketstream(Socket *sock, streamsize n = 4096);
virtual ~isocketstream();
};
class osocketstream : public socketstreambase, public ostream {
public:
explicit osocketstream(Socket *sock, streamsize n = 4096);
virtual ~osocketstream();
};
#endif // __SocketStream2_H