int realmain(int argc, char* argv[])
{
    whoami = QUtil::getWhoami(argv[0]);
    QUtil::setLineBuf(stdout);

    // Remove prefix added by libtool for consistency during testing.
    if (strncmp(whoami, "lt-", 3) == 0)
    {
	whoami += 3;
    }

    // ArgParser must stay in scope for the duration of qpdf's run as
    // it holds dynamic memory used for argv.
    Options o;
    ArgParser ap(argc, argv, o);
    ap.parseOptions();

    try
    {
	PointerHolder<QPDF> pdf_ph =
            process_file(o.infilename, o.password, o);
        QPDF& pdf = *pdf_ph;
        if (! o.page_specs.empty())
        {
            handle_page_specs(pdf, o);
        }
        if (! o.rotations.empty())
        {
            handle_rotations(pdf, o);
        }
        handle_under_overlay(pdf, o);
        handle_transformations(pdf, o);

	if (o.outfilename == 0)
	{
            do_inspection(pdf, o);
	}
	else
	{
            write_outfile(pdf, o);
	}
	if (! pdf.getWarnings().empty())
	{
            if (! o.suppress_warnings)
            {
                std::cerr << whoami << ": operation succeeded with warnings;"
                          << " resulting file may have some problems"
                          << std::endl;
            }
            // Still exit with warning code even if warnings were suppressed.
            exit(EXIT_WARNING);
	}
    }
    catch (std::exception& e)
    {
	std::cerr << e.what() << std::endl;
	exit(EXIT_ERROR);
    }

    return 0;
}
int realmain(int argc, char* argv[])
{
    whoami = QUtil::getWhoami(argv[0]);
    QUtil::setLineBuf(stdout);

     
    if (strncmp(whoami, "lt-", 3) == 0)
    {
	whoami += 3;
    }

     
     
    Options o;
    ArgParser ap(argc, argv, o);
    ap.parseOptions();

    try
    {
	PointerHolder<QPDF> pdf_ph =
            process_file(o.infilename, o.password, o);
        QPDF& pdf = *pdf_ph;
        if (! o.page_specs.empty())
        {
            handle_page_specs(pdf, o);
        }
        if (! o.rotations.empty())
        {
            handle_rotations(pdf, o);
        }
        handle_under_overlay(pdf, o);
        handle_transformations(pdf, o);

	if (o.outfilename == 0)
	{
            do_inspection(pdf, o);
	}
	else
	{
            write_outfile(pdf, o);
	}
	if (! pdf.getWarnings().empty())
	{
            if (! o.suppress_warnings)
            {
                std::cerr << whoami << ": operation succeeded with warnings;"
                          << " resulting file may have some problems"
                          << std::endl;
            }
             
            exit(EXIT_WARNING);
	}
    }
    catch (std::exception& e)
    {
	std::cerr << e.what() << std::endl;
	exit(EXIT_ERROR);
    }

    return 0;
}