Gosh, why do people always have to be so harsh? I am learning and I've spent the past few months learning how to build this recovery from source. That's not exactly something a complete noob could figure out. If it helps you, I did order K&R and plan on learning more. I thought starting with fgets would be a pretty safe thing to add to an existing recovery I'm modifying. You know, that whole open source model? Salem helped me and I really appreciate that. I've helped a lot of people on forums myself, just not this one. This is the final code I ended up with and it works good.
Code:
void get_my_rom_info()
{
ui_print("\n");
ui_print("Getting current ROM version...\n");
char* result;
ensure_root_path_mounted("SYSTEM:");
FILE * vers = fopen("/system/build.prop", "r");
if (vers == NULL)
{
return NULL;
}
char line[512];
while(fgets(line, sizeof(line), vers) != NULL) //read a line
{
if (strstr(line, "modversion") != NULL || strstr(line, "romversion") != NULL)
{
char* strptr = strstr(line, "=") + 1;
result = calloc(strlen(strptr) + 1, sizeof(line));
strcpy(result, strptr);
break;
}
}
fclose(vers);
ensure_root_path_unmounted("SYSTEM:");
ui_print("\nCurrent ROM: %s\n", result);
}