readability.c (714B)
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #define READABILITY_N 88097 + 1000 5 6 void read_readability_js(char* string) 7 { 8 FILE* fp = fopen("/opt/rosenrot/readability.js", "r"); 9 if (!fp) { // fp is NULL, fopen failed 10 fprintf(stderr, "Failed to open file\n"); 11 fprintf(stderr, "Consider running $ sudo make runtime_files\n"); 12 string = NULL; 13 return; 14 } 15 int i = 0; 16 int c; 17 while ((c = fgetc(fp)) != EOF) { 18 string[i++] = c; 19 } 20 string[i] = '\0'; 21 fclose(fp); 22 } 23 24 /* 25 int main(){ 26 char* readability_js = malloc(READABILITY_N+1); 27 read_readability_js(readability_js); 28 printf("%s", readability_js); 29 free(readability_js); 30 } 31 */