AqualinkD/utils.h

71 lines
1.7 KiB
C
Raw Normal View History

2017-12-30 20:12:01 +00:00
#include <syslog.h>
#include <stdbool.h>
#ifndef UTILS_H_
#define UTILS_H_
2018-03-05 23:52:42 +00:00
#define LOG_DEBUG_SERIAL 8
2017-12-30 20:12:01 +00:00
#ifndef EXIT_SUCCESS
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
#endif
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#define MAXLEN 256
#define round(a) (int) (a+0.5) // 0 decimal places
#define roundf(a) (float) ((a*100)/100) // 2 decimal places
2017-12-30 20:12:01 +00:00
/*
typedef enum
{
false = FALSE, true = TRUE
} bool;
*/
2019-08-18 20:54:10 +00:00
//void setLoggingPrms(int level , bool deamonized, char* log_file);
void setLoggingPrms(int level , bool deamonized, char* log_file, char *error_messages);
2017-12-30 20:12:01 +00:00
int getLogLevel();
void daemonise ( char *pidFile, void (*main_function)(void) );
//void debugPrint (char *format, ...);
void displayLastSystemError (const char *on_what);
void logMessage(int level, char *format, ...);
int count_characters(const char *str, char character);
//void readCfg (char *cfgFile);
int text2elevel(char* level);
char *elevel2text(int level);
char *cleanwhitespace(char *str);
//char *cleanquotes(char *str);
2019-06-05 16:41:38 +00:00
char *chopwhitespace(char *str);
char *trimwhitespace(char *str);
2018-03-16 17:18:15 +00:00
char *stripwhitespace(char *str);
2017-12-30 20:12:01 +00:00
int cleanint(char*str);
bool text2bool(char *str);
2019-10-13 15:07:14 +00:00
bool request2bool(char *str);
2017-12-30 20:12:01 +00:00
char *bool2text(bool val);
void delay (unsigned int howLong);
float degFtoC(float degF);
float degCtoF(float degC);
2018-02-18 14:07:53 +00:00
char* stristr(const char* haystack, const char* needle);
2018-07-29 14:31:35 +00:00
int ascii(char *destination, char *source);
2019-05-25 16:52:36 +00:00
char *prittyString(char *str);
2019-08-18 20:54:10 +00:00
//void writePacketLog(char *buff);
//void closePacketLog();
2019-08-25 20:57:51 +00:00
void startInlineDebug();
void stopInlineDebug();
void cleanInlineDebug();
char *getInlineLogFName();
bool islogFileReady();
2017-12-30 20:12:01 +00:00
//#ifndef _UTILS_C_
extern bool _daemon_;
extern bool _debuglog_;
extern bool _debug2file_;
//#endif
#endif /* UTILS_H_ */