From 8da24df29a287c0ae61f7e2b969260a19e203294 Mon Sep 17 00:00:00 2001 From: midipix Date: Jun 24 2020 21:45:20 +0000 Subject: helper api: added toks_guid_to_string(), toks_string_to_guid(). --- diff --git a/include/toksvc/toksvc.h b/include/toksvc/toksvc.h index bd596cb..2a41b33 100644 --- a/include/toksvc/toksvc.h +++ b/include/toksvc/toksvc.h @@ -187,6 +187,10 @@ toks_api int toks_main (char **, char **); toks_api int toks_output_error_record (const struct toks_driver_ctx *, const struct toks_error_info *); toks_api int toks_output_error_vector (const struct toks_driver_ctx *); +/* helper api */ +toks_api int toks_string_to_guid (const char (*)[40], struct _nt_guid *); +toks_api void toks_guid_to_string (const struct _nt_guid *, char (*)[40]); + /* package info */ toks_api const struct toks_source_version * toks_source_version(void); diff --git a/project/common.mk b/project/common.mk index 79ad331..5f8b868 100644 --- a/project/common.mk +++ b/project/common.mk @@ -18,6 +18,7 @@ INTERNAL_SRCS = \ src/daemon/toks_daemon_signal.c \ src/driver/toks_amain.c \ src/driver/toks_driver_ctx.c \ + src/helper/toks_guid_string.c \ src/internal/nolibc/toksvc_compiler.c \ src/internal/toksvc_dprintf_impl.c \ src/internal/toksvc_log_impl.c \ diff --git a/project/tree.mk b/project/tree.mk index e1154e5..aaa2ccd 100644 --- a/project/tree.mk +++ b/project/tree.mk @@ -2,6 +2,7 @@ TREE_DIRS = bin src lib \ src/client \ src/daemon \ src/driver \ + src/helper \ src/internal \ src/internal/nolibc \ src/log \ diff --git a/src/helper/toks_guid_string.c b/src/helper/toks_guid_string.c new file mode 100644 index 0000000..46ab01d --- /dev/null +++ b/src/helper/toks_guid_string.c @@ -0,0 +1,44 @@ +/*********************************************************/ +/* toksvc: a framework-native token broker service */ +/* Copyright (C) 2020 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.TOKSVC. */ +/*********************************************************/ + +#include +#include +#include +#include + +#include +#include "toksvc_init_impl.h" +#include "toksvc_driver_impl.h" +#include "toksvc_nolibc_impl.h" + +int toks_string_to_guid(const char (*guidstr)[40], struct _nt_guid * uuid) +{ + toks_init(); + + return ntapi->tt_string_to_guid_utf8( + guidstr[0],uuid); +} + +void toks_guid_to_string(const struct _nt_guid * uuid, char (*guidstr)[40]) +{ + struct _nt_guid_str_utf8 buf; + void * addr; + char * ch; + + toks_init(); + + ntapi->tt_guid_to_string_utf8( + uuid,&buf); + + addr = &buf.lbrace; + ch = addr; + + toks_memcpy( + guidstr[0], + ch,sizeof(buf)); + + guidstr[0][39] = 0; +}