tools.cpp File Reference

#include "mmstools/tools.h"
#include "mmstools/mmsmutex.h"
#include "mmsconfig/mmsconfigdata.h"
#include "mmstools/mmserror.h"
#include <algorithm>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <stdlib.h>

Include dependency graph for tools.cpp:

Go to the source code of this file.


Defines

#define MAX_MTIMESTAMP   999999

Functions

string substituteEnvVars (string input)
 substitutes environment variables in a string
string maskChars (string str)
string * strToUpr (string *src)
string strToUpr (string src)
string * strToLwr (string *src)
string strToLwr (string src)
int hexToInt (const char *in)
string ucharToHex (unsigned char in)
string getSimpleTimeString ()
bool getCurrentTimeBuffer (char *dtbuf, char *datebuf, char *timebuf, time_t *clock)
bool getCurrentTimeString (string *dtstr, string *datestr, string *timestr, time_t *clock)
string getDayOfWeek (time_t *clock)
static void bufferDestroy (void *buffer)
static void bufferKeyAlloc ()
void initLogging (char *Iam, char *logfile)
void writeMessage (const char *ctrl,...)
int strToInt (string s)
unsigned int strToUInt (string s)
string iToStr (int i)
string fToStr (double i)
char * scanForString (char *buf, char *toFind, char **ret, int offset, unsigned int length)
char * scanForString (char *buf, char *toFind, string *ret, int offset, unsigned int length)
string scanForString (string buf, string toFind, string *ret, int offset, unsigned int length)
void split (string str, string delim, vector< string > &results, bool allowEmpty)
void msleep (unsigned long msec)
bool scanString (string toscan, string frontkey, string backkey, unsigned int offset, unsigned int length, string *result, unsigned int *nextpos)
string cpToStr (char *str)
string cToStr (char chr)
void trim (string &str)
bool strToBool (string s)
bool dblSlash (char a, char b)
void fixPathStr (string &path)
 Removes double slashes from strings containing filesystem paths.
void executeCmd (string cmd, pid_t *cpid)
bool file_exist (string filename)
void writeDebugMessage (const char *identity, const char *filename, const int lineno, const char *msg,...)
void writeDebugMessage (const char *identity, const char *filename, const int lineno, const string &msg)
void writeMessage2Stdout (const char *identity, const char *filename, const int lineno, const char *msg,...)
void writeMessage2Stdout (const char *identity, const char *filename, const int lineno, const string &msg)
unsigned int getMTimeStamp ()
unsigned int getMDiff (unsigned int start_ts, unsigned int end_ts)
int64_t timespecDiff (struct timespec *timeA, struct timespec *timeB)
void rotateUCharBuffer180 (unsigned char *buffer, int pitch, int w, int h)
void rotateUShortIntBuffer180 (unsigned short int *buffer, int pitch, int w, int h)
void rotateUIntBuffer180 (unsigned int *buffer, int pitch, int w, int h)
bool convBidiString (const string &in_str, string &out_str, bool bArabic)
 Convert a bidirectional string.
string XMLencode (const string &source)

Variables

static pthread_once_t buffer_key_once = PTHREAD_ONCE_INIT
static pthread_key_t key_iam
static pthread_key_t key_logfile
static FILE * fp = NULL
static MMSMutex debugMsgMutex

Define Documentation

#define MAX_MTIMESTAMP   999999

Definition at line 750 of file tools.cpp.


Function Documentation

static void bufferDestroy ( void *  buffer  )  [static]

Definition at line 269 of file tools.cpp.

static void bufferKeyAlloc (  )  [static]

Definition at line 273 of file tools.cpp.

bool convBidiString ( const string &  in_str,
string &  out_str,
bool  bArabic = false 
)

Convert a bidirectional string.

Parameters:
in_str source string (UTF-8)
out_str destination string (UTF-8)
Returns:
true if successfully converted
Note:
in_str and out_str can be the same

Definition at line 853 of file tools.cpp.

string cpToStr ( char *  str  ) 

Definition at line 518 of file tools.cpp.

string cToStr ( char  chr  ) 

Definition at line 524 of file tools.cpp.

bool dblSlash ( char  a,
char  b 
)

Definition at line 555 of file tools.cpp.

void executeCmd ( string  cmd,
pid_t *  cpid 
)

Definition at line 561 of file tools.cpp.

bool file_exist ( string  filename  ) 

Definition at line 639 of file tools.cpp.

void fixPathStr ( string &  path  ) 

Removes double slashes from strings containing filesystem paths.

Parameters:
path string to fix

Definition at line 556 of file tools.cpp.

string fToStr ( double  i  ) 

Definition at line 360 of file tools.cpp.

bool getCurrentTimeBuffer ( char *  dtbuf,
char *  datebuf,
char *  timebuf,
time_t *  clock 
)

Definition at line 176 of file tools.cpp.

