}
if (cache.version == 1)
- mergesort(cache.entries, cache.num_entries, sizeof(*cache.entries), ent_cmp);
+ qsort(cache.entries, cache.num_entries, sizeof(*cache.entries), ent_cmp);
else if (cache.version == 0)
- mergesort(cache.hashes, cache.num_entries, sizeof(*cache.hashes), hash_cmp);
+ qsort(cache.hashes, cache.num_entries, sizeof(*cache.hashes), hash_cmp);
switch (keepuuid) {
case 0:
* SUCH DAMAGE.
*/
+#define _XOPEN_SOURCE 500
#include <ftw.h>
#include <stdio.h>
#include <string.h>
static struct trust_cache cache = {};
-int
+static int
tccallback(const char *path, const struct stat *sb, int typeflag, struct FTW *ftw)
{
if (!S_ISREG(sb->st_mode))
* $OpenBSD: strtonum.c,v 1.7 2013/04/17 18:40:58 tedu Exp $
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
+#include "compat.h"
+
#define INVALID 1
#define TOOSMALL 2
#define TOOLARGE 3
}
if (cache.version == 1)
- mergesort(cache.entries, cache.num_entries, sizeof(*cache.entries), ent_cmp);
+ qsort(cache.entries, cache.num_entries, sizeof(*cache.entries), ent_cmp);
else if (cache.version == 0)
- mergesort(cache.hashes, cache.num_entries, sizeof(*cache.hashes), hash_cmp);
+ qsort(cache.hashes, cache.num_entries, sizeof(*cache.hashes), hash_cmp);
FILE *f = NULL;
if ((f = fopen(argv[0], "wb")) == NULL) {
{
struct trust_cache cache;
bool headeronly = false, onlyhash = false;
- uint32_t entrynum = -1;
+ uint32_t entrynum = 0;
const char *errstr = NULL;
int ch;
cache = opentrustcache(argv[0]);
- if (entrynum == -1 && !onlyhash)
+ if (entrynum == 0 && !onlyhash)
print_header(cache);
if (!headeronly) {
if (onlyhash) {
}
goto done;
}
- if (entrynum != -1) {
+ if (entrynum != 0) {
if (entrynum > cache.num_entries) {
fprintf(stderr, "no entry %i\n", entrynum);
exit(1);
# define be32toh(x) OSSwapBigToHostInt32(x)
#elif __has_include(<endian.h>)
# include <endian.h>
+# define bswap32(x) __builtin_bswap32(x)
#else
# include <sys/endian.h>
#endif
return csblob_cdhash((CS_GenericBlob *)cs_data, cs_end - cs_data, cdhash);
}
-bool
+static bool
compute_cdhash(const void *file, size_t size, struct hashes *cdhash) {
// Try to compute the cdhash for a Mach-O file.
const struct mach_header_64 *mh = file;
return false;
}
-void
+static void
compute_cdhashes(const void *file, size_t size, struct cdhashes *h) {
const struct fat_header *fh = NULL;
if (*((uint32_t*)file) == FAT_MAGIC || *((uint32_t*)file) == FAT_CIGAM)
void uuid_unparse(const uuid_t uu, char *out)
{
const uint8_t *uuid_array = (const uint8_t *)uu;
- int uuid_index;
+ unsigned int uuid_index;
static const char *fmt = "0123456789ABCDEF";
for ( uuid_index = 0; uuid_index < sizeof(uuid_t); ++uuid_index ) {
#ifndef _UUID_H_
#define _UUID_H_
-#include <sys/types.h>
+#include <stdint.h>
typedef unsigned char uuid_t[16];