Blame src/helper/toks_guid_string.c

8da24d
/*********************************************************/
8da24d
/*  toksvc: a framework-native token broker service      */
d91fa0
/*  Copyright (C) 2020  SysDeer Technologies, LLC        */
8da24d
/*  Released under GPLv2 and GPLv3; see COPYING.TOKSVC.  */
8da24d
/*********************************************************/
8da24d
8da24d
#include <psxtypes/psxtypes.h>
8da24d
#include <ntapi/nt_object.h>
8da24d
#include <ntapi/nt_guid.h>
8da24d
#include <ntapi/ntapi.h>
8da24d
8da24d
#include <toksvc/toksvc.h>
8da24d
#include "toksvc_init_impl.h"
8da24d
#include "toksvc_driver_impl.h"
8da24d
#include "toksvc_nolibc_impl.h"
8da24d
0021e3
int toks_string_to_uuid(const char (*guidstr)[40], struct toks_uuid * uuid)
8da24d
{
0021e3
	int32_t         status;
0021e3
	struct _nt_guid guid;
0021e3
8da24d
	toks_init();
8da24d
0021e3
	status = ntapi->tt_string_to_guid_utf8(
0021e3
		guidstr[0],&guid);
0021e3
0021e3
	if (status == NT_STATUS_SUCCESS)
0021e3
		toks_guid_to_uuid(&guid,uuid);
0021e3
0021e3
	return status;
8da24d
}
8da24d
0021e3
void toks_uuid_to_string(const struct toks_uuid * uuid, char (*guidstr)[40])
8da24d
{
8da24d
	struct _nt_guid_str_utf8 buf;
8da24d
	void *                   addr;
8da24d
	char *                   ch;
0021e3
	struct _nt_guid          guid;
8da24d
8da24d
	toks_init();
8da24d
0021e3
	toks_uuid_to_guid(uuid,&guid);
0021e3
8da24d
	ntapi->tt_guid_to_string_utf8(
0021e3
		&guid,&buf;;
8da24d
8da24d
	addr = &buf.lbrace;
8da24d
	ch   = addr;
8da24d
8da24d
	toks_memcpy(
8da24d
		guidstr[0],
8da24d
		ch,sizeof(buf));
8da24d
8da24d
	guidstr[0][39] = 0;
8da24d
}