#include #include #include #define MAX 200 void pad(char *site, char *p) { char date[11], lyrline[MAX], name[32]; char lyrfn[64] = "lyrics/"; /* char url[64] = "https://files.catbox.moe/"; */ char url[64] = "https://mesacsclub.com/kaa/"; int year, month, day, i; FILE *lyrics; char *humonth[] = { "mystery", "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december" }; for ( i = 0; i < 10; ++i ) date[i] = p[i]; date[10] = '\0'; year = (date[0] - 0x30) * 1000; year += (date[1] - 0x30) * 100; year += (date[2] - 0x30) * 10; year += date[3] - 0x30; month = (date[5] - 0x30) * 10; month += date[6] - 0x30; day = (date[8] - 0x30) * 10; day += date[9] - 0x30; p = strstr(p, "--") + 2; i = 1; while (p[i] != '.') { name[i-1] = p[i-1]; ++i; } name[i-1] = '\0'; strcat(url, name); strcat(url, ".mp3"); printf("\t\t\t%s\n", "

"); printf( "\t\t\t\t%d ", year); printf("%s %d\n", humonth[month], day); printf("\t\t\t%s\n", "

"); printf("\t\t\t%s\n", "
"); printf("\t\t\t\t%s%s", ""); printf("\t\t\t\t%s%s%s", ""); printf("\t\t\t\t\t%s%s%s", "", ""); printf("\t\t\t\t%s\n", "

"); strcat(lyrfn, name); strcat(lyrfn, ".txt"); lyrics = fopen(lyrfn, "r"); if (lyrics == NULL) puts("RAW!"); else while (fgets(lyrline, MAX, lyrics) != NULL) { printf("\t\t\t\t\t%s", lyrline); printf("\t\t\t\t\t%s\n", "
"); } fclose(lyrics); printf("\t\t\t\t%s\n", "

"); printf("\t\t\t
\n"); } int main() { FILE* in = fopen("files.json", "r"); FILE* header = fopen("header/composed.txt", "r"); FILE* footer = fopen("footer/composed.txt", "r"); char line[MAX], buffer[MAX]; char site[32] = "https://kaa.neocities.org/"; char pattern[32] = "Link/", end[32] = ".txt\","; int patlen = strlen(pattern); int endlen = strlen(end); int ch, cnt, len; char *p; if ( (in == NULL) || (header == NULL) || (footer == NULL) ) { puts("That's pungent!"); return 1; } while (fgets(line, MAX, header) != NULL) printf("%s", line); fclose(header); fseek(in, 0, SEEK_END); while ( fseek(in, -2, SEEK_CUR) != -1 ) { ch = fgetc(in); for ( cnt = 0; ch != '\n' && ftell(in) > 1; ++cnt ) { fseek(in, -2, SEEK_CUR); line[cnt] = ch; ch = fgetc(in); } line[cnt] = ch; for (len = cnt; cnt >= 0; --cnt) buffer[len - cnt] = line[cnt]; buffer[len] = '\0'; if ( ( p = strstr(buffer, pattern) ) != NULL) { p += patlen; p[ strlen(p) - endlen + 1 ] = '\0'; pad(site, p); } } fclose(in); while (fgets(line, MAX, footer) != NULL) printf("%s", line); fclose(footer); return 0; }