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
@@ -1,327 +1,323 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#include <list> #include <list>
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#ifdef WIN32 #define stricmp strcasecmp
#include <minmax.h>
#else #include "HttpURLConnection.h"
#define stricmp strcasecmp #include "Socket.h"
#endif
using namespace std;
#include "HttpURLConnection.h"
#include "Socket.h" #define DEFAULT_PORT 80;
using namespace std; Field::Field(char *field)
{
#define DEFAULT_PORT 80; char *p = strtok(field, ": \t\r\n");
key = p ? p : "";
Field::Field(char *field) p = strtok(NULL, " \t\r\n");
{ value = p ? p : "";
char *p = strtok(field, ": \t\r\n"); }
key = p ? p : "";
p = strtok(NULL, " \t\r\n"); Field::Field(const char *k, const char *v)
value = p ? p : ""; {
} key = k ? k : "";
value = v ? v : "";
Field::Field(const char *k, const char *v) }
{
key = k ? k : ""; Field::Field(const Field &o)
value = v ? v : ""; {
} key = o.key;
value = o.value;
Field::Field(const Field &o) }
{
key = o.key; Field &Field::operator = (const Field &o)
value = o.value; {
} key = o.key;
value = o.value;
Field &Field::operator = (const Field &o) return *this;
{ }
key = o.key;
value = o.value; bool Field::operator == (const Field &o)
return *this; {
} return (key == o.key) && (value == o.value);
}
bool Field::operator == (const Field &o)
{ HttpURLConnection::HttpURLConnection(const URL &Url)
return (key == o.key) && (value == o.value); : connected(false), doInput(true), doOutput(false), url(Url)
} {
__sock = NULL;
HttpURLConnection::HttpURLConnection(const URL &Url) __method = "GET";
: connected(false), doInput(true), doOutput(false), url(Url) __request = NULL;
{ __response = NULL;
__sock = NULL; __response_code = HTTP_UNKNOWN;
__method = "GET"; }
__request = NULL;
__response = NULL; HttpURLConnection::~HttpURLConnection()
__response_code = HTTP_UNKNOWN; {
} disconnect();
HttpURLConnection::~HttpURLConnection() if (__sock) {
{ delete __sock;
disconnect(); }
if (__sock) { if (__request) {
delete __sock; delete __request;
} }
if (__request) { if (__response) {
delete __request; delete __response;
} }
}
if (__response) {
delete __response; void HttpURLConnection::disconnect()
} {
} if (connected) {
connected = false;
void HttpURLConnection::disconnect() __sock->close();
{ }
if (connected) { }
connected = false;
__sock->close(); const char *HttpURLConnection::getRequestMethod() const
} {
} return __method.c_str();
}
const char *HttpURLConnection::getRequestMethod() const
{ void HttpURLConnection::setRequestMethod(const char *method)
return __method.c_str(); {
} __method = method;
}
void HttpURLConnection::setRequestMethod(const char *method)
{ void HttpURLConnection::setRequestProperty(const char *key, const char *value)
__method = method; {
} if (__request == NULL) {
__request = new Fields;
void HttpURLConnection::setRequestProperty(const char *key, const char *value) }
{ __request->push_back(Field(key, value));
if (__request == NULL) { }
__request = new Fields;
} istream &HttpURLConnection::getInputStream()
__request->push_back(Field(key, value)); {
} if (!connected) {
connect();
istream &HttpURLConnection::getInputStream() setRequest();
{ }
if (!connected) { return __sock->getInputStream();
connect(); }
setRequest();
} ostream &HttpURLConnection::getOutputStream()
return __sock->getInputStream(); {
} if (!connected) {
connect();
ostream &HttpURLConnection::getOutputStream() }
{ return __sock->getOutputStream();
if (!connected) { }
connect();
} void HttpURLConnection::setDoInput(bool doinput)
return __sock->getOutputStream(); {
} doinput = doinput;
}
void HttpURLConnection::setDoInput(bool doinput)
{ void HttpURLConnection::setDoOutput(bool dooutput)
doinput = doinput; {
} dooutput = dooutput;
}
void HttpURLConnection::setDoOutput(bool dooutput)
{ void HttpURLConnection::connect()
dooutput = dooutput; {
} if (!connected) {
int port = url.getPort();
void HttpURLConnection::connect() if (port < 0) {
{ const char *protocol = url.getProtocol();
if (!connected) { if (!stricmp(protocol, "http")) {
int port = url.getPort(); port = DEFAULT_PORT;
if (port < 0) { } else if (!stricmp(protocol, "ipp")) {
const char *protocol = url.getProtocol(); port = 631;
if (!stricmp(protocol, "http")) { } else {
port = DEFAULT_PORT; port = DEFAULT_PORT;
} else if (!stricmp(protocol, "ipp")) { }
port = 631; }
} else { __sock = new Socket(url.getHost(), port);
port = DEFAULT_PORT; if (__sock->fail()) {
} __error_msg = __sock->getLastError();
} } else {
__sock = new Socket(url.getHost(), port); connected = true;
if (__sock->fail()) { }
__error_msg = __sock->getLastError(); }
} else { }
connected = true;
} const char *HttpURLConnection::getContentType()
} {
} return getHeaderField("Content-Type");
}
const char *HttpURLConnection::getContentType()
{ const char *HttpURLConnection::getContentEncoding()
return getHeaderField("Content-Type"); {
} return getHeaderField("Content-Encoding");
}
const char *HttpURLConnection::getContentEncoding()
{ int HttpURLConnection::getContentLength()
return getHeaderField("Content-Encoding"); {
} const char *p = getHeaderField("Content-Length");
return p ? atoi(p) : -1;
int HttpURLConnection::getContentLength() }
{
const char *p = getHeaderField("Content-Length"); const char *HttpURLConnection::getHeaderField(const char *s)
return p ? atoi(p) : -1; {
} if (__response == NULL) {
action();
const char *HttpURLConnection::getHeaderField(const char *s) }
{ if (__response) {
if (__response == NULL) { for (Fields::iterator it = __response->begin(); it != __response->end(); it++) {
action(); if ((*it).key == s) {
} return (*it).value.c_str();
if (__response) { }
for (Fields::iterator it = __response->begin(); it != __response->end(); it++) { }
if ((*it).key == s) { }
return (*it).value.c_str(); return NULL;
} }
}
} HTTP_RESPONSECODE HttpURLConnection::getResponseCode()
return NULL; {
} if (__response == NULL) {
action();
HTTP_RESPONSECODE HttpURLConnection::getResponseCode() }
{ return __response_code;
if (__response == NULL) { }
action();
} const char *HttpURLConnection::getResponseMessage()
return __response_code; {
} if (__response == NULL) {
action();
const char *HttpURLConnection::getResponseMessage() }
{ return __response_message.c_str();
if (__response == NULL) { }
action();
} void HttpURLConnection::action()
return __response_message.c_str(); {
} if (!connected) {
connect();
void HttpURLConnection::action() }
{ if (connected) {
if (!connected) { setRequest();
connect(); }
} if (connected) {
if (connected) { getResponse();
setRequest(); }
} }
if (connected) {
getResponse(); void HttpURLConnection::setRequest()
} {
} if (connected) {
setRequestProperty("Host", url.getHost());
void HttpURLConnection::setRequest() ostream &os = getOutputStream();
{ os << __method << ' ' << url.getFile() << " HTTP/1.1" << '\r' << '\n';
if (connected) { for (Fields::iterator it = __request->begin(); it != __request->end(); it++) {
setRequestProperty("Host", url.getHost()); os << (*it).key << ": " << (*it).value << '\r' << '\n';
ostream &os = getOutputStream(); }
os << __method << ' ' << url.getFile() << " HTTP/1.1" << '\r' << '\n'; os << '\r' << '\n';
for (Fields::iterator it = __request->begin(); it != __request->end(); it++) {
os << (*it).key << ": " << (*it).value << '\r' << '\n'; setContent();
}
os << '\r' << '\n'; if (!doOutput) {
os.flush();
setContent(); }
if (!doOutput) { if (__response) {
os.flush(); delete __response;
} __response = NULL;
}
if (__response) { }
delete __response; }
__response = NULL;
} void HttpURLConnection::setContent()
} {
} }
void HttpURLConnection::setContent() void HttpURLConnection::getResponse()
{ {
} if (connected) {
void HttpURLConnection::getResponse() if (__response == NULL) {
{ __response = new Fields;
if (connected) {
istream &is = getInputStream();
if (__response == NULL) {
__response = new Fields; char buffer[1024];
istream &is = getInputStream(); if (!is.getline(buffer, sizeof(buffer))) {
__error_msg = __sock->getLastError();
char buffer[1024]; return;
}
if (!is.getline(buffer, sizeof(buffer))) { buffer[is.gcount() - 2] = '\0';
__error_msg = __sock->getLastError(); __response_message = buffer;
return; strtok(buffer, " ");
} char *p = strtok(NULL, " ");
buffer[is.gcount() - 2] = '\0'; __response_code = p ? (HTTP_RESPONSECODE)atoi(p) : HTTP_UNKNOWN;
__response_message = buffer;
strtok(buffer, " "); while (is.getline(buffer, sizeof(buffer))) {
char *p = strtok(NULL, " "); if (buffer[0] == '\r') {
__response_code = p ? (HTTP_RESPONSECODE)atoi(p) : HTTP_UNKNOWN; break;
}
while (is.getline(buffer, sizeof(buffer))) { buffer[is.gcount() - 2] = '\0';
if (buffer[0] == '\r') { __response->push_back(Field(buffer));
break; }
}
buffer[is.gcount() - 2] = '\0'; int size = getContentLength();
__response->push_back(Field(buffer)); if (size > 0) {
} getContent();
}
int size = getContentLength();
if (size > 0) { if (__response_code != HTTP_CONTINUE) {
getContent(); const char *s = getHeaderField("Connection");
} if (s == NULL) {
connected = false;
if (__response_code != HTTP_CONTINUE) { __error_msg = "cannot found \"Connection\" field";
const char *s = getHeaderField("Connection"); } else if (stricmp(s, "Keep-Alive")) {
if (s == NULL) { connected = false;
connected = false; }
__error_msg = "cannot found \"Connection\" field"; }
} else if (stricmp(s, "Keep-Alive")) {
connected = false; switch (__response_code) {
} case HTTP_MOVED_TEMP:
} {
const char *p = getHeaderField("Location");
switch (__response_code) { if (p) {
case HTTP_MOVED_TEMP: URL trueUrl(p);
{ url = trueUrl;
const char *p = getHeaderField("Location"); delete __response;
if (p) { __response = NULL;
URL trueUrl(p); action();
url = trueUrl; }
delete __response; }
__response = NULL; break;
action(); case HTTP_CONTINUE:
} delete __response;
} __response = NULL;
break; getResponse();
case HTTP_CONTINUE: break;
delete __response; default:
__response = NULL; break;
getResponse(); }
break; }
default: }
break; }
}
} void HttpURLConnection::getContent()
} {
} const int maxBufSize = 1024;
if (connected) {
void HttpURLConnection::getContent() int size = getContentLength();
{ if (size > 0) {
const int maxBufSize = 1024; istream &is = getInputStream();
if (connected) { int bufsize = min(size, maxBufSize);
int size = getContentLength(); char buf[maxBufSize];
if (size > 0) { while (size > 0 && is.read(buf, bufsize)) {
istream &is = getInputStream(); size -= bufsize;
int bufsize = min(size, maxBufSize); }
char buf[maxBufSize]; }
while (size > 0 && is.read(buf, bufsize)) { }
size -= bufsize; }
}
}
}
}
@@ -1,148 +1,143 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#ifndef __HttpURLConnection_H #ifndef __HttpURLConnection_H
#define __HttpURLConnection_H #define __HttpURLConnection_H
#ifdef WIN32 #include <istream.h>
#include <istream> #include <ostream.h>
#include <ostream>
#else #include <list>
#include <istream.h> #include <string>
#include <ostream.h>
#endif #include "URL.h"
#include <list> using namespace std;
#include <string>
class Socket;
#include "URL.h"
enum HTTP_RESPONSECODE {
using namespace std; HTTP_UNKNOWN = -1, //
class Socket; HTTP_CONTINUE = 100, // Everything OK, keep going...
HTTP_SWITCH_PROC = 101, // Switching Protocols
enum HTTP_RESPONSECODE {
HTTP_UNKNOWN = -1, // HTTP_OK = 200, // OPTIONS/GET/HEAD/POST/TRACE command was successful
HTTP_CREATED, // PUT command was successful
HTTP_CONTINUE = 100, // Everything OK, keep going... HTTP_ACCEPTED, // DELETE command was successful
HTTP_SWITCH_PROC = 101, // Switching Protocols HTTP_NOT_AUTHORITATIVE, // Information isn't authoritative
HTTP_NO_CONTENT, // Successful command, no new data
HTTP_OK = 200, // OPTIONS/GET/HEAD/POST/TRACE command was successful HTTP_RESET, // Content was reset/recreated
HTTP_CREATED, // PUT command was successful HTTP_PARTIAL, // Only a partial file was recieved/sent
HTTP_ACCEPTED, // DELETE command was successful
HTTP_NOT_AUTHORITATIVE, // Information isn't authoritative HTTP_MULTI_CHOICE = 300, // Multiple files match request
HTTP_NO_CONTENT, // Successful command, no new data HTTP_MOVED_PERM, // Document has moved permanently
HTTP_RESET, // Content was reset/recreated HTTP_MOVED_TEMP, // Document has moved temporarily
HTTP_PARTIAL, // Only a partial file was recieved/sent HTTP_SEE_OTHER, // See this other link...
HTTP_NOT_MODIFIED, // File not modified
HTTP_MULTI_CHOICE = 300, // Multiple files match request HTTP_USE_PROXY, // Must use a proxy to access this URI
HTTP_MOVED_PERM, // Document has moved permanently
HTTP_MOVED_TEMP, // Document has moved temporarily HTTP_BAD_REQUEST = 400, // Bad request
HTTP_SEE_OTHER, // See this other link... HTTP_UNAUTHORIZED, // Unauthorized to access host
HTTP_NOT_MODIFIED, // File not modified HTTP_PAYMENT_REQUIRED, // Payment required
HTTP_USE_PROXY, // Must use a proxy to access this URI HTTP_FORBIDDEN, // Forbidden to access this URI
HTTP_NOT_FOUND, // URI was not found
HTTP_BAD_REQUEST = 400, // Bad request HTTP_BAD_METHOD, // Method is not allowed
HTTP_UNAUTHORIZED, // Unauthorized to access host HTTP_NOT_ACCEPTABLE, // Not Acceptable
HTTP_PAYMENT_REQUIRED, // Payment required HTTP_PROXY_AUTH, // Proxy Authentication is Required
HTTP_FORBIDDEN, // Forbidden to access this URI HTTP_REQUEST_TIMEOUT, // Request timed out
HTTP_NOT_FOUND, // URI was not found HTTP_CONFLICT, // Request is self-conflicting
HTTP_BAD_METHOD, // Method is not allowed HTTP_GONE, // Server has gone away
HTTP_NOT_ACCEPTABLE, // Not Acceptable HTTP_LENGTH_REQUIRED, // A content length or encoding is required
HTTP_PROXY_AUTH, // Proxy Authentication is Required HTTP_PRECON_FAILED, // Precondition failed
HTTP_REQUEST_TIMEOUT, // Request timed out HTTP_ENTITY_TOO_LARGE, // URI too long
HTTP_CONFLICT, // Request is self-conflicting HTTP_REQ_TOO_LONG, // Request entity too large
HTTP_GONE, // Server has gone away HTTP_UNSUPPORTED_TYPE, // The requested media type is unsupported
HTTP_LENGTH_REQUIRED, // A content length or encoding is required
HTTP_PRECON_FAILED, // Precondition failed HTTP_SERVER_ERROR = 500, // Internal server error
HTTP_ENTITY_TOO_LARGE, // URI too long HTTP_INTERNAL_ERROR, // Feature not implemented
HTTP_REQ_TOO_LONG, // Request entity too large HTTP_BAD_GATEWAY, // Bad gateway
HTTP_UNSUPPORTED_TYPE, // The requested media type is unsupported HTTP_UNAVAILABLE, // Service is unavailable
HTTP_GATEWAY_TIMEOUT, // Gateway connection timed out
HTTP_SERVER_ERROR = 500, // Internal server error HTTP_VERSION // HTTP version not supported
HTTP_INTERNAL_ERROR, // Feature not implemented };
HTTP_BAD_GATEWAY, // Bad gateway
HTTP_UNAVAILABLE, // Service is unavailable struct Field {
HTTP_GATEWAY_TIMEOUT, // Gateway connection timed out string key;
HTTP_VERSION // HTTP version not supported string value;
}; Field() {}
Field(char *field);
struct Field { Field(const char *k, const char *v);
string key; Field(const Field &);
string value; Field &operator = (const Field &);
Field() {} bool operator == (const Field &);
Field(char *field); };
Field(const char *k, const char *v);
Field(const Field &); typedef list<Field> Fields;
Field &operator = (const Field &);
bool operator == (const Field &); class HttpURLConnection {
}; public:
HttpURLConnection(const URL &url);
typedef list<Field> Fields; virtual ~HttpURLConnection();
class HttpURLConnection { virtual void connect();
public: void disconnect();
HttpURLConnection(const URL &url);
virtual ~HttpURLConnection(); void setRequestMethod(const char *method);
const char *getRequestMethod() const;
virtual void connect(); void setRequestProperty(const char *key, const char *value);
void disconnect();
const char *getContentType();
void setRequestMethod(const char *method); const char *getContentEncoding();
const char *getRequestMethod() const; int getContentLength();
void setRequestProperty(const char *key, const char *value); long getDate();
const char *getHeaderField(int n);
const char *getContentType(); const char *getHeaderField(const char *);
const char *getContentEncoding(); const URL &getURL() const;
int getContentLength(); HTTP_RESPONSECODE getResponseCode();
long getDate(); const char *getResponseMessage();
const char *getHeaderField(int n);
const char *getHeaderField(const char *); bool getDoInput() const;
const URL &getURL() const; bool getDoOutput() const;
HTTP_RESPONSECODE getResponseCode(); void setDoInput(bool doinput);
const char *getResponseMessage(); void setDoOutput(bool dooutput);
bool getDoInput() const; istream &getInputStream();
bool getDoOutput() const; ostream &getOutputStream();
void setDoInput(bool doinput);
void setDoOutput(bool dooutput); const char *getLastError() const;
void setLastError(const char *);
istream &getInputStream();
ostream &getOutputStream(); protected:
bool connected;
const char *getLastError() const; bool doInput;
void setLastError(const char *); bool doOutput;
URL url;
protected:
bool connected; virtual void action();
bool doInput; virtual void setRequest();
bool doOutput; virtual void setContent();
URL url; virtual void getResponse();
virtual void getContent();
virtual void action();
virtual void setRequest(); private:
virtual void setContent(); Fields *__request;
virtual void getResponse(); Fields *__response;
virtual void getContent(); Socket *__sock;
string __method;
private: string __response_message;
Fields *__request; HTTP_RESPONSECODE __response_code;
Fields *__response; string __error_msg;
Socket *__sock; };
string __method;
string __response_message; inline const char *HttpURLConnection::getLastError() const
HTTP_RESPONSECODE __response_code; {
string __error_msg; return __error_msg.c_str();
}; }
inline const char *HttpURLConnection::getLastError() const inline void HttpURLConnection::setLastError(const char *e)
{ {
return __error_msg.c_str(); __error_msg = e;
} }
inline void HttpURLConnection::setLastError(const char *e) #endif // __HttpURLConnection_H
{
__error_msg = e;
}
#endif // __HttpURLConnection_H
@@ -1,9 +1,7 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#ifdef WIN32 #if defined(__HAIKU__)
# include <winsock.h>
#elif defined(__HAIKU__)
# include <sys/socket.h> # include <sys/socket.h>
# include <netinet/in.h> # include <netinet/in.h>
#else #else
+450 -455
View File
@@ -1,455 +1,450 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#ifndef __IppContent_H #ifndef __IppContent_H
#define __IppContent_H #define __IppContent_H
#ifdef WIN32 #include <istream.h>
#include <istream> #include <ostream.h>
#include <ostream> #include <list>
#else #include <string>
#include <istream.h>
#include <ostream.h> #if (!__MWERKS__)
#endif using namespace std;
#include <list> #else
#include <string> #define std
#endif
#if (!__MWERKS__ || defined(WIN32))
using namespace std; enum IPP_OPERATION_ID {
#else
#define std /* reserved, not used: 0x0000 */
#endif /* reserved, not used: 0x0001 */
enum IPP_OPERATION_ID { IPP_PRINT_JOB = 0x0002, // printer operation
IPP_PRINT_URI = 0x0003, // printer operation
/* reserved, not used: 0x0000 */ IPP_VALIDATE_JOB = 0x0004, // printer operation
/* reserved, not used: 0x0001 */ IPP_CREATE_JOB = 0x0005, // printer operation
IPP_PRINT_JOB = 0x0002, // printer operation IPP_SEND_DOCUMENT = 0x0006, // job operation
IPP_PRINT_URI = 0x0003, // printer operation IPP_SEND_URI = 0x0007, // job operation
IPP_VALIDATE_JOB = 0x0004, // printer operation IPP_CANCEL_JOB = 0x0008, // job operation
IPP_CREATE_JOB = 0x0005, // printer operation IPP_GET_JOB_ATTRIBUTES = 0x0009, // job operation
IPP_SEND_DOCUMENT = 0x0006, // job operation IPP_GET_JOBS = 0x000A, // printer operation
IPP_SEND_URI = 0x0007, // job operation IPP_GET_PRINTER_ATTRIBUTES = 0x000B // printer operation
IPP_CANCEL_JOB = 0x0008, // job operation
IPP_GET_JOB_ATTRIBUTES = 0x0009, // job operation /* reserved for future operations: 0x000C-0x3FFF */
/* reserved for private extensions: 0x4000-0x8FFF */
IPP_GET_JOBS = 0x000A, // printer operation };
IPP_GET_PRINTER_ATTRIBUTES = 0x000B // printer operation
enum IPP_STATUS_CODE {
/* reserved for future operations: 0x000C-0x3FFF */
/* reserved for private extensions: 0x4000-0x8FFF */ IPP_SUCCESSFUL_OK_S = 0x0000, // successful
}; IPP_SUCCESSFUL_OK = 0x0000, // successful
IPP_SUCCESSFUL_OK_IGNORED_OR_SUBSTITUTED_ATTRIBUTES = 0x0001, // successful
enum IPP_STATUS_CODE { IPP_SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES = 0x0002, // successful
IPP_SUCCESSFUL_OK_E = 0x00FF, // successful
IPP_SUCCESSFUL_OK_S = 0x0000, // successful
IPP_SUCCESSFUL_OK = 0x0000, // successful IPP_INFORMATIONAL_S = 0x0100, // informational
IPP_SUCCESSFUL_OK_IGNORED_OR_SUBSTITUTED_ATTRIBUTES = 0x0001, // successful IPP_INFORMATIONAL_E = 0x01FF, // informational
IPP_SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES = 0x0002, // successful
IPP_SUCCESSFUL_OK_E = 0x00FF, // successful IPP_REDIRECTION_S = 0x0200, // redirection
IPP_REDIRECTION_SE = 0x02FF, // redirection
IPP_INFORMATIONAL_S = 0x0100, // informational
IPP_INFORMATIONAL_E = 0x01FF, // informational IPP_CLIENT_ERROR_S = 0x0400, // client-error
IPP_CLIENT_ERROR_BAD_REQUEST = 0x0400, // client-error
IPP_REDIRECTION_S = 0x0200, // redirection IPP_CLIENT_ERROR_FORBIDDEN = 0x0401, // client-error
IPP_REDIRECTION_SE = 0x02FF, // redirection IPP_CLIENT_ERROR_NOT_AUTHENTICATED = 0x0402, // client-error
IPP_CLIENT_ERROR_NOT_AUTHORIZED = 0x0403, // client-error
IPP_CLIENT_ERROR_S = 0x0400, // client-error IPP_CLIENT_ERROR_NOT_POSSIBLE = 0x0404, // client-error
IPP_CLIENT_ERROR_BAD_REQUEST = 0x0400, // client-error IPP_CLIENT_ERROR_TIMEOUT = 0x0405, // client-error
IPP_CLIENT_ERROR_FORBIDDEN = 0x0401, // client-error IPP_CLIENT_ERROR_NOT_FOUND = 0x0406, // client-error
IPP_CLIENT_ERROR_NOT_AUTHENTICATED = 0x0402, // client-error IPP_CLIENT_ERROR_GONE = 0x0407, // client-error
IPP_CLIENT_ERROR_NOT_AUTHORIZED = 0x0403, // client-error IPP_CLIENT_ERROR_REQUEST_ENTITY_TOO_LARGE = 0x0408, // client-error
IPP_CLIENT_ERROR_NOT_POSSIBLE = 0x0404, // client-error IPP_CLIENT_ERROR_REQUEST_VALUE_TOO_LONG = 0x0409, // client-error
IPP_CLIENT_ERROR_TIMEOUT = 0x0405, // client-error IPP_CLIENT_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED = 0x040A, // client-error
IPP_CLIENT_ERROR_NOT_FOUND = 0x0406, // client-error IPP_CLIENT_ERROR_ATTRIBUTES_OR_VALUES_NOT_SUPPORTED = 0x040B, // client-error
IPP_CLIENT_ERROR_GONE = 0x0407, // client-error IPP_CLIENT_ERROR_URI_SCHEME_NOT_SUPPORTED = 0x040C, // client-error
IPP_CLIENT_ERROR_REQUEST_ENTITY_TOO_LARGE = 0x0408, // client-error IPP_CLIENT_ERROR_CHARSET_NOT_SUPPORTED = 0x040D, // client-error
IPP_CLIENT_ERROR_REQUEST_VALUE_TOO_LONG = 0x0409, // client-error IPP_CLIENT_ERROR_CONFLICTING_ATTRIBUTES = 0x040E, // client-error
IPP_CLIENT_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED = 0x040A, // client-error IPP_CLIENT_ERROR_E = 0x04FF, // client-error
IPP_CLIENT_ERROR_ATTRIBUTES_OR_VALUES_NOT_SUPPORTED = 0x040B, // client-error
IPP_CLIENT_ERROR_URI_SCHEME_NOT_SUPPORTED = 0x040C, // client-error IPP_SERVER_ERROR_S = 0x0500, // server-error
IPP_CLIENT_ERROR_CHARSET_NOT_SUPPORTED = 0x040D, // client-error IPP_SERVER_ERROR_INTERNAL_ERROR = 0x0500, // server-error
IPP_CLIENT_ERROR_CONFLICTING_ATTRIBUTES = 0x040E, // client-error IPP_SERVER_ERROR_OPERATION_NOT_SUPPORTED = 0x0501, // server-error
IPP_CLIENT_ERROR_E = 0x04FF, // client-error IPP_SERVER_ERROR_SERVICE_UNAVAILABLE = 0x0502, // server-error
IPP_SERVER_ERROR_VERSION_NOT_SUPPORTED = 0x0503, // server-error
IPP_SERVER_ERROR_S = 0x0500, // server-error IPP_SERVER_ERROR_DEVICE_ERROR = 0x0504, // server-error
IPP_SERVER_ERROR_INTERNAL_ERROR = 0x0500, // server-error IPP_SERVER_ERROR_TEMPORARY_ERROR = 0x0505, // server-error
IPP_SERVER_ERROR_OPERATION_NOT_SUPPORTED = 0x0501, // server-error IPP_SERVER_ERROR_NOT_ACCEPTING_JOBS = 0x0506, // server-error
IPP_SERVER_ERROR_SERVICE_UNAVAILABLE = 0x0502, // server-error IPP_SERVER_ERROR_BUSY = 0x0507, // server-error
IPP_SERVER_ERROR_VERSION_NOT_SUPPORTED = 0x0503, // server-error IPP_SERVER_ERROR_JOB_CANCELED = 0x0508, // server-error
IPP_SERVER_ERROR_DEVICE_ERROR = 0x0504, // server-error IPP_SERVER_ERROR_E = 0x05FF // server-error
IPP_SERVER_ERROR_TEMPORARY_ERROR = 0x0505, // server-error };
IPP_SERVER_ERROR_NOT_ACCEPTING_JOBS = 0x0506, // server-error
IPP_SERVER_ERROR_BUSY = 0x0507, // server-error enum IPP_TAG {
IPP_SERVER_ERROR_JOB_CANCELED = 0x0508, // server-error /* reserved: 0x00 */
IPP_SERVER_ERROR_E = 0x05FF // server-error IPP_OPERATION_ATTRIBUTES_TAG = 0x01,
}; IPP_JOB_ATTRIBUTES_TAG = 0x02,
IPP_END_OF_ATTRIBUTES_TAG = 0x03,
enum IPP_TAG { IPP_PRINTER_ATTRIBUTES_TAG = 0x04,
/* reserved: 0x00 */ IPP_UNSUPPORTED_ATTRIBUTES_TAG = 0x05,
IPP_OPERATION_ATTRIBUTES_TAG = 0x01, /* reserved for future delimiters: 0x06-0x0e */
IPP_JOB_ATTRIBUTES_TAG = 0x02, /* reserved for future chunking-end-of-attributes-tag: 0x0F */
IPP_END_OF_ATTRIBUTES_TAG = 0x03,
IPP_PRINTER_ATTRIBUTES_TAG = 0x04, IPP_UNSUPPORTED = 0x10,
IPP_UNSUPPORTED_ATTRIBUTES_TAG = 0x05, /* reserved for future 'default': 0x11 */
/* reserved for future delimiters: 0x06-0x0e */ IPP_UNKNOWN = 0x12,
/* reserved for future chunking-end-of-attributes-tag: 0x0F */ IPP_NO_VALUE = 0x13,
/* reserved for future "out-of-band" values: 0x14-0x1F */
IPP_UNSUPPORTED = 0x10, /* reserved: 0x20 */
/* reserved for future 'default': 0x11 */ IPP_INTEGER = 0x21,
IPP_UNKNOWN = 0x12, IPP_BOOLEAN = 0x22,
IPP_NO_VALUE = 0x13, IPP_ENUM = 0x23,
/* reserved for future "out-of-band" values: 0x14-0x1F */ /* reserved for future integer types: 0x24-0x2F */
/* reserved: 0x20 */ IPP_STRING = 0x30,
IPP_INTEGER = 0x21, IPP_DATETIME = 0x31,
IPP_BOOLEAN = 0x22, IPP_RESOLUTION = 0x32,
IPP_ENUM = 0x23, IPP_RANGE_OF_INTEGER = 0x33,
/* reserved for future integer types: 0x24-0x2F */ /* reserved for collection (in the future): 0x34 */
IPP_STRING = 0x30, IPP_TEXT_WITH_LANGUAGE = 0x35,
IPP_DATETIME = 0x31, IPP_NAME_WITH_LANGUAGE = 0x36,
IPP_RESOLUTION = 0x32, /* reserved for future octetString types: 0x37-0x3F */
IPP_RANGE_OF_INTEGER = 0x33, /* reserved: 0x40 */
/* reserved for collection (in the future): 0x34 */ IPP_TEXT_WITHOUT_LANGUAGE = 0x41,
IPP_TEXT_WITH_LANGUAGE = 0x35, IPP_NAME_WITHOUT_LANGUAGE = 0x42,
IPP_NAME_WITH_LANGUAGE = 0x36, /* reserved: 0x43 */
/* reserved for future octetString types: 0x37-0x3F */ IPP_KEYWORD = 0x44,
/* reserved: 0x40 */ IPP_URI = 0x45,
IPP_TEXT_WITHOUT_LANGUAGE = 0x41, IPP_URISCHEME = 0x46,
IPP_NAME_WITHOUT_LANGUAGE = 0x42, IPP_CHARSET = 0x47,
/* reserved: 0x43 */ IPP_NATURAL_LANGUAGE = 0x48,
IPP_KEYWORD = 0x44, IPP_MIME_MEDIA_TYPE = 0x49
IPP_URI = 0x45, /* reserved for future character string types: 0x4A-0x5F */
IPP_URISCHEME = 0x46, };
IPP_CHARSET = 0x47,
IPP_NATURAL_LANGUAGE = 0x48, enum IPP_RESOLUTION_UNITS {
IPP_MIME_MEDIA_TYPE = 0x49 IPP_DOTS_PER_INCH = 3,
/* reserved for future character string types: 0x4A-0x5F */ IPP_DOTS_PER_CENTIMETER = 4
}; };
enum IPP_RESOLUTION_UNITS { enum IPP_FINISHINGS {
IPP_DOTS_PER_INCH = 3, IPP_NONE = 3,
IPP_DOTS_PER_CENTIMETER = 4 IPP_STAPLE = 4,
}; IPP_PUNCH = 5,
IPP_COVER = 6,
enum IPP_FINISHINGS { IPP_BIND = 7
IPP_NONE = 3, };
IPP_STAPLE = 4,
IPP_PUNCH = 5, enum IPP_ORIENTATION_REQUESTED {
IPP_COVER = 6, IPP_PORTRAIT = 3,
IPP_BIND = 7 IPP_LANDSCAPE = 4,
}; IPP_REVERSE_LANDSCAPE = 5,
IPP_REVERSE_PORTRAIT = 6
enum IPP_ORIENTATION_REQUESTED { };
IPP_PORTRAIT = 3,
IPP_LANDSCAPE = 4, enum IPP_PRINT_QUALITY {
IPP_REVERSE_LANDSCAPE = 5, IPP_DRAFT = 3,
IPP_REVERSE_PORTRAIT = 6 IPP_NORMAL = 4,
}; IPP_HIGH = 5
};
enum IPP_PRINT_QUALITY {
IPP_DRAFT = 3, enum IPP_JOB_STATE {
IPP_NORMAL = 4, IPP_JOB_STATE_PENDING = 3,
IPP_HIGH = 5 IPP_JOB_STATE_PENDING_HELD = 4,
}; IPP_JOB_STATE_PROCESSING = 5,
IPP_JOB_STATE_PROCESSING_STOPPED= 6,
enum IPP_JOB_STATE { IPP_JOB_STATE_CANCELED = 7,
IPP_JOB_STATE_PENDING = 3, IPP_JOB_STATE_ABORTED = 8,
IPP_JOB_STATE_PENDING_HELD = 4, IPP_JOB_STATE_COMPLETED = 9
IPP_JOB_STATE_PROCESSING = 5, };
IPP_JOB_STATE_PROCESSING_STOPPED= 6,
IPP_JOB_STATE_CANCELED = 7, enum IPP_PRINTER_STATE {
IPP_JOB_STATE_ABORTED = 8, IPP_PRINTER_STATEIDLE = 3,
IPP_JOB_STATE_COMPLETED = 9 IPP_PRINTER_STATEPROCESSING = 4,
}; IPP_PRINTER_STATESTOPPED = 5
};
enum IPP_PRINTER_STATE {
IPP_PRINTER_STATEIDLE = 3,
IPP_PRINTER_STATEPROCESSING = 4, class IppAttribute {
IPP_PRINTER_STATESTOPPED = 5 public:
}; IppAttribute(IPP_TAG);
virtual ~IppAttribute() {}
virtual int length() const;
class IppAttribute { virtual istream &input(istream &is);
public: virtual ostream &output(ostream &os) const;
IppAttribute(IPP_TAG); virtual ostream &print(ostream &) const;
virtual ~IppAttribute() {} friend istream& operator >> (istream &is, IppAttribute &attr)
virtual int length() const; {
virtual istream &input(istream &is); return attr.input(is);
virtual ostream &output(ostream &os) const; }
virtual ostream &print(ostream &) const; friend ostream& operator << (ostream &os, const IppAttribute &attr)
friend istream& operator >> (istream &is, IppAttribute &attr) {
{ return attr.output(os);
return attr.input(is); }
}
friend ostream& operator << (ostream &os, const IppAttribute &attr) IPP_TAG tag;
{ };
return attr.output(os);
} class IppNamedAttribute : public IppAttribute {
public:
IPP_TAG tag; IppNamedAttribute(IPP_TAG t);
}; IppNamedAttribute(IPP_TAG t, const char *n);
virtual ~IppNamedAttribute() {}
class IppNamedAttribute : public IppAttribute { virtual int length() const;
public: virtual istream &input(istream &is);
IppNamedAttribute(IPP_TAG t); virtual ostream &output(ostream &os) const;
IppNamedAttribute(IPP_TAG t, const char *n); string name;
virtual ~IppNamedAttribute() {} friend istream& operator >> (istream &is, IppNamedAttribute &attr)
virtual int length() const; {
virtual istream &input(istream &is); return attr.input(is);
virtual ostream &output(ostream &os) const; }
string name; friend ostream& operator << (ostream &os, const IppNamedAttribute &attr)
friend istream& operator >> (istream &is, IppNamedAttribute &attr) {
{ return attr.output(os);
return attr.input(is); }
} virtual ostream &print(ostream &) const;
friend ostream& operator << (ostream &os, const IppNamedAttribute &attr) };
{
return attr.output(os); class IppNoValueAttribute : public IppNamedAttribute {
} public:
virtual ostream &print(ostream &) const; IppNoValueAttribute(IPP_TAG t);
}; IppNoValueAttribute(IPP_TAG t, const char *n);
virtual ~IppNoValueAttribute() {}
class IppNoValueAttribute : public IppNamedAttribute { virtual int length() const;
public: virtual istream &input(istream &is);
IppNoValueAttribute(IPP_TAG t); virtual ostream &output(ostream &os) const;
IppNoValueAttribute(IPP_TAG t, const char *n); virtual ostream &print(ostream &) const;
virtual ~IppNoValueAttribute() {} friend istream& operator >> (istream &is, IppNoValueAttribute &attr)
virtual int length() const; {
virtual istream &input(istream &is); return attr.input(is);
virtual ostream &output(ostream &os) const; }
virtual ostream &print(ostream &) const; friend ostream& operator << (ostream &os, const IppNoValueAttribute &attr)
friend istream& operator >> (istream &is, IppNoValueAttribute &attr) {
{ return attr.output(os);
return attr.input(is); }
} };
friend ostream& operator << (ostream &os, const IppNoValueAttribute &attr)
{ class IppBooleanAttribute : public IppNamedAttribute {
return attr.output(os); public:
} IppBooleanAttribute(IPP_TAG t);
}; IppBooleanAttribute(IPP_TAG t, const char *n, bool f);
virtual ~IppBooleanAttribute() {}
class IppBooleanAttribute : public IppNamedAttribute { virtual int length() const;
public: virtual istream &input(istream &is);
IppBooleanAttribute(IPP_TAG t); virtual ostream &output(ostream &os) const;
IppBooleanAttribute(IPP_TAG t, const char *n, bool f); virtual ostream &print(ostream &) const;
virtual ~IppBooleanAttribute() {} friend istream& operator >> (istream &is, IppBooleanAttribute &attr)
virtual int length() const; {
virtual istream &input(istream &is); return attr.input(is);
virtual ostream &output(ostream &os) const; }
virtual ostream &print(ostream &) const; friend ostream& operator << (ostream &os, const IppBooleanAttribute &attr)
friend istream& operator >> (istream &is, IppBooleanAttribute &attr) {
{ return attr.output(os);
return attr.input(is); }
}
friend ostream& operator << (ostream &os, const IppBooleanAttribute &attr) bool value;
{ };
return attr.output(os);
} class IppIntegerAttribute : public IppNamedAttribute {
public:
bool value; IppIntegerAttribute(IPP_TAG t);
}; IppIntegerAttribute(IPP_TAG t, const char *n, int v);
virtual ~IppIntegerAttribute() {}
class IppIntegerAttribute : public IppNamedAttribute { virtual int length() const;
public: virtual istream &input(istream &is);
IppIntegerAttribute(IPP_TAG t); virtual ostream &output(ostream &os) const;
IppIntegerAttribute(IPP_TAG t, const char *n, int v); virtual ostream &print(ostream &) const;
virtual ~IppIntegerAttribute() {} friend istream& operator >> (istream &is, IppIntegerAttribute &attr)
virtual int length() const; {
virtual istream &input(istream &is); return attr.input(is);
virtual ostream &output(ostream &os) const; }
virtual ostream &print(ostream &) const; friend ostream& operator << (ostream &os, const IppIntegerAttribute &attr)
friend istream& operator >> (istream &is, IppIntegerAttribute &attr) {
{ return attr.output(os);
return attr.input(is); }
}
friend ostream& operator << (ostream &os, const IppIntegerAttribute &attr) long value;
{ };
return attr.output(os);
} class DATETIME {
public:
long value; DATETIME();
}; DATETIME(const DATETIME &);
DATETIME & operator = (const DATETIME &);
class DATETIME { friend istream& operator >> (istream &is, DATETIME &attr);
public: friend ostream& operator << (ostream &os, const DATETIME &attr);
DATETIME();
DATETIME(const DATETIME &); unsigned char datetime[11];
DATETIME & operator = (const DATETIME &); };
friend istream& operator >> (istream &is, DATETIME &attr);
friend ostream& operator << (ostream &os, const DATETIME &attr); class IppDatetimeAttribute : public IppNamedAttribute {
public:
unsigned char datetime[11]; IppDatetimeAttribute(IPP_TAG t);
}; IppDatetimeAttribute(IPP_TAG t, const char *n, const DATETIME *dt);
virtual ~IppDatetimeAttribute() {}
class IppDatetimeAttribute : public IppNamedAttribute { virtual int length() const;
public: virtual istream &input(istream &is);
IppDatetimeAttribute(IPP_TAG t); virtual ostream &output(ostream &os) const;
IppDatetimeAttribute(IPP_TAG t, const char *n, const DATETIME *dt); virtual ostream &print(ostream &) const;
virtual ~IppDatetimeAttribute() {} friend istream& operator >> (istream &is, IppDatetimeAttribute &attr)
virtual int length() const; {
virtual istream &input(istream &is); return attr.input(is);
virtual ostream &output(ostream &os) const; }
virtual ostream &print(ostream &) const; friend ostream& operator << (ostream &os, const IppDatetimeAttribute &attr)
friend istream& operator >> (istream &is, IppDatetimeAttribute &attr) {
{ return attr.output(os);
return attr.input(is); }
}
friend ostream& operator << (ostream &os, const IppDatetimeAttribute &attr) DATETIME datetime;
{ };
return attr.output(os);
} class IppStringAttribute : public IppNamedAttribute {
public:
DATETIME datetime; IppStringAttribute(IPP_TAG t);
}; IppStringAttribute(IPP_TAG t, const char *s, const char *s1);
virtual ~IppStringAttribute() {}
class IppStringAttribute : public IppNamedAttribute { virtual int length() const;
public: virtual istream &input(istream &is);
IppStringAttribute(IPP_TAG t); virtual ostream &output(ostream &os) const;
IppStringAttribute(IPP_TAG t, const char *s, const char *s1); virtual ostream &print(ostream &) const;
virtual ~IppStringAttribute() {} friend istream& operator >> (istream &is, IppStringAttribute &attr)
virtual int length() const; {
virtual istream &input(istream &is); return attr.input(is);
virtual ostream &output(ostream &os) const; }
virtual ostream &print(ostream &) const; friend ostream& operator << (ostream &os, const IppStringAttribute &attr)
friend istream& operator >> (istream &is, IppStringAttribute &attr) {
{ return attr.output(os);
return attr.input(is); }
}
friend ostream& operator << (ostream &os, const IppStringAttribute &attr) string text;
{ };
return attr.output(os);
} class IppDoubleStringAttribute : public IppNamedAttribute {
public:
string text; IppDoubleStringAttribute(IPP_TAG t);
}; IppDoubleStringAttribute(IPP_TAG t, const char *n, const char *s1, const char *s2);
virtual ~IppDoubleStringAttribute() {}
class IppDoubleStringAttribute : public IppNamedAttribute { virtual int length() const;
public: virtual istream &input(istream &is);
IppDoubleStringAttribute(IPP_TAG t); virtual ostream &output(ostream &os) const;
IppDoubleStringAttribute(IPP_TAG t, const char *n, const char *s1, const char *s2); friend istream& operator >> (istream &is, IppDoubleStringAttribute &attr)
virtual ~IppDoubleStringAttribute() {} {
virtual int length() const; return attr.input(is);
virtual istream &input(istream &is); }
virtual ostream &output(ostream &os) const; friend ostream& operator << (ostream &os, const IppDoubleStringAttribute &attr)
friend istream& operator >> (istream &is, IppDoubleStringAttribute &attr) {
{ return attr.output(os);
return attr.input(is); }
} virtual ostream &print(ostream &) const;
friend ostream& operator << (ostream &os, const IppDoubleStringAttribute &attr)
{ string text1;
return attr.output(os); string text2;
} };
virtual ostream &print(ostream &) const;
class IppResolutionAttribute : public IppNamedAttribute {
string text1; public:
string text2; IppResolutionAttribute(IPP_TAG t);
}; IppResolutionAttribute(IPP_TAG t, const char *n, int, int, IPP_RESOLUTION_UNITS);
virtual ~IppResolutionAttribute() {}
class IppResolutionAttribute : public IppNamedAttribute { virtual int length() const;
public: virtual istream &input(istream &is);
IppResolutionAttribute(IPP_TAG t); virtual ostream &output(ostream &os) const;
IppResolutionAttribute(IPP_TAG t, const char *n, int, int, IPP_RESOLUTION_UNITS); virtual ostream &print(ostream &) const;
virtual ~IppResolutionAttribute() {} friend istream& operator >> (istream &is, IppResolutionAttribute &attr)
virtual int length() const; {
virtual istream &input(istream &is); return attr.input(is);
virtual ostream &output(ostream &os) const; }
virtual ostream &print(ostream &) const; friend ostream& operator << (ostream &os, const IppResolutionAttribute &attr)
friend istream& operator >> (istream &is, IppResolutionAttribute &attr) {
{ return attr.output(os);
return attr.input(is); }
}
friend ostream& operator << (ostream &os, const IppResolutionAttribute &attr) int xres;
{ int yres;
return attr.output(os); IPP_RESOLUTION_UNITS resolution_units;
} };
int xres; class IppRangeOfIntegerAttribute : public IppNamedAttribute {
int yres; public:
IPP_RESOLUTION_UNITS resolution_units; IppRangeOfIntegerAttribute(IPP_TAG t);
}; IppRangeOfIntegerAttribute(IPP_TAG t, const char *n, int, int);
virtual ~IppRangeOfIntegerAttribute() {}
class IppRangeOfIntegerAttribute : public IppNamedAttribute { virtual int length() const;
public: virtual istream &input(istream &is);
IppRangeOfIntegerAttribute(IPP_TAG t); virtual ostream &output(ostream &os) const;
IppRangeOfIntegerAttribute(IPP_TAG t, const char *n, int, int); virtual ostream &print(ostream &) const;
virtual ~IppRangeOfIntegerAttribute() {} friend istream& operator >> (istream &is, IppRangeOfIntegerAttribute &attr)
virtual int length() const; {
virtual istream &input(istream &is); return attr.input(is);
virtual ostream &output(ostream &os) const; }
virtual ostream &print(ostream &) const; friend ostream& operator << (ostream &os, const IppRangeOfIntegerAttribute &attr)
friend istream& operator >> (istream &is, IppRangeOfIntegerAttribute &attr) {
{ return attr.output(os);
return attr.input(is); }
}
friend ostream& operator << (ostream &os, const IppRangeOfIntegerAttribute &attr) long lower;
{ long upper;
return attr.output(os); };
}
class IppContent {
long lower; public:
long upper; IppContent();
}; ~IppContent();
int length() const;
class IppContent { istream &input(istream &);
public: ostream &output(ostream &) const;
IppContent(); friend istream& operator >> (istream &is, IppContent &ic)
~IppContent(); {
int length() const; return ic.input(is);
istream &input(istream &); }
ostream &output(ostream &) const; friend ostream& operator << (ostream &os, const IppContent &ic)
friend istream& operator >> (istream &is, IppContent &ic) {
{ return ic.output(os);
return ic.input(is); }
} void setVersion(unsigned short);
friend ostream& operator << (ostream &os, const IppContent &ic) unsigned short getVersion() const;
{ void setOperationId(IPP_OPERATION_ID);
return ic.output(os); IPP_OPERATION_ID getOperationId() const;
} void setRequestId(unsigned long);
void setVersion(unsigned short); unsigned long getRequestId() const;
unsigned short getVersion() const; IPP_STATUS_CODE getStatusCode() const;
void setOperationId(IPP_OPERATION_ID); const char *getStatusMessage() const;
IPP_OPERATION_ID getOperationId() const;
void setRequestId(unsigned long); void setDelimiter(IPP_TAG tag);
unsigned long getRequestId() const; void setInteger(const char *name, int value);
IPP_STATUS_CODE getStatusCode() const; void setBoolean(const char *name, bool value);
const char *getStatusMessage() const; void setString(const char *name, const char *value);
void setDateTime(const char *name, const DATETIME *dt);
void setDelimiter(IPP_TAG tag); void setResolution(const char *name, int x, int y, IPP_RESOLUTION_UNITS u);
void setInteger(const char *name, int value); void setRangeOfInteger(const char *name, int lower, int upper);
void setBoolean(const char *name, bool value); void setTextWithLanguage(const char *name, const char *s1, const char *s2);
void setString(const char *name, const char *value); void setNameWithLanguage(const char *name, const char *s1, const char *s2);
void setDateTime(const char *name, const DATETIME *dt); void setTextWithoutLanguage(const char *name, const char *value);
void setResolution(const char *name, int x, int y, IPP_RESOLUTION_UNITS u); void setNameWithoutLanguage(const char *name, const char *value);
void setRangeOfInteger(const char *name, int lower, int upper); void setKeyword(const char *name, const char *value);
void setTextWithLanguage(const char *name, const char *s1, const char *s2); void setURI(const char *name, const char *value);
void setNameWithLanguage(const char *name, const char *s1, const char *s2); void setURIScheme(const char *name, const char *value);
void setTextWithoutLanguage(const char *name, const char *value); void setCharset(const char *name, const char *value);
void setNameWithoutLanguage(const char *name, const char *value); void setNaturalLanguage(const char *name, const char *value);
void setKeyword(const char *name, const char *value); void setMimeMediaType(const char *name, const char *value);
void setURI(const char *name, const char *value);
void setURIScheme(const char *name, const char *value); void setRawData(const char *file, int size = -1);
void setCharset(const char *name, const char *value); void setRawData(istream &is, int size = -1);
void setNaturalLanguage(const char *name, const char *value); ostream &print(ostream &) const;
void setMimeMediaType(const char *name, const char *value);
bool operator !() const;
void setRawData(const char *file, int size = -1); bool good() const;
void setRawData(istream &is, int size = -1); bool fail() const;
ostream &print(ostream &) const;
private:
bool operator !() const; list<IppAttribute *> attrs;
bool good() const; unsigned short version;
bool fail() const; unsigned short operation_id;
unsigned long request_id;
private: string file_path;
list<IppAttribute *> attrs; istream *is;
unsigned short version; int size;
unsigned short operation_id; };
unsigned long request_id;
string file_path; #endif // __IppContent_H
istream *is;
int size;
};
#endif // __IppContent_H
@@ -18,7 +18,7 @@
#include "IppDefs.h" #include "IppDefs.h"
#include "DbgMsg.h" #include "DbgMsg.h"
#if (!__MWERKS__ || defined(WIN32)) #if (!__MWERKS__)
using namespace std; using namespace std;
#else #else
#define std #define std
+47 -47
View File
@@ -1,47 +1,47 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#ifndef __IppTransport_H #ifndef __IppTransport_H
#define __IppTransport_H #define __IppTransport_H
#include <DataIO.h> #include <DataIO.h>
#include <Message.h> #include <Message.h>
#include <fstream> #include <fstream>
#include <string> #include <string>
#if (!__MWERKS__ || defined(WIN32)) #if (!__MWERKS__)
using namespace std; using namespace std;
#else #else
#define std #define std
#endif #endif
class IppTransport : public BDataIO { class IppTransport : public BDataIO {
public: public:
IppTransport(BMessage *msg); IppTransport(BMessage *msg);
virtual ~IppTransport(); virtual ~IppTransport();
virtual ssize_t Read(void *buffer, size_t size); virtual ssize_t Read(void *buffer, size_t size);
virtual ssize_t Write(const void *buffer, size_t size); virtual ssize_t Write(const void *buffer, size_t size);
bool operator !() const; bool operator !() const;
bool fail() const; bool fail() const;
private: private:
char __url[256]; char __url[256];
char __user[256]; char __user[256];
char __file[256]; char __file[256];
int32 __jobid; int32 __jobid;
bool __error; bool __error;
fstream __fs; fstream __fs;
}; };
inline bool IppTransport::fail() const inline bool IppTransport::fail() const
{ {
return __error; return __error;
} }
inline bool IppTransport::operator !() const inline bool IppTransport::operator !() const
{ {
return fail(); return fail();
} }
#endif // __IppTransport_H #endif // __IppTransport_H
@@ -1,11 +1,6 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#ifdef WIN32
#include <winsock.h>
#include <ostream>
#include <cstring>
#else
#ifdef __HAIKU__ #ifdef __HAIKU__
# include <sys/socket.h> # include <sys/socket.h>
#else #else
@@ -21,7 +16,6 @@ char *itoa(int i, char *buf, int unit)
} }
#define stricmp strcasecmp #define stricmp strcasecmp
#define strnicmp strncasecmp #define strnicmp strncasecmp
#endif // WIN32
#include <list> #include <list>
#include "IppURLConnection.h" #include "IppURLConnection.h"
+68 -68
View File
@@ -1,68 +1,68 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#ifndef __URL_H #ifndef __URL_H
#define __URL_H #define __URL_H
#include <string> #include <string>
#if (!__MWERKS__ || defined(WIN32)) #if (!__MWERKS__)
using namespace std; using namespace std;
#else #else
#define std #define std
#endif #endif
class URL { class URL {
public: public:
URL(const char *spec); URL(const char *spec);
URL(const char *protocol, const char *host, int port, const char *file); URL(const char *protocol, const char *host, int port, const char *file);
URL(const char *protocol, const char *host, const char *file); URL(const char *protocol, const char *host, const char *file);
// URL(URL &, const char *spec); // URL(URL &, const char *spec);
int getPort() const; int getPort() const;
const char *getProtocol() const; const char *getProtocol() const;
const char *getHost() const; const char *getHost() const;
const char *getFile() const; const char *getFile() const;
const char *getRef() const; const char *getRef() const;
URL(const URL &); URL(const URL &);
URL &operator = (const URL &); URL &operator = (const URL &);
bool operator == (const URL &); bool operator == (const URL &);
protected: protected:
// void set(const char *protocol, const char *host, int port, const char *file, const char *ref); // void set(const char *protocol, const char *host, int port, const char *file, const char *ref);
private: private:
string __protocol; string __protocol;
string __host; string __host;
string __file; string __file;
string __ref; string __ref;
int __port; int __port;
}; };
inline int URL::getPort() const inline int URL::getPort() const
{ {
return __port; return __port;
} }
inline const char *URL::getProtocol() const inline const char *URL::getProtocol() const
{ {
return __protocol.c_str(); return __protocol.c_str();
} }
inline const char *URL::getHost() const inline const char *URL::getHost() const
{ {
return __host.c_str(); return __host.c_str();
} }
inline const char *URL::getFile() const inline const char *URL::getFile() const
{ {
return __file.c_str(); return __file.c_str();
} }
inline const char *URL::getRef() const inline const char *URL::getRef() const
{ {
return __ref.c_str(); return __ref.c_str();
} }
#endif // __URL_H #endif // __URL_H
@@ -19,7 +19,7 @@
#include "LprDefs.h" #include "LprDefs.h"
#include "DbgMsg.h" #include "DbgMsg.h"
#if (!__MWERKS__ || defined(WIN32)) #if (!__MWERKS__)
using namespace std; using namespace std;
#else #else
#define std #define std
+48 -48
View File
@@ -1,48 +1,48 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#ifndef __LprTransport_H #ifndef __LprTransport_H
#define __LprTransport_H #define __LprTransport_H
#include <DataIO.h> #include <DataIO.h>
#include <Message.h> #include <Message.h>
#include <fstream> #include <fstream>
#include <string> #include <string>
#if (!__MWERKS__ || defined(WIN32)) #if (!__MWERKS__)
using namespace std; using namespace std;
#else #else
#define std #define std
#endif #endif
class LprTransport : public BDataIO { class LprTransport : public BDataIO {
public: public:
LprTransport(BMessage *msg); LprTransport(BMessage *msg);
virtual ~LprTransport(); virtual ~LprTransport();
virtual ssize_t Read(void *buffer, size_t size); virtual ssize_t Read(void *buffer, size_t size);
virtual ssize_t Write(const void *buffer, size_t size); virtual ssize_t Write(const void *buffer, size_t size);
bool operator !() const; bool operator !() const;
bool fail() const; bool fail() const;
private: private:
char __server[256]; char __server[256];
char __queue[256]; char __queue[256];
char __file[256]; char __file[256];
char __user[256]; char __user[256];
int32 __jobid; int32 __jobid;
fstream __fs; fstream __fs;
bool __error; bool __error;
}; };
inline bool LprTransport::fail() const inline bool LprTransport::fail() const
{ {
return __error; return __error;
} }
inline bool LprTransport::operator !() const inline bool LprTransport::operator !() const
{ {
return fail(); return fail();
} }
#endif // __LprTransport_H #endif // __LprTransport_H
+9 -20
View File
@@ -1,21 +1,15 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#ifdef WIN32 #ifdef __HAIKU__
# include <windows.h> # include <sys/socket.h>
# include <winsock.h> # include <netdb.h>
# include <sstream>
#else #else
# ifdef __HAIKU__ # include <net/socket.h>
# include <sys/socket.h> # include <net/netdb.h>
# include <netdb.h>
# else
# include <net/socket.h>
# include <net/netdb.h>
# endif
# include <errno.h>
# include "_sstream"
#endif #endif
#include <errno.h>
#include "_sstream"
#include <iomanip> #include <iomanip>
#include <algorithm> #include <algorithm>
@@ -23,7 +17,7 @@
#include "Socket.h" #include "Socket.h"
//#include "DbgMsg.h" //#include "DbgMsg.h"
#if (!__MWERKS__ || defined(WIN32)) #if (!__MWERKS__)
using namespace std; using namespace std;
#else #else
#define std #define std
@@ -51,12 +45,7 @@ using namespace std;
#define INADDR_NONE 0xffffffff #define INADDR_NONE 0xffffffff
#endif #endif
#ifdef WIN32 #define ERRNO errno
#define EADDRINUSE WSAEADDRINUSE
#define ERRNO WSAGetLastError()
#else
#define ERRNO errno
#endif
LpsClient::LpsClient(const char *host) LpsClient::LpsClient(const char *host)
+51 -56
View File
@@ -1,56 +1,51 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#ifndef __LPSCLIENT_H #ifndef __LPSCLIENT_H
#define __LPSCLIENT_H #define __LPSCLIENT_H
#ifdef WIN32 #include <istream.h>
#include <istream> #include <ostream.h>
#include <ostream> #include <string>
#else
#include <istream.h> #if (!__MWERKS__)
#include <ostream.h> using namespace std;
#endif #else
#include <string> #define std
#endif
#if (!__MWERKS__ || defined(WIN32))
using namespace std; class Socket;
#else
#define std class LPSException {
#endif private:
string str;
class Socket; public:
LPSException(const string &what_arg) : str(what_arg) {}
class LPSException { const char *what() const { return str.c_str(); }
private: };
string str;
public: class LpsClient {
LPSException(const string &what_arg) : str(what_arg) {} public:
const char *what() const { return str.c_str(); } LpsClient(const char *host);
}; ~LpsClient();
void connect() throw(LPSException);
class LpsClient { void close();
public: void receiveJob(const char *queue) throw(LPSException);
LpsClient(const char *host); void receiveControlFile(int cfsize, const char *cfname) throw(LPSException);
~LpsClient(); void receiveDataFile(int dfsize, const char *dfname) throw(LPSException);
void connect() throw(LPSException); void transferData(const char *buffer, int size = -1) throw(LPSException);
void close(); void transferData(istream &is, int size = -1) throw(LPSException);
void receiveJob(const char *queue) throw(LPSException); void endTransfer() throw(LPSException);
void receiveControlFile(int cfsize, const char *cfname) throw(LPSException); void checkAck() throw(LPSException);
void receiveDataFile(int dfsize, const char *dfname) throw(LPSException);
void transferData(const char *buffer, int size = -1) throw(LPSException); protected:
void transferData(istream &is, int size = -1) throw(LPSException); bool connected;
void endTransfer() throw(LPSException);
void checkAck() throw(LPSException); private:
string __host;
protected: Socket *__sock;
bool connected; istream *__is;
ostream *__os;
private: };
string __host;
Socket *__sock; #endif /* __LPSCLIENT_H */
istream *__is;
ostream *__os;
};
#endif /* __LPSCLIENT_H */
+1 -2
View File
@@ -9,8 +9,7 @@ if $(BONE_COMPATIBLE) {
Objects Objects
DbgMsg.cpp DbgMsg.cpp
Socket.cpp Socket.cpp
SocketStream1.cpp SocketStream.cpp
SocketStream2.cpp
; ;
+3 -29
View File
@@ -1,17 +1,13 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#ifdef WIN32
#include <winsock.h>
#else
#ifdef __HAIKU__ #ifdef __HAIKU__
# include <sys/socket.h> # include <sys/socket.h>
#else #else
# include <net/socket.h> # include <net/socket.h>
#endif #endif
#include <netdb.h> #include <netdb.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#endif // WIN32
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
@@ -23,29 +19,7 @@
#define INADDR_NONE 0xffffffff #define INADDR_NONE 0xffffffff
#endif #endif
#ifdef WIN32 #include <errno.h>
#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) Socket::Socket(const char *host, int port)
: __sock(-1), __is(NULL), __os(NULL), __error(false) : __sock(-1), __is(NULL), __os(NULL), __error(false)
+63 -68
View File
@@ -1,68 +1,63 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#ifndef __Socket_H #ifndef __Socket_H
#define __Socket_H #define __Socket_H
#ifdef WIN32 #include <istream.h>
#include <istream> #include <ostream.h>
#include <ostream>
#else #include <string>
#include <istream.h>
#include <ostream.h> #if (!__MWERKS__)
#endif // WIN32 using namespace std;
#else
#include <string> #define std
#endif
#if (!__MWERKS__ || defined(WIN32))
using namespace std; class Socket {
#else public:
#define std Socket(const char *host, int port);
#endif Socket(const char *host, int port, int localPort);
~Socket();
class Socket {
public: bool operator !() const;
Socket(const char *host, int port); bool good() const;
Socket(const char *host, int port, int localPort); bool fail() const;
~Socket();
void close();
bool operator !() const; int read(char *buffer, int size, int flags = 0);
bool good() const; int write(const char *buffer, int size, int flags = 0);
bool fail() const;
istream &getInputStream();
void close(); ostream &getOutputStream();
int read(char *buffer, int size, int flags = 0);
int write(const char *buffer, int size, int flags = 0); int getPort() const;
const char *getLastError() const;
istream &getInputStream();
ostream &getOutputStream(); private:
Socket(const Socket &);
int getPort() const; Socket &operator = (const Socket &);
const char *getLastError() const; void open();
private: string __host;
Socket(const Socket &); int __port;
Socket &operator = (const Socket &); int __localPort;
void open(); int __sock;
istream *__is;
string __host; ostream *__os;
int __port; bool __error;
int __localPort; char __error_msg[256];
int __sock; };
istream *__is;
ostream *__os; inline int Socket::getPort() const
bool __error; {
char __error_msg[256]; return __port;
}; }
inline int Socket::getPort() const inline const char *Socket::getLastError() const
{ {
return __port; return __error_msg;
} }
inline const char *Socket::getLastError() const #endif // __Socket_H
{
return __error_msg;
}
#endif // __Socket_H
@@ -1,7 +1,6 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#ifndef WIN32
#ifdef __HAIKU__ #ifdef __HAIKU__
# include <sys/socket.h> # include <sys/socket.h>
#else #else
@@ -127,5 +126,3 @@ osocketstream::~osocketstream()
{ {
flush(); flush();
} }
#endif // !WIN32
@@ -1,8 +1,60 @@
// Sun, 18 Jun 2000 // Sun, 18 Jun 2000
// Y.Takagi // Y.Takagi
#ifdef WIN32 #ifndef __SocketStream_H
#include "SocketStream1.h" #define __SocketStream_H
#else
#include "SocketStream2.h" #include <istream.h>
#endif #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
@@ -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
@@ -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
@@ -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