| 1 | // **************************************************************************** |
| 2 | // Project: libguytools |
| 3 | // **************************************************************************** |
| 4 | // Programmer: Guy Voncken |
| 5 | // Police Grand-Ducale |
| 6 | // Service de Police Judiciaire |
| 7 | // Section Nouvelles Technologies |
| 8 | // **************************************************************************** |
| 9 | // Module: Different useful constants |
| 10 | // **************************************************************************** |
| 11 | |
| 12 | // Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, |
| 13 | // 2018, 2019 |
| 14 | // Guy Voncken |
| 15 | // |
| 16 | // This file is part of libguytools. |
| 17 | // |
| 18 | // libguytools is free software: you can redistribute it and/or modify |
| 19 | // it under the terms of the GNU General Public License as published by |
| 20 | // the Free Software Foundation, either version 2 of the License, or |
| 21 | // (at your option) any later version. |
| 22 | // |
| 23 | // libguytools is distributed in the hope that it will be useful, |
| 24 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 | // GNU General Public License for more details. |
| 27 | // |
| 28 | // You should have received a copy of the GNU General Public License |
| 29 | // along with libguytools. If not, see <http://www.gnu.org/licenses/>. |
| 30 | |
| 31 | #ifndef __TOOLCONSTANTS_H__ |
| 32 | #define __TOOLCONSTANTS_H__ |
| 33 | |
| 34 | /* --------------------------------------------------------------------------------------------- */ |
| 35 | /* Attention */ |
| 36 | /* This files only defines general, never-changing constants. Do not add application dependant */ |
| 37 | /* definitions, such as string lengths, stack sizes etc. */ |
| 38 | /* --------------------------------------------------------------------------------------------- */ |
| 39 | |
| 40 | /* ---------------- */ |
| 41 | /* Time constants */ |
| 42 | /* ---------------- */ |
| 43 | |
| 44 | #define MSEC_PER_SECOND 1000 |
| 45 | #define USEC_PER_MSEC 1000 |
| 46 | |
| 47 | #define SECONDS_PER_DAY 86400 |
| 48 | #define SECONDS_PER_HOUR 3600 |
| 49 | #define SECONDS_PER_MINUTE 60 |
| 50 | |
| 51 | #define MSEC_PER_DAY (MS_PER_S * S_PER_DAY ) |
| 52 | #define MSEC_PER_HOUR (MS_PER_S * S_PER_HOUR ) |
| 53 | #define MSEC_PER_MINUTE (MS_PER_S * S_PER_MINUTE) |
| 54 | |
| 55 | #define DAYS_PER_WEEK 7 |
| 56 | #define SECONDS_PER_WEEK (DAYS_PER_WEEK*SECONDS_PER_DAY) |
| 57 | #define DAYS_PER_YEAR 365 // Attention, this is of |
| 58 | #define SECONDS_PER_YEAR (SECONDS_PER_DAY * DAYS_PER_YEAR) // course just an estimation |
| 59 | #define MONTHS_PER_YEAR 12 |
| 60 | |
| 61 | /* ---------------------- */ |
| 62 | /* Weights and measures */ |
| 63 | /* ---------------------- */ |
| 64 | |
| 65 | static const double LBS_PER_KG = 2.204623; |
| 66 | static const double MM_PER_INCH = 25.4; |
| 67 | |
| 68 | #define UM_PER_M 1000000 |
| 69 | #define UM_PER_MM 1000 |
| 70 | #define MM_PER_M 1000 |
| 71 | |
| 72 | /* ---------------------- */ |
| 73 | /* Mathematics */ |
| 74 | /* ---------------------- */ |
| 75 | |
| 76 | static const double PI = 3.141592654; |
| 77 | |
| 78 | /* ---------------------- */ |
| 79 | /* Computer stuff */ |
| 80 | /* ---------------------- */ |
| 81 | |
| 82 | #define BYTES_PER_KILOBYTE 1024 |
| 83 | #define BYTES_PER_MEGABYTE 1048576 |
| 84 | |
| 85 | #define CLIB_YEAROFFSET 1900 // Fixed year offset for struct tm (by ANSI) |
| 86 | |
| 87 | #define TCPIP_ADDRESS_LEN 15 // Address format: XXX.XXX.XXX.XXX -> 15 -- do not forget to add +1 if using C strings |
| 88 | |
| 89 | #ifndef TRUE |
| 90 | #define TRUE 1 |
| 91 | #define FALSE 0 |
| 92 | #endif |
| 93 | |
| 94 | /* ------------------ */ |
| 95 | /* ASCII characters */ |
| 96 | /* ------------------ */ |
| 97 | |
| 98 | static const char ASCII_ESC = 27; |
| 99 | static const char ASCII_BS = 0x08; |
| 100 | static const char ASCII_LF = 0x0A; |
| 101 | static const char ASCII_CR = 0x0D; |
| 102 | static const char ASCII_ENTER = ASCII_CR; |
| 103 | static const char ASCII_EOF = 0x1A; |
| 104 | |
| 105 | #endif |
| 106 |