static int file_stat_info(char *file, long *size, long *line, long *word, long *long_max)...{#define TMP_BUF_SIZE 8192 char buf[TMP_BUF_SIZE]; int buf_size = TMP_BUF_SIZE; FILE *fp = NULL; long file_size = 0; long file_line = 0; long file_word = 0; long line_long = 0; int read_count = 0; int read_size = 0; int word_in = 0; int word_out = 0; int long_tmp = 0; int i,j; if (fp = fopen(file, "rb")) ...{ fseek(fp, 0, SEEK_END); file_size = ftell(fp);//size rewind(fp); if (file_size > 0) ...{ file_line = 1;//line read_count = file_size/buf_size; read_count++; } for (i = 0; i < read_count; i++) ...{ read_size = fread(buf, sizeof(char), buf_size, fp); if (read_size > 0) ...{ for (j = 0; j < read_size; j++) ...{ //line if (' ' == buf[j]) file_line++; //word if (' ' == buf[j] || ' ' == buf[j] || ' ' == buf[j] || ' ' == buf[j]) ...{ if (word_in) ...{ file_word++; word_in = 0; } } else ...{ word_in = 1; } //long_max if (' ' == buf[j] || ' ' == buf[j]) ...{ long_tmp = 0; } else ...{ long_tmp++; if (long_tmp > line_long) line_long = long_tmp; } } if (word_in) file_word++;//word if (long_tmp > line_long) line_long = long_tmp;//long_max } } if (size && file_size >= 0) *size = file_size; if (line && file_line >= 0) *line = file_line; if (word && file_word >= 0) *word = file_word; if (long_max && line_long >= 0) *long_max = line_long; fclose(fp); return 0; } return -1;}