#include "readDMAT.h"
#include "verbose.h"
#include <cstdio>
#include <iostream>
#include <cassert>
Go to the source code of this file.
◆ readDMAT_read_header()
| static int readDMAT_read_header |
( |
FILE * |
fp, |
|
|
int & |
num_rows, |
|
|
int & |
num_cols |
|
) |
| |
|
inlinestatic |
28{
29
30 int res = fscanf(fp,"%d %d",&num_cols,&num_rows);
31 if(res != 2)
32 {
33 return 1;
34 }
35
36 if(num_cols < 0)
37 {
38 fprintf(stderr,"IOError: readDMAT() number of columns %d < 0\n",num_cols);
39 return 2;
40 }
41 if(num_rows < 0)
42 {
43 fprintf(stderr,"IOError: readDMAT() number of rows %d < 0\n",num_rows);
44 return 3;
45 }
46
47 char lf;
48
49 if(fread(&lf, sizeof(char), 1, fp)!=1 || !(lf == '\n' || lf == '\r'))
50 {
51 fprintf(stderr,"IOError: bad line ending in header\n");
52 return 4;
53 }
54
55 return 0;
56}
Referenced by igl::readDMAT(), and igl::readDMAT().