1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
/* $Id: liborange_internal.h,v 1.2 2003/08/22 15:27:04 twogood Exp $ */
#ifndef __liborange_internal_h__
#define __liborange_internal_h__
#include "liborange.h"
#include <stdio.h>
/*
Helper functions
*/
bool orange_make_sure_directory_exists(const char* directory);
long orange_fsize(FILE* file);
bool orange_write(const uint8_t* output_buffer, size_t output_size, const char* output_directory, const char* basename);
/*
Macros for in-place byte order conversion
*/
#define LETOH16(x) x = letoh16(x)
#define LETOH32(x) x = letoh32(x)
#define HTOLE16(x) x = htole16(x)
#define HTOLE32(x) x = htole32(x)
/*
Macros for safer development
*/
#define FREE(ptr) { if (ptr) { free(ptr); ptr = NULL; } }
#define STRDUP(str) ((str) ? strdup(str) : NULL)
#define NEW1(type) ((type*)calloc(1, sizeof(type)))
#define FCLOSE(file) if (file) { fclose(file); file = NULL; }
#define FSIZE(file) (file ? orange_fsize(file) : 0)
#define CLOSEDIR(dir) if (dir) { closedir(dir); dir = NULL; }
/*
Utility macros
*/
#define STR_EQUAL(a,b) (0 == strcasecmp(a,b))
#endif
|