コード例 #1
0
int main(int argc, char *argv[])
{
  if (argc != 4)
    invocation_error(argv[0], "[input file 1] [input file 2] [output file]"); 

  char *output_filename = argv[3];
  struct stat file1_stat, file2_stat;
  FileInfo larger, smaller;
  off_t record_size = (off_t)get_part_record_size();

  validate_input_file(argv[1], &file1_stat, record_size);
  validate_input_file(argv[2], &file2_stat, record_size);

  sort_input_files(argv[1], &file1_stat, argv[2], &file2_stat, &larger, &smaller, record_size);

  Part out_buffer = (Part)malloc(larger.size + smaller.size);
  if (!out_buffer)
    memory_error(__FILE__, __LINE__, __func__);

  if (read_input(&larger, out_buffer, record_size) != 0) {
    free(out_buffer);
    exit(EXIT_FAILURE);
  }

  Part in_buffer = malloc(smaller.size);
  if (!in_buffer) {
    free(out_buffer);
    memory_error(__FILE__, __LINE__, __func__);
  }

  if (read_input(&smaller, in_buffer, record_size) != 0) {
    free(in_buffer);
    free(out_buffer);
    exit(EXIT_FAILURE);
  }

  size_t out_count = merge_buffers(in_buffer, smaller.count, out_buffer, larger.count);
  free(in_buffer);

  if (write_output(output_filename, out_buffer, out_count, record_size) != 0) {
    free(out_buffer);
    exit(EXIT_FAILURE);
  }

  free(out_buffer);
  return 0;
}
コード例 #2
0
ファイル: gen_idt.c プロジェクト: bboozzoo/zephyr
int main(int argc, char *argv[])
{
	get_exec_name(argv[0]);
	get_options(argc, argv);             /* may exit */
	open_files();                        /* may exit */
	read_input_file();                   /* may exit */
	validate_input_file();               /* may exit */
	generate_interrupt_vector_bitmap();  /* may exit */
	generate_idt();                      /* may exit */
	close_files();
	return 0;
}