Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* BRM.h */
- #ifndef BRM_H
- #define BRM_H
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <string.h>
- #include <io.h>
- #include <windows.h>
- #pragma warning( disable : 4996 )
- /* 글꼴 색상 */
- enum
- {
- BLACK,/* 0 : 검정 */
- DARK_BLUE,/* 1 : 어두운 파랑 */
- DARK_GREEN,/* 2 : 어두운 초록 */
- DARK_SKY_BLUE, /* 3 : 어두운 하늘 */
- DARK_RED, /* 4 : 어두운 빨강 */
- DARK_VIOLET, /* 5 : 어두운 보라 */
- DARK_YELLOW, /* 6 : 어두운 노랑 */
- GRAY, /* 7 : 회색 */
- DARK_GRAY, /* 8 : 어두운 회색 */
- BLUE, /* 9 : 파랑 */
- GREEN, /* 10 : 초록 */
- SKY_BLUE, /* 11 : 하늘 */
- RED, /* 12 : 빨강 */
- VIOLET, /* 13 : 보라 */
- YELLOW, /* 14 : 노랑 */
- WHITE, /* 15 : 하양 */
- };
- void Setcolor(int color) // 글자색
- {
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (short)color);
- }
- /* BOOL Type 정의 */
- typedef int BOOL;
- #define FALSE 0
- #define TRUE 1
- /* 구조체 선언 */
- typedef struct tagBook // 도서 구조체
- {
- char ID[10]; // 도서번호
- char Name[20]; // 도서명
- char Author[10]; // 저자
- char publisher[20];// 출판사
- BOOL IsRetal; // 대여 여부
- } Book;
- typedef struct tagCustomer // 고객 구조체
- {
- char Name[20]; // 고객명( ID )
- char HPnumber[20]; // 고객 연락처
- char PW[10]; // 비밀번호
- Book RentalList[10]; // 대여 도서 목록
- } Customer;
- /* 함수 원형 선언 */
- /* 건드리지 말 것 */
- int ReadBL ( Book **BookList );
- int ReadCL ( Customer **CustomerList );
- int ReadAI ( char *AdminPW);
- int LogIn ( Book *BookList, Customer *CustomerList, int CLRecordCount, int BLRecordCount );
- int ShowMainMenu ( ); // 미구현
- int SignIn ( Customer **CustomerList, int CLRecordCount ); // 미구현
- /* 정용만 건드릴 것 */
- int ShowUserMenu ( );
- int UserMenu ( Customer *User );
- /* 민식만 건드릴 것 */
- int ShowAdminMenu( );
- int AdminMenu ( Book *BookList, Customer *CustomerList, int CLRecordCount, int BLRecordCount );
- /* 창완만 건드릴 것 */
- int Exit ( );
- #endif
- /* BRM.c */
- #include "BRM.h"
- int ReadBL( Book **BookList )
- {
- FILE* BLfp;
- int i, BLRecordCount;
- char buf[200];
- /* BookList.txt 파일 개방 */
- BLfp = fopen("BookList.txt","r");
- if(BLfp == NULL)
- {
- puts("지정된 경로에서 'BookList.txt' 를 찾을 수 없습니다");
- exit(-1);
- }
- /* 레코드 개수 계산 */
- for( i=0 ;; i++ )
- {
- if ( NULL == fgets( buf, sizeof(buf), BLfp ) )
- break;
- }
- BLRecordCount = i; // 루프의 총 반복 횟수를 BLRecordCount 에 저장
- /* 읽은 크기만큼 동적 할당하여 레코드 저장 */
- *BookList = (Book *)malloc( sizeof(BookList) * BLRecordCount );
- /* 레코드를 메모리로 읽어온다 */
- for( i = 0; i < BLRecordCount; i++ )
- {
- fscanf( BLfp, "%s%s%s%s", &(*BookList)[i].ID, &(*BookList)[i].Name, &(*BookList)[i].Author, &(*BookList)[i].publisher );
- }
- fclose( BLfp );
- return BLRecordCount;
- }
- int ReadCL( Customer **CustomerList )
- {
- FILE *CLfp, *Psnlfp;
- int i, CLRecordCount;
- char buf[200];
- /* CustomerList.txt 파일 개방 */
- CLfp = fopen("CustomerList.txt","r");
- if(CLfp == NULL)
- {
- puts("지정된 경로에서 'CustomerList.txt' 를 찾을 수 없습니다");
- exit(-1);
- }
- /* 레코드 개수 계산 */
- for( i=0 ;; i++ )
- {
- if ( NULL == fgets( buf, sizeof(buf), CLfp ) )
- break;
- }
- CLRecordCount = i; // 루프의 총 반복 횟수를 CLRecordCount 에 저장
- /* 읽은 크기만큼 동적 할당하여 레코드 저장 */
- *CustomerList = (Customer *)malloc( sizeof( Customer ) * CLRecordCount );
- /* 레코드를 메모리로 읽어온다 */
- rewind( CLfp ); // 파일 위치 지시자를 시작점으로
- for( i = 0; i < CLRecordCount; i++ )
- {
- int j;
- char buf2[200]={0};
- char title[] = "PersonalRentalList\\";
- char txt[] = ".txt";
- fscanf( CLfp, "%s%s%s", (*CustomerList)[i].Name, (*CustomerList)[i].PW, (*CustomerList)[i].HPnumber );
- strcpy( buf2, title );
- strcat( buf2, (*CustomerList)[i].Name);
- strcat(buf2, ".txt");
- /* 고객명으로 된 파일제목을 가진 파일이 존재하는지 확인 */
- if ( 0 == access(buf2, 0 ) )
- {
- Psnlfp = fopen(buf2,"r");
- for( j = 0; j < 10 ; j++ )
- {
- if ( EOF == fscanf( Psnlfp, "%s%s%s%s",(*CustomerList)[i].RentalList[j].ID, (*CustomerList)[i].RentalList[j].Name,(*CustomerList)[i].RentalList[j].Author,(*CustomerList)[i].RentalList[j].publisher ) )
- break;
Add Comment
Please, Sign In to add comment