Increased resilience and added some more logging
This commit is contained in:
17
src/util.c
17
src/util.c
@@ -20,6 +20,7 @@
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
@@ -125,6 +126,22 @@ int createErrorLog(char *msg, int err) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int createFormatLog(char *fmt, ...) {
|
||||
va_list ap;
|
||||
char *log;
|
||||
int code;
|
||||
va_start(ap, fmt);
|
||||
log = malloc(vsnprintf(NULL, 0, fmt, ap) + 1);
|
||||
va_end(ap);
|
||||
if (log == NULL)
|
||||
return 1;
|
||||
va_start(ap, fmt);
|
||||
vsprintf(log, fmt, ap);
|
||||
va_end(ap);
|
||||
code = createLog(log);
|
||||
return code;
|
||||
}
|
||||
|
||||
int istrcmp(char *s1, char *s2) {
|
||||
int i;
|
||||
for (i = 0;; i++) {
|
||||
|
||||
Reference in New Issue
Block a user