Increased resilience and added some more logging

This commit is contained in:
2022-07-02 08:17:15 -05:00
parent ad88090956
commit 6db24d8ab6
5 changed files with 27 additions and 7 deletions

View File

@@ -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++) {