1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Amaury Pouly
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
28 #define STR(a) _STR(a)
30 #define bug(...) do { fprintf(stderr,"["__FILE__":"STR(__LINE__)"]ERROR: "__VA_ARGS__); exit(1); } while(0)
31 #define bugp(...) do { fprintf(stderr, __VA_ARGS__); perror(" "); exit(1); } while(0)
33 #define ROUND_UP(val, round) ((((val) + (round) - 1) / (round)) * (round))
37 typedef struct crypto_key_t
*key_array_t
;
39 key_array_t g_key_array
;
41 void *memdup(const void *p
, size_t len
);
42 void *augment_array(void *arr
, size_t elem_sz
, size_t cnt
, void *aug
, size_t aug_cnt
);
43 void generate_random_data(void *buf
, size_t sz
);
44 void *xmalloc(size_t s
);
45 int convxdigit(char digit
, byte
*val
);
46 void print_hex(byte
*data
, int len
, bool newline
);
47 void add_keys(key_array_t ka
, int kac
);
48 bool parse_key(char **str
, struct crypto_key_t
*key
);
49 bool add_keys_from_file(const char *key_file
);
50 void print_key(struct crypto_key_t
*key
, bool newline
);
53 typedef char color_t
[];
55 extern color_t OFF
, GREY
, RED
, GREEN
, YELLOW
, BLUE
;
56 void color(color_t c
);
57 void enable_color(bool enable
);
59 #endif /* __MISC_H__ */