操作系统2014课程设计(5)
InputPW(loginpw); /*input new password,use '*' replace*/
printf(\ InputPW(logincpw);
if (strcmp(loginpw,logincpw)==0)
{strcpy(ufd_lp.ufdname,strupr(loginame)); strcpy(ufd_lp.ufdpword,loginpw); fp_mfd=fopen(\
fwrite(&ufd_lp,sizeof(OSUFD_LOGIN),1,fp_mfd); fclose(fp_mfd);
strcpy(username,strupr(loginame)); strcpy(dirname,loginame); strcpy(str,\ strcat(str,username);
if((fp_ufd=fopen(str,\{fp_ufd=fopen(str,\ fclose(fp_ufd); }
fp_mfd=fopen(\
for(j=0;fread(&ufd_lp,sizeof(OSUFD_LOGIN),1,fp_mfd)!=0;j++) {strcpy(str,\ strcat(str,ufd_lp.ufdname);
ufd[j]=(OSUFD*)malloc(sizeof(OSUFD));
strcpy(ufd[j]->ufdname,strupr(ufd_lp.ufdname)); fp_ufd=fopen(str,\
for(i=0;fread(&ufd[j]->ufdfile[i],sizeof(OSFILE),1,fp_ufd)!=0;i++,fcount[j]++) {ifopen[j][i].ifopen=0; ifopen[j][i].openmode=4;} fclose(fp_ufd);} fclose(fp_mfd); ucount=j; SetPANo(0);
printf(\ loginsuc=1; return; } else
{printf(\ flag=1; while(flag)
{printf(\ gets(a);
ltrim(rtrim(a));
if (strcmp(strupr(a),\
else if(strcmp(strupr(a),\
} } } } }
void SetPANo(int RorW) /*Set physical address num,0-read,1-write*/ {int i,j; if (RorW==0)
{if((fp_file_p=fopen(\ {fp_file_p=fopen(\ fclose(fp_file_p); }
fp_file_p=fopen(\ for(i=0;fread(&j,sizeof(int),1,fp_file_p)!=0;i++) fpaddrno[j]=1; /*for(i=1;i if ((i)==0) fpaddrno[i]=1;*/ } else {fp_file_p=fopen(\ /*for(i=1;i if((i)==0) fpaddrno[i]=0;*/ for(i=0;i fwrite(&i,sizeof(int),1,fp_file_p); } fclose(fp_file_p); } void InputPW(char *password) /*input password,use '*' replace*/ {int j; for(j=0;j<=7;j++) {password[j]=getch(); if ((int)(password[j])!=13) {if((int)(password[j])!=8) putchar('*'); else {if (j>0) {j--;j--; putchar('\\b');putchar(' ');putchar('\\b'); } else j--; } } else {password[j]='\\0'; break; } } password[j]='\\0'; } void DirF() /*Dir FileSystem*/ {int i,j,count=0; char sfmode[25],sfpaddr[25],str[25]; int ExistD(char *dirname); /*Whether DirName Exist,Exist-i,Not Exist-0*/ clrscr(); if (strcmp(strupr(ltrim(rtrim(dirname))),\ {printf(\ printf(\eMode\ j=ExistD(dirname); for(i=0;i {printf(\ getch(); clrscr(); printf(\eMode\ } itoa(ufd[j]->ufdfile[i].fpaddr,str,10); strcpy(sfpaddr,\strcat(sfpaddr,str); if (ufd[j]->ufdfile[i].fmode==0) strcpy(sfmode,\else if(ufd[j]->ufdfile[i].fmode==1) strcpy(sfmode,\else if(ufd[j]->ufdfile[i].fmode==2)strcpy(sfmode,\else strcpy(sfmode,\ printf(\.flength,\ } printf(\ else {printf(\ printf(\ for(i=0;i {if ((i==0)&&(i!=0)) {printf(\ getch(); clrscr(); printf(\} printf(\count=count+fcount[i]; } printf(\ } } int ExistD(char *dirname) /*Whether DirName Exist,Exist-i,Not Exist-0*/ {int i; int exist=0; for(i=0;i if (strcmp(strupr(ufd[i]->ufdname),strupr(dirname))==0) {exist=1; break; } if (exist) return(i); else return(-1); } void CdF() /*Exchange Dir*/ {char dname[MAXNAME]; char *rtrim(char *str); /*remove the trailing blanks.*/ char *ltrim(char *str); /*remove the heading blanks.*/ int ExistD(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/ printf(\ gets(dname); ltrim(rtrim(dname)); if (ExistD(dname)>=0) strcpy(dirname,strupr(dname)); else if(strcmp(strupr(dname),\ else printf(\} void CreateF() /*Create File*/ {int fpaddrno,flag=1,i; char fname[MAXNAME],str[50],str1[50],strtext[255],a[25]; char fmode[25]; char *rtrim(char *str); /*remove the trailing blanks.*/ char *ltrim(char *str); /*remove the heading blanks.*/ int FindPANo(); /*find out physical address num*/ int WriteF1(); /*write file*/ int ExistF(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/ int ExistD(char *dirname); if (strcmp(strupr(dirname),strupr(username))!=0) {printf(\ else { printf(\ gets(fname); ltrim(rtrim(fname)); if (ExistF(fname)>=0) {printf(\wgetchar=1; } else {printf(\3-Protect):\gets(fmode); ltrim(rtrim(fmode)); if((strcmp(fmode,\fmode,\ {fpaddrno=FindPANo(); if (fpaddrno>=0) {i=ExistD(username); strcpy(ufd[i]->ufdfile[fcount[i]].fname,fname); ufd[i]->ufdfile[fcount[i]].fpaddr=fpaddrno; ufd[i]->ufdfile[fcount[i]].fmode=atoi(fmode); ifopen[i][fcount[i]].ifopen=0; ifopen[i][fcount[i]].openmode=4; strcpy(str,\ itoa(fpaddrno,str1,10); strcat(str,str1); fp_file=fopen(str,\ fclose(fp_file); fcount[i]++; while(flag) {printf(\ gets(a); ltrim(rtrim(a)); ufd[i]->ufdfile[fcount[i]-1].flength=0; if(strcmp(strupr(a),\{fp_file=fopen(str,\
相关推荐:
- [政务民生]2013年公共基础知识热点问题(七)
- [政务民生]检验检测机构资质认定评审准则及释义20
- [政务民生]关于印发重庆市房屋建筑和市政基础设施
- [政务民生]1、隧道洞身开挖支护施工技术交底书
- [政务民生]2015年山东省17地市中考语文试题分类汇
- [政务民生]2-高级会计师资格考试和评审流程图
- [政务民生]2018版中国清分机行业发展分析及前景策
- [政务民生]新课改高中政治探究
- [政务民生]2018-2024年中国新型组合房屋行业投资
- [政务民生]2015年上海市春季高考数学模拟试卷五
- [政务民生]灌砂法及环刀法测压实度(带计算过程)
- [政务民生]运筹学实验2求解非线性规划
- [政务民生]劝学、逍遥游默写(教师卷)
- [政务民生]《运筹学》 - 期末考试 - 试卷A - 答案
- [政务民生]八年级英语下册 Module 6 Hobbies测试
- [政务民生]2019年宪法知识竞赛试题库100题(含答
- [政务民生]自动化英文文献翻译
- [政务民生]公文格式实施细则
- [政务民生]高一地理上册课堂跟踪练习题6
- [政务民生]会计继续教育习题及答案
- 第三章 无约束最优化方法
- 泛读教程第三册答案
- 魏晋南北朝文学
- 幂的运算复习题
- 城市环境问题的成因与治理策略_以社会
- 钢结构行业产业链及竞争分析研究
- 新型热塑性弹性体增韧聚丙烯的研究
- 中国旅游地理B卷试题及答案
- (苏教版)五年级数学上册第三单元测试卷
- 不稳定性心绞痛诊断与治疗
- 俞氏国际后勤职能部门绩效考核办法
- GB7258-2017新标准考试题含答案
- 小学生汉字听写比赛活动方案
- 1.3《平抛运动》学案 教科版必修2
- 2011香港特别行政区公务员考试复习资料
- 考虑水力条件变化的城市给水管网可靠性
- 表面活性剂在油田开发和生产中的应用
- ITT内部培训资料-FI端吸泵的介绍
- 文明守纪,从我做起学生发言稿
- 初中读《聊斋志异》心得体会800字范文




