示例#1
0
/*********************
return RET_NOK on error
*********************/
ret_code_t entry_read_int(const char * table, const char * file, int * res, ...)
{
	ret_code_t ret;
	va_list ap;

	va_start(ap, res);
	ret = __read_int(table, file, res, ap);
	va_end(ap);

	return ret;
}
示例#2
0
static bool fortio_is_fortran_stream__(FILE * stream , bool endian_flip) {
  const bool strict_checking = true;          /* True: requires that *ALL* records in the file are fortran formatted */
  offset_type init_pos              = util_ftell(stream);
  bool is_fortran_stream     = false;
  int header , tail;
  bool cont;

  do {
    cont = false;
    if (__read_int(stream , &header , endian_flip)) {
      if (header >= 0) {
        if (util_fseek(stream , (offset_type) header , SEEK_CUR) == 0) {
          if (__read_int(stream , &tail , endian_flip)) {
            cont = true;
            /* 
               OK - now we have read a header and a tail - it might be
               a fortran file.
            */
            if (header == tail) {
              if (header != 0) {
                /* This is (most probably) a fortran file */
                is_fortran_stream = true;
                if (strict_checking)
                  cont = true;  
                else
                  cont = false;
              }
              /* Header == tail == 0 - we don't make any inference on this. */
            } else {
              /* Header != tail => this is *not* a fortran file */
              cont = false;
              is_fortran_stream = false;
            }
          }
        }
      } 
    }
  } while (cont);
  util_fseek(stream , init_pos , SEEK_SET);
  return is_fortran_stream;
}