#include #include #include #define MAX_LINE_SIZE 255 #define SEARCH_STR "genre" /* Space dlimited list of words that can't be genre themselves */ /* This is done in order to prevent errors from .nfo scan when genre field is left empty */ #define CANT_BE_GENRE "genre format audio encode resolution year music video" /* Prototypes */ int GenreIsFine(char* str); void NormalizeStr(char* str); /* Arguments: */ int main(int argc, char ** argv) { FILE * f; char fullpath[MAX_LINE_SIZE]; char line[MAX_LINE_SIZE]; char chkline[MAX_LINE_SIZE]; char gnrline[MAX_LINE_SIZE]; int found_genre = 0; char * foundpos; int i, n, k, j; /* Checking the external arguments */ if (argc < 3 ) { printf("Error! Not enough parameters ...\n"); printf("Syntax: %s \n", argv[0]); return(1); } else { /* Opening the file */ strcpy(fullpath, argv[1]); strcat(fullpath,"/"); strcat(fullpath, argv[2]); f = fopen(fullpath, "r"); if (f == NULL) { strcpy(fullpath, argv[1]); strcat(fullpath, "/CD1/"); strcat(fullpath, argv[2]); f = fopen(fullpath, "r"); if (f == NULL) { strcpy(fullpath, argv[1]); strcat(fullpath, "/Cd1/"); strcat(fullpath, argv[2]); f = fopen(fullpath, "r"); if (f == NULL) { strcpy(fullpath, argv[1]); strcat(fullpath, "/cd1/"); strcat(fullpath, argv[2]); f = fopen(fullpath, "r"); if (f == NULL) return 0; } } } /* Scan loop */ while (!(feof(f)) && (!found_genre)) { if (fgets(line, MAX_LINE_SIZE, f) != NULL) { strcpy(chkline, line); n = strlen(chkline); for (i=0; i