mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-27 01:26:30 +00:00
Changed: Minor changes
This commit is contained in:
parent
5f912f713a
commit
3b38f01d5f
5 changed files with 210 additions and 174 deletions
|
@ -21,7 +21,7 @@
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Library Includes */
|
/* Library Includes */
|
||||||
#include "wwwsys.h"
|
#include "wwwsys.h"
|
||||||
#include "WWWUtil.h"
|
#include "WWWUtil.h"
|
||||||
#include "WWWCore.h"
|
#include "WWWCore.h"
|
||||||
|
@ -41,8 +41,9 @@ using namespace NLMISC;
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Final states have negative value */
|
/* Final states have negative value */
|
||||||
typedef enum _FileState {
|
typedef enum _FileState
|
||||||
|
{
|
||||||
FS_RETRY = -4,
|
FS_RETRY = -4,
|
||||||
FS_ERROR = -3,
|
FS_ERROR = -3,
|
||||||
FS_NO_DATA = -2,
|
FS_NO_DATA = -2,
|
||||||
|
@ -57,26 +58,29 @@ typedef enum _FileState {
|
||||||
} FileState;
|
} FileState;
|
||||||
|
|
||||||
/* This is the context structure for the this module */
|
/* This is the context structure for the this module */
|
||||||
typedef struct _file_info {
|
typedef struct _file_info
|
||||||
FileState state; /* Current state of the connection */
|
{
|
||||||
char * local; /* Local representation of file name */
|
FileState state; /* Current state of the connection */
|
||||||
struct stat stat_info; /* Contains actual file chosen */
|
char * local; /* Local representation of file name */
|
||||||
|
struct stat stat_info; /* Contains actual file chosen */
|
||||||
HTNet * net;
|
HTNet * net;
|
||||||
HTTimer * timer;
|
HTTimer * timer;
|
||||||
} file_info;
|
} file_info;
|
||||||
|
|
||||||
struct _HTStream {
|
struct _HTStream
|
||||||
|
{
|
||||||
const HTStreamClass * isa;
|
const HTStreamClass * isa;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _HTInputStream {
|
struct _HTInputStream
|
||||||
|
{
|
||||||
const HTInputStreamClass * isa;
|
const HTInputStreamClass * isa;
|
||||||
HTChannel * ch;
|
HTChannel * ch;
|
||||||
HTHost * host;
|
HTHost * host;
|
||||||
char * write; /* Last byte written */
|
char * write; /* Last byte written */
|
||||||
char * read; /* Last byte read */
|
char * read; /* Last byte read */
|
||||||
int b_read;
|
int b_read;
|
||||||
char data [INPUT_BUFFER_SIZE]; /* buffer */
|
char data [INPUT_BUFFER_SIZE]; /* buffer */
|
||||||
};
|
};
|
||||||
|
|
||||||
PRIVATE int FileCleanup (HTRequest *req, int status)
|
PRIVATE int FileCleanup (HTRequest *req, int status)
|
||||||
|
@ -96,7 +100,7 @@ PRIVATE int FileCleanup (HTRequest *req, int status)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Remove if we have registered a timer function as a callback
|
** Remove if we have registered a timer function as a callback
|
||||||
*/
|
*/
|
||||||
if (file->timer)
|
if (file->timer)
|
||||||
{
|
{
|
||||||
|
@ -123,10 +127,8 @@ PUBLIC int HTLoadNeLFile (SOCKET soc, HTRequest * request)
|
||||||
HTNet * net = HTRequest_net(request);
|
HTNet * net = HTRequest_net(request);
|
||||||
HTParentAnchor * anchor = HTRequest_anchor(request);
|
HTParentAnchor * anchor = HTRequest_anchor(request);
|
||||||
|
|
||||||
HTTRACE(PROT_TRACE, "HTLoadFile.. Looking for `%s\'\n" _
|
HTTRACE(PROT_TRACE, "HTLoadFile.. Looking for `%s\'\n" _ HTAnchor_physical(anchor));
|
||||||
HTAnchor_physical(anchor));
|
if ((file = (file_info *) HT_CALLOC(1, sizeof(file_info))) == NULL) HT_OUTOFMEM("HTLoadFILE");
|
||||||
if ((file = (file_info *) HT_CALLOC(1, sizeof(file_info))) == NULL)
|
|
||||||
HT_OUTOFMEM((char*)"HTLoadFILE");
|
|
||||||
file->state = FS_BEGIN;
|
file->state = FS_BEGIN;
|
||||||
file->net = net;
|
file->net = net;
|
||||||
HTNet_setContext(net, file);
|
HTNet_setContext(net, file);
|
||||||
|
@ -139,8 +141,8 @@ PUBLIC int HTLoadNeLFile (SOCKET soc, HTRequest * request)
|
||||||
PRIVATE int ReturnEvent (HTTimer * timer, void * param, HTEventType /* type */)
|
PRIVATE int ReturnEvent (HTTimer * timer, void * param, HTEventType /* type */)
|
||||||
{
|
{
|
||||||
file_info * file = (file_info *) param;
|
file_info * file = (file_info *) param;
|
||||||
if (timer != file->timer)
|
if (timer != file->timer) HTDEBUGBREAK("File timer %p not in sync\n" _ timer);
|
||||||
HTDEBUGBREAK((char*)"File timer %p not in sync\n" _ timer);
|
|
||||||
HTTRACE(PROT_TRACE, "HTLoadFile.. Continuing %p with timer %p\n" _ file _ timer);
|
HTTRACE(PROT_TRACE, "HTLoadFile.. Continuing %p with timer %p\n" _ file _ timer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -163,7 +165,7 @@ PUBLIC int HTNeLFileOpen (HTNet * net, char * local, HTLocalMode /* mode */)
|
||||||
|
|
||||||
if (!fp->open (local))
|
if (!fp->open (local))
|
||||||
{
|
{
|
||||||
HTRequest_addSystemError(request, ERR_FATAL, errno, NO, (char*)"CIFile::open");
|
HTRequest_addSystemError(request, ERR_FATAL, errno, NO, "CIFile::open");
|
||||||
return HT_ERROR;
|
return HT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +188,7 @@ PRIVATE int FileEvent (SOCKET /* soc */, void * pVoid, HTEventType type)
|
||||||
{
|
{
|
||||||
/* Interrupted */
|
/* Interrupted */
|
||||||
HTRequest_addError(request, ERR_FATAL, NO, HTERR_INTERRUPTED,
|
HTRequest_addError(request, ERR_FATAL, NO, HTERR_INTERRUPTED,
|
||||||
NULL, 0, (char*)"HTLoadFile");
|
NULL, 0, "HTLoadFile");
|
||||||
FileCleanup(request, HT_INTERRUPTED);
|
FileCleanup(request, HT_INTERRUPTED);
|
||||||
return HT_OK;
|
return HT_OK;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +204,7 @@ PRIVATE int FileEvent (SOCKET /* soc */, void * pVoid, HTEventType type)
|
||||||
/* We only support safe (GET, HEAD, etc) methods for the moment */
|
/* We only support safe (GET, HEAD, etc) methods for the moment */
|
||||||
if (!HTMethod_isSafe(HTRequest_method(request))) {
|
if (!HTMethod_isSafe(HTRequest_method(request))) {
|
||||||
HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_ALLOWED,
|
HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_ALLOWED,
|
||||||
NULL, 0, (char*)"HTLoadFile");
|
NULL, 0, "HTLoadFile");
|
||||||
file->state = FS_ERROR;
|
file->state = FS_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -234,166 +236,188 @@ PRIVATE int FileEvent (SOCKET /* soc */, void * pVoid, HTEventType type)
|
||||||
|
|
||||||
/* Create a new host object and link it to the net object */
|
/* Create a new host object and link it to the net object */
|
||||||
{
|
{
|
||||||
HTHost * host = NULL;
|
HTHost * host = NULL;
|
||||||
if ((host = HTHost_new((char*)"localhost", 0)) == NULL) return HT_ERROR;
|
if ((host = HTHost_new("localhost", 0)) == NULL) return HT_ERROR;
|
||||||
HTNet_setHost(net, host);
|
HTNet_setHost(net, host);
|
||||||
if (HTHost_addNet(host, net) == HT_PENDING) {
|
if (HTHost_addNet(host, net) == HT_PENDING)
|
||||||
HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n");
|
{
|
||||||
/* move to the hack state */
|
HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n");
|
||||||
file->state = FS_PENDING;
|
/* move to the hack state */
|
||||||
return HT_OK;
|
file->state = FS_PENDING;
|
||||||
}
|
return HT_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
file->state = FS_DO_CN;
|
file->state = FS_DO_CN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FS_PENDING:
|
case FS_PENDING:
|
||||||
{
|
{
|
||||||
HTHost * host = NULL;
|
HTHost * host = NULL;
|
||||||
if ((host = HTHost_new((char*)"localhost", 0)) == NULL) return HT_ERROR;
|
if ((host = HTHost_new((char*)"localhost", 0)) == NULL) return HT_ERROR;
|
||||||
HTNet_setHost(net, host);
|
HTNet_setHost(net, host);
|
||||||
if (HTHost_addNet(host, net) == HT_PENDING) {
|
if (HTHost_addNet(host, net) == HT_PENDING)
|
||||||
HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n");
|
{
|
||||||
file->state = FS_PENDING;
|
HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n");
|
||||||
return HT_OK;
|
file->state = FS_PENDING;
|
||||||
}
|
return HT_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
file->state = FS_DO_CN;
|
file->state = FS_DO_CN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FS_DO_CN:
|
case FS_DO_CN:
|
||||||
if (HTRequest_negotiation(request) &&
|
if (HTRequest_negotiation(request) &&
|
||||||
HTMethod_isSafe(HTRequest_method(request))) {
|
HTMethod_isSafe(HTRequest_method(request)))
|
||||||
|
{
|
||||||
|
HTAnchor_setPhysical(anchor, file->local);
|
||||||
|
HTTRACE(PROT_TRACE, "Load File... Found `%s\'\n" _ file->local);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (HT_STAT(file->local, &file->stat_info) == -1)
|
||||||
|
{
|
||||||
|
HTTRACE(PROT_TRACE, "Load File... Not found `%s\'\n" _ file->local);
|
||||||
|
HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_FOUND, NULL, 0, "HTLoadFile");
|
||||||
|
file->state = FS_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HTAnchor_setPhysical(anchor, file->local);
|
if (((file->stat_info.st_mode) & S_IFMT) == S_IFDIR)
|
||||||
HTTRACE(PROT_TRACE, "Load File... Found `%s\'\n" _ file->local);
|
{
|
||||||
|
if (HTRequest_method(request) == METHOD_GET)
|
||||||
} else {
|
{
|
||||||
if (HT_STAT(file->local, &file->stat_info) == -1) {
|
file->state = FS_PARSE_DIR;
|
||||||
HTTRACE(PROT_TRACE, "Load File... Not found `%s\'\n" _ file->local);
|
}
|
||||||
HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_FOUND,
|
else
|
||||||
NULL, 0, (char*)"HTLoadFile");
|
{
|
||||||
file->state = FS_ERROR;
|
HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT, NULL, 0, "HTLoadFile");
|
||||||
|
file->state = FS_NO_DATA;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (((file->stat_info.st_mode) & S_IFMT) == S_IFDIR) {
|
|
||||||
if (HTRequest_method(request) == METHOD_GET)
|
|
||||||
file->state = FS_PARSE_DIR;
|
|
||||||
else {
|
|
||||||
HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT,
|
|
||||||
NULL, 0, (char*)"HTLoadFile");
|
|
||||||
file->state = FS_NO_DATA;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
BOOL editable = FALSE;
|
BOOL editable = FALSE;
|
||||||
HTBind_getAnchorBindings(anchor);
|
HTBind_getAnchorBindings(anchor);
|
||||||
if (editable) HTAnchor_appendAllow(anchor, METHOD_PUT);
|
if (editable) HTAnchor_appendAllow(anchor, METHOD_PUT);
|
||||||
|
|
||||||
/* Set the file size */
|
/* Set the file size */
|
||||||
CIFile nelFile;
|
CIFile nelFile;
|
||||||
if (nelFile.open (file->local))
|
if (nelFile.open (file->local))
|
||||||
{
|
{
|
||||||
file->stat_info.st_size = nelFile.getFileSize();
|
file->stat_info.st_size = nelFile.getFileSize();
|
||||||
}
|
}
|
||||||
nelFile.close();
|
nelFile.close();
|
||||||
|
|
||||||
if (file->stat_info.st_size)
|
if (file->stat_info.st_size)
|
||||||
HTAnchor_setLength(anchor, file->stat_info.st_size);
|
HTAnchor_setLength(anchor, file->stat_info.st_size);
|
||||||
|
|
||||||
/* Set the file last modified time stamp */
|
/* Set the file last modified time stamp */
|
||||||
if (file->stat_info.st_mtime > 0)
|
if (file->stat_info.st_mtime > 0)
|
||||||
HTAnchor_setLastModified(anchor, file->stat_info.st_mtime);
|
HTAnchor_setLastModified(anchor, file->stat_info.st_mtime);
|
||||||
|
|
||||||
/* Check to see if we can edit it */
|
/* Check to see if we can edit it */
|
||||||
if (!editable && !file->stat_info.st_size) {
|
if (!editable && !file->stat_info.st_size)
|
||||||
HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT,
|
{
|
||||||
NULL, 0, (char*)"HTLoadFile");
|
HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT, NULL, 0, "HTLoadFile");
|
||||||
file->state = FS_NO_DATA;
|
file->state = FS_NO_DATA;
|
||||||
} else {
|
}
|
||||||
file->state = (HTRequest_method(request)==METHOD_GET) ?
|
else
|
||||||
FS_NEED_OPEN_FILE : FS_GOT_DATA;
|
{
|
||||||
}
|
file->state = (HTRequest_method(request)==METHOD_GET) ? FS_NEED_OPEN_FILE : FS_GOT_DATA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FS_NEED_OPEN_FILE:
|
case FS_NEED_OPEN_FILE:
|
||||||
status = HTNeLFileOpen(net, file->local, HT_FB_RDONLY);
|
status = HTNeLFileOpen(net, file->local, HT_FB_RDONLY);
|
||||||
if (status == HT_OK) {
|
if (status == HT_OK)
|
||||||
{
|
{
|
||||||
HTStream * rstream = HTStreamStack(HTAnchor_format(anchor),
|
{
|
||||||
HTRequest_outputFormat(request),
|
HTStream * rstream = HTStreamStack(HTAnchor_format(anchor),
|
||||||
HTRequest_outputStream(request),
|
HTRequest_outputFormat(request),
|
||||||
request, YES);
|
HTRequest_outputStream(request),
|
||||||
HTNet_setReadStream(net, rstream);
|
request, YES);
|
||||||
HTRequest_setOutputConnected(request, YES);
|
HTNet_setReadStream(net, rstream);
|
||||||
}
|
HTRequest_setOutputConnected(request, YES);
|
||||||
|
|
||||||
{
|
|
||||||
HTOutputStream * output = HTNet_getOutput(net, NULL, 0);
|
|
||||||
HTRequest_setInputStream(request, (HTStream *) output);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HTRequest_isSource(request) && !HTRequest_destinationsReady(request))
|
|
||||||
return HT_OK;
|
|
||||||
HTRequest_addError(request, ERR_INFO, NO, HTERR_OK, NULL, 0,
|
|
||||||
(char*)"HTLoadFile");
|
|
||||||
file->state = FS_NEED_BODY;
|
|
||||||
|
|
||||||
if (HTEvent_isCallbacksRegistered()) {
|
|
||||||
if (!HTRequest_preemptive(request)) {
|
|
||||||
if (!HTNet_preemptive(net)) {
|
|
||||||
HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n");
|
|
||||||
HTHost_register(HTNet_host(net), net, HTEvent_READ);
|
|
||||||
} else if (!file->timer) {
|
|
||||||
HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n");
|
|
||||||
file->timer =
|
|
||||||
HTTimer_new(NULL, ReturnEvent, file, 1, YES, NO);
|
|
||||||
}
|
}
|
||||||
return HT_OK;
|
|
||||||
|
{
|
||||||
|
HTOutputStream * output = HTNet_getOutput(net, NULL, 0);
|
||||||
|
HTRequest_setInputStream(request, (HTStream *) output);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HTRequest_isSource(request) && !HTRequest_destinationsReady(request)) return HT_OK;
|
||||||
|
|
||||||
|
HTRequest_addError(request, ERR_INFO, NO, HTERR_OK, NULL, 0, "HTLoadFile");
|
||||||
|
file->state = FS_NEED_BODY;
|
||||||
|
|
||||||
|
if (HTEvent_isCallbacksRegistered())
|
||||||
|
{
|
||||||
|
if (!HTRequest_preemptive(request))
|
||||||
|
{
|
||||||
|
if (!HTNet_preemptive(net))
|
||||||
|
{
|
||||||
|
HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n");
|
||||||
|
HTHost_register(HTNet_host(net), net, HTEvent_READ);
|
||||||
|
}
|
||||||
|
else if (!file->timer)
|
||||||
|
{
|
||||||
|
HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n");
|
||||||
|
file->timer = HTTimer_new(NULL, ReturnEvent, file, 1, YES, NO);
|
||||||
|
}
|
||||||
|
return HT_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (status == HT_WOULD_BLOCK || status == HT_PENDING)
|
else if (status == HT_WOULD_BLOCK || status == HT_PENDING)
|
||||||
return HT_OK;
|
{
|
||||||
else {
|
return HT_OK;
|
||||||
HTRequest_addError(request, ERR_INFO, NO, HTERR_INTERNAL,
|
}
|
||||||
NULL, 0, (char*)"HTLoadFile");
|
else
|
||||||
file->state = FS_ERROR; /* Error or interrupt */
|
{
|
||||||
|
HTRequest_addError(request, ERR_INFO, NO, HTERR_INTERNAL, NULL, 0, "HTLoadFile");
|
||||||
|
file->state = FS_ERROR; /* Error or interrupt */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FS_NEED_BODY:
|
case FS_NEED_BODY:
|
||||||
status = HTHost_read(HTNet_host(net), net);
|
status = HTHost_read(HTNet_host(net), net);
|
||||||
if (status == HT_WOULD_BLOCK)
|
if (status == HT_WOULD_BLOCK)
|
||||||
return HT_OK;
|
{
|
||||||
else if (status == HT_LOADED || status == HT_CLOSED) {
|
return HT_OK;
|
||||||
file->state = FS_GOT_DATA;
|
}
|
||||||
} else {
|
else if (status == HT_LOADED || status == HT_CLOSED)
|
||||||
HTRequest_addError(request, ERR_INFO, NO, HTERR_FORBIDDEN,
|
{
|
||||||
NULL, 0, (char*)"HTLoadFile");
|
file->state = FS_GOT_DATA;
|
||||||
file->state = FS_ERROR;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HTRequest_addError(request, ERR_INFO, NO, HTERR_FORBIDDEN, NULL, 0, "HTLoadFile");
|
||||||
|
file->state = FS_ERROR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FS_TRY_FTP:
|
case FS_TRY_FTP:
|
||||||
{
|
{
|
||||||
char *url = HTAnchor_physical(anchor);
|
char *url = HTAnchor_physical(anchor);
|
||||||
HTAnchor *anchor;
|
HTAnchor *anchor;
|
||||||
char *newname = NULL;
|
char *newname = NULL;
|
||||||
StrAllocCopy(newname, "ftp:");
|
StrAllocCopy(newname, "ftp:");
|
||||||
if (!strncmp(url, "file:", 5))
|
if (!strncmp(url, "file:", 5))
|
||||||
StrAllocCat(newname, url+5);
|
{
|
||||||
else
|
StrAllocCat(newname, url+5);
|
||||||
StrAllocCat(newname, url);
|
}
|
||||||
anchor = HTAnchor_findAddress(newname);
|
else
|
||||||
HTRequest_setAnchor(request, anchor);
|
{
|
||||||
HT_FREE(newname);
|
StrAllocCat(newname, url);
|
||||||
FileCleanup(request, HT_IGNORE);
|
}
|
||||||
return HTLoad(request, YES);
|
anchor = HTAnchor_findAddress(newname);
|
||||||
|
HTRequest_setAnchor(request, anchor);
|
||||||
|
HT_FREE(newname);
|
||||||
|
FileCleanup(request, HT_IGNORE);
|
||||||
|
return HTLoad(request, YES);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -461,7 +485,8 @@ PRIVATE int HTNeLReader_read (HTInputStream * me)
|
||||||
{
|
{
|
||||||
HTAlertCallback * cbf = HTAlert_find(HT_PROG_READ);
|
HTAlertCallback * cbf = HTAlert_find(HT_PROG_READ);
|
||||||
HTNet_addBytesRead(net, me->b_read);
|
HTNet_addBytesRead(net, me->b_read);
|
||||||
if (cbf) {
|
if (cbf)
|
||||||
|
{
|
||||||
int tr = HTNet_bytesRead(net);
|
int tr = HTNet_bytesRead(net);
|
||||||
(*cbf)(net->request, HT_PROG_READ, HT_MSG_NULL, NULL, &tr, NULL);
|
(*cbf)(net->request, HT_PROG_READ, HT_MSG_NULL, NULL, &tr, NULL);
|
||||||
}
|
}
|
||||||
|
@ -472,18 +497,28 @@ PRIVATE int HTNeLReader_read (HTInputStream * me)
|
||||||
|
|
||||||
/* Now push the data down the stream */
|
/* Now push the data down the stream */
|
||||||
if ((status = (*net->readStream->isa->put_block)
|
if ((status = (*net->readStream->isa->put_block)
|
||||||
(net->readStream, me->data, me->b_read)) != HT_OK) {
|
(net->readStream, me->data, me->b_read)) != HT_OK)
|
||||||
if (status == HT_WOULD_BLOCK) {
|
{
|
||||||
|
if (status == HT_WOULD_BLOCK)
|
||||||
|
{
|
||||||
HTTRACE(PROT_TRACE, "ANSI read... Target WOULD BLOCK\n");
|
HTTRACE(PROT_TRACE, "ANSI read... Target WOULD BLOCK\n");
|
||||||
return HT_WOULD_BLOCK;
|
return HT_WOULD_BLOCK;
|
||||||
} else if (status == HT_PAUSE) {
|
}
|
||||||
|
else if (status == HT_PAUSE)
|
||||||
|
{
|
||||||
HTTRACE(PROT_TRACE, "ANSI read... Target PAUSED\n");
|
HTTRACE(PROT_TRACE, "ANSI read... Target PAUSED\n");
|
||||||
return HT_PAUSE;
|
return HT_PAUSE;
|
||||||
} else if (status > 0) { /* Stream specific return code */
|
}
|
||||||
|
else if (status > 0)
|
||||||
|
{
|
||||||
|
/* Stream specific return code */
|
||||||
HTTRACE(PROT_TRACE, "ANSI read... Target returns %d\n" _ status);
|
HTTRACE(PROT_TRACE, "ANSI read... Target returns %d\n" _ status);
|
||||||
me->write = me->data + me->b_read;
|
me->write = me->data + me->b_read;
|
||||||
return status;
|
return status;
|
||||||
} else { /* We have a real error */
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* We have a real error */
|
||||||
HTTRACE(PROT_TRACE, "ANSI read... Target ERROR\n");
|
HTTRACE(PROT_TRACE, "ANSI read... Target ERROR\n");
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -506,13 +541,15 @@ PRIVATE int HTNeLReader_close (HTInputStream * me)
|
||||||
HTNet * net = HTHost_getReadNet(me->host);
|
HTNet * net = HTHost_getReadNet(me->host);
|
||||||
|
|
||||||
|
|
||||||
if (net && net->readStream) {
|
if (net && net->readStream)
|
||||||
if ((status = (*net->readStream->isa->_free)(net->readStream))==HT_WOULD_BLOCK)
|
{
|
||||||
return HT_WOULD_BLOCK;
|
if ((status = (*net->readStream->isa->_free)(net->readStream))==HT_WOULD_BLOCK) return HT_WOULD_BLOCK;
|
||||||
net->readStream = NULL;
|
net->readStream = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTRACE(STREAM_TRACE, "Socket read. FREEING....\n");
|
HTTRACE(STREAM_TRACE, "Socket read. FREEING....\n");
|
||||||
HT_FREE(me);
|
HT_FREE(me);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,7 +577,8 @@ PRIVATE int HTNeLReader_free (HTInputStream * me)
|
||||||
}
|
}
|
||||||
|
|
||||||
HTNet * net = HTHost_getReadNet(me->host);
|
HTNet * net = HTHost_getReadNet(me->host);
|
||||||
if (net && net->readStream) {
|
if (net && net->readStream)
|
||||||
|
{
|
||||||
int status = (*net->readStream->isa->_free)(net->readStream);
|
int status = (*net->readStream->isa->_free)(net->readStream);
|
||||||
if (status == HT_OK) net->readStream = NULL;
|
if (status == HT_OK) net->readStream = NULL;
|
||||||
return status;
|
return status;
|
||||||
|
@ -551,7 +589,8 @@ PRIVATE int HTNeLReader_free (HTInputStream * me)
|
||||||
PRIVATE int HTNeLReader_abort (HTInputStream * me, HTList * /* e */)
|
PRIVATE int HTNeLReader_abort (HTInputStream * me, HTList * /* e */)
|
||||||
{
|
{
|
||||||
HTNet * net = HTHost_getReadNet(me->host);
|
HTNet * net = HTHost_getReadNet(me->host);
|
||||||
if (net && net->readStream) {
|
if (net && net->readStream)
|
||||||
|
{
|
||||||
int status = (*net->readStream->isa->abort)(net->readStream, NULL);
|
int status = (*net->readStream->isa->abort)(net->readStream, NULL);
|
||||||
if (status != HT_IGNORE) net->readStream = NULL;
|
if (status != HT_IGNORE) net->readStream = NULL;
|
||||||
}
|
}
|
||||||
|
@ -560,7 +599,7 @@ PRIVATE int HTNeLReader_abort (HTInputStream * me, HTList * /* e */)
|
||||||
|
|
||||||
PRIVATE const HTInputStreamClass HTNeLReader =
|
PRIVATE const HTInputStreamClass HTNeLReader =
|
||||||
{
|
{
|
||||||
(char*)"SocketReader",
|
"SocketReader",
|
||||||
HTNeLReader_flush,
|
HTNeLReader_flush,
|
||||||
HTNeLReader_free,
|
HTNeLReader_free,
|
||||||
HTNeLReader_abort,
|
HTNeLReader_abort,
|
||||||
|
@ -569,20 +608,20 @@ PRIVATE const HTInputStreamClass HTNeLReader =
|
||||||
HTNeLReader_consumed
|
HTNeLReader_consumed
|
||||||
};
|
};
|
||||||
|
|
||||||
PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch,
|
PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch, void * /* param */, int /* mode */)
|
||||||
void * /* param */, int /* mode */)
|
|
||||||
{
|
{
|
||||||
if (host && ch) {
|
if (host && ch)
|
||||||
HTInputStream * me = HTChannel_input(ch);
|
{
|
||||||
if (me == NULL) {
|
HTInputStream * me = HTChannel_input(ch);
|
||||||
if ((me=(HTInputStream *) HT_CALLOC(1, sizeof(HTInputStream))) == NULL)
|
if (me == NULL)
|
||||||
HT_OUTOFMEM((char*)"HTNeLReader_new");
|
{
|
||||||
me->isa = &HTNeLReader;
|
if ((me=(HTInputStream *) HT_CALLOC(1, sizeof(HTInputStream))) == NULL) HT_OUTOFMEM("HTNeLReader_new");
|
||||||
me->ch = ch;
|
me->isa = &HTNeLReader;
|
||||||
me->host = host;
|
me->ch = ch;
|
||||||
HTTRACE(STREAM_TRACE, "Reader...... Created reader stream %p\n" _ me);
|
me->host = host;
|
||||||
}
|
HTTRACE(STREAM_TRACE, "Reader...... Created reader stream %p\n" _ me);
|
||||||
return me;
|
}
|
||||||
|
return me;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,6 @@ void CColorModifier::convertBitmap(NLMISC::CBitmap &destBitmap, const NLMISC::CB
|
||||||
|
|
||||||
// blend to the destination by using the mask alpha
|
// blend to the destination by using the mask alpha
|
||||||
result.blendFromui(*dest, result, mask->R);
|
result.blendFromui(*dest, result, mask->R);
|
||||||
|
|
||||||
|
|
||||||
/// keep alpha from the source
|
/// keep alpha from the source
|
||||||
dest->R = result.R;
|
dest->R = result.R;
|
||||||
|
@ -78,7 +77,6 @@ void CColorModifier::convertBitmap(NLMISC::CBitmap &destBitmap, const NLMISC::CB
|
||||||
dest->B = result.B;
|
dest->B = result.B;
|
||||||
dest->A = src->A;
|
dest->A = src->A;
|
||||||
|
|
||||||
|
|
||||||
++ mask;
|
++ mask;
|
||||||
++ src;
|
++ src;
|
||||||
++ dest;
|
++ dest;
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "session_browser.h"
|
#include "session_browser.h"
|
||||||
#include "game_share/ring_session_manager_itf.h"
|
#include "game_share/ring_session_manager_itf.h"
|
||||||
#include "nel/gui/lua_helper.h"
|
#include "nel/gui/lua_helper.h"
|
||||||
using namespace NLGUI;
|
|
||||||
#include "far_tp.h"
|
#include "far_tp.h"
|
||||||
|
|
||||||
class CSessionBrowserImpl : public CSessionBrowser,
|
class CSessionBrowserImpl : public CSessionBrowser,
|
||||||
|
|
|
@ -97,7 +97,7 @@ class CMsgAIFeedback : public NLNET::CTransportClass
|
||||||
public:
|
public:
|
||||||
std::string Message;
|
std::string Message;
|
||||||
|
|
||||||
CMsgAIFeedback()
|
CMsgAIFeedback()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +120,5 @@ public:
|
||||||
virtual void callback (const std::string &name, NLNET::TServiceId id);
|
virtual void callback (const std::string &name, NLNET::TServiceId id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,9 @@
|
||||||
|
|
||||||
|
|
||||||
#include "stdpch.h"
|
#include "stdpch.h"
|
||||||
#include <nel/net/service.h>
|
|
||||||
#include "used_continent.h"
|
#include "used_continent.h"
|
||||||
|
#include "nel/net/service.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace NLMISC;
|
using namespace NLMISC;
|
||||||
|
|
Loading…
Reference in a new issue