if (errno == EINVAL) error (EXIT_FAILURE, 0, _("conversion from `%s' to `%s' not supported"), from_code, to_code); else error (EXIT_FAILURE, errno, _("failed to start conversion processing"));
{ if (errno == EINVAL) error (EXIT_FAILURE, 0, _("conversion from `%s' to `%s' not supported"), from_code, to_code); else error (EXIT_FAILURE, errno, _("failed to start conversion processing")); }
main (int argc, char *argv[]){  int status = EXIT_SUCCESS;  int remaining;  FILE *output;  iconv_t cd;  /* Set locale via LC_ALL.  */  setlocale (LC_ALL, "");  /* Set the text message domain.  */  textdomain (_libc_intl_domainname);  /* Parse and process arguments.  */  argp_parse (&argp, argc, argv, 0, &remaining, NULL);  /* List all coded character sets if wanted.  */  if (list)    {      print_known_names ();      exit (EXIT_SUCCESS);    }  /* If either the from- or to-code is not specified this is an error     since we do not know what to do.  */  if (from_code == NULL && to_code == NULL)    error (EXIT_FAILURE, 0,	   _("neither original nor target encoding specified"));  if (from_code == NULL)    error (EXIT_FAILURE, 0, _("original encoding not specified using `-f'"));  if (to_code == NULL)    error (EXIT_FAILURE, 0, _("target encoding not specified using `-t'"));  /* Let's see whether we have these coded character sets.  */  cd = iconv_open (to_code, from_code);  if (cd == (iconv_t) -1)    if (errno == EINVAL)      error (EXIT_FAILURE, 0, _("conversion from `%s' to `%s' not supported"),	     from_code, to_code);    else      error (EXIT_FAILURE, errno, _("failed to start conversion processing"));  /* Determine output file.  */  if (output_file != NULL)    {      output = fopen (output_file, "w");      if (output == NULL)	error (EXIT_FAILURE, errno, _("cannot open output file"));    }  else    output = stdout;  /* Now process the remaining files.  Write them to stdout or the file     specified with the `-o' parameter.  If we have no file given as     the parameter process all from stdin.  */  if (remaining == argc)    process_file (cd, stdin, output);  else    do      {	struct stat st;	const char *addr;	int fd = open (argv[remaining], O_RDONLY);	if (verbose)	  printf ("%s:\n", argv[remaining]);	if (fd == -1)	  {	    error (0, errno, _("cannot open input file `%s'"),		   argv[remaining]);	    status = EXIT_FAILURE;	    continue;	  }#ifdef _POSIX_MAPPED_FILES	/* We have possibilities for reading the input file.  First try	   to mmap() it since this will provide the fastest solution.  */	if (fstat (fd, &st) == 0	    && ((addr = mmap (NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0))		!= MAP_FAILED))	  {	    /* Yes, we can use mmap().  The descriptor is not needed               anymore.  */	    if (close (fd) != 0)	      error (EXIT_FAILURE, errno, _("error while closing input `%s'"),		     argv[remaining]);	    if (process_block (cd, addr, st.st_size, output) < 0)	      {		/* Something went wrong.  */		status = EXIT_FAILURE;		/* We don't need the input data anymore.  */		munmap ((void *) addr, st.st_size);		/* We cannot go on with producing output since it might		   lead to problem because the last output might leave		   the output stream in an undefined state.  */		break;	      }	    /* We don't need the input data anymore.  */	    munmap ((void *) addr, st.st_size);	  }	else#endif	/* _POSIX_MAPPED_FILES */	  {	    /* Read the file in pieces.  */	    if (process_fd (cd, fd, output) != 0)	      {		/* Something went wrong.  */		status = EXIT_FAILURE;		/* We don't need the input file anymore.  */		close (fd);		/* We cannot go on with producing output since it might		   lead to problem because the last output might leave		   the output stream in an undefined state.  */		break;	      }	    /* Now close the file.  */	    close (fd);	  }      }    while (++remaining < argc);  /* Close the output file now.  */  if (fclose (output))    error (EXIT_FAILURE, errno, _("error while closing output file"));  return status;}