Fixed windows compatibility

This commit is contained in:
TheDarkBug 2021-12-23 16:46:58 +01:00
parent 475ff4a8d6
commit a79e426218

View file

@ -145,7 +145,11 @@ struct info {
#endif // _WIN32
};
char* MOVE_CURSOR = "\033[18C"; // moves the cursor after printing the image or the ascii logo
#ifdef _WIN32
char* MOVE_CURSOR = "\033[21C"; // moves the cursor after printing the image or the ascii logo
#else
char* MOVE_CURSOR = "\033[18C";
#endif
// reads the config file
struct configuration parse_config(struct info* user_info) {
@ -739,6 +743,23 @@ void remove_brackets(char* str) {
i++;
}
#ifdef _WIN32
// windows sucks and hasn't a strstep, so I copied one from
// https://stackoverflow.com/questions/8512958/is-there-a-windows-variant-of-strsep-function
char* strsep(char** stringp, const char* delim) {
char* start = *stringp;
char* p;
p = (start != NULL) ? strpbrk(start, delim) : NULL;
if (p == NULL)
*stringp = NULL;
else {
*p = '\0';
*stringp = p + 1;
}
return start;
}
#endif
// uwufies kernel name
void uwu_kernel(char* kernel) {
#define KERNEL_TO_UWU(str, original, uwufied) \
@ -1229,23 +1250,6 @@ void usage(char* arg) {
NORMAL);
}
#ifdef _WIN32
// windows sucks and hasn't a strstep, so I copied one from
// https://stackoverflow.com/questions/8512958/is-there-a-windows-variant-of-strsep-function
char* strsep(char** stringp, const char* delim) {
char* start = *stringp;
char* p;
p = (start != NULL) ? strpbrk(start, delim) : NULL;
if (p == NULL)
*stringp = NULL;
else {
*p = '\0';
*stringp = p + 1;
}
return start;
}
#endif
// the main function is on the bottom of the file to avoid double function declarations
int main(int argc, char* argv[]) {
char* cache_env = getenv("UWUFETCH_CACHE_ENABLED"); // getting cache env variable