mirror of
https://github.com/MiSTer-devel/Main_MiSTer.git
synced 2026-04-12 03:04:02 +00:00
Add ini option `unique_mapping` which makes controller mappings unique to the physical port the controller is connected to. Calculates a uint32_t unique_hash for each device during enumeration. Co-authored-by: Martin Donlon <github-martin@donlons.com>
43 lines
883 B
C++
43 lines
883 B
C++
/*
|
|
* str_util.h
|
|
*
|
|
*/
|
|
|
|
#ifndef STR_UTIL_H
|
|
#define STR_UTIL_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
|
|
int str_tokenize(char *s, const char *delim, char **tokens, int max_tokens);
|
|
|
|
// String copy with guaranteed null termination
|
|
char *strncpyz(char *dest, size_t dest_size, const char *src, size_t num);
|
|
char *strcpyz(char *dest, size_t dest_size, const char *src);
|
|
|
|
template<size_t N>
|
|
char *strncpyz(char (&dest)[N], const char *src, size_t num)
|
|
{
|
|
return strncpyz(dest, N, src, num);
|
|
}
|
|
|
|
template<size_t N>
|
|
char *strcpyz(char (&dest)[N], const char *src)
|
|
{
|
|
return strcpyz(dest, N, src);
|
|
}
|
|
|
|
template<size_t N>
|
|
size_t sprintfz(char (&dest)[N], const char *fmt, ...)
|
|
{
|
|
va_list args;
|
|
va_start(args, fmt);
|
|
size_t r = vsnprintf(dest, N, fmt, args);
|
|
va_end(args);
|
|
return r;
|
|
}
|
|
|
|
unsigned int str_hash(const char *s, unsigned int initial = 5381);
|
|
|
|
#endif // STR_UTIL_H
|