All pastes #816198 Raw Edit

Something

public text v1 · immutable
·published 2007-12-14 18:11 UTC
rendered paste body
/* ====================================================== */
/*                      proboles.h                        */
/* ====================================================== */

/* ====================================================== */
/*           Sunartish epiloghs tupou probolhs            */
/* ====================================================== */

void probolh(){
	char choice;
	int flag = 0;

	system(clear_screen);
	printf(".-------------| Probolh |-------------.\n");
	printf("|                                     |\n");
	printf("|  1. Probolh tou arxeiou index       |\n");
	printf("|  2. Probolh olwn                    |\n");
	printf("|  3. Probolh ana eidos               |\n");
	printf("|  4. Probolh ana eidos k diathesimot |\n");
	printf("|  5. Probolh ana titlo taksinomimena |\n");
	printf("|  6. Epistrofh                       |\n");
	printf("|                                     |\n");
	printf("|-------------------------------------'\n");
	printf("|  Epilogh :                          |\n");
	printf("'-------------------------------------'\n");

	do{
		choice = getchar();
		switch(choice){
			case '1': probolh_index(); break;
			case '2': probolh_all(); break;
			case '3': prob_genre(select_genre()); break;
			case '4': prob_gen_av(select_genre()); break;
			case '5': prob_titl_taksin(); break;
			case '6': return;
			default : printf("\nLathos epilogh, ksanaprospathise\n"); flag = 1; getchar();
		}
	}while(flag == 1);
}

/* ====================================================== */
/*     Sunartish probolhs mias eggrafhs pairnontas ws     */
/* parametro th dieuthunsh ths eggrafhs sto master arxeio */
/* ====================================================== */

void probolh_one(int deiktis){
	dataf  = fopen(oad, "rb");
	fseek(dataf, deiktis * sizeof(struct tenies), SEEK_SET);
	fread(&film, sizeof(struct tenies), 1, dataf);
	fclose(dataf);

	printf("\n.-------------| Probolh |-------------.\n");
	printf("|                                     |\n");
	printf("| Kwdikos tenias   : ");
	printf("%s\n", film.code);
	printf("| Titlos tenias    : ");
	printf("%s\n", film.title);
	printf("| Eidos tenias     : ");
	printf("%s\n", film.genre);
	printf("| Skhnotheths      : ");
	printf("%s\n", film.director);
	printf("| Protagwnisths 1  : ");
	printf("%s\n", film.actor1);
	printf("| Protagwnisths 2  : ");
	printf("%s\n", film.actor2);
	printf("| Etos tenias      : ");
	printf("%d\n", film.year);
	printf("| Diatheshmothta   : ");
	printf("%d\n", film.avail);
	printf("|                                     |\n");
	printf("'-------------------------------------'\n");
}

/* ====================================================== */
/*         Sunartish probolhs tou index arxeiou           */
/* ====================================================== */

void probolh_index(){
	struct teniesIndex temp;
	int i, pl = check_files();
	if (pl == 0) {
		printf("\n\nTo arxeio einai adeio...\n\n");
		getchar();
		return;
	}
	indexf = fopen(oai, "rb");
	fseek(indexf, 0, SEEK_SET);
	printf("\n.---------| Probolh index |---------.\n");
	printf("|                                     |\n");
	for (i=0; i<pl;i++) { 
		fread(&temp, sizeof(struct teniesIndex), 1, indexf);      
		printf("| %s ==> %d \n", temp.code, temp.dief);
	}
	printf("|                                     |\n");
	printf("'-------------------------------------'\n");
	fclose(indexf);
}

/* ====================================================== */
/*  Sunartish probolhs twn eggrafwn apo to master arxeio  */
/* ====================================================== */

void probolh_all(){
	int i, pl = check_files();

	if (pl == 0) {
		printf("\n\nTo arxeio einai adeio...\n\n");
		getchar();
		return;
	}

	dataf  = fopen(oad, "rb");

	printf(".-----------| Probolh olwn|----------.\n");
	printf("|                                     |\n");
	for (i=0;i<pl;i++){
		fread(&film, sizeof(struct tenies), 1, dataf);

		printf("| Kwdikos tenias   : ");
		printf("%s\n", film.code);
		printf("| Titlos tenias    : ");
		printf("%s\n", film.title);
		printf("| Eidos tenias     : ");
		printf("%s\n", film.genre);
		printf("| Skhnotheths      : ");
		printf("%s\n", film.director);	
		printf("| Protagwnisths 1  : ");	
		printf("%s\n", film.actor1)	;
		printf("| Protagwnisths 2  : ");
		printf("%s\n", film.actor2);
		printf("| Etos tenias      : ");
		printf("%d\n", film.year);
		printf("| Diatheshmothta   : ");
		printf("%d\n", film.avail);
		printf("|-------------------------------------|\n");
	}
	printf("|                                     |\n");
	printf("'-------------------------------------'\n");
	fclose(dataf);
}

