mirror of
https://github.com/preble/libpinproc
synced 2026-02-24 18:25:23 +01:00
Added PRGetLastErrorText().
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
#include "../include/pinproc.h"
|
||||
#include "PRDevice.h"
|
||||
|
||||
#define MAX_TEXT (1024)
|
||||
|
||||
typedef void (*PRLogCallback)(PRLogLevel level, const char *text);
|
||||
|
||||
PRLogCallback logCallback = NULL;
|
||||
@@ -41,11 +43,10 @@ void PRLog(PRLogLevel level, const char *format, ...)
|
||||
if (level < logLevel)
|
||||
return;
|
||||
|
||||
const int maxLogLineLength = 1024;
|
||||
char line[maxLogLineLength];
|
||||
char line[MAX_TEXT];
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vsnprintf(line, maxLogLineLength, format, ap);
|
||||
vsnprintf(line, MAX_TEXT, format, ap);
|
||||
if (logCallback)
|
||||
logCallback(level, line);
|
||||
else
|
||||
@@ -62,6 +63,21 @@ void PRLogSetLevel(PRLogLevel level)
|
||||
logLevel = level;
|
||||
}
|
||||
|
||||
char lastErrorText[MAX_TEXT];
|
||||
|
||||
void PRSetLastErrorText(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vsnprintf(lastErrorText, MAX_TEXT, format, ap);
|
||||
PRLog(kPRLogError, "%s\n", lastErrorText);
|
||||
}
|
||||
|
||||
PR_EXPORT const char *PRGetLastErrorText()
|
||||
{
|
||||
return lastErrorText;
|
||||
}
|
||||
|
||||
#define handleAsDevice ((PRDevice*)handle)
|
||||
|
||||
/** Create a new P-ROC device handle. Only one handle per device may be created. This handle must be destroyed with PRDelete() when it is no longer needed. */
|
||||
|
||||
Reference in New Issue
Block a user