2023-09-01 08:57:49 +03:00
|
|
|
#include "name_generator.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <furi_hal_rtc.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <furi.h>
|
|
|
|
|
|
|
|
const char* const name_generator_left[] = {
|
2023-09-02 13:33:32 +03:00
|
|
|
"super",
|
|
|
|
"big",
|
|
|
|
"little",
|
|
|
|
"liquid",
|
|
|
|
"unknown",
|
|
|
|
"thin",
|
|
|
|
"thick",
|
|
|
|
"great",
|
|
|
|
"my",
|
|
|
|
"mini",
|
|
|
|
"ultra",
|
|
|
|
"haupt",
|
|
|
|
"small",
|
|
|
|
"random",
|
|
|
|
"strange",
|
2023-09-01 08:57:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
const char* const name_generator_right[] = {
|
2023-09-02 13:33:32 +03:00
|
|
|
"maslina",
|
|
|
|
"sus",
|
|
|
|
"anomalija",
|
|
|
|
"artefact",
|
|
|
|
"monolit",
|
|
|
|
"burer",
|
|
|
|
"sidorovich",
|
|
|
|
"habar",
|
|
|
|
"radar",
|
|
|
|
"borov",
|
|
|
|
"pda",
|
|
|
|
"konserva",
|
|
|
|
"aptechka",
|
2023-09-01 08:57:49 +03:00
|
|
|
"door",
|
2023-09-02 13:33:32 +03:00
|
|
|
"thing",
|
|
|
|
"stuff",
|
2023-09-01 08:57:49 +03:00
|
|
|
};
|
|
|
|
|
2024-01-28 06:45:33 +03:00
|
|
|
void name_generator_make_auto_datetime(
|
|
|
|
char* name,
|
|
|
|
size_t max_name_size,
|
|
|
|
const char* prefix,
|
2024-02-15 14:08:10 +03:00
|
|
|
DateTime* custom_time) {
|
2023-09-01 08:57:49 +03:00
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDetailedFilename)) {
|
2024-01-28 06:45:33 +03:00
|
|
|
name_generator_make_detailed_datetime(name, max_name_size, prefix, custom_time);
|
2023-09-01 08:57:49 +03:00
|
|
|
} else {
|
2024-01-28 06:45:33 +03:00
|
|
|
name_generator_make_random_prefixed(name, max_name_size, prefix);
|
2023-09-01 08:57:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-28 06:45:33 +03:00
|
|
|
void name_generator_make_auto(char* name, size_t max_name_size, const char* prefix) {
|
|
|
|
name_generator_make_auto_datetime(name, max_name_size, prefix, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void name_generator_make_random_prefixed(char* name, size_t max_name_size, const char* prefix) {
|
2023-09-01 08:57:49 +03:00
|
|
|
furi_assert(name);
|
|
|
|
furi_assert(max_name_size);
|
|
|
|
|
|
|
|
uint8_t name_generator_left_i = rand() % COUNT_OF(name_generator_left);
|
|
|
|
uint8_t name_generator_right_i = rand() % COUNT_OF(name_generator_right);
|
|
|
|
|
|
|
|
snprintf(
|
|
|
|
name,
|
|
|
|
max_name_size,
|
2024-01-28 06:45:33 +03:00
|
|
|
"%s%s%s_%s",
|
|
|
|
prefix ? prefix : "",
|
|
|
|
prefix ? "_" : "",
|
2023-09-01 08:57:49 +03:00
|
|
|
name_generator_left[name_generator_left_i],
|
|
|
|
name_generator_right[name_generator_right_i]);
|
|
|
|
|
|
|
|
// Set first symbol to upper case
|
2024-01-28 06:45:33 +03:00
|
|
|
if(islower((int)name[0])) name[0] = name[0] - 0x20;
|
2023-09-01 08:57:49 +03:00
|
|
|
}
|
|
|
|
|
2024-01-28 06:45:33 +03:00
|
|
|
void name_generator_make_random(char* name, size_t max_name_size) {
|
|
|
|
name_generator_make_random_prefixed(name, max_name_size, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void name_generator_make_detailed_datetime(
|
|
|
|
char* name,
|
|
|
|
size_t max_name_size,
|
|
|
|
const char* prefix,
|
2024-02-15 14:08:10 +03:00
|
|
|
DateTime* custom_time) {
|
2023-09-01 08:57:49 +03:00
|
|
|
furi_assert(name);
|
|
|
|
furi_assert(max_name_size);
|
|
|
|
furi_assert(prefix);
|
|
|
|
|
2024-02-15 14:08:10 +03:00
|
|
|
DateTime dateTime;
|
2024-01-28 06:45:33 +03:00
|
|
|
if(custom_time) {
|
|
|
|
dateTime = *custom_time;
|
|
|
|
} else {
|
|
|
|
furi_hal_rtc_get_datetime(&dateTime);
|
|
|
|
}
|
2023-09-01 08:57:49 +03:00
|
|
|
|
|
|
|
snprintf(
|
|
|
|
name,
|
|
|
|
max_name_size,
|
2024-01-28 06:45:33 +03:00
|
|
|
"%s-%.4d_%.2d_%.2d-%.2d_%.2d_%.2d",
|
|
|
|
prefix ? prefix : "S",
|
2023-09-01 08:57:49 +03:00
|
|
|
dateTime.year,
|
|
|
|
dateTime.month,
|
|
|
|
dateTime.day,
|
|
|
|
dateTime.hour,
|
2024-01-28 06:45:33 +03:00
|
|
|
dateTime.minute,
|
|
|
|
dateTime.second);
|
|
|
|
|
|
|
|
// Set first symbol to upper case
|
|
|
|
if(islower((int)name[0])) name[0] = name[0] - 0x20;
|
|
|
|
}
|
|
|
|
|
|
|
|
void name_generator_make_detailed(char* name, size_t max_name_size, const char* prefix) {
|
|
|
|
name_generator_make_detailed_datetime(name, max_name_size, prefix, NULL);
|
2023-09-01 08:57:49 +03:00
|
|
|
}
|