Skip to content

Instantly share code, notes, and snippets.

@kkevlar
Created May 19, 2018 00:57
Show Gist options
  • Save kkevlar/28e48deeb57b45ebf182e0a5fd070d6d to your computer and use it in GitHub Desktop.
Save kkevlar/28e48deeb57b45ebf182e0a5fd070d6d to your computer and use it in GitHub Desktop.
noahs a goon
int header_set_uid_itsbig(char* where, size_t size, int32_t val)
{
int err = 0;
if (val < 0 || size < sizeof(val))
{
err++;
}
else
{
memset(where, 0, size);
*(int32_t *)(where+size-sizeof(val)) = htonl(val);
*where |= 0x80;
}
return err;
}
void header_set_uid_bigsafe(char* buf, int32_t uid)
{
int toobig = 07777777;
if(uid > toobig)
{
header_set_uid_itsbig(buf,8,uid);
}
else
{
header_8octal(buf, uid);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment