**
/tmp/test.txt 内容如下:
test_field=23
test_field1=“test”
**
**
> > int check_file_fields(const char *file, char *dst, int len) {
> > #define FILEBUFSIZE 128
> > FILE *stream = NULL;
> > char line[FILEBUFSIZE] = {0};
> > int num = 0;
> > char buf[16] = {0};
> >
> > stream = fopen(file, "r");
> > if (NULL == stream) {
> > return -1;
> > }
> >
> > while (NULL != (fgets(line, FILEBUFSIZE - 1, stream))) {
> > if (1 == sscanf(line, "test_field=%d", (int *)&num)) {
> > strncpy(dst, (char *)&num, len);
> > fclose(stream);
> > return 0;
> > }else if(1 == sscanf(line, "test_field1=%s", buf)){
> > strncpy(dst, buf, len);
> > fclose(stream);
> > return 0;
> }
> > }
> > fclose(stream);
> > return -1;
> > #undef FILEBUFSIZE
> > }
**