dreamphp기록과 추억이 머무는 곳
고전 프로그램

디스크 관리 v1.2 [C 소스 포함]

disk_1.png
디스크 관리 v1.2
1991.03.13
정진범, 정진만
70.8 KiB

간단한 디스크 관리 프로그램입니다.

disk_1_1.png

disk_1_2.png

DISK.C
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include "bplus.c"
#include "c:\tc\jin\jinman.c"

struct personstruct
{
unsigned char lname[18+1], num[5+1], head[12+1], id[2+1], list[27+1];
/* 프로그램의 이름, 디스크 번호, 디스크 종류, 프로그램의 장수, 프로그램의 설명 */
} person, pushdm;
struct dmxy
{
unsigned int lname, num, head, id, list;
};
struct dmxy dmx, dmy;

IX_DESC nameindex;
FILE *namefile;
long currentrec;
char s_scrbuf[4000+1];
int s_x, s_y;

void help(void);
void openfile(void);
void closefile(void);
int addfile(void);
void getstring(char*, int);
void printname(ENTRY*);
void findfile(void);
void listfile(void);
int deletefile(void);
void osshell(void);
void title(void);
void listprint(ENTRY*,int);
void datain(void);

main()
{
char sunjung;
int done=0;
clrscr();
openfile();
datain();
title();
do
{
closefile();
}
while (!done);
}

void openfile()
{
if ((namefile = fopen("disk.dat","r+")) != NULL)
open_index("disk.inx", &nameindex, 1);
else
{
namefile = fopen("disk.dat","w+");
if (namefile == NULL)
{
printf(" 데이타 화일을 만들수가 없습니다.\n");
exit(1);
}
make_index("disk.inx", &nameindex, 1);
}
}

void closefile()
{
fclose(namefile);
close_index(&nameindex);
clrscr();
exit(0);
}

int addfile()
{
ENTRY ee;
char name[67];
int ret;
ret = fseek(namefile, 0, SEEK_END);
if (ret == 0)
{
strcpy(ee.key, person.lname);
strupr(ee.key);
ee.recptr = ftell(namefile);
if (ee.recptr != -1)
{
if (add_key(&ee, &nameindex) == IX_OK)
{
fwrite(&person, sizeof(person), 1, namefile);
buffer_flush(&nameindex);
return (IX_OK);
}
}
}
else printf("\n용량이 모자람니다.");
return (IX_FAIL);
}

void getstring(mes, length)
char *mes;
int length;
{
char message[67];
gets(message);
if (strlen(message) > length) message[length] = '\0';
strcpy(mes, message);
}

void findfile()
{
ENTRY ee;
title();
gets(ee.key);
strupr(ee.key);
if (locate_key(&ee, &nameindex) != EOIX) printname(&ee);
else printxy(25, 30, "데이타가 없습니다.", 0x07, 500);
}

int deletefile(void)
{
ENTRY ee;
char sunjung;
strcpy(ee.key, person.lname);
strupr(ee.key);
if(find_key(&ee, &nameindex) != IX_OK) { jindelaysleep(30, 25, "삭제할 키가 없습니다.", 0x07, 500); return IX_FAIL;}
if(delete_key(&ee, &nameindex) == IX_OK)
{
buffer_flush(&nameindex);
fseek(namefile, ee.recptr, SEEK_SET);
fwrite(&person, sizeof(person), 1, namefile);
memset(&person,32,sizeof(person));
jindelaysleep(30, 25, "삭제합니다.", 0x07, 500);
return(IX_OK);
}
return (IX_FAIL);
}

void listfile()
{
ENTRY ee;
int dline;
char sunjung;
dline = 2;
puts("┍━━━━━━━━━┯━━퐈활퐈퐈퐈퐈퐈퐈활퐈퐈활퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈┑");
printxy(1, 2, "│", 0, 0x07);
printxy(3, 2, " 이 름 │번 호│ 종 류 │장수│ 설 명 ", 0, 0x70);
printxy(77, 2, "│", 0, 0x07);
first_key(&nameindex);
while (next_key(&ee, &nameindex) == IX_OK)
{
listprint(&ee, dline);
++dline;
if (dline == 21)
{
printxy(1, dline+1, "┕━━━━━━━━━┷━━퐈핑퐈퐈퐈퐈퐈퐈핑퐈퐈핑퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈┙", 0, 0x07);
printxy(5, 23, "아무키나 누르세요.", 0, 0x70); gotoxy(23, 23);
if(getch()==0) getch();
dline = 2;
gotoxy(1,dline);
clrscr();
puts("┍━━━━━━━━━┯━━퐈활퐈퐈퐈퐈퐈퐈활퐈퐈활퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈┑");
printxy(1, 2, "│", 0, 0x07);
printxy(3, 2, " 이 름 │번 호│ 종 류 │장수│ 설 명 ", 0, 0x70);
printxy(77, 2, "│", 0, 0x07);
}
}
printxy(1, dline+1, "┕━━━━━━━━━┷━━퐈핑퐈퐈퐈퐈퐈퐈핑퐈퐈핑퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈퐈┙", 0, 0x07);
printxy(5, 23, "마지막 자료입니다.", 0, 0x70);gotoxy(23, 23);
if(getch()==0) getch();
memset(&person,32,sizeof(person));
first_key(&nameindex);
}

