/*
 * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Created in Samsung Ukraine R&D Center (SRK) under a contract between
 * LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
 * and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
 *
 * Created on: Dec 18, 2017
 * Author: Kostiantyn Volobuiev <k.volobuyev@samsung.com>
 * Brief: Module that responds for string operations.
 */

#ifndef TZWSTRING_H
#define TZWSTRING_H

#include <stddef.h>
#include <stdint.h>

/**
 * @brief Copies size bytes from the object pointed to by src
 *        into the object pointed to by dest
 * @param[out] dest - a pointer to the destination buffer
 * @param[in] src - a pointer to the source buffer
 * @param[in] size - the number of bytes to be copied
 */
void tzwMemMove(void *dest, const void *src, uint32_t size);

/**
 * @brief Writes the byte x into the first size bytes of the object pointed
 *        to by buffer
 * @param[out] buffer - a pointer to the destination buffer
 * @param[in] x - the value to be set
 * @param[in] size - the number of bytes to be set
 */
void tzwMemFill(void *buffer, uint32_t x, uint32_t size);

/**
 * @brief Compares the first size bytes of the object pointed to by buffer1
 *        to the first size bytes of the object pointed to by buffer2
 * @param[in] buffer1 - a pointer to the first buffer
 * @param[in] buffer2 - a pointer to the second buffer
 * @param[in] size - encrypted data length
 * @return an integral value indicating the relationship between
 *         the content of the memory blocks
 */
int32_t tzwMemCompare(const void *buffer1, const void *buffer2, uint32_t size);

/**
 * @brief Converts string to unsigned long integer
 * @param[in] uidStr - a pointer to a string to convert to
 *                     an unsigned long integer
 * @param[in] uidStrBase - the base of the number being converted
 * @return the unsigned long integer representation of a string
 */
unsigned long tzwStrtoul(const char* uidStr, int uidStrBase);

/**
 * @brief Concatenates a string into a destination buffer.
 *        NOTE: QSEE guarantees that result string is NULL-terminated
 * @param[out] dest - destination string to copy into
 * @param[in] src - source string to copy from
 * @param[in] srcLen - max number of symbols to be concatenated
 * @param[in] destLen - size of the destination buffer in bytes
 * @return length of the full string copied, if successful
 */
char* tzwStrncat(char* dest, const char* src, size_t srcLen, uint32_t destLen);

#endif // TZWSTRING_H
