Introduce src, obj, build, docs & modify Makefile
This commit is contained in:
32
src/enum_functions.c
Normal file
32
src/enum_functions.c
Normal 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user