2018-02-05 19:32:30 +02:00
|
|
|
# ----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
# Config Test Perl Exports
|
|
|
|
# ----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
MODULE = pgBackRest::LibC PACKAGE = pgBackRest::LibC
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Parse command line and return a JSON object with results
|
|
|
|
####################################################################################################################################
|
|
|
|
SV *
|
|
|
|
cfgParseTest(backrestBin, parseParam)
|
|
|
|
const char *backrestBin
|
|
|
|
const char *parseParam
|
|
|
|
CODE:
|
|
|
|
RETVAL = NULL;
|
|
|
|
|
|
|
|
ERROR_XS_BEGIN()
|
|
|
|
{
|
|
|
|
// This should run in a temp context but for some reason getopt_long gets upset when if gets called again after the previous
|
|
|
|
// arg list being freed. So, this is a memory leak but it is only used for testing, not production.
|
|
|
|
StringList *paramList = strLstNewSplitZ(strCat(strNew("pgbackrest|"), parseParam), "|");
|
2018-04-13 22:05:52 +02:00
|
|
|
|
|
|
|
// Don't use cfgLoad() because it has a lot of side effects that we don't want
|
2018-07-21 00:51:42 +02:00
|
|
|
configParse(strLstSize(paramList), strLstPtr(paramList), false);
|
2018-04-13 22:05:52 +02:00
|
|
|
cfgExeSet(strNew(backrestBin));
|
|
|
|
cfgLoadUpdateOption();
|
2018-02-05 19:32:30 +02:00
|
|
|
|
|
|
|
String *result = perlOptionJson();
|
|
|
|
|
|
|
|
RETVAL = newSV(strSize(result));
|
|
|
|
SvPOK_only(RETVAL);
|
|
|
|
|
|
|
|
strcpy(SvPV_nolen(RETVAL), strPtr(result));
|
|
|
|
SvCUR_set(RETVAL, strSize(result));
|
|
|
|
}
|
|
|
|
ERROR_XS_END()
|
|
|
|
OUTPUT:
|
|
|
|
RETVAL
|