ZNC  trunk
Public Member Functions | Static Public Member Functions | List of all members
CUtils Class Reference

#include <Utils.h>

Public Member Functions

 CUtils ()
 
 ~CUtils ()
 

Static Public Member Functions

static CString GetIP (unsigned long addr)
 
static unsigned long GetLongIP (const CString &sIP)
 
static void PrintError (const CString &sMessage)
 
static void PrintMessage (const CString &sMessage, bool bStrong=false)
 
static void PrintPrompt (const CString &sMessage)
 
static void PrintAction (const CString &sMessage)
 
static void PrintStatus (bool bSuccess, const CString &sMessage="")
 
static CString AskSaltedHashPassForConfig ()
 Asks password from stdin, with confirmation. More...
 
static CString GetSalt ()
 
static CString SaltedMD5Hash (const CString &sPass, const CString &sSalt)
 
static CString SaltedSHA256Hash (const CString &sPass, const CString &sSalt)
 
static CString SaltedHash (const CString &sPass, const CString &sSalt)
 
static CString GetPass (const CString &sPrompt)
 
static bool GetInput (const CString &sPrompt, CString &sRet, const CString &sDefault="", const CString &sHint="")
 
static bool GetBoolInput (const CString &sPrompt, bool bDefault)
 
static bool GetBoolInput (const CString &sPrompt, bool *pbDefault=nullptr)
 
static bool GetNumInput (const CString &sPrompt, unsigned int &uRet, unsigned int uMin=0, unsigned int uMax=~0, unsigned int uDefault=~0)
 
static timeval GetTime ()
 
static unsigned long long GetMillTime ()
 
static void GenerateCert (FILE *pOut, const CString &sHost="")
 
static CString CTime (time_t t, const CString &sTZ)
 
static CString FormatTime (time_t t, const CString &sFormat, const CString &sTZ)
 
static CString FormatTime (const timeval &tv, const CString &sFormat, const CString &sTZ)
 Supports an additional format specifier for formatting sub-second values: More...
 
static CString FormatServerTime (const timeval &tv)
 
static timeval ParseServerTime (const CString &sTime)
 
static SCString GetTimezones ()
 
static SCString GetEncodings ()
 
static bool CheckCIDR (const CString &sIP, const CString &sRange)
 CIDR notation checker, e.g. More...
 
static MCString GetMessageTags (const CString &sLine)
 
static void SetMessageTags (CString &sLine, const MCString &mssTags)
 

Constructor & Destructor Documentation

◆ CUtils()

CUtils::CUtils ( )

◆ ~CUtils()

CUtils::~CUtils ( )

Member Function Documentation

◆ AskSaltedHashPassForConfig()

static CString CUtils::AskSaltedHashPassForConfig ( )
static

Asks password from stdin, with confirmation.

Returns
Piece of znc.conf with <Pass> block

◆ CheckCIDR()

static bool CUtils::CheckCIDR ( const CString sIP,
const CString sRange 
)
static

CIDR notation checker, e.g.

"192.0.2.0/24" or "2001:db8::/32"

For historical reasons also allows wildcards, e.g. "192.168.*"

◆ CTime()

static CString CUtils::CTime ( time_t  t,
const CString sTZ 
)
static

◆ FormatServerTime()

static CString CUtils::FormatServerTime ( const timeval &  tv)
static

◆ FormatTime() [1/2]

static CString CUtils::FormatTime ( const timeval &  tv,
const CString sFormat,
const CString sTZ 
)
static

Supports an additional format specifier for formatting sub-second values:

  • f - sub-second fraction
    • %3f - millisecond (default, if no width is specified)
    • %6f - microsecond

However, note that timeval only supports microsecond precision (thus, formatting with higher-than-microsecond precision will always result in trailing zeroes), and IRC server-time is specified in millisecond precision (thus formatting received timestamps with higher-than-millisecond precision will always result in trailing zeroes).

◆ FormatTime() [2/2]

static CString CUtils::FormatTime ( time_t  t,
const CString sFormat,
const CString sTZ 
)
static

◆ GenerateCert()

static void CUtils::GenerateCert ( FILE *  pOut,
const CString sHost = "" 
)
static

◆ GetBoolInput() [1/2]

static bool CUtils::GetBoolInput ( const CString sPrompt,
bool *  pbDefault = nullptr 
)
static

◆ GetBoolInput() [2/2]

static bool CUtils::GetBoolInput ( const CString sPrompt,
bool  bDefault 
)
static

◆ GetEncodings()

static SCString CUtils::GetEncodings ( )
static

◆ GetInput()

static bool CUtils::GetInput ( const CString sPrompt,
CString sRet,
const CString sDefault = "",
const CString sHint = "" 
)
static

◆ GetIP()

static CString CUtils::GetIP ( unsigned long  addr)
static

◆ GetLongIP()

static unsigned long CUtils::GetLongIP ( const CString sIP)
static

◆ GetMessageTags()

static MCString CUtils::GetMessageTags ( const CString sLine)
static
Deprecated:
Use CMessage instead

◆ GetMillTime()

static unsigned long long CUtils::GetMillTime ( )
static

◆ GetNumInput()

static bool CUtils::GetNumInput ( const CString sPrompt,
unsigned int &  uRet,
unsigned int  uMin = 0,
unsigned int  uMax = ~0,
unsigned int  uDefault = ~0 
)
static

◆ GetPass()

static CString CUtils::GetPass ( const CString sPrompt)
static

◆ GetSalt()

static CString CUtils::GetSalt ( )
static

◆ GetTime()

static timeval CUtils::GetTime ( )
static

◆ GetTimezones()

static SCString CUtils::GetTimezones ( )
static

◆ ParseServerTime()

static timeval CUtils::ParseServerTime ( const CString sTime)
static

◆ PrintAction()

static void CUtils::PrintAction ( const CString sMessage)
static

◆ PrintError()

static void CUtils::PrintError ( const CString sMessage)
static

◆ PrintMessage()

static void CUtils::PrintMessage ( const CString sMessage,
bool  bStrong = false 
)
static

◆ PrintPrompt()

static void CUtils::PrintPrompt ( const CString sMessage)
static

◆ PrintStatus()

static void CUtils::PrintStatus ( bool  bSuccess,
const CString sMessage = "" 
)
static

◆ SaltedHash()

static CString CUtils::SaltedHash ( const CString sPass,
const CString sSalt 
)
static

Referenced by CUser::SaltedHash().

◆ SaltedMD5Hash()

static CString CUtils::SaltedMD5Hash ( const CString sPass,
const CString sSalt 
)
static

◆ SaltedSHA256Hash()

static CString CUtils::SaltedSHA256Hash ( const CString sPass,
const CString sSalt 
)
static

◆ SetMessageTags()

static void CUtils::SetMessageTags ( CString sLine,
const MCString mssTags 
)
static
Deprecated:
Use CMessage instead

The documentation for this class was generated from the following file: