Add missing statics, and remove the 'tildefriends check' command.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4838 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2024-02-10 16:50:00 +00:00
parent 51a327c52d
commit 6c5a7b0751
17 changed files with 93 additions and 304 deletions

View File

@ -3,25 +3,10 @@
#include "task.h"
#include "ow-crypt.h"
#include "quickjs.h"
#include "uv.h"
#include <uv.h>
JSValue _crypt_hashpw(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
JSValue _crypt_gensalt(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
void tf_bcrypt_register(JSContext* context)
{
JSValue global = JS_GetGlobalObject(context);
JSValue bcrypt = JS_NewObject(context);
JS_SetPropertyStr(context, global, "bCrypt", bcrypt);
JS_SetPropertyStr(context, bcrypt, "hashpw", JS_NewCFunction(context, _crypt_hashpw, "hashpw", 2));
JS_SetPropertyStr(context, bcrypt, "gensalt", JS_NewCFunction(context, _crypt_gensalt, "gensalt", 1));
JS_FreeValue(context, global);
}
JSValue _crypt_hashpw(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
static JSValue _crypt_hashpw(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
{
const char* key = JS_ToCString(context, argv[0]);
const char* salt = JS_ToCString(context, argv[1]);
@ -33,7 +18,7 @@ JSValue _crypt_hashpw(JSContext* context, JSValueConst this_val, int argc, JSVal
return result;
}
JSValue _crypt_gensalt(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
static JSValue _crypt_gensalt(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
{
int length = 0;
JS_ToInt32(context, &length, argv[0]);
@ -45,3 +30,13 @@ JSValue _crypt_gensalt(JSContext* context, JSValueConst this_val, int argc, JSVa
JSValue result = JS_NewString(context, salt);
return result;
}
void tf_bcrypt_register(JSContext* context)
{
JSValue global = JS_GetGlobalObject(context);
JSValue bcrypt = JS_NewObject(context);
JS_SetPropertyStr(context, global, "bCrypt", bcrypt);
JS_SetPropertyStr(context, bcrypt, "hashpw", JS_NewCFunction(context, _crypt_hashpw, "hashpw", 2));
JS_SetPropertyStr(context, bcrypt, "gensalt", JS_NewCFunction(context, _crypt_gensalt, "gensalt", 1));
JS_FreeValue(context, global);
}