smartmontools SVN Rev 5645
Utility to control and monitor storage systems with "S.M.A.R.T."
Macros | Functions | Variables
utility.cpp File Reference
#include "config.h"
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <stdexcept>
#include "svnversion.h"
#include "utility.h"
#include "atacmds.h"
#include "dev_interface.h"
#include "sg_unaligned.h"
#include <chrono>
Include dependency graph for utility.cpp:

Go to the source code of this file.

Macros

#define __STDC_FORMAT_MACROS   1
 
#define USE_CLOCK_MONOTONIC   0
 
#define BUILD_INFO   "(local build)"
 
#define N2S_(s)   #s
 
#define N2S(s)   N2S_(s)
 

Functions

std::string format_version_info (const char *prog_name, int lines)
 
void FixGlibcTimeZoneBug ()
 
const char * packetdevicetype (int type)
 
struct tm * time_to_tm_local (struct tm *tp, time_t t)
 
void dateandtimezoneepoch (char(&buffer)[DATEANDEPOCHLEN], time_t tval)
 
void syserror (const char *message)
 
static const char * check_regex (const char *pattern)
 
int split_selective_arg (char *s, uint64_t *start, uint64_t *stop, int *mode)
 
bool nonempty (const void *data, int size)
 
const char * format_char_array (char *str, int strsize, const char *chr, int chrsize)
 
const char * format_with_thousands_sep (char *str, int strsize, uint64_t val, const char *thousands_sep)
 
const char * format_capacity (char *str, int strsize, uint64_t val, const char *decimal_point)
 
 __attribute_format_printf (1, 0) std
 
std::string strprintf (const char *fmt,...)
 
const char * uint128_hilo_to_str (char *str, int strsize, uint64_t value_hi, uint64_t value_lo)
 
long long get_timer_usec ()
 Get microseconds since some unspecified starting point.
 
static void check_endianness ()
 
static void check_snprintf ()
 
void check_config ()
 

Variables

const char * utility_cpp_cvsid
 
const char * packet_types []
 

Macro Definition Documentation

◆ __STDC_FORMAT_MACROS

#define __STDC_FORMAT_MACROS   1

Definition at line 18 of file utility.cpp.

◆ BUILD_INFO

#define BUILD_INFO   "(local build)"

Definition at line 82 of file utility.cpp.

◆ N2S

#define N2S (   s)    N2S_(s)

◆ N2S_

#define N2S_ (   s)    #s

◆ USE_CLOCK_MONOTONIC

#define USE_CLOCK_MONOTONIC   0

Definition at line 54 of file utility.cpp.

Function Documentation

◆ __attribute_format_printf()

__attribute_format_printf ( ,
 
)

Definition at line 790 of file utility.cpp.

◆ check_config()

void check_config ( )

Definition at line 919 of file utility.cpp.

◆ check_endianness()

static void check_endianness ( )
static

Definition at line 880 of file utility.cpp.

◆ check_regex()

static const char * check_regex ( const char *  pattern)
static

Definition at line 443 of file utility.cpp.

◆ check_snprintf()

static void check_snprintf ( )
static

Definition at line 907 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 
)

Definition at line 748 of file utility.cpp.

◆ format_char_array()

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

Definition at line 692 of file utility.cpp.

◆ format_version_info()

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

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 
)

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.

◆ 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.

◆ 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.

◆ strprintf()

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

Definition at line 799 of file utility.cpp.

◆ syserror()

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()

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.

Variable Documentation

◆ packet_types

const char* packet_types[]
Initial value:
= {
"Direct-access (disk)",
"Sequential-access (tape)",
"Printer",
"Processor",
"Write-once (optical disk)",
"CD/DVD",
"Scanner",
"Optical memory (optical disk)",
"Medium changer",
"Communications",
"Graphic arts pre-press (10)",
"Graphic arts pre-press (11)",
"Array controller",
"Enclosure services",
"Reduced block command (simplified disk)",
"Optical card reader/writer"
}

Definition at line 61 of file utility.cpp.

◆ utility_cpp_cvsid

const char* utility_cpp_cvsid
Initial value:
= "$Id: utility.cpp 5592 2024-01-17 16:17:10Z chrfranke $"
#define UTILITY_H_CVSID
Definition: utility.h:16

Definition at line 58 of file utility.cpp.