/** * util.h * Copyright (C) 2016 Alexander Koch * Utility / helper functions */ #ifndef util_h #define util_h #include "../core/mem.h" #include #include #include #include // String operations #if defined(__GNUC__) && !defined(__llvm__) #include char* strdup(const char* str); char* strndup(const char* str, size_t n); #else #define _POSIX_C_SOURCE 200809L #include #endif char* concat(char *s1, char *s2); // Custom format function uses $ for elements char* strf(const char* fmt, ...); // djb2 hashing algorithm unsigned long djb2(unsigned char* str); // File reading methods //FILE *openFile(const char* path, const char* mode); //for compatibility with nspire char* readFile(const char* path); char* replaceExt(char* filename, const char* ext, size_t len); char* getDirectory(const char* path); // Memory void memset64(void* dest, uint64_t value, uintptr_t size); // Mersenne-Twister void seed_prng(const uint32_t seed_value); double prng(void); #endif