Exemplo n.º 1
0
Arquivo: output.c Projeto: rhash/RHash
/**
 * Finish one-line percent mode. If in hash verification mode,
 * then print the results of file check.
 *
 * @param info pointer to the file-info structure
 * @param process_res non-zero if error occurred while hashing/checking
 */
static void p_finish_percents(struct file_info *info, int process_res)
{
	int need_check_result;

	need_check_result = (opt.mode & (MODE_CHECK | MODE_CHECK_EMBEDDED)) &&
		!((opt.flags & OPT_SKIP_OK) && errno == 0 && !HC_FAILED(info->hc.flags));
	info->error = process_res;

	if (percents.same_output && need_check_result) {
		print_check_result(info, 0, 1);
	} else {
		rsh_fprintf(rhash_data.log, "100%%\n");
		fflush(rhash_data.log);
		if (need_check_result) print_check_result(info, 1, 1);
	}
}
Exemplo n.º 2
0
/**
 * Finish one-line percent mode. If in hash verification mode,
 * then print the results of file check.
 *
 * @param info pointer to the file-info structure
 * @param process_res non-zero if error occurred while hashing/checking
 */
static void p_finish_percents(struct file_info *info, int process_res)
{
	int need_check_result;

#ifdef WIN32_USE_CURSOR
	if(percents.use_cursor && percents.hOut == NULL) return;
#endif

	need_check_result = (opt.mode & (MODE_CHECK | MODE_CHECK_EMBEDDED)) &&
		!((opt.flags & OPT_SKIP_OK) && errno == 0 && !HC_FAILED(info->hc.flags));
	info->error = process_res;

	if(percents.same_output && need_check_result) {
		print_check_result(info, 0, 1);
	} else {
		fprintf(rhash_data.log, "100%%\n");
		fflush(rhash_data.log);
		if(need_check_result) print_check_result(info, 1, 1);
	}
}
Exemplo n.º 3
0
Arquivo: output.c Projeto: rhash/RHash
/**
 * Prepare or print result of file processing.
 *
 * @param info pointer to the file-info structure
 * @param init non-zero on initialization before hash calculation,
 *             and zero after hash calculation finished.
 */
static void print_results_on_check(struct file_info *info, int init)
{
	if (opt.mode & (MODE_CHECK | MODE_CHECK_EMBEDDED)) {
		int print_name = (opt.flags & (OPT_PERCENTS | OPT_SKIP_OK) ? !init : init);

		if (!init && (opt.flags & OPT_SKIP_OK) && errno == 0 && !HC_FAILED(info->hc.flags)) {
			return; /* skip OK message */
		}

		print_check_result(info, print_name, !init);
	}
}
Exemplo n.º 4
0
/**
 * Main function for command-line check utility
 */
int main(int argc, char *argv[])
{
  /** Checking functions to call */
  check_func checks[] = {
    check_tables,
    check_header,
    check_keywords,
    check_visrefmap,
    check_unique_targets,
    check_targets_present,
    check_arrname,
    check_elements_present,
    check_corr_present,
    check_flagging,
    check_t3amp,
    check_waveorder,
    check_time,
    check_flux,
    NULL
  };
  oi_fits oi;
  oi_check_result result;
  oi_breach_level worst;
  char filename[FLEN_FILENAME];
  int status, i;

  /* Parse command-line */
  if (argc != 2) {
    printf("Usage:\n%s FILE\n", argv[0]);
    exit(2); /* standard unix behaviour */
  }
  (void)g_strlcpy(filename, argv[1], FLEN_FILENAME);

  /* Read FITS file */
  status = 0;
  read_oi_fits(filename, &oi, &status);
  if (status) goto except;

  /* Display summary info */
  print_oi_fits_summary(&oi);

  /* Run checks */
  worst = OI_BREACH_NONE;
  i = 0;
  while (checks[i] != NULL) {
    if ((*checks[i++])(&oi, &result) != OI_BREACH_NONE) {
      print_check_result(&result);
      if (result.level > worst) worst = result.level;
    }
    free_check_result(&result);
  }

  if (worst == OI_BREACH_NONE)
    printf("All checks passed\n");

  free_oi_fits(&oi);
  exit(EXIT_SUCCESS);

except:
  exit(EXIT_FAILURE);
}