/*
* debug代码要用宏括起来
* 例如
* #if xxx
* #endi
* 自动删除#if xxx 和#endif之间的代码
*/
#include <stdio.h>
#include <string.h>
#define DEBUG 1
#if DEBUG
#define dbg_out(x,y) do{printf("[- %d -] ",__LINE__);printf(x,y);}while(0);
#else
#define dbg_out(x,y)
#endif
enum
{
TRUE,
FALSE,
PARAM_ERROR,
FORWARD,
BACK,
FOUND_NO_STR,
STR_FOUND,
FSEEK_ERR,
HEADER_OF_FILE,
FILE_OPERATE_API_ERR,
};
/*****************************************************************/
/****** copy file tmp.txt to source file *****/
/*****************************************************************/
int Cp_File(FILE *source_file,FILE *dst_file)
{
char ch;
ch = fgetc(source_file);
while(!feof(source_file))
{
fputc(ch,dst_file);
ch = fgetc(source_file);
}
return TRUE;
}/*end Cp_File*/
/*****************************************************************/
/****** Del_Words_In_File *****/
/*****************************************************************/
int Del_Words_In_File(char *filename,int start,int end)
{
FILE *fp;
FILE *tmp_fp;
char buf[8000];
char ch;
int ret;
if(start > end)/*param judge*/
{
#if DEBUG
printf("Param error,start > end\n");
#endif
return PARAM_ERROR;
}
/*open dst_file*/
fp = fopen(filename,"rt+");
if(fp == NULL)
{
#if DEBUG