1 /* 2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) 3 * 4 * Copyright (c) 1997-2021 ircd-hybrid development team 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 * USA 20 */ 21 22 /*! \file misc.h 23 * \brief A header for the miscellaneous functions. 24 * \version $Id: misc.h 10005 2021-06-28 12:10:15Z michael $ 25 */ 26 27 #ifndef INCLUDED_misc_h 28 #define INCLUDED_misc_h 29 30 /* Just blindly define our own MIN/MAX macro */ 31 #define IRCD_MAX(a, b) ((a) > (b) ? (a) : (b)) 32 #define IRCD_MIN(a, b) ((a) < (b) ? (a) : (b)) 33 34 #define _1MEG (1024.0f) 35 #define _1GIG (1024.0f*1024.0f) 36 #define _1TER (1024.0f*1024.0f*1024.0f) 37 #define _GMKs(x) (((x) > _1TER) ? "Tebibytes" : (((x) > _1GIG) ? "Gibibytes" :\ 38 (((x) > _1MEG) ? "Mebibytes" : "Kibibytes"))) 39 #define _GMKv(x) (((x) > _1TER) ? (float)((x)/_1TER) : (((x) > _1GIG) ? \ 40 (float)((x)/_1GIG) : (((x) > _1MEG) ? (float)((x)/_1MEG) : \ 41 (float)(x)))) 42 43 extern const char *date(uintmax_t); 44 extern const char *date_iso8601(uintmax_t); 45 extern const char *date_ctime(uintmax_t); 46 extern const char *time_dissect(uintmax_t); 47 extern void binary_to_hex(const unsigned char *, char *, unsigned int); 48 #endif /* INCLUDED_misc_h */ 49