Skip to content

Commit d2fe416

Browse files
committed
Updated xhost tool
1 parent f7eb17e commit d2fe416

File tree

3 files changed

+154
-135
lines changed

3 files changed

+154
-135
lines changed

src/sys/log.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,32 @@ XSTATUS XLog_Throw(int nRetVal, const char *pFmt, ...)
342342
return nRetVal;
343343
}
344344

345+
XSTATUS XLog_Throwe(int nRetVal, const char *pFmt, ...)
346+
{
347+
XASSERT_RET(g_bInit, nRetVal);
348+
int nFlag = (nRetVal <= 0) ?
349+
XLOG_ERROR : XLOG_NONE;
350+
351+
if (pFmt == NULL)
352+
{
353+
xlogfl(nFlag, "%s", XSTRERR);
354+
return nRetVal;
355+
}
356+
357+
size_t nSize = 0;
358+
va_list args;
359+
360+
va_start(args, pFmt);
361+
char *pDest = xstracpyargs(pFmt, args, &nSize);
362+
va_end(args);
363+
364+
XASSERT(pDest, nRetVal);
365+
xlogfl(nFlag, "%s (%s)", pDest, XSTRERR);
366+
367+
free(pDest);
368+
return nRetVal;
369+
}
370+
345371
void* XLog_ThrowPtr(void* pRetVal, const char *pFmt, ...)
346372
{
347373
XASSERT_RET(g_bInit, pRetVal);

src/sys/log.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ typedef enum
129129

130130
#define xthrowp(r, ...) XLog_ThrowPtr(r, __VA_ARGS__)
131131
#define xthrowr(r, ...) XLog_Throw(r, __VA_ARGS__)
132+
#define xthrowe(...) XLog_Throwe(XSTDERR, __VA_ARGS__)
132133
#define xthrow(...) XLog_Throw(XSTDERR, __VA_ARGS__)
133134

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

228229
void XLog_Display(xlog_flag_t eFlag, xbool_t bNewLine, const char *pFormat, ...);
229230
XSTATUS XLog_Throw(int nRetVal, const char *pFmt, ...);
231+
XSTATUS XLog_Throwe(int nRetVal, const char *pFmt, ...);
230232
void* XLog_ThrowPtr(void* pRetVal, const char *pFmt, ...);
231233

232234
#ifdef __cplusplus

0 commit comments

Comments
 (0)