aisl-sdk/cStuff/string.h

62 lines
1.6 KiB
C

/******************************************************************************
*
* Copyright (c) 2017-2019 by Löwenware Ltd
* Please, refer LICENSE file for legal information
*
******************************************************************************/
/**
* @file string.h
* @author Ilja Kartašov <ik@lowenware.com>
* @brief String module declarations
*
* @see https://lowenware.com/
*/
#ifndef CSTUFF_STRING_H_938B242C_B750_40E9_8B67_A69F2F37EB87
#define CSTUFF_STRING_H_938B242C_B750_40E9_8B67_A69F2F37EB87
#include <stdarg.h>
#include "retcode.h"
/** @brief Copies in string to newly allocated out buffer
* @param out a pointer to an address where new pointer must be stored
* @param in an input string
* @return length of string or -1 if out of memory
*/
int
cstuff_strcpy(char **out, const char *in);
int
cstuff_strncpy(char **out, const char *in, int len);
/** @brief Overwrites content of out buffer with in string using realloc
* @param out a pointer to an address where new string must be stored
* @param in an input string
* @return length of string or -1 if out of memory
*/
int
cstuff_strset(char **out, const char *in);
int
cstuff_strnset(char **out, const char *in, int len);
/** @brief Allocates memory and prints a formatted string into it
* @param out a pointer to an address where new string must be stored
* @param format a format for string (see manual for stdlib sprintf)
* @return length of string or -1 if out of memory
*/
int
cstuff_sprintf(char **out, const char *format, ...);
int
cstuff_vsprintf(char **out, const char *format, va_list args);
#endif /* !CSTUFF_STRING_H */