smartmontools SVN Rev 5640
Utility to control and monitor storage systems with "S.M.A.R.T."
Classes | Macros | Functions
utility.h File Reference
#include <float.h>
#include <time.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <sys/types.h>
#include <regex.h>
Include dependency graph for utility.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  raw_buffer
 
class  stdio_file
 Wrapper class for FILE *. More...
 
class  regular_expression
 Wrapper class for POSIX regex(3) or std::regex Supports copy & assignment and is compatible with STL containers. More...
 

Macros

#define UTILITY_H_CVSID   "$Id: utility.h 5519 2023-07-24 15:57:54Z chrfranke $"
 
#define __attribute_format_printf(x, y)
 
#define DATEANDEPOCHLEN   64
 

Functions

std::string format_version_info (const char *prog_name, int lines=2)
 
std::string strprintf (const char *fmt,...) __attribute_format_printf(1
 
std::string std::string vstrprintf (const char *fmt, va_list ap)
 
bool str_starts_with (const char *str, const char *prefix)
 
bool str_starts_with (const std::string &str, const char *prefix)
 
struct tm * time_to_tm_local (struct tm *tp, time_t t)
 
void dateandtimezoneepoch (char(&buffer)[DATEANDEPOCHLEN], time_t tval)
 
void pout (const char *fmt,...) __attribute_format_printf(1
 
void void syserror (const char *message)
 
int split_selective_arg (char *s, uint64_t *start, uint64_t *stop, int *mode)
 
bool isbigendian ()
 
void swap2 (char *location)
 
void swap4 (char *location)
 
void swap8 (char *location)
 
void swapx (unsigned short *p)
 
void swapx (unsigned int *p)
 
void swapx (uint64_t *p)
 
void check_config ()
 
const char * packetdevicetype (int type)
 
bool nonempty (const void *data, int size)
 
void FixGlibcTimeZoneBug ()
 
const char * format_char_array (char *str, int strsize, const char *chr, int chrsize)
 
template<size_t STRSIZE, size_t CHRSIZE>
const char * format_char_array (char(&str)[STRSIZE], const char(&chr)[CHRSIZE])
 
const char * format_with_thousands_sep (char *str, int strsize, uint64_t val, const char *thousands_sep=0)
 
const char * format_capacity (char *str, int strsize, uint64_t val, const char *decimal_point=0)
 
int uint128_to_str_precision_bits ()
 
const char * uint128_hilo_to_str (char *str, int strsize, uint64_t value_hi, uint64_t value_lo)
 
template<size_t SIZE>
const char * uint128_hilo_to_str (char(&str)[SIZE], uint64_t value_hi, uint64_t value_lo)
 
long long get_timer_usec ()
 Get microseconds since some unspecified starting point.
 

Macro Definition Documentation

◆ __attribute_format_printf

#define __attribute_format_printf (   x,
 
)

Definition at line 34 of file utility.h.

◆ DATEANDEPOCHLEN

#define DATEANDEPOCHLEN   64

Definition at line 64 of file utility.h.

◆ UTILITY_H_CVSID

#define UTILITY_H_CVSID   "$Id: utility.h 5519 2023-07-24 15:57:54Z chrfranke $"

Definition at line 16 of file utility.h.

Function Documentation

◆ check_config()

void check_config ( )

Definition at line 919 of file utility.cpp.

◆ dateandtimezoneepoch()

void dateandtimezoneepoch ( char(&)  buffer[DATEANDEPOCHLEN],
time_t  tval 
)

Definition at line 349 of file utility.cpp.

◆ FixGlibcTimeZoneBug()

void FixGlibcTimeZoneBug ( )

Definition at line 214 of file utility.cpp.

◆ format_capacity()

const char * format_capacity ( char *  str,
int  strsize,
uint64_t  val,
const char *  decimal_point = 0 
)

Definition at line 748 of file utility.cpp.

◆ format_char_array() [1/2]

const char * format_char_array ( char *  str,
int  strsize,
const char *  chr,
int  chrsize 
)

Definition at line 692 of file utility.cpp.

◆ format_char_array() [2/2]

template<size_t STRSIZE, size_t CHRSIZE>
const char * format_char_array ( char(&)  str[STRSIZE],
const char(&)  chr[CHRSIZE] 
)
inline

Definition at line 122 of file utility.h.

◆ format_version_info()

std::string format_version_info ( const char *  prog_name,
int  lines = 2 
)

Definition at line 87 of file utility.cpp.

◆ format_with_thousands_sep()

const char * format_with_thousands_sep ( char *  str,
int  strsize,
uint64_t  val,
const char *  thousands_sep = 0 
)

Definition at line 716 of file utility.cpp.

◆ get_timer_usec()

long long get_timer_usec ( )

Get microseconds since some unspecified starting point.

Used only for command duration measurements in debug outputs. Returns -1 if unsupported.

Definition at line 865 of file utility.cpp.

◆ isbigendian()

bool isbigendian ( )
inline

Definition at line 82 of file utility.h.

◆ nonempty()

bool nonempty ( const void *  data,
int  size 
)

Definition at line 682 of file utility.cpp.

◆ packetdevicetype()

const char * packetdevicetype ( int  type)

Definition at line 315 of file utility.cpp.

◆ pout()

void pout ( const char *  fmt,
  ... 
)

◆ split_selective_arg()

int split_selective_arg ( char *  s,
uint64_t *  start,
uint64_t *  stop,
int *  mode 
)

Definition at line 630 of file utility.cpp.

◆ str_starts_with() [1/2]

bool str_starts_with ( const char *  str,
const char *  prefix 
)
inline

Definition at line 52 of file utility.h.

◆ str_starts_with() [2/2]

bool str_starts_with ( const std::string &  str,
const char *  prefix 
)
inline

Definition at line 55 of file utility.h.

◆ strprintf()

std::string strprintf ( const char *  fmt,
  ... 
)

◆ swap2()

void swap2 ( char *  location)

Definition at line 304 of file atacmds.cpp.

◆ swap4()

void swap4 ( char *  location)

Definition at line 312 of file atacmds.cpp.

◆ swap8()

void swap8 ( char *  location)

Definition at line 321 of file atacmds.cpp.

◆ swapx() [1/3]

void swapx ( uint64_t *  p)
inline

Definition at line 99 of file utility.h.

◆ swapx() [2/3]

void swapx ( unsigned int *  p)
inline

Definition at line 97 of file utility.h.

◆ swapx() [3/3]

void swapx ( unsigned short *  p)
inline

Definition at line 95 of file utility.h.

◆ syserror()

void void syserror ( const char *  message)

Definition at line 409 of file utility.cpp.

◆ time_to_tm_local()

struct tm * time_to_tm_local ( struct tm *  tp,
time_t  t 
)

Definition at line 326 of file utility.cpp.

◆ uint128_hilo_to_str() [1/2]

const char * uint128_hilo_to_str ( char *  str,
int  strsize,
uint64_t  value_hi,
uint64_t  value_lo 
)

Definition at line 856 of file utility.cpp.

◆ uint128_hilo_to_str() [2/2]

template<size_t SIZE>
const char * uint128_hilo_to_str ( char(&)  str[SIZE],
uint64_t  value_hi,
uint64_t  value_lo 
)
inline

Definition at line 312 of file utility.h.

◆ uint128_to_str_precision_bits()

int uint128_to_str_precision_bits ( )
inline

Definition at line 296 of file utility.h.

◆ vstrprintf()

std::string std::string vstrprintf ( const char *  fmt,
va_list  ap 
)