tools.cpp File Reference

#include "mmstools/tools.h"
#include "mmstools/mmsmutex.h"
#include "mmsconfig/mmsconfigdata.h"
#include "mmstools/mmserror.h"
#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)
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 739 of file tools.cpp.


Function Documentation

static void bufferDestroy ( void *  buffer  )  [static]

Definition at line 264 of file tools.cpp.

static void bufferKeyAlloc (  )  [static]

Definition at line 268 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 842 of file tools.cpp.

string cpToStr ( char *  str  ) 

Definition at line 513 of file tools.cpp.

string cToStr ( char  chr  ) 

Definition at line 519 of file tools.cpp.

void executeCmd ( string  cmd,
pid_t *  cpid 
)

Definition at line 550 of file tools.cpp.

bool file_exist ( string  filename  ) 

Definition at line 628 of file tools.cpp.

string fToStr ( double  i  ) 

Definition at line 355 of file tools.cpp.

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

Definition at line 171 of file tools.cpp.

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

Definition at line 212 of file tools.cpp.

string getDayOfWeek ( time_t *  clock  ) 

Definition at line 230 of file tools.cpp.

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

Definition at line 751 of file tools.cpp.

unsigned int getMTimeStamp (  ) 

Definition at line 741 of file tools.cpp.

string getSimpleTimeString (  ) 

Definition at line 163 of file tools.cpp.

int hexToInt ( const char *  in  ) 

Definition at line 130 of file tools.cpp.

void initLogging ( char *  Iam,
char *  logfile 
)

Definition at line 273 of file tools.cpp.

string iToStr ( int  i  ) 

Definition at line 345 of file tools.cpp.

string maskChars ( string  str  ) 

Definition at line 85 of file tools.cpp.

void msleep ( unsigned long  msec  ) 

Definition at line 456 of file tools.cpp.

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

Definition at line 770 of file tools.cpp.

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

Definition at line 804 of file tools.cpp.

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

Definition at line 787 of file tools.cpp.

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

Definition at line 412 of file tools.cpp.

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

Definition at line 396 of file tools.cpp.

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

Definition at line 365 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 462 of file tools.cpp.

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

Definition at line 443 of file tools.cpp.

bool strToBool ( string  s  ) 

Definition at line 540 of file tools.cpp.

int strToInt ( string  s  ) 

Definition at line 336 of file tools.cpp.

string strToLwr ( string  src  ) 

Definition at line 123 of file tools.cpp.

string* strToLwr ( string *  src  ) 

Definition at line 113 of file tools.cpp.

unsigned int strToUInt ( string  s  ) 

Definition at line 340 of file tools.cpp.

string strToUpr ( string  src  ) 

Definition at line 106 of file tools.cpp.

string* strToUpr ( string *  src  ) 

Definition at line 96 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 63 of file tools.cpp.

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

Definition at line 761 of file tools.cpp.

void trim ( string &  str  ) 

Definition at line 529 of file tools.cpp.

string ucharToHex ( unsigned char  in  ) 

Definition at line 157 of file tools.cpp.

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

Definition at line 672 of file tools.cpp.

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

Definition at line 637 of file tools.cpp.

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

Definition at line 295 of file tools.cpp.

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

Definition at line 724 of file tools.cpp.

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

Definition at line 700 of file tools.cpp.

string XMLencode ( const string &  source  ) 

Definition at line 942 of file tools.cpp.


Variable Documentation

pthread_once_t buffer_key_once = PTHREAD_ONCE_INIT [static]

Definition at line 52 of file tools.cpp.

Definition at line 60 of file tools.cpp.

FILE* fp = NULL [static]

Definition at line 59 of file tools.cpp.

pthread_key_t key_iam [static]

Definition at line 54 of file tools.cpp.

pthread_key_t key_logfile [static]

Definition at line 55 of file tools.cpp.