1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-05 15:05:48 +02:00
pgbackrest/src/main.c

64 lines
2.1 KiB
C
Raw Normal View History

/***********************************************************************************************************************************
Main
***********************************************************************************************************************************/
2017-11-28 21:44:05 -05:00
#include <stdio.h>
#include <stdlib.h>
#include "command/archive/push/push.h"
2018-01-23 13:34:24 -05:00
#include "command/help/help.h"
#include "command/command.h"
2017-11-28 21:44:05 -05:00
#include "common/error.h"
2018-01-17 09:15:51 -05:00
#include "common/exit.h"
2017-11-28 21:44:05 -05:00
#include "config/config.h"
2018-01-16 13:52:20 -05:00
#include "config/load.h"
#include "perl/exec.h"
2017-11-28 21:44:05 -05:00
#include "version.h"
int
main(int argListSize, const char *argList[])
{
2017-11-28 21:44:05 -05:00
TRY_BEGIN()
{
2018-01-16 13:52:20 -05:00
// Load the configuration
// -------------------------------------------------------------------------------------------------------------------------
cfgLoad(argListSize, argList);
2017-11-28 21:44:05 -05:00
2018-01-23 13:34:24 -05:00
// Display help
// -------------------------------------------------------------------------------------------------------------------------
if (cfgCommandHelp())
{
cmdHelp();
exit(0);
}
2017-11-28 21:44:05 -05:00
// Display version
2018-01-16 13:52:20 -05:00
// -------------------------------------------------------------------------------------------------------------------------
2018-01-23 13:34:24 -05:00
if (cfgCommand() == cfgCmdVersion)
2017-11-28 21:44:05 -05:00
{
printf(PGBACKREST_NAME " " PGBACKREST_VERSION "\n");
fflush(stdout);
exit(0);
}
// Archive push command. Currently only implements local operations of async archive push.
// -------------------------------------------------------------------------------------------------------------------------
if (cfgCommand() == cfgCmdArchivePush && cfgOptionBool(cfgOptArchiveAsync))
{
cmdBegin();
cmdArchivePush();
exit(exitSafe(false));
}
2017-11-28 21:44:05 -05:00
// Execute Perl for commands not implemented in C
2018-01-17 09:15:51 -05:00
// -------------------------------------------------------------------------------------------------------------------------
perlExec();
2017-11-28 21:44:05 -05:00
}
CATCH_ANY()
{
2018-01-17 09:15:51 -05:00
exit(exitSafe(true));
2017-11-28 21:44:05 -05:00
}
TRY_END();
2018-01-17 09:15:51 -05:00
exit(exitSafe(false));
}