Skip to content

Commit

Permalink
Updated xhost tool
Browse files Browse the repository at this point in the history
  • Loading branch information
kala13x committed Mar 4, 2025
1 parent f7eb17e commit d2fe416
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 135 deletions.
26 changes: 26 additions & 0 deletions src/sys/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,32 @@ XSTATUS XLog_Throw(int nRetVal, const char *pFmt, ...)
return nRetVal;
}

XSTATUS XLog_Throwe(int nRetVal, const char *pFmt, ...)
{
XASSERT_RET(g_bInit, nRetVal);
int nFlag = (nRetVal <= 0) ?
XLOG_ERROR : XLOG_NONE;

if (pFmt == NULL)
{
xlogfl(nFlag, "%s", XSTRERR);
return nRetVal;
}

size_t nSize = 0;
va_list args;

va_start(args, pFmt);
char *pDest = xstracpyargs(pFmt, args, &nSize);
va_end(args);

XASSERT(pDest, nRetVal);
xlogfl(nFlag, "%s (%s)", pDest, XSTRERR);

free(pDest);
return nRetVal;
}

void* XLog_ThrowPtr(void* pRetVal, const char *pFmt, ...)
{
XASSERT_RET(g_bInit, pRetVal);
Expand Down
2 changes: 2 additions & 0 deletions src/sys/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ typedef enum

#define xthrowp(r, ...) XLog_ThrowPtr(r, __VA_ARGS__)
#define xthrowr(r, ...) XLog_Throw(r, __VA_ARGS__)
#define xthrowe(...) XLog_Throwe(XSTDERR, __VA_ARGS__)
#define xthrow(...) XLog_Throw(XSTDERR, __VA_ARGS__)

#define xlog_init(name,flags,safe) XLog_Init(name, flags, safe)
Expand Down Expand Up @@ -227,6 +228,7 @@ void XLog_Destroy(void);

void XLog_Display(xlog_flag_t eFlag, xbool_t bNewLine, const char *pFormat, ...);
XSTATUS XLog_Throw(int nRetVal, const char *pFmt, ...);
XSTATUS XLog_Throwe(int nRetVal, const char *pFmt, ...);
void* XLog_ThrowPtr(void* pRetVal, const char *pFmt, ...);

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit d2fe416

Please sign in to comment.