Critical Link MityCam SoC Firmware  1.0
Critical Link MityCam SoC Firmware
str_funcs.cpp File Reference
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <list>
#include <vector>
#include <algorithm>
#include "str_funcs.h"
Include dependency graph for str_funcs.cpp:

Functions

void str_replace (std::string &s1, const std::string &s2, const std::string &s3)
 
void str_remove (std::string &s1, const std::string &s2)
 
void str_length_trim (std::string &s1, int maxlen)
 
void str_pad (std::string &s1, int len, char cc)
 
uint32_t str_to_uint32 (const std::string &s1, int base)
 
void str_toupper (std::string &s1)
 
void str_tolower (std::string &s1)
 
void str_vsprintf (std::string &s1, const char *fmt, va_list args)
 
void str_sprintf (std::string &s1, const char *fmt,...)
 
std::string str_sprintf (const char *fmt_str,...)
 
void str_split (std::vector< std::string > &list, const std::string &s1, const std::string &s2, bool keep_empty)
 
void str_strcpy (char *destination, const std::string &source, size_t dest_buf_size)
 
void str_from_ip (std::string &s1, uint32_t ip)
 
std::string format_ipaddr (uint32_t ip)
 
uint32_t ip_from_str (const char *s1)
 
uint32_t ip_from_str (const std::string &s1)
 
void parse_macaddr (const std::string &s1, uint8_t *macaddr)
 
std::string format_macaddr (const uint8_t *macaddr)
 
std::string xml_escape (const char *str)
 
std::string xml_escape (std::string str)
 
std::string json_escape (const char *str)
 
std::string json_escape (std::string str)
 
void split_ip (uint32_t ip, uint8_t *octets)
 Converts a uint32 IP address into four octets. More...
 
void form_ip (uint32_t &ip, uint8_t *octets)
 Converts four octets into a uint32 IP address. More...
 
std::string fileToString (const char *filename)
 
std::string getcwd_string ()
 Get the cwd as a string object. More...
 
void hexdump (void *ptr, int buflen)
 simple hex dump routine More...
 

Function Documentation

◆ fileToString()

std::string fileToString ( const char *  filename)

◆ form_ip()

void form_ip ( uint32_t &  ip,
uint8_t *  octets 
)

Converts four octets into a uint32 IP address.

◆ format_ipaddr()

std::string format_ipaddr ( uint32_t  ip)

◆ format_macaddr()

std::string format_macaddr ( const uint8_t *  macaddr)

◆ getcwd_string()

std::string getcwd_string ( )

Get the cwd as a string object.

Returns
std::string

◆ hexdump()

void hexdump ( void *  ptr,
int  buflen 
)

simple hex dump routine

Parameters
ptrmemory to print
buflennumber of bytes

◆ ip_from_str() [1/2]

uint32_t ip_from_str ( const char *  s1)

◆ ip_from_str() [2/2]

uint32_t ip_from_str ( const std::string &  s1)

◆ json_escape() [1/2]

std::string json_escape ( const char *  str)

◆ json_escape() [2/2]

std::string json_escape ( std::string  str)

◆ parse_macaddr()

void parse_macaddr ( const std::string &  s1,
uint8_t *  macaddr 
)

◆ split_ip()

void split_ip ( uint32_t  ip,
uint8_t *  octets 
)

Converts a uint32 IP address into four octets.

◆ str_from_ip()

void str_from_ip ( std::string &  s1,
uint32_t  ip 
)

◆ str_length_trim()

void str_length_trim ( std::string &  s1,
int  maxlen 
)

◆ str_pad()

void str_pad ( std::string &  s1,
int  len,
char  cc 
)

◆ str_remove()

void str_remove ( std::string &  s1,
const std::string &  s2 
)

◆ str_replace()

void str_replace ( std::string &  s1,
const std::string &  s2,
const std::string &  s3 
)

◆ str_split()

void str_split ( std::vector< std::string > &  list,
const std::string &  s1,
const std::string &  s2,
bool  keep_empty 
)

◆ str_sprintf() [1/2]

std::string str_sprintf ( const char *  fmt_str,
  ... 
)

◆ str_sprintf() [2/2]

void str_sprintf ( std::string &  s1,
const char *  fmt,
  ... 
)

◆ str_strcpy()

void str_strcpy ( char *  destination,
const std::string &  source,
size_t  dest_buf_size 
)

◆ str_to_uint32()

uint32_t str_to_uint32 ( const std::string &  s1,
int  base 
)

◆ str_tolower()

void str_tolower ( std::string &  s1)

◆ str_toupper()

void str_toupper ( std::string &  s1)

◆ str_vsprintf()

void str_vsprintf ( std::string &  s1,
const char *  fmt,
va_list  args 
)

◆ xml_escape() [1/2]

std::string xml_escape ( const char *  str)

◆ xml_escape() [2/2]

std::string xml_escape ( std::string  str)