qLibc
qsystem.c File Reference

System APIs. More...

Go to the source code of this file.

Functions

const char * qgetenv (const char *envname, const char *defstr)
 Get a system environment variable.
char * qsyscmd (const char *cmd)
 Run an external command and return its output.

Detailed Description

System APIs.

Definition in file qsystem.c.

Function Documentation

◆ qgetenv()

const char * qgetenv ( const char * envname,
const char * defstr )

Get a system environment variable.

Parameters
envnameenvironment variable name.
defstrdefault string to return if the variable is not set.
Returns
pointer to the environment variable value, or defstr if not found.

Definition at line 54 of file qsystem.c.

◆ qsyscmd()

char * qsyscmd ( const char * cmd)

Run an external command and return its output.

Parameters
cmdcommand string to run.
Returns
allocated string that contains the command output on success, or NULL on failure.
Note
If the command runs successfully but produces no output, this function returns an empty string, not NULL.

Definition at line 71 of file qsystem.c.