nxducominer
A multithreaded DUCO miner for the Nintendo Switch
 
Loading...
Searching...
No Matches
Utility Functions

Functions

const char * get_psm_charger_type (PsmChargerType type)
 string representation of charger type
 
void get_time_string (char *buffer, int size)
 get current time as formatted string
 
void * safe_malloc (size_t size)
 safe malloc with zero-initialization
 
char * safe_strdup (const char *src)
 safe strdup
 
void set_dynamic_string (char **field, const char *value)
 set dynamic string field with memory management
 
ssize_t safe_write (int fd, const char *buf, size_t len)
 safe socket write with retry
 
static size_t write_memory_callback (void *contents, size_t size, size_t nmemb, void *userp)
 CURL write callback for memory buffer.
 
void replace_placeholder (char **str, const char *placeholder, const char *value)
 replace all occurrences of placeholder in string (html) with value
 

Detailed Description

Function Documentation

◆ get_psm_charger_type()

const char * get_psm_charger_type ( PsmChargerType  type)

string representation of charger type

Parameters
typecharger type enum value
Returns
human readable charger state string

Definition at line 236 of file main.c.

◆ get_time_string()

void get_time_string ( char *  buffer,
int  size 
)

get current time as formatted string

Parameters
bufferoutput buffer for time string
sizesize of output buffer

Definition at line 251 of file main.c.

◆ replace_placeholder()

void replace_placeholder ( char **  str,
const char *  placeholder,
const char *  value 
)

replace all occurrences of placeholder in string (html) with value

Parameters
strptr to the string pointer that contains placeholders to replace.
placeholderthe placeholder text to search for in the string (e.g., "@@HASHRATE@@").
valuethe replacement text to substitute for the placeholder.

Definition at line 352 of file main.c.

◆ safe_malloc()

void * safe_malloc ( size_t  size)

safe malloc with zero-initialization

Parameters
sizenumber of bytes to allocate
Returns
ptr to allocated memory
Note
calls cleanup() on allocation failure

Definition at line 263 of file main.c.

◆ safe_strdup()

char * safe_strdup ( const char *  src)

safe strdup

Parameters
srcsource string to duplicate
Returns
new string copy
Note
calls cleanup() on allocation failure

Definition at line 278 of file main.c.

◆ safe_write()

ssize_t safe_write ( int  fd,
const char *  buf,
size_t  len 
)

safe socket write with retry

Parameters
fdfd to write to
bufbuffer to write
lenlength of data to write
Returns
total bytes written, or -1 on error

Definition at line 306 of file main.c.

◆ set_dynamic_string()

void set_dynamic_string ( char **  field,
const char *  value 
)

set dynamic string field with memory management

Parameters
fieldpointer to string to update
valuenew string value
Note
calls cleanup() on allocation failure

Definition at line 291 of file main.c.

◆ write_memory_callback()

static size_t write_memory_callback ( void *  contents,
size_t  size,
size_t  nmemb,
void *  userp 
)
static

CURL write callback for memory buffer.

Parameters
contentsreceived data
sizesize of data
nmembnumber of elements
userpptr to MemoryStruct
Returns
total size of processed data

Definition at line 326 of file main.c.