(M)JPG HTTP output support

This commit is contained in:
Thulinma 2024-06-24 12:04:00 +02:00
parent ecd7e324dd
commit eed71b66d4
10 changed files with 92 additions and 300 deletions

View file

@ -316,6 +316,24 @@ namespace Util{
rndSrc.close();
}
/// Secure random alphanumeric string generator
/// Uses getRandomBytes internally
std::string getRandomAlphanumeric(size_t len){
std::string ret(len, 'X');
getRandomBytes((void*)ret.data(), len);
for (size_t i = 0; i < len; ++i){
uint8_t v = (ret[i] % 62);
if (v < 10){
ret[i] = v + '0';
}else if (v < 36){
ret[i] = v - 10 + 'A';
}else{
ret[i] = v - 10 - 26 + 'a';
}
}
return ret;
}
/// 64-bits version of ftell
uint64_t ftell(FILE *stream){
/// \TODO Windows implementation (e.g. _ftelli64 ?)

View file

@ -21,6 +21,7 @@ namespace Util{
int64_t expBackoffMs(const size_t currIter, const size_t maxIter, const int64_t maxWait);
void getRandomBytes(void * dest, size_t len);
std::string getRandomAlphanumeric(size_t len);
uint64_t ftell(FILE *stream);
uint64_t fseek(FILE *stream, uint64_t offset, int whence);