Last active
May 11, 2022 00:17
-
-
Save snipsnipsnip/306686 to your computer and use it in GitHub Desktop.
int rwgetc(SDL_RWops *rw)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* fgetc equivalent for SDL_rwops */ | |
int rwgetc(SDL_RWops *rw) | |
{ | |
char c; | |
return SDL_RWread(rw, &c, 1, 1) == 1 ? c : EOF; | |
} | |
/* fgets equivalent for SDL_rwops */ | |
char *rwgets(char *buf, int count, SDL_RWops *rw) | |
{ | |
int i; | |
buf[count - 1] = '\0'; | |
for (i = 0; i < count - 1; i++) | |
{ | |
if (SDL_RWread(rw, buf + i, 1, 1) != 1) | |
{ | |
if (i == 0) | |
{ | |
return NULL; | |
} | |
break; | |
} | |
if (buf[i] == '\n') | |
{ | |
break; | |
} | |
} | |
buf[i] = '\0'; | |
return buf; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment