#include"stdio.h"#include#include#include#define getpch(type) (type *)malloc(sizeof(type))
#define UserNumber 10
#define UserFNumber 10
#define UserOFNumber 5
struct fname{z
char fname[1];
int flag;
}fnameA[26]={'a','0','b','0','c','0','d','0','e','0','f','0','g','0','h','0','i','0','j',
'0','k','0','l','0','m','0','n','0','o','0','p','0','q','0','r','0','s','0','t','0','u','0','v','0',
'w','0','x','0','y','0','z','0'};
struct afd{
char opname[10];
int flag;
char opfprotect[3];
int rwpoint;
}AFD[UserOFNumber];
typedef struct{
char fname[10];
int flag;
int fprotect[3];
int flength;
}ufd,UF[UserFNumber];
struct mdf{
char uname[10];
UF Udir;
}UFD[UserNumber];
void intFSystem()
{
int i,j,k,l;
strcpy(UFD[0].uname,"a");
strcpy(UFD[1].uname,"a");
strcpy(UFD[2].uname,"a");
strcpy(UFD[3].uname,"a");
strcpy(UFD[4].uname,"a");
strcpy(UFD[5].uname,"a");
strcpy(UFD[6].uname,"a");
strcpy(UFD[7].uname,"a");
strcpy(UFD[8].uname,"a");
strcpy(UFD[9].uname,"a");
for(i=0;i<10;i++)
{
for(k=0;k<5;k++)
{
do j=rand()%26;
while(fnameA[j].flag);
strcpy(UFD[i].Udir[k].fname,fnameA[j].fname);
fnameA[j].flag=1;
UFD[i].Udir[k].flength=rand()%2048+1;
UFD[i].Udir[k].flag=1;
UFD[i].Udir[k].fprotect[0]=rand()%2;
UFD[i].Udir[k].fprotect[1]=rand()%2;
UFD[i].Udir[k].fprotect[2]=rand()%2;
}
for(j=0;j<26;j++)
fnameA[j].flag=0;
}
for(l=0;l<5;l++)
{
strcpy(AFD[i].opname,"");
AFD[l].flag=0;
AFD[l].opfprotect[0]=0;
AFD[l].opfprotect[1]=0;
AFD[l].opfprotect[2]=0;
AFD[l].rwpoint=0;
}
}
void printUFD(int i)
{
int k;
printf("main file content:\n",UFD[i].uname);
printf("User\t filename\t ReadWriteExe\t filelength\n");
for(k=0;k<10;k++)
{
if(UFD[i].Udir[k].flag)
printf("%s\t%s\t%d %d %d\t\t%d\n",UFD[i].uname,UFD[i].Udir[k].fname,UFD[i].Udir[k].fprotect[0],
UFD[i].Udir[k].fprotect[1],UFD[i].Udir[k].fprotect[2],UFD[i].Udir[k].flength);
}
}
void printAFD()
{
int l;
printf("exe file content:\n");
printf("filename\t readwriteExe\n");
for(l=0;l<5;l++)
{
if(AFD.[l].flag)
printf("%s\t%d%d%d\n",AFD[l].opname,AFD[l].opfprotect[0],AFD[l].opfprotect[1],AFD[l].opfprotect[2]);
}
}
void Create(int i)
{
int k;
for(k=0;k<10;k++)
{
if(!UFD[i].Udir[k].flag)
break;
}
if(k>=0)
{
printf("one User cann't have files more than 10\n");
return;
}
}