Archived
1
0
Fork 0

sha1_io: inline functions

This commit is contained in:
Henrik Hautakoski 2012-08-22 11:57:33 +02:00
parent ee17b5e370
commit 569d0167d8
3 changed files with 15 additions and 40 deletions

View file

@ -20,13 +20,23 @@
#ifndef SHA1_IO_H
#define SHA1_IO_H
#include <unistd.h>
#include <arpa/inet.h>
#include <openssl/sha.h>
int sha1_write(SHA_CTX *ctx, int fd, void *buf, size_t size);
inline int sha1_write(SHA_CTX *ctx, int fd, void *buf, size_t size) {
SHA1_Update(ctx, buf, size);
return write(fd, buf, size);
}
/* This function makes sure that the integer is in
network byte order before it is written to disk
by 'sha1_write'. */
int sha1_write_int(SHA_CTX *ctx, int fd, int val);
inline int sha1_write_int(SHA_CTX *ctx, int fd, int val) {
val = htonl(val);
return sha1_write(ctx, fd, &val, sizeof val);
}
#endif /* SHA1_IO_H */