bool getCurrentTimeString ( string *  dtstr,
string *  datestr,
string *  timestr,
time_t *  clock 
)

Definition at line 217 of file tools.cpp.

string getDayOfWeek ( time_t *  clock  ) 

Definition at line 235 of file tools.cpp.

unsigned int getMDiff ( unsigned int  start_ts,
unsigned int  end_ts 
)

Definition at line 762 of file tools.cpp.

unsigned int getMTimeStamp (  ) 

Definition at line 752 of file tools.cpp.

string getSimpleTimeString (  ) 

Definition at line 168 of file tools.cpp.

int hexToInt ( const char *  in  ) 

Definition at line 135 of file tools.cpp.

void initLogging ( char *  Iam,
char *  logfile 
)

Definition at line 278 of file tools.cpp.

string iToStr ( int  i  ) 

Definition at line 350 of file tools.cpp.

string maskChars ( string  str  ) 

Definition at line 90 of file tools.cpp.

void msleep ( unsigned long  msec  ) 

Definition at line 461 of file tools.cpp.

void rotateUCharBuffer180 ( unsigned char *  buffer,
int  pitch,
int  w,
int  h 
)

Definition at line 781 of file tools.cpp.

void rotateUIntBuffer180 ( unsigned int *  buffer,
int  pitch,
int  w,
int  h 
)

Definition at line 815 of file tools.cpp.

void rotateUShortIntBuffer180 ( unsigned short int *  buffer,
int  pitch,
int  w,
int  h 
)

Definition at line 798 of file tools.cpp.

string scanForString ( string  buf,
string  toFind,
string *  ret,
int  offset,
unsigned int  length 
)

Definition at line 417 of file tools.cpp.

char* scanForString ( char *  buf,
char *  toFind,
string *  ret,
int  offset,
unsigned int  length 
)

Definition at line 401 of file tools.cpp.

char* scanForString ( char *  buf,
char *  toFind,
char **  ret,
int  offset,
unsigned int  length 
)

Definition at line 370 of file tools.cpp.

bool scanString ( string  toscan,
string  frontkey,
string  backkey,
unsigned int  offset,
unsigned int  length,
string *  result,
unsigned int *  nextpos 
)

Definition at line 467 of file tools.cpp.

void split ( string  str,
string  delim,
vector< string > &  results,
bool  allowEmpty 
)

Definition at line 448 of file tools.cpp.

bool strToBool ( string  s  ) 

Definition at line 545 of file tools.cpp.

int strToInt ( string  s  ) 

Definition at line 341 of file tools.cpp.

string strToLwr ( string  src  ) 

Definition at line 128 of file tools.cpp.

string* strToLwr ( string *  src  ) 

Definition at line 118 of file tools.cpp.

unsigned int strToUInt ( string  s  ) 

Definition at line 345 of file tools.cpp.

string strToUpr ( string  src  ) 

Definition at line 111 of file tools.cpp.

string* strToUpr ( string *  src  ) 

Definition at line 101 of file tools.cpp.

string substituteEnvVars ( string  input  ) 

substitutes environment variables in a string

Parameters:
input string containing the variable components
Returns:
the string with the replaced components
Note:
this will only work if the libc supports _XOPEN_SOURCE

Definition at line 68 of file tools.cpp.

int64_t timespecDiff ( struct timespec *  timeA,
struct timespec *  timeB 
)

Definition at line 772 of file tools.cpp.

void trim ( string &  str  ) 

Definition at line 534 of file tools.cpp.

string ucharToHex ( unsigned char  in  ) 

Definition at line 162 of file tools.cpp.

void writeDebugMessage ( const char *  identity,
const char *  filename,
const int  lineno,
const string &  msg 
)

Definition at line 683 of file tools.cpp.

void writeDebugMessage ( const char *  identity,
const char *  filename,
const int  lineno,
const char *  msg,
  ... 
)

Definition at line 648 of file tools.cpp.

void writeMessage ( const char *  ctrl,
  ... 
)

Definition at line 300 of file tools.cpp.

void writeMessage2Stdout ( const char *  identity,
const char *  filename,
const int  lineno,
const string &  msg 
)

Definition at line 735 of file tools.cpp.

void writeMessage2Stdout ( const char *  identity,
const char *  filename,
const int  lineno,
const char *  msg,
  ... 
)

Definition at line 711 of file tools.cpp.

string XMLencode ( const string &  source  ) 

Definition at line 953 of file tools.cpp.


Variable Documentation

pthread_once_t buffer_key_once = PTHREAD_ONCE_INIT [static]

Definition at line 57 of file tools.cpp.

Definition at line 65 of file tools.cpp.

FILE* fp = NULL [static]

Definition at line 64 of file tools.cpp.

pthread_key_t key_iam [static]

Definition at line 59 of file tools.cpp.

pthread_key_t key_logfile [static]

Definition at line 60 of file tools.cpp.