Pine64 Updates.
This commit is contained in:
parent
635b673492
commit
96b3b1ac0a
@ -279,7 +279,6 @@ cw::filesys::pathPart_t* cw::filesys::pathParts( const char* pathStr )
|
|||||||
char* cp = nullptr;
|
char* cp = nullptr;
|
||||||
pathPart_t* rp = nullptr;
|
pathPart_t* rp = nullptr;
|
||||||
|
|
||||||
|
|
||||||
if( pathStr==nullptr )
|
if( pathStr==nullptr )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -352,13 +351,13 @@ cw::filesys::pathPart_t* cw::filesys::pathParts( const char* pathStr )
|
|||||||
n = sizeof(pathPart_t) + dn + fn + en + 3;
|
n = sizeof(pathPart_t) + dn + fn + en + 3;
|
||||||
|
|
||||||
// alloc memory
|
// alloc memory
|
||||||
if((rp = mem::allocZ<pathPart_t>( n )) == nullptr )
|
if((rp = (pathPart_t*)mem::allocZ<char>( n )) == nullptr )
|
||||||
{
|
{
|
||||||
cwLogError( kMemAllocFailRC, "Unable to allocate the file system path part record for '%s'.",pathStr);
|
cwLogError( kMemAllocFailRC, "Unable to allocate the file system path part record for '%s'.",pathStr);
|
||||||
return nullptr;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the return pointers for ecmh of the parts
|
// set the return pointers for each of the parts
|
||||||
rp->dirStr = (const char* )(rp + 1);
|
rp->dirStr = (const char* )(rp + 1);
|
||||||
rp->fnStr = rp->dirStr + dn + 1;
|
rp->fnStr = rp->dirStr + dn + 1;
|
||||||
rp->extStr = rp->fnStr + fn + 1;
|
rp->extStr = rp->fnStr + fn + 1;
|
||||||
@ -375,7 +374,7 @@ cw::filesys::pathPart_t* cw::filesys::pathParts( const char* pathStr )
|
|||||||
// Get the trailing word again.
|
// Get the trailing word again.
|
||||||
// pathStr must be copied into a buf because basename() may
|
// pathStr must be copied into a buf because basename() may
|
||||||
// is allowed to change the values in its arg.
|
// is allowed to change the values in its arg.
|
||||||
strncpy(buf,pathStr,n);
|
strcpy(buf,pathStr);
|
||||||
cp = basename(buf);
|
cp = basename(buf);
|
||||||
|
|
||||||
|
|
||||||
@ -405,6 +404,7 @@ cw::filesys::pathPart_t* cw::filesys::pathParts( const char* pathStr )
|
|||||||
if( en == 0 )
|
if( en == 0 )
|
||||||
rp->extStr = nullptr;
|
rp->extStr = nullptr;
|
||||||
|
|
||||||
|
errLabel:
|
||||||
return rp;
|
return rp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
cwMem.cpp
14
cwMem.cpp
@ -10,13 +10,13 @@ void* cw::mem::_alloc( void* p0, unsigned n, unsigned flags )
|
|||||||
unsigned p0N = 0; // size of existing block
|
unsigned p0N = 0; // size of existing block
|
||||||
unsigned* p0_1 = nullptr; // pointer to base of existing block
|
unsigned* p0_1 = nullptr; // pointer to base of existing block
|
||||||
|
|
||||||
n += sizeof(unsigned); // add space for the size of the block
|
n += 2*sizeof(unsigned); // add space for the size of the block
|
||||||
|
|
||||||
// if there is no existing block
|
// if there is no existing block
|
||||||
if( p0 != nullptr )
|
if( p0 != nullptr )
|
||||||
{
|
{
|
||||||
// get a pointer to the base of the exsting block
|
// get a pointer to the base of the exsting block
|
||||||
p0_1 = ((unsigned*)p0) - 1;
|
p0_1 = ((unsigned*)p0) - 2;
|
||||||
|
|
||||||
p0N = p0_1[0]; // get size of existing block
|
p0N = p0_1[0]; // get size of existing block
|
||||||
|
|
||||||
@ -49,7 +49,13 @@ void* cw::mem::_alloc( void* p0, unsigned n, unsigned flags )
|
|||||||
p1[0] = n; // set size of new block
|
p1[0] = n; // set size of new block
|
||||||
|
|
||||||
// advance past the block size and return
|
// advance past the block size and return
|
||||||
return p1+1;
|
return p1+2;
|
||||||
|
|
||||||
|
/*
|
||||||
|
n += 8;
|
||||||
|
char* p = (char*)calloc(1,n);
|
||||||
|
return p+8;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -96,6 +102,6 @@ void cw::mem::free( void* p )
|
|||||||
{
|
{
|
||||||
if( p != nullptr)
|
if( p != nullptr)
|
||||||
{
|
{
|
||||||
::free(static_cast<unsigned*>(p)-1);
|
::free(static_cast<unsigned*>(p)-2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,10 @@ namespace cw
|
|||||||
{
|
{
|
||||||
typedef struct spsc_buf_str
|
typedef struct spsc_buf_str
|
||||||
{
|
{
|
||||||
uint8_t* buf;
|
|
||||||
unsigned bufByteN;
|
|
||||||
std::atomic<uint8_t*> w; // write ptr
|
std::atomic<uint8_t*> w; // write ptr
|
||||||
std::atomic<uint8_t*> r; // read ptr
|
std::atomic<uint8_t*> r; // read ptr
|
||||||
|
uint8_t* buf;
|
||||||
|
unsigned bufByteN;
|
||||||
} spsc_buf_t;
|
} spsc_buf_t;
|
||||||
|
|
||||||
// Note: r==w indicates an empty buffer.
|
// Note: r==w indicates an empty buffer.
|
||||||
@ -57,11 +57,11 @@ cw::rc_t cw::spsc_buf::create( handle_t& hRef, unsigned bufByteN )
|
|||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
spsc_buf_t* p = mem::allocZ<spsc_buf_t>();
|
spsc_buf_t* p = mem::allocZ<spsc_buf_t>();
|
||||||
|
|
||||||
p->buf = mem::allocZ<uint8_t>(bufByteN);
|
p->buf = mem::allocZ<uint8_t>(bufByteN);
|
||||||
p->bufByteN = bufByteN;
|
p->bufByteN = bufByteN;
|
||||||
p->w = p->buf;
|
p->w.store(p->buf);
|
||||||
p->r = p->buf;
|
p->r.store(p->buf);
|
||||||
|
|
||||||
hRef.set(p);
|
hRef.set(p);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
@ -392,7 +392,9 @@ cw::rc_t cw::spsc_buf::test()
|
|||||||
|
|
||||||
// create the SPSC buffer
|
// create the SPSC buffer
|
||||||
if((rc = create( share.h, bufByteN )) != kOkRC )
|
if((rc = create( share.h, bufByteN )) != kOkRC )
|
||||||
|
{
|
||||||
return cwLogError(rc,"spsc_buf create failed.");
|
return cwLogError(rc,"spsc_buf create failed.");
|
||||||
|
}
|
||||||
|
|
||||||
// create the thread machine
|
// create the thread machine
|
||||||
if((rc = thread_mach::create( h, _threadFunc, ctxArray, sizeof(ctx_t), ctxArrayN )) != kOkRC )
|
if((rc = thread_mach::create( h, _threadFunc, ctxArray, sizeof(ctx_t), ctxArrayN )) != kOkRC )
|
||||||
|
@ -163,6 +163,7 @@ cw::rc_t cw::testSpScQueueTmpl()
|
|||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cwLogInfo("running for 1 minute ...");
|
||||||
sleepMs(60 * 1000);
|
sleepMs(60 * 1000);
|
||||||
|
|
||||||
errLabel:
|
errLabel:
|
||||||
|
2
cwUi.cpp
2
cwUi.cpp
@ -3,11 +3,11 @@
|
|||||||
#include "cwCommonImpl.h"
|
#include "cwCommonImpl.h"
|
||||||
#include "cwMem.h"
|
#include "cwMem.h"
|
||||||
#include "cwThread.h"
|
#include "cwThread.h"
|
||||||
|
#include "cwObject.h"
|
||||||
#include "cwWebSock.h"
|
#include "cwWebSock.h"
|
||||||
#include "cwWebSockSvr.h"
|
#include "cwWebSockSvr.h"
|
||||||
#include "cwText.h"
|
#include "cwText.h"
|
||||||
#include "cwNumericConvert.h"
|
#include "cwNumericConvert.h"
|
||||||
#include "cwObject.h"
|
|
||||||
|
|
||||||
#include "cwUi.h"
|
#include "cwUi.h"
|
||||||
|
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
#include "cwMem.h"
|
#include "cwMem.h"
|
||||||
#include "cwWebSock.h"
|
#include "cwWebSock.h"
|
||||||
#include "cwThread.h"
|
#include "cwThread.h"
|
||||||
|
#include "cwObject.h"
|
||||||
#include "cwWebSockSvr.h"
|
#include "cwWebSockSvr.h"
|
||||||
#include "cwText.h"
|
#include "cwText.h"
|
||||||
|
#include "cwFileSys.h"
|
||||||
|
|
||||||
namespace cw
|
namespace cw
|
||||||
{
|
{
|
||||||
@ -71,6 +73,8 @@ cw::rc_t cw::websockSrv::create(
|
|||||||
|
|
||||||
p->_timeOutMs = timeOutMs;
|
p->_timeOutMs = timeOutMs;
|
||||||
|
|
||||||
|
cwLogInfo("Listening on port:%i root dir:%s default page:%s\n", port, cwStringNullGuard(physRootDir), cwStringNullGuard(dfltHtmlPageFn));
|
||||||
|
|
||||||
h.set(p);
|
h.set(p);
|
||||||
|
|
||||||
errLabel:
|
errLabel:
|
||||||
@ -162,12 +166,12 @@ namespace cw
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cw::rc_t cw::websockSrvTest()
|
cw::rc_t cw::websockSrvTest( const object_t* cfg )
|
||||||
{
|
{
|
||||||
rc_t rc;
|
rc_t rc;
|
||||||
websockSrv::handle_t h;
|
websockSrv::handle_t h;
|
||||||
const char* physRootDir = "/home/kevin/src/cwtest/src/libcw/html/websockSrvTest";
|
const char* physRootDirArg = nullptr; //"/home/kevin/src/cwtest/src/libcw/html/websockSrvTest";
|
||||||
const char* dfltHtmlPageFn = "test_websocket.html";
|
const char* dfltHtmlPageFn = nullptr; //"test_websocket.html";
|
||||||
unsigned timeOutMs = 50;
|
unsigned timeOutMs = 50;
|
||||||
int port = 5687;
|
int port = 5687;
|
||||||
unsigned rcvBufByteN = 128;
|
unsigned rcvBufByteN = 128;
|
||||||
@ -186,6 +190,11 @@ cw::rc_t cw::websockSrvTest()
|
|||||||
{ "websocksrv_test_protocol",kWebsockSrvProtocolId,rcvBufByteN,xmtBufByteN}
|
{ "websocksrv_test_protocol",kWebsockSrvProtocolId,rcvBufByteN,xmtBufByteN}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if((rc = cfg->getv("physRootDir",physRootDirArg,"dfltHtmlPageFn",dfltHtmlPageFn)) != kOkRC )
|
||||||
|
return cwLogError(rc,"Args parse failed.");
|
||||||
|
|
||||||
|
char* physRootDir = cw::filesys::expandPath(physRootDirArg);
|
||||||
unsigned protocolN = sizeof(protocolA)/sizeof(protocolA[0]);
|
unsigned protocolN = sizeof(protocolA)/sizeof(protocolA[0]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ namespace cw {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rc_t websockSrvTest();
|
rc_t websockSrvTest( const object_t* cfg );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user