1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-30 05:39:12 +02:00

Add cvtZToMode().

The companion function to cvtModeToZ().
This commit is contained in:
David Steele 2019-08-08 11:59:39 -04:00
parent 1f93e147fa
commit 969e5817c5
3 changed files with 15 additions and 0 deletions

View File

@ -324,6 +324,18 @@ cvtModeToZ(mode_t value, char *buffer, size_t bufferSize)
FUNCTION_TEST_RETURN(result);
}
mode_t
cvtZToMode(const char *value)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(STRINGZ, value);
FUNCTION_TEST_END();
ASSERT(value != NULL);
FUNCTION_TEST_RETURN(cvtZToUIntBase(value, 8));
}
/***********************************************************************************************************************************
Convert size to zero-terminated string
***********************************************************************************************************************************/

View File

@ -30,6 +30,7 @@ int64_t cvtZToInt64(const char *value);
int64_t cvtZToInt64Base(const char *value, int base);
size_t cvtModeToZ(mode_t value, char *buffer, size_t bufferSize);
mode_t cvtZToMode(const char *value);
size_t cvtSizeToZ(size_t value, char *buffer, size_t bufferSize);
size_t cvtSSizeToZ(ssize_t value, char *buffer, size_t bufferSize);

View File

@ -87,6 +87,8 @@ testRun(void)
TEST_RESULT_INT(cvtModeToZ(0777, buffer, STACK_TRACE_PARAM_MAX), 4, "convert mode to string");
TEST_RESULT_STR(buffer, "0777", " check buffer");
TEST_RESULT_UINT(cvtZToMode("0700"), 0700, "convert string to mode");
}
// *****************************************************************************************************************************