- token = malloc(TOKEN_SIZE * 2 + 1);
- read(token_fd, token, TOKEN_SIZE * 2);
- close(token_fd);
-
- return token;
-}
-
-int auth_check_token(const char *username, const char *given_token) {
- char *token = auth_get_token(username);
- if (token != NULL && given_token != NULL) {
- int ret = (strncmp(token, given_token, TOKEN_SIZE * 2) == 0);
- free(token);
- return ret;
- } else {
- return 0;
- }