1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-05 20:26:46 +02:00

implement avatars (setting only) and generalize path tab-complete

This commit is contained in:
Jfreegman
2014-09-26 03:10:44 -04:00
parent cee9e624b8
commit 544c402f78
17 changed files with 169 additions and 29 deletions

View File

@ -322,3 +322,22 @@ off_t file_size(const char *path)
return st.st_size;
}
/* compares the first size bytes of fp to signature.
Returns 0 if they are the same, 1 if they differ, and -1 on error.
On success this function will seek back to the beginning of fp */
int check_file_signature(const char *signature, size_t size, FILE *fp)
{
char buf[size];
if (fread(buf, size, 1, fp) == -1)
return -1;
int ret = memcmp(signature, buf, size);
if (fseek(fp, 0L, SEEK_SET) == -1)
return -1;
return ret == 0 ? 0 : 1;
}