All pastes #619072 Raw Edit

Untitled

public c v1 · immutable
·published 2007-07-14 12:53 UTC
rendered paste body
  	FILE *fsys;  	char *bufString;	char *mounted = malloc(14*sizeof(char));	char bufsys;	unsigned short size_line = 1, Fsize_line = 0, num_line = 1;    unsigned short i = 0, j = 0;	fpos_t *orPos = malloc(sizeof(fpos_t));	show_msg("Parsing the file system configuration (\\sidetext\\fsys).....");	//First we look for the file system config file	sprintf(mounted, "%s\\fsys", mounted_rep); //mounted_rep is a global char*	fsys = fopen(mounted, "r");	if(!fsys)		return error(ERR_FILE);	if(fgetpos(fsys, orPos))		return error(ERR_FILE);	//Scan the file to have the malloc values	do	{		bufsys = fgetc(fsys);		if(bufsys != ':' && bufsys != CR) { //CR = '\r' (#define)			size_line++;		} else if(bufsys == CR) {			num_line++;		} else {			if(size_line > Fsize_line)				Fsize_line = size_line;			size_line = 0;		}	}while(bufsys != EOF);	Fsize_line++;	//Let's malloc our big stuff	bufString = malloc(Fsize_line*sizeof(char));	FileSystem1 = malloc(num_line); //it's global variable: char **	FileSystem2 = malloc(num_line); // the same here char **	for(i=0;i<num_line-1;i++) {	  FileSystem1[i] = malloc(Fsize_line);	  FileSystem2[i] = malloc(6);	}	//Check there were enough memory	if(!FileSystem1[num_line-1] || !FileSystem2[num_line-1])		return error(ERR_MEMORY);	if(fsetpos(fsys, orPos))		return error(ERR_FILE);	//Now we can fill the char **FileSystemX	i = 1;	j = 0;	do	{		bufsys = fgetc(fsys);		if(bufsys != ':' && bufsys != CR) {			char *buf = bufString;			//strcat(bufString, buf);			sprintf(bufString, "%s%c", buf, bufsys);			i++;		} else if(bufsys == CR) {			bufString[i] = '\0';			strcpy(FileSystem2[j], bufString);			*bufString = 0;			i = 1;			j++;		} else {			bufString[i] = '\0';			strcpy(FileSystem1[j], bufString);			*bufString = 0;			i = 1;		}	}while(bufsys != EOF);	//char *title = malloc(3*sizeof(unsigned char));	//char *message = malloc(3*sizeof(unsigned char));	//sprintf(title, "%u", Fsize_line);	//sprintf(message, "%u", num_line);	//	//DlgMessage(title, message, BT_OK, BT_NONE);	DlgMessage(FileSystem2[2], FileSystem1[2], BT_OK, BT_NONE); //this functions (which perfectly works) prints me FileSystem2[2] and FileSystem1[2]	//Free our stuff        free(mounted);	free(orPos);	for(i=0;i<num_line-1;i++) {  	  free(FileSystem1[i]);	  free(FileSystem2[i]);	}	free(FileSystem1);	free(FileSystem2);	fclose(fsys);	free(bufString);