ZNC trunk
Loading...
Searching...
No Matches
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.
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:
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.
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()

CString CUtils::AskSaltedHashPassForConfig ( )
static

Asks password from stdin, with confirmation.

Returns
Piece of znc.conf with <Pass> block

◆ CheckCIDR()

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

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

◆ FormatServerTime()

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

◆ FormatTime() [1/2]

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]

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

◆ GenerateCert()

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

◆ GetBoolInput() [1/2]

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

◆ GetBoolInput() [2/2]

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

◆ GetEncodings()

SCString CUtils::GetEncodings ( )
static

◆ GetInput()

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

◆ GetIP()

CString CUtils::GetIP ( unsigned long addr)
static

◆ GetLongIP()

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

◆ GetMessageTags()

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

◆ GetMillTime()

unsigned long long CUtils::GetMillTime ( )
static

◆ GetNumInput()

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

◆ GetPass()

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

◆ GetSalt()

CString CUtils::GetSalt ( )
static

◆ GetTime()

timeval CUtils::GetTime ( )
static

◆ GetTimezones()

SCString CUtils::GetTimezones ( )
static

◆ ParseServerTime()

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

◆ PrintAction()

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

◆ PrintError()

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

◆ PrintMessage()

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

◆ PrintPrompt()

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

◆ PrintStatus()

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

◆ SaltedHash()

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

Referenced by CUser::SaltedHash().

◆ SaltedMD5Hash()

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

◆ SaltedSHA256Hash()

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

◆ SetMessageTags()

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

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