void printname(e)
ENTRY *e;
{
int ret;
ret = fseek(namefile, e->recptr, SEEK_SET);
if (ret == 0)
{
fread(&person, sizeof(person), 1, namefile);
gotoxy(40, 9); printf("%-18.18s", person.lname);
gotoxy(40, 11); printf("%-5.5s", person.num);
gotoxy(40, 13); printf("%-12.12s", person.head);
gotoxy(40, 15); printf("%-2.2s", person.id);
gotoxy(28, 18); printf("%-27.27s", person.list);
}
else printxy(30, 25, "데이타가 없습니다.", 0, 0x70);
}

void listprint(e, dl)
ENTRY *e;
int dl;
{
char pbuf[80];
int ret;
ret = fseek(namefile, e->recptr, SEEK_SET);
if (ret == 0)
{
fread(&person, sizeof(person),1,namefile);
sprintf(pbuf,"│%-18.18s│%-5.5s│%-12.12s│ %-2.2s │%-27.27s│", person.lname, person.num, person.head, person.id, person.list);
printxy(1,dl+1,pbuf,0,0x07);
}
}

void osshell(void)
{
char scrbuf[4001];
gettext(1, 1, 80, 25, scrbuf);
puttext(1, 1, 80, 25, s_scrbuf);
gotoxy(s_x, s_y);
cursor_on();
printf("\n다시 돌아 오려면 'EXIT' 치세요.\n");
if(system("") != 0) jindelaysleep(wherex(), wherey(), "DOS 로 갈수가 없습니다.", 0x70, 500);
gettext(1, 1, 80, 25, s_scrbuf);
s_x = wherex(); s_y = wherey();
puttext(1, 1, 80, 25, scrbuf);
}

void datain(void)
{
ENTRY ee;
unsigned char str[255];
int sw=0, rt=0, px=40, py=9, err;
dmx.lname = px; dmy.lname = py;
dmx.num = px; dmy.num = py+2;
dmx.head = px; dmy.head = py+4;
dmx.id = px; dmy.id = py+6;
dmx.list = px-12; dmy.list = py+9;
textattr(0x07);
clrscr();
title();
do
{
if(sw>4) sw=0;
if(sw<0) sw=4;
switch(sw)
{
case 0: strcpy(str, person.lname);
rt=jingetstring(&sw, dmx.lname, dmy.lname, person.lname, sizeof(person.lname)-1);
if(strcmp(str, person.lname)!=0)
{
memcpy(&pushdm.lname, &person.lname, sizeof(person.lname));
buffer_flush(&nameindex);
} break;
case 1: rt=jingetstring(&sw, dmx.num, dmy.num, person.num, sizeof(person.num)-1); break;
case 2: rt=jingetstring(&sw, dmx.head, dmy.head, person.head, sizeof(person.head)-1); break;
case 3: rt=jingetstring(&sw, dmx.id, dmy.id, person.id, sizeof(person.id)-1); break;
case 4: rt=jingetstring(&sw, dmx.list, dmy.list, person.list, sizeof(person.list)-1); break;
}
switch(rt)
{
case PGUPKEY: if (prev_key(&ee, &nameindex) == IX_OK) printname(&ee);
else
{
jindelaysleep(30, 25, "여기가 처음입니다.", 0x07, 500);
sw=0;
} break;
case PGDNKEY: if (next_key(&ee, &nameindex) == IX_OK) printname(&ee);
else
{
jindelaysleep(30, 25, "여기가 마지막입니다.", 0x07, 500);
sw=0;
} break;
case F1KEY: help(); break;
case F2KEY: osshell(); break;
case F3KEY: clrscr(); listfile(); clrscr(); title(); break;
case F4KEY: findfile(); break;
case F9KEY: if(yesno(64, 25, "삭제", 'Y')=='Y')
{
err = deletefile();
if(err == IX_OK)
{
title();
jindelaysleep(31, 25, "삭제 되었습니다.", 0x70, 500);
sw=0;
}
} break;
case F10KEY: if(yesno(64, 25, "저장", 'Y')=='Y')
{
err = addfile();
if(err == IX_OK)
{
jindelaysleep(31,25,"저장했습니다.", 0x70, 500);
sw=0;
}
} break;
}
if(rt==27) rt = (yesno(64, 25, "빠짐", 'Y')=='Y') ? 27 : 0;
} while(rt!=27);
}

