mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-23 03:33:35 +00:00
Fixed compiler warning on GCC related to duktape specific issue
This commit is contained in:
4
makefile
4
makefile
@@ -59,9 +59,9 @@
|
|||||||
SOURCES = microstack/ILibAsyncServerSocket.c microstack/ILibAsyncSocket.c microstack/ILibAsyncUDPSocket.c microstack/ILibParsers.c microstack/ILibMulticastSocket.c
|
SOURCES = microstack/ILibAsyncServerSocket.c microstack/ILibAsyncSocket.c microstack/ILibAsyncUDPSocket.c microstack/ILibParsers.c microstack/ILibMulticastSocket.c
|
||||||
SOURCES += microstack/ILibRemoteLogging.c microstack/ILibWebClient.c microstack/ILibWebRTC.c microstack/ILibWebServer.c microstack/ILibCrypto.c
|
SOURCES += microstack/ILibRemoteLogging.c microstack/ILibWebClient.c microstack/ILibWebRTC.c microstack/ILibWebServer.c microstack/ILibCrypto.c
|
||||||
SOURCES += microstack/ILibWrapperWebRTC.c microstack/ILibSimpleDataStore.c microstack/ILibProcessPipe.c microstack/ILibIPAddressMonitor.c
|
SOURCES += microstack/ILibWrapperWebRTC.c microstack/ILibSimpleDataStore.c microstack/ILibProcessPipe.c microstack/ILibIPAddressMonitor.c
|
||||||
SOURCES += microscript/duktape.c microscript/duk_module_duktape.c microscript/ILibAsyncSocket_Duktape.c microscript/ILibDuktape_DuplexStream.c microscript/ILibDuktape_Helpers.c
|
SOURCES += microscript/duktape.c microscript/duk_module_duktape.c microscript/ILibDuktape_DuplexStream.c microscript/ILibDuktape_Helpers.c
|
||||||
SOURCES += microscript/ILibDuktape_http.c microscript/ILibDuktape_net.c microscript/ILibDuktape_ReadableStream.c microscript/ILibDuktape_WritableStream.c
|
SOURCES += microscript/ILibDuktape_http.c microscript/ILibDuktape_net.c microscript/ILibDuktape_ReadableStream.c microscript/ILibDuktape_WritableStream.c
|
||||||
SOURCES += microscript/ILibDuktapeModSearch.c microscript/ILibParsers_Duktape.c microscript/ILibWebClient_Duktape.c microscript/ILibDuktape_WebRTC.c
|
SOURCES += microscript/ILibDuktapeModSearch.c microscript/ILibParsers_Duktape.c microscript/ILibDuktape_WebRTC.c
|
||||||
SOURCES += microscript/ILibWebServer_Duktape.c microscript/ILibDuktape_SimpleDataStore.c microscript/ILibDuktape_GenericMarshal.c
|
SOURCES += microscript/ILibWebServer_Duktape.c microscript/ILibDuktape_SimpleDataStore.c microscript/ILibDuktape_GenericMarshal.c
|
||||||
SOURCES += microscript/ILibDuktape_fs.c microscript/ILibDuktape_SHA256.c microscript/ILibduktape_EventEmitter.c
|
SOURCES += microscript/ILibDuktape_fs.c microscript/ILibDuktape_SHA256.c microscript/ILibduktape_EventEmitter.c
|
||||||
SOURCES += microscript/ILibDuktape_EncryptionStream.c microscript/ILibDuktape_Polyfills.c microscript/ILibDuktape_Dgram.c
|
SOURCES += microscript/ILibDuktape_EncryptionStream.c microscript/ILibDuktape_Polyfills.c microscript/ILibDuktape_Dgram.c
|
||||||
|
|||||||
@@ -209,10 +209,7 @@ duk_ret_t mod_Search_Files(duk_context *ctx, char* id)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf_s(fileName, sizeof(fileName), "Module: %s (NOT FOUND)", id);
|
return(ILibDuktape_Error(ctx, "Module: %s (NOT FOUND)", id));
|
||||||
duk_push_string(ctx, fileName);
|
|
||||||
duk_throw(ctx);
|
|
||||||
return DUK_RET_ERROR;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ILibDuktape_ModSearch_AddHandler_AlsoIncludeJS(duk_context *ctx, char *js, size_t jsLen)
|
void ILibDuktape_ModSearch_AddHandler_AlsoIncludeJS(duk_context *ctx, char *js, size_t jsLen)
|
||||||
|
|||||||
@@ -133,9 +133,9 @@ duk_ret_t ILibDuktape_EncryptionStream_CreateEncryption(duk_context *ctx)
|
|||||||
ILibDuktape_EncryptionStream_Ptrs *ptrs;
|
ILibDuktape_EncryptionStream_Ptrs *ptrs;
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
char *iv = NULL;
|
char *iv = NULL;
|
||||||
|
|
||||||
if (!duk_has_prop_string(ctx, 0, "key")) { duk_push_string(ctx, "EncryptionStream.Create(): key must be specified!"); duk_throw(ctx); return DUK_RET_ERROR; }
|
if (!duk_has_prop_string(ctx, 0, "key")) { return(ILibDuktape_Error(ctx, "EncryptionStream.Create(): key must be specified!")); }
|
||||||
if (!duk_has_prop_string(ctx, 0, "iv")) { duk_push_string(ctx, "EncryptionStream.Create(): iv must be specified!"); duk_throw(ctx); return DUK_RET_ERROR; }
|
if (!duk_has_prop_string(ctx, 0, "iv")) { return(ILibDuktape_Error(ctx, "EncryptionStream.Create(): iv must be specified!")); }
|
||||||
|
|
||||||
duk_get_prop_string(ctx, 0, "key"); // [key]
|
duk_get_prop_string(ctx, 0, "key"); // [key]
|
||||||
if (duk_is_string(ctx, -1))
|
if (duk_is_string(ctx, -1))
|
||||||
|
|||||||
@@ -220,9 +220,7 @@ duk_ret_t ILibDuktape_GenericMarshal_Variable_Val_SET(duk_context *ctx)
|
|||||||
((unsigned int*)ptr)[0] = (unsigned int)duk_require_int(ctx, 0);
|
((unsigned int*)ptr)[0] = (unsigned int)duk_require_int(ctx, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
duk_push_string(ctx, "UNSUPPORTED VAL SIZE, with integral type");
|
return(ILibDuktape_Error(ctx, "Unsupported VAL size, with integral type"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (duk_is_object(ctx, 0) && duk_has_prop_string(ctx, 0, ILibDuktape_GenericMarshal_VariableType))
|
else if (duk_is_object(ctx, 0) && duk_has_prop_string(ctx, 0, ILibDuktape_GenericMarshal_VariableType))
|
||||||
@@ -301,7 +299,7 @@ duk_ret_t ILibDuktape_GenericMarshal_Variable_GetEx(duk_context *ctx)
|
|||||||
duk_push_int(ctx, (int)((unsigned int*)ptr)[0]);
|
duk_push_int(ctx, (int)((unsigned int*)ptr)[0]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
duk_push_string(ctx, "Invalid Variable"); duk_throw(ctx); return(DUK_RET_ERROR);
|
return(ILibDuktape_Error(ctx, "Invalid Variable"));
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -328,7 +326,7 @@ duk_ret_t ILibDuktape_GenericMarshal_Variable_SetEx(duk_context *ctx)
|
|||||||
((unsigned int*)ptr)[0] = (unsigned int)newVal;
|
((unsigned int*)ptr)[0] = (unsigned int)newVal;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
duk_push_string(ctx, "Invalid Variable"); duk_throw(ctx); return(DUK_RET_ERROR);
|
return(ILibDuktape_Error(ctx, "Invalid Variable"));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -657,9 +655,7 @@ duk_ret_t ILibDuktape_GenericMashal_CallbackProxy_Callback(duk_context *ctx)
|
|||||||
duk_push_pointer(ctx, (void*)ILibDuktape_GenericMarshal_CallbackProxy_NativeSink_9);
|
duk_push_pointer(ctx, (void*)ILibDuktape_GenericMarshal_CallbackProxy_NativeSink_9);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
duk_push_string(ctx, "More than 9 parameters in the callback isn't supported yet");
|
return(ILibDuktape_Error(ctx, "More than 9 parameters in the callback isn't supported yet"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1122,9 +1118,7 @@ duk_ret_t ILibDuktape_GenericMarshal_MethodInvoke(duk_context *ctx)
|
|||||||
|
|
||||||
if (fptr == NULL)
|
if (fptr == NULL)
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "INVALID METHOD");
|
return(ILibDuktape_Error(ctx, "Invalid Method"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < parms; ++i)
|
for (i = 0; i < parms; ++i)
|
||||||
@@ -1144,17 +1138,13 @@ duk_ret_t ILibDuktape_GenericMarshal_MethodInvoke(duk_context *ctx)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "INVALID PARAMETER");
|
return(ILibDuktape_Error(ctx, "Invalid Parameter"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parms > 20)
|
if (parms > 20)
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "INVALID NUMBER OF PARAMETERS, MAX of 20");
|
return(ILibDuktape_Error(ctx, "Invalid number of parameters (%d), max of 20", parms));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1250,11 +1240,7 @@ duk_ret_t ILibDuktape_GenericMarshal_CreateMethod(duk_context *ctx)
|
|||||||
|
|
||||||
if (funcAddress == NULL)
|
if (funcAddress == NULL)
|
||||||
{
|
{
|
||||||
char errstr[4096];
|
return(ILibDuktape_Error(ctx, "CreateMethod Error: Method Name [%s] Not Found", funcName));
|
||||||
sprintf_s(errstr, sizeof(errstr), "CreateMethod Error: Method Name [%s] Not Found", funcName);
|
|
||||||
duk_push_string(ctx, errstr);
|
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
else if(deref!=0)
|
else if(deref!=0)
|
||||||
{
|
{
|
||||||
@@ -1324,11 +1310,11 @@ duk_ret_t ILibDuktape_GenericMarshal_CreateNativeProxy(duk_context *ctx)
|
|||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
duk_push_string(ctx, "Could not create Native Proxy");
|
duk_push_string(ctx, "Could not create Native Proxy");
|
||||||
|
return(ILibDuktape_Error(ctx, "Could not create Native Proxy"));
|
||||||
#else
|
#else
|
||||||
duk_push_string(ctx, dlerror());
|
duk_push_string(ctx, dlerror());
|
||||||
|
return(ILibDuktape_Error(ctx, "%s", dlerror()));
|
||||||
#endif
|
#endif
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
duk_push_object(ctx); // [obj]
|
duk_push_object(ctx); // [obj]
|
||||||
|
|||||||
@@ -1057,13 +1057,14 @@ void ILibDuktape_HECI_Push(duk_context *ctx, void *chain)
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
HANDLE h = ILibDuktape_HECI_windowsInit();
|
HANDLE h = ILibDuktape_HECI_windowsInit();
|
||||||
if (h == NULL) { duk_push_string(ctx, "error initializing HECI"); duk_throw(ctx); }
|
if (h == NULL) { ILibDuktape_Error(ctx, "Error initializing HECI"); return; }
|
||||||
duk_push_pointer(ctx, h); // [HECI][HANDLE]
|
duk_push_pointer(ctx, h); // [HECI][HANDLE]
|
||||||
duk_put_prop_string(ctx, -2, ILibDuktape_HECI_Descriptor); // [HECI]
|
duk_put_prop_string(ctx, -2, ILibDuktape_HECI_Descriptor); // [HECI]
|
||||||
|
|
||||||
if (duk_peval_string(ctx, "require('child_process');") != 0) // [HECI][child_process]
|
if (duk_peval_string(ctx, "require('child_process');") != 0) // [HECI][child_process]
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "Error instantiating dependency 'child_process'"); duk_throw(ctx); return;
|
ILibDuktape_Error(ctx, "Error instantiating dependency 'child_process'");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
duk_put_prop_string(ctx, -2, ILibDuktape_HECI_ChildProcess); // [HECI]
|
duk_put_prop_string(ctx, -2, ILibDuktape_HECI_ChildProcess); // [HECI]
|
||||||
@@ -1071,7 +1072,7 @@ void ILibDuktape_HECI_Push(duk_context *ctx, void *chain)
|
|||||||
duk_put_prop_string(ctx, -2, ILibDuktape_HECI_IoctlWaitHandle); // [HECI]
|
duk_put_prop_string(ctx, -2, ILibDuktape_HECI_IoctlWaitHandle); // [HECI]
|
||||||
#elif defined(_POSIX) && !defined(__APPLE__)
|
#elif defined(_POSIX) && !defined(__APPLE__)
|
||||||
int h = ILibDuktape_HECI_linuxInit();
|
int h = ILibDuktape_HECI_linuxInit();
|
||||||
if (h < 0) { duk_push_string(ctx, "error initializing HECI"); duk_throw(ctx); }
|
if (h < 0) { ILibDuktape_Error(ctx, "error initializing HECI"); return; }
|
||||||
duk_push_int(ctx, h); // [HECI][descriptor]
|
duk_push_int(ctx, h); // [HECI][descriptor]
|
||||||
duk_put_prop_string(ctx, -2, ILibDuktape_HECI_Descriptor); // [HECI]
|
duk_put_prop_string(ctx, -2, ILibDuktape_HECI_Descriptor); // [HECI]
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,14 @@ duk_ret_t ILibDuktape_Error(duk_context *ctx, char *format, ...)
|
|||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
duk_push_string(ctx, dest);
|
duk_push_string(ctx, dest);
|
||||||
|
#ifdef _POSIX
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-value"
|
||||||
|
#endif
|
||||||
duk_throw(ctx);
|
duk_throw(ctx);
|
||||||
|
#ifdef _POSIX
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
return DUK_RET_ERROR;
|
return DUK_RET_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -316,9 +316,7 @@ duk_ret_t ILibDuktape_Polyfills_Buffer_toString(duk_context *ctx)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "buffer.toString(): Unrecognized parameter");
|
return(ILibDuktape_Error(ctx, "Unrecognized parameter"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@@ -342,9 +340,7 @@ duk_ret_t ILibDuktape_Polyfills_Buffer_from(duk_context *ctx)
|
|||||||
}
|
}
|
||||||
else if(!(nargs == 2 && duk_is_string(ctx, 0) && duk_is_string(ctx, 1)))
|
else if(!(nargs == 2 && duk_is_string(ctx, 0) && duk_is_string(ctx, 1)))
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "Buffer.from(): Usage not supported yet.");
|
return(ILibDuktape_Error(ctx, "usage not supported yet"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
str = (char*)duk_get_lstring(ctx, 0, &strlength);
|
str = (char*)duk_get_lstring(ctx, 0, &strlength);
|
||||||
@@ -365,9 +361,7 @@ duk_ret_t ILibDuktape_Polyfills_Buffer_from(duk_context *ctx)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "Buffer.from(): Encoding not supported yet.");
|
return(ILibDuktape_Error(ctx, "unsupported encoding"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -828,7 +822,7 @@ duk_ret_t ILibDuktape_ntohl(duk_context *ctx)
|
|||||||
char *buffer = Duktape_GetBuffer(ctx, 0, &bufferLen);
|
char *buffer = Duktape_GetBuffer(ctx, 0, &bufferLen);
|
||||||
int offset = duk_require_int(ctx, 1);
|
int offset = duk_require_int(ctx, 1);
|
||||||
|
|
||||||
if ((int)bufferLen < (4 + offset)) { duk_push_string(ctx, "buffer too small"); duk_throw(ctx); return(DUK_RET_ERROR); }
|
if ((int)bufferLen < (4 + offset)) { return(ILibDuktape_Error(ctx, "buffer too small")); }
|
||||||
duk_push_int(ctx, ntohl(((unsigned int*)(buffer + offset))[0]));
|
duk_push_int(ctx, ntohl(((unsigned int*)(buffer + offset))[0]));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -838,7 +832,7 @@ duk_ret_t ILibDuktape_ntohs(duk_context *ctx)
|
|||||||
char *buffer = Duktape_GetBuffer(ctx, 0, &bufferLen);
|
char *buffer = Duktape_GetBuffer(ctx, 0, &bufferLen);
|
||||||
int offset = duk_require_int(ctx, 1);
|
int offset = duk_require_int(ctx, 1);
|
||||||
|
|
||||||
if ((int)bufferLen < 2 + offset) { duk_push_string(ctx, "buffer too small"); duk_throw(ctx); return(DUK_RET_ERROR); }
|
if ((int)bufferLen < 2 + offset) { return(ILibDuktape_Error(ctx, "buffer too small")); }
|
||||||
duk_push_int(ctx, ntohs(((unsigned short*)(buffer + offset))[0]));
|
duk_push_int(ctx, ntohs(((unsigned short*)(buffer + offset))[0]));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -849,7 +843,7 @@ duk_ret_t ILibDuktape_htonl(duk_context *ctx)
|
|||||||
int offset = duk_require_int(ctx, 1);
|
int offset = duk_require_int(ctx, 1);
|
||||||
unsigned int val = (unsigned int)duk_require_int(ctx, 2);
|
unsigned int val = (unsigned int)duk_require_int(ctx, 2);
|
||||||
|
|
||||||
if ((int)bufferLen < (4 + offset)) { duk_push_string(ctx, "buffer too small"); duk_throw(ctx); return(DUK_RET_ERROR); }
|
if ((int)bufferLen < (4 + offset)) { return(ILibDuktape_Error(ctx, "buffer too small")); }
|
||||||
((unsigned int*)(buffer + offset))[0] = htonl(val);
|
((unsigned int*)(buffer + offset))[0] = htonl(val);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -860,7 +854,7 @@ duk_ret_t ILibDuktape_htons(duk_context *ctx)
|
|||||||
int offset = duk_require_int(ctx, 1);
|
int offset = duk_require_int(ctx, 1);
|
||||||
unsigned int val = (unsigned int)duk_require_int(ctx, 2);
|
unsigned int val = (unsigned int)duk_require_int(ctx, 2);
|
||||||
|
|
||||||
if ((int)bufferLen < (2 + offset)) { duk_push_string(ctx, "buffer too small"); duk_throw(ctx); return(DUK_RET_ERROR); }
|
if ((int)bufferLen < (2 + offset)) { return(ILibDuktape_Error(ctx, "buffer too small")); }
|
||||||
((unsigned short*)(buffer + offset))[0] = htons(val);
|
((unsigned short*)(buffer + offset))[0] = htons(val);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,9 +216,7 @@ duk_ret_t ILibDuktape_SHA256_SIGNER_Create(duk_context *ctx)
|
|||||||
duk_put_prop_string(ctx, -2, ILibDuktape_SHA256_SIGNER_CERT); // [signer]
|
duk_put_prop_string(ctx, -2, ILibDuktape_SHA256_SIGNER_CERT); // [signer]
|
||||||
if (util_from_p12(pfx, (int)pfxLen, passphrase, cert) == 0)
|
if (util_from_p12(pfx, (int)pfxLen, passphrase, cert) == 0)
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "SHA256_Signer_Create: Invalid PFX/Passphrase");
|
return(ILibDuktape_Error(ctx, "Invalid PFX/Passphrase"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -235,9 +233,7 @@ duk_ret_t ILibDuktape_SHA256_SIGNER_Create(duk_context *ctx)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "SHA256_Signer_Create: Unrecognized paramter");
|
return(ILibDuktape_Error(ctx, "Unrecognized parameter"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ILibDuktape_CreateFinalizer(ctx, ILibDuktape_SHA256_SIGNER_Finalizer);
|
ILibDuktape_CreateFinalizer(ctx, ILibDuktape_SHA256_SIGNER_Finalizer);
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ duk_ret_t ILibWebRTC_Duktape_ConnectionFactory_SetTurn(duk_context *ctx)
|
|||||||
struct sockaddr_in6* server;
|
struct sockaddr_in6* server;
|
||||||
ILibWrapper_WebRTC_ConnectionFactory factory;
|
ILibWrapper_WebRTC_ConnectionFactory factory;
|
||||||
|
|
||||||
if (host == NULL || username == NULL) { duk_push_string(ctx, "Invalid TURN Parameters"); duk_throw(ctx); return(DUK_RET_ERROR); }
|
if (host == NULL || username == NULL) { return(ILibDuktape_Error(ctx, "Invalid TURN parameters")); }
|
||||||
server = Duktape_IPAddress4_FromString(host, (unsigned short)port);
|
server = Duktape_IPAddress4_FromString(host, (unsigned short)port);
|
||||||
|
|
||||||
duk_push_this(ctx);
|
duk_push_this(ctx);
|
||||||
|
|||||||
@@ -213,9 +213,7 @@ duk_ret_t ILibDuktape_fs_closeSync(duk_context *ctx)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "invalid FD");
|
return(ILibDuktape_Error(ctx, "Invalid FD"));
|
||||||
duk_throw(ctx);
|
|
||||||
return DUK_RET_ERROR;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -266,7 +264,7 @@ duk_ret_t ILibDuktape_fs_openSync(duk_context *ctx)
|
|||||||
char *flags = (char*)duk_require_string(ctx, 1);
|
char *flags = (char*)duk_require_string(ctx, 1);
|
||||||
int retVal = -1;
|
int retVal = -1;
|
||||||
|
|
||||||
if (nargs < 2) { duk_push_string(ctx, "Too few arguments"); duk_throw(ctx); return(DUK_RET_ERROR); }
|
if (nargs < 2) { return(ILibDuktape_Error(ctx, "Too few arguments")); }
|
||||||
|
|
||||||
retVal = ILibDuktape_fs_openSyncEx(ctx, path, flags, NULL);
|
retVal = ILibDuktape_fs_openSyncEx(ctx, path, flags, NULL);
|
||||||
if (retVal > 0)
|
if (retVal > 0)
|
||||||
@@ -301,9 +299,7 @@ duk_ret_t ILibDuktape_fs_readSync(duk_context *ctx)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
duk_push_string(ctx, "FS I/O Error");
|
return(ILibDuktape_Error(ctx, "FS I/O Error"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
duk_ret_t ILibDuktape_fs_writeSync(duk_context *ctx)
|
duk_ret_t ILibDuktape_fs_writeSync(duk_context *ctx)
|
||||||
{
|
{
|
||||||
@@ -325,9 +321,7 @@ duk_ret_t ILibDuktape_fs_writeSync(duk_context *ctx)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
duk_push_string(ctx, "FS I/O ERROR");
|
return(ILibDuktape_Error(ctx, "FS I/O Error"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ILibduktape_fs_CloseFD(duk_context *ctx, void *fs, int fd)
|
int ILibduktape_fs_CloseFD(duk_context *ctx, void *fs, int fd)
|
||||||
@@ -466,9 +460,7 @@ duk_ret_t ILibDuktape_fs_createWriteStream(duk_context *ctx)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "FS CreateWriteStream Error");
|
return(ILibDuktape_Error(ctx, "FS CreateWriteStream Error"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ILibDuktape_fs_readStream_Pause(struct ILibDuktape_readableStream *sender, void *user)
|
void ILibDuktape_fs_readStream_Pause(struct ILibDuktape_readableStream *sender, void *user)
|
||||||
@@ -594,9 +586,7 @@ duk_ret_t ILibDuktape_fs_createReadStream(duk_context *ctx)
|
|||||||
f = ILibDuktape_fs_getFilePtr(ctx, fd);
|
f = ILibDuktape_fs_getFilePtr(ctx, fd);
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "FS CreateReadStream Error");
|
return(ILibDuktape_Error(ctx, "FS CreateReadStream Error"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
duk_push_object(ctx); // [readStream]
|
duk_push_object(ctx); // [readStream]
|
||||||
@@ -762,9 +752,7 @@ duk_ret_t ILibDuktape_fs_statSync(duk_context *ctx)
|
|||||||
|
|
||||||
if(GetFileAttributesExW((LPCWSTR)path, GetFileExInfoStandard, (void*)data) == 0)
|
if(GetFileAttributesExW((LPCWSTR)path, GetFileExInfoStandard, (void*)data) == 0)
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "fs.statSync(): Invalid path");
|
return(ILibDuktape_Error(ctx, "fs.statSync(): Invalid Path"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
duk_push_object(ctx);
|
duk_push_object(ctx);
|
||||||
@@ -888,9 +876,7 @@ duk_ret_t ILibDuktape_fs_readDrivesSync(duk_context *ctx)
|
|||||||
|
|
||||||
if (h == INVALID_HANDLE_VALUE)
|
if (h == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "fs.readDrivesSync(): Unknown Error");
|
return(ILibDuktape_Error(ctx, "fs.readDrivesSync(): Unknown Error"));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
if (ILibDuktape_fs_readDrivesSync_result_PUSH(ctx, volumeName) != 0) { duk_put_prop_index(ctx, -2, i++); }
|
if (ILibDuktape_fs_readDrivesSync_result_PUSH(ctx, volumeName) != 0) { duk_put_prop_index(ctx, -2, i++); }
|
||||||
|
|
||||||
@@ -1401,13 +1387,13 @@ duk_ret_t ILibDuktape_fs_watch(duk_context *ctx)
|
|||||||
|
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
if ((data->overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL)) == NULL) { duk_push_string(ctx, "Could not create HANDLE"); duk_throw(ctx); return(DUK_RET_ERROR); }
|
if ((data->overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL)) == NULL) { return(ILibDuktape_Error(ctx, "Could not create handle")); }
|
||||||
data->h = CreateFile(path, FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL);
|
data->h = CreateFile(path, FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL);
|
||||||
if (data->h == INVALID_HANDLE_VALUE) { duk_push_string(ctx, "fs.watch(): Invalid Path or Access Denied"); duk_throw(ctx); return(DUK_RET_ERROR); }
|
if (data->h == INVALID_HANDLE_VALUE) { return(ILibDuktape_Error(ctx, "fs.watch(): Invalid Path or Access Denied")); }
|
||||||
|
|
||||||
if (ReadDirectoryChangesW(data->h, data->results, sizeof(data->results), recursive, FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_CREATION | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_LAST_ACCESS, NULL, &(data->overlapped), NULL) == 0)
|
if (ReadDirectoryChangesW(data->h, data->results, sizeof(data->results), recursive, FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_CREATION | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_LAST_ACCESS, NULL, &(data->overlapped), NULL) == 0)
|
||||||
{
|
{
|
||||||
duk_push_string(ctx, "fs.watch(): Error creating watcher"); duk_throw(ctx); return(DUK_RET_ERROR);
|
return(ILibDuktape_Error(ctx, "fs.watch(): Error creating watcher"));
|
||||||
}
|
}
|
||||||
ILibProcessPipe_WaitHandle_Add(pipeMgr, data->overlapped.hEvent, data, ILibDuktape_fs_watch_iocompletion);
|
ILibProcessPipe_WaitHandle_Add(pipeMgr, data->overlapped.hEvent, data, ILibDuktape_fs_watch_iocompletion);
|
||||||
#elif defined(_POSIX) && !defined(__APPLE__)
|
#elif defined(_POSIX) && !defined(__APPLE__)
|
||||||
@@ -1455,9 +1441,7 @@ duk_ret_t ILibDuktape_fs_rename(duk_context *ctx)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "fs.renameSync(): Error renaming %s to %s", oldPath, newPath);
|
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "fs.renameSync(): Error renaming %s to %s", oldPath, newPath);
|
||||||
duk_push_string(ctx, ILibScratchPad);
|
return(ILibDuktape_Error(ctx, "%s", ILibScratchPad));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1479,9 +1463,7 @@ duk_ret_t ILibDuktape_fs_unlink(duk_context *ctx)
|
|||||||
if (RemoveDirectoryW((LPCWSTR)path) != 0) { return 0; }
|
if (RemoveDirectoryW((LPCWSTR)path) != 0) { return 0; }
|
||||||
#endif
|
#endif
|
||||||
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "fs.unlinkSync(): Error trying to unlink: %s", ILibDuktape_String_WideToUTF8(ctx, path));
|
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "fs.unlinkSync(): Error trying to unlink: %s", ILibDuktape_String_WideToUTF8(ctx, path));
|
||||||
duk_push_string(ctx, ILibScratchPad);
|
return(ILibDuktape_Error(ctx, "%s", ILibScratchPad));
|
||||||
duk_throw(ctx);
|
|
||||||
return(DUK_RET_ERROR);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ duk_ret_t ILibDuktape_httpDigest_clientRequest_propagateEvent(duk_context *ctx)
|
|||||||
{
|
{
|
||||||
duk_dup(ctx, i); // [func][emit][this][eventName][params]
|
duk_dup(ctx, i); // [func][emit][this][eventName][params]
|
||||||
}
|
}
|
||||||
if (duk_pcall_method(ctx, 1 + nargs) != 0) { duk_throw(ctx); return(DUK_RET_ERROR); }
|
if (duk_pcall_method(ctx, 1 + nargs) != 0) { return(ILibDuktape_Error(ctx, "propagateEvent() Error")); }
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,7 +393,7 @@ duk_ret_t ILibDuktape_httpDigest_digestRequest_end(duk_context *ctx)
|
|||||||
{
|
{
|
||||||
duk_dup(ctx, i); // [digestClientRequest][end][this][params...]
|
duk_dup(ctx, i); // [digestClientRequest][end][this][params...]
|
||||||
}
|
}
|
||||||
if (duk_pcall_method(ctx, nargs) != 0) { duk_throw(ctx); return(DUK_RET_ERROR); }
|
if (duk_pcall_method(ctx, nargs) != 0) { return(ILibDuktape_Error(ctx, "digestRequest().end() error")); }
|
||||||
|
|
||||||
duk_push_this(ctx);
|
duk_push_this(ctx);
|
||||||
duk_del_prop_string(ctx, -1, "DIGEST_CLIENT_REQUEST");
|
duk_del_prop_string(ctx, -1, "DIGEST_CLIENT_REQUEST");
|
||||||
@@ -581,7 +581,7 @@ duk_ret_t ILibDuktape_httpDigest_http_request(duk_context *ctx)
|
|||||||
duk_push_this(ctx); // [once][this][response][method][digest-clientRequest][digest]
|
duk_push_this(ctx); // [once][this][response][method][digest-clientRequest][digest]
|
||||||
duk_put_prop_string(ctx, -2, "digest"); // [once][this][response][method][digest-clientRequest]
|
duk_put_prop_string(ctx, -2, "digest"); // [once][this][response][method][digest-clientRequest]
|
||||||
duk_put_prop_string(ctx, -2, "digestClientRequest"); // [once][this][response][method]
|
duk_put_prop_string(ctx, -2, "digestClientRequest"); // [once][this][response][method]
|
||||||
if (duk_pcall_method(ctx, 2) != 0) { duk_throw(ctx); return(DUK_RET_ERROR); } // [clientRequest]
|
if (duk_pcall_method(ctx, 2) != 0) { return(ILibDuktape_Error(ctx, "request error")); } // [clientRequest]
|
||||||
|
|
||||||
duk_push_heapptr(emitter->ctx, clientRequest);
|
duk_push_heapptr(emitter->ctx, clientRequest);
|
||||||
duk_push_heapptr(emitter->ctx, emitter->object); // [clientRequest][digestClientRequest]
|
duk_push_heapptr(emitter->ctx, emitter->object); // [clientRequest][digestClientRequest]
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ duk_ret_t ILibDuktape_net_socket_connect(duk_context *ctx)
|
|||||||
ILibDuktape_net_socket *ptrs;
|
ILibDuktape_net_socket *ptrs;
|
||||||
struct sockaddr_in6 dest;
|
struct sockaddr_in6 dest;
|
||||||
|
|
||||||
if (nargs == 0) { duk_push_string(ctx, "Too Few Arguments"); duk_throw(ctx); return(DUK_RET_ERROR); }
|
if (nargs == 0) { return(ILibDuktape_Error(ctx, "Too few arguments")); }
|
||||||
duk_push_this(ctx); // [socket]
|
duk_push_this(ctx); // [socket]
|
||||||
duk_get_prop_string(ctx, -1, ILibDuktape_net_socket_ptr); // [socket][ptrs]
|
duk_get_prop_string(ctx, -1, ILibDuktape_net_socket_ptr); // [socket][ptrs]
|
||||||
ptrs = (ILibDuktape_net_socket*)duk_to_pointer(ctx, -1);
|
ptrs = (ILibDuktape_net_socket*)duk_to_pointer(ctx, -1);
|
||||||
@@ -487,7 +487,7 @@ duk_ret_t ILibDuktape_net_socket_constructor(duk_context *ctx)
|
|||||||
void *chain;
|
void *chain;
|
||||||
void *net;
|
void *net;
|
||||||
|
|
||||||
if (!duk_is_constructor_call(ctx)) { duk_push_string(ctx, "Invalid Call"); duk_throw(ctx); return(DUK_RET_ERROR); }
|
if (!duk_is_constructor_call(ctx)) { return(ILibDuktape_Error(ctx, "Invalid call")); }
|
||||||
|
|
||||||
duk_push_current_function(ctx); // [func]
|
duk_push_current_function(ctx); // [func]
|
||||||
duk_get_prop_string(ctx, -1, "chain"); // [func][chain]
|
duk_get_prop_string(ctx, -1, "chain"); // [func][chain]
|
||||||
|
|||||||
Reference in New Issue
Block a user