Esempio n. 1
0
void delete_file(MyFile *MyFp, char flname[],int node)
{
	rewind(MyFp);
	int k = 0,r=0;
	printf("k node %d %d\n", k, node);
	struct table *t = (struct table*)malloc(sizeof(struct table));
	while (k<10)
	{
		fseek(MyFp, (k*sizeof(struct table)) + 2048, SEEK_SET);
		fread(t, sizeof(struct table), 1, MyFp);
		if (string_comp(t->file_name, flname) == 1)
		{
			fseek(MyFp, (k*sizeof(struct table)) + 2048, SEEK_SET);
			printf("entered");
			for (r = 0; r < sizeof(struct table); r++)
				fputc(48,MyFp);
			fseek(MyFp, ((k + 1) * 4096) + 2048, SEEK_SET);
			for (k = 0; k < 4096; k++)
				fputc(48, MyFp);
			fseek(MyFp, t->index, SEEK_SET);
			fputc(48, MyFp);
			rewind(MyFp);
			break;
		}
		k++;
	}
}
Esempio n. 2
0
int main()
{
    char* s1 = "Liheyuanxx";
    char* s2 = "liheyuan";
    char buf[1024];
    printf("string_comp:%d\n", string_comp(s1, s2));
    string_copy(s1, buf);
    printf("copy result:%s\n", buf);
    string_concat(buf, s2);
    printf("concat result:%s\n", buf);
    printf("length:%d\n", string_length(buf));
    return 0;
}
Esempio n. 3
0
void MyOpenFile(MyFile *MyFp,char *flname,int node)
{
	int k = 0;
	struct table *t = (struct table*)malloc(sizeof(struct table));
	while (k < node)
	{
		fseek(MyFp, k*sizeof(struct table), SEEK_SET);
		fread(t, sizeof(struct table), 1, MyFp);
		if (string_comp(t->file_name, flname) == 1)
		{
			fseek(MyFp, ((t->index) * 4096)+2048, SEEK_SET);
			char b[10];
			fread(b, sizeof(b), 1, MyFp);
			printf("Memory : %s\n", b);
		}
		k++;
	}
}
Esempio n. 4
0
void MyRead(MyFile *MyFp,char flname[], int buffersize,int node)
{
	rewind(MyFp);
	int k = 0;
	char buffer[10];
	struct table *t = (struct table*)malloc(sizeof(struct table));
	while (k<10)
	{
		fseek(MyFp, 2048,SEEK_SET);
		fread(t, sizeof(struct table), 1, MyFp);
		if (string_comp(t->file_name, flname) == 1)
		{
			fseek(MyFp, ((k + 1) * 4096)+2048, SEEK_SET);
			fread(buffer, sizeof(buffer), 1, MyFp);
			printf("buffer %s\n", buffer);
			break;
		}
		k++;
	}
}
Esempio n. 5
0
void insert_data(MyFile *MyFp,char flname[],char buffer[],int bufferSize,int node)
{
	rewind(MyFp);
	int k = 0;
	printf("k node %d %d\n", k, node);
	struct table *t = (struct table*)malloc(sizeof(struct table));
	while (k < node)
	{
		fseek(MyFp, (k*sizeof(struct table))+2048, SEEK_SET);
		fread(t, sizeof(struct table), 1, MyFp);
		if (string_comp(t->file_name, flname) == 1)
		{
			fseek(MyFp, ((k + 1) * 4096)+2048, SEEK_SET);
			int i = fwrite(buffer, bufferSize, 1, MyFp);
			printf("i==%d\n", i);
			char b[10] = "ad";
			fseek(MyFp, ((k + 1) * 4096)+2048, SEEK_SET);
			fread(b, bufferSize, 1, MyFp);
			b[bufferSize] = '\0';
			printf("%s", b);
		}
		k++;
	}
}
Esempio n. 6
0
 int
 type_comp(void* T1,void* T2){
   string s1=((Type*)T1)->name;
   string s2=((Type*)T2)->name;
   return string_comp(&s1,&s2);
 }