void title(void)
{
int x=7, y=3;
printxy(x, y++, "┌───────────────────────────────┒", 0, 0x07);
printxy(x, y++, "│ ▲ ●●●●●●●●●●●●●● ▲ ┃", 0, 0x07);
printxy(x, y++, "│ ∼ ☆ ● 디스크 관리 프로그램 ● ★ ← ┃", 0, 0x07);
printxy(x, y++, "│ ●●●●●●●●●●●●●● ┃", 0, 0x07);
printxy(x, y++, "│ ┃", 0, 0x07);
printxy(x, y++, "│ ┏━━━━━━━━┳━━━━━━━━━━━┓ ┃", 0, 0x07);
printxy(x, y++, "│ ┃ 프로그램 이름 ┃ [ ] ┃ ┃", 0, 0x07);
printxy(x, y++, "│ ┣━━━━━━━━╋━━━━━━━━━━━┫ ┃", 0, 0x07);
printxy(x, y++, "│ ┃ 프로그램 번호 ┃ [ ] ┃ ┃", 0, 0x07);
printxy(x, y++, "│ ┣━━━━━━━━╋━━━━━━━━━━━┫ ┃", 0, 0x07);
printxy(x, y++, "│ ┃ 프로그램 종류 ┃ [ ] ┃ ┃", 0, 0x07);
printxy(x, y++, "│ ┣━━━━━━━━╋━━━━━━━━━━━┫ ┃", 0, 0x07);
printxy(x, y++, "│ ┃ 프로그램 장수 ┃ [ ] ┃ ┃", 0, 0x07);
printxy(x, y++, "│ ┣━━━━━━━━┻━━━━━━━━━━━┫ ┃", 0, 0x07);
printxy(x, y++, "│ ┃ 프로그램 설명 ┃ ┃", 0, 0x07);
printxy(x, y++, "│ ┃ [ ] ┃ ┃", 0, 0x07);
printxy(x, y++, "│ ┣━━━━━━━━━━━━━━━━━━━━┫ ┃", 0, 0x07);
printxy(x, y++, "│ ┃F1(도움말) F2(나들이) F3(전체목록) ┃ ┃", 0, 0x07);
printxy(x, y++, "│ ┃F4(찾기) F9(삭제) F10(저장) Esc(끝)┃ ┃", 0, 0x07);
printxy(x, y++, "│ ┗━━━━━━━━━━━━━━━━━━━━┛ ┃", 0, 0x07);
printxy(x, y++, "┕━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛", 0, 0x07);
}

void help(void)
{
char scrbuf[4001];
int x=10, y=3;
gettext(1,1,80,25,scrbuf);
printxy(x, y, " ", 0, 0x70); y++;
printxy(x, y, " ┌──────────────────────────┐ ", 0, 0x70); y++;
printxy(x, y, " │ 쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀 │ ", 0, 0x70); y++;
printxy(x, y, " │ ㅆ ♥ 디스크 관리 Ver 1.2 ♥ ㅆ │ ", 0, 0x70); y++;
printxy(x, y, " │ 쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀쒀 │ ", 0, 0x70); y++;
printxy(x, y, " │ │ ", 0, 0x70); y++;
printxy(x, y, " │ F1 도움말 F2 나들이 │ ", 0, 0x70); y++;
printxy(x, y, " │ F3 전체목록보기 F4 이름찾기 │ ", 0, 0x70); y++;
printxy(x, y, " │ F5 F6 │ ", 0, 0x70); y++;
printxy(x, y, " │ F7 F8 │ ", 0, 0x70); y++;
printxy(x, y, " │ F9 삭제 F10 저장 │ ", 0, 0x70); y++;
printxy(x, y, " │ │ ", 0, 0x70); y++;
printxy(x, y, " │ PgUp/PgDn 앞/뒤 자료 ESC 종료 │ ", 0, 0x70); y++;
printxy(x, y, " │ │ ", 0, 0x70); y++;
printxy(x, y, " │ 만든이 : 정 진범 도운이 : 정 진만 │ ", 0, 0x70); y++;
printxy(x, y, " │ 만든날 : 1991년 3월 13일 │ ", 0, 0x70); y++;
printxy(x, y, " │ 필료한 화일 : DISK.EXE │ ", 0, 0x70); y++;
printxy(x, y, " │ 자동 생성화일 : DISK.DAT, DISK.INX │ ", 0, 0x70); y++;
printxy(x, y, " │ │ ", 0, 0x70); y++;
printxy(x, y, " └──────────────────────────┘ ", 0, 0x70); y++;
printxy(x, y, " ", 0, 0x70); y++;
cursor_off();
if(getch()==0) getch();
cursor_on();
puttext(1,1,80,25,scrbuf);
}
목록

함께 나눈 이야기

댓글

댓글 남기기

이미지와 영상은 본문에 표시됩니다. 삭제한 첨부와 본문 연결은 수정 저장할 때 함께 반영됩니다.

취소

작성자 삭제 후에도 삭제 안내가 남으며 운영자는 원문을 확인할 수 있습니다.