Introduce src, obj, build, docs & modify Makefile

This commit is contained in:
2018-02-16 15:30:36 +02:00
parent 3a0ccd3b31
commit bd9ebee627
29 changed files with 15 additions and 21 deletions

32
src/enum_functions.c Normal file
View File

@@ -0,0 +1,32 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "enum_functions.h"
#include "log.h"
void enumtostr(char *scode, int code)
{
char line[128];
FILE *fp;
int bytes = 0;
snprintf(scode, 10, "%d", code);
fp = fopen("/usr/lib/rmps/resources/enum_codes", "r");
if (fp == NULL) {
log(ERROR, "Failed to fetch error enum code!");
return;
}
while (fgets(line, sizeof(line), fp) != NULL)
if (strstr(line, scode) != NULL) {
char *byte;
bytes = sprintf(scode, "%s", line);
byte = memchr(scode, '\n', bytes);
byte[-1] = '\0';
break;
}
strncpy(scode, (char *)memchr(scode, '\"', bytes) + 1, bytes);
fclose(fp);
}