/* ====================================================== */
/*   Sunartish probolhs eggrafwn ana eidos apo to master  */
/* ====================================================== */

void prob_genre(char *eidos){
	int i, pl = check_files();

	if (pl == 0) {
		printf("\n\nTo arxeio einai adeio...\n\n");
		getchar();
		return;
	}

	dataf  = fopen(oad, "rb");

	for (i=0;i<pl;i++){
		fread(&film, sizeof(struct tenies), 1, dataf);
		if (strcmp(film.genre, eidos) == 0){
			printf("\nKwdikos tenias   : ");
			printf("%s", film.code);
			printf("\nTitlos tenias    : ");
			printf("%s", film.title);
			printf("\nEidos tenias     : ");
			printf("%s", film.genre);
			printf("\nSkhnotheths      : ");
			printf("%s", film.director);
			printf("\nProtagwnisths 1  : ");
			printf("%s", film.actor1);
			printf("\nProtagwnisths 2  : ");
			printf("%s", film.actor2);
			printf("\nEtos tenias      : ");
			printf("%d", film.year);
			printf("\nDiatheshmothta   : ");
			printf("%d", film.avail);
		}
	}
	fclose(dataf);
}

/* ====================================================== */
/*           Sunartish epiloghs eidous tenias             */
/* ====================================================== */

char* select_genre(){
	char choice;
	int flag = 0;

	system(clear_screen);
	printf(".---------------| Eidh |--------------.\n");
	printf("|                                     |\n");
	printf("|  1. Komodia                         |\n");
	printf("|  2. Ntokimanter                     |\n");
	printf("|  3. Istoriko                        |\n");
	printf("|  4. Fantasias                       |\n");
	printf("|  5. Thriler                         |\n");
	printf("|  6. Koinwnikh                       |\n");
	printf("|  7. Drama                           |\n");
	printf("|  8. Paidiko                         |\n");
	printf("|  9. Miouzikal                       |\n");
	printf("|                                     |\n");
	printf("|-------------------------------------'\n");
	printf("|  Epilogh :                          |\n");
	printf("'-------------------------------------'\n");

	do{
		choice = getchar();
		switch(choice){
			case '1': return "Komodia";
			case '2': return "Ntokimanter";
			case '3': return "Istoriko";
			case '4': return "Fantasias";
			case '5': return "Thriler";
			case '6': return "Koinwnikh";
			case '7': return "Drama";
			case '8': return "Paidiko";
			case '9': return "Miouzikal";
			default : printf("\nLathos epilogh, ksanaprospathise\n"); flag = 1; getchar();
		}
	}while(flag == 1);
}

/* ====================================================== */
/* Sunartish probolhs eggrafwn ana eidos k diathesimothta */
/* ====================================================== */

void prob_gen_av(char *eidos){
	int i, pl = check_files();

	if (pl == 0) {
		printf("\n\nTo arxeio einai adeio...\n\n");
		getchar();
		return;
	}

	dataf  = fopen(oad, "rb");

	for (i=0;i<pl;i++){
		fread(&film, sizeof(struct tenies), 1, dataf);
		if (strcmp(film.genre, eidos) == 0 && film.avail == 1){
			printf("\nKwdikos tenias   : ");
			printf("%s", film.code);
			printf("\nTitlos tenias    : ");
			printf("%s", film.title);
			printf("\nEidos tenias     : ");
			printf("%s", film.genre);
			printf("\nSkhnotheths      : ");
			printf("%s", film.director);
			printf("\nProtagwnisths 1  : ");
			printf("%s", film.actor1);
			printf("\nProtagwnisths 2  : ");
			printf("%s", film.actor2);
			printf("\nEtos tenias      : ");
			printf("%d", film.year);
			printf("\nDiatheshmothta   : ");
			printf("%d", film.avail);
		}
	}
	fclose(dataf);
}

/* ====================================================== */
/*   Sunartish probolhs eggrafwn ana titlo taksinomimena  */
/* ====================================================== */

void prob_titl_taksin(){
}