Files
rmps/enum_functions.c
2017-05-17 18:48:11 +03:00

33 lines
654 B
C

#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);
}