File: toolconstants.h

package info (click to toggle)
libguytools2 2.1.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300 kB
  • sloc: cpp: 2,675; ansic: 288; makefile: 47; sh: 4
file content (106 lines) | stat: -rw-r--r-- 3,826 bytes parent folder | download | duplicates (2)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// ****************************************************************************
//  Project:        libguytools
// ****************************************************************************
//  Programmer:     Guy Voncken
//                  Police Grand-Ducale
//                  Service de Police Judiciaire
//                  Section Nouvelles Technologies
// ****************************************************************************
//  Module:         Different useful constants
// ****************************************************************************

// Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
// 2018, 2019
// Guy Voncken
//
// This file is part of libguytools.
//
// libguytools is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// libguytools is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libguytools. If not, see <http://www.gnu.org/licenses/>.

#ifndef __TOOLCONSTANTS_H__
#define __TOOLCONSTANTS_H__

/* --------------------------------------------------------------------------------------------- */
/*  Attention                                                                                    */
/*  This files only defines general, never-changing constants. Do not add application dependant  */
/*  definitions, such as string lengths, stack sizes etc.                                        */
/* --------------------------------------------------------------------------------------------- */

/* ---------------- */
/*  Time constants  */
/* ---------------- */

#define MSEC_PER_SECOND         1000
#define USEC_PER_MSEC           1000

#define SECONDS_PER_DAY        86400
#define SECONDS_PER_HOUR        3600
#define SECONDS_PER_MINUTE        60

#define MSEC_PER_DAY        (MS_PER_S * S_PER_DAY   )
#define MSEC_PER_HOUR       (MS_PER_S * S_PER_HOUR  )
#define MSEC_PER_MINUTE     (MS_PER_S * S_PER_MINUTE)

#define DAYS_PER_WEEK              7
#define SECONDS_PER_WEEK    (DAYS_PER_WEEK*SECONDS_PER_DAY)
#define DAYS_PER_YEAR            365                              // Attention, this is of
#define SECONDS_PER_YEAR    (SECONDS_PER_DAY * DAYS_PER_YEAR)     // course just an estimation
#define MONTHS_PER_YEAR           12

/* ---------------------- */
/*  Weights and measures  */
/* ---------------------- */

static const double LBS_PER_KG   = 2.204623;
static const double MM_PER_INCH  = 25.4;

#define UM_PER_M   1000000
#define UM_PER_MM     1000
#define MM_PER_M      1000

/* ---------------------- */
/*       Mathematics      */
/* ---------------------- */

static const double PI = 3.141592654;

/* ---------------------- */
/*     Computer stuff     */
/* ---------------------- */

#define BYTES_PER_KILOBYTE      1024
#define BYTES_PER_MEGABYTE   1048576

#define CLIB_YEAROFFSET         1900    // Fixed year offset for struct tm (by ANSI)

#define TCPIP_ADDRESS_LEN         15    // Address format: XXX.XXX.XXX.XXX -> 15  -- do not forget to add +1 if using C strings

#ifndef TRUE
   #define TRUE  1
   #define FALSE 0
#endif

/* ------------------ */
/*  ASCII characters  */
/* ------------------ */

static const char ASCII_ESC        =  27;
static const char ASCII_BS         = 0x08;
static const char ASCII_LF         = 0x0A;
static const char ASCII_CR         = 0x0D;
static const char ASCII_ENTER      = ASCII_CR;
static const char ASCII_EOF        = 0x1A;

#endif