Merge commit '36f161a9cce7b6f460b3884dc825240891b40d5b'
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(akstdlib LANGUAGES C)
|
||||
|
||||
if(TARGET akerror::akerror)
|
||||
message(STATUS "FOUND akerror::akerror")
|
||||
else()
|
||||
message(STATUS "MISSING akerror::akerror")
|
||||
endif()
|
||||
|
||||
include(CTest)
|
||||
include(GNUInstallDirs)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
if(NOT TARGET akerror::akerror)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(akerror REQUIRED)
|
||||
endif()
|
||||
|
||||
set(akstdlib_install_cmakedir "${CMAKE_INSTALL_LIBDIR}/cmake/akstdlib")
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
@@ -41,7 +50,7 @@ install(FILES "include/akstdlib.h" DESTINATION "include/")
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/akstdlib.pc DESTINATION "lib/pkgconfig/")
|
||||
|
||||
|
||||
install(EXPORT akstdlib
|
||||
install(EXPORT akstdlibTargets
|
||||
FILE akstdlibTargets.cmake
|
||||
NAMESPACE akstdlib::
|
||||
DESTINATION ${akstdlib_install_cmakedir}
|
||||
|
||||
@@ -21,5 +21,10 @@ akerr_ErrorContext AKERR_NOIGNORE *aksl_printf(int *count, const char *restrict
|
||||
akerr_ErrorContext AKERR_NOIGNORE *aksl_fprintf(int *count, FILE *restrict stream, const char *restrict format, ...);
|
||||
akerr_ErrorContext AKERR_NOIGNORE *aksl_sprintf(int *count, char *restrict str, const char *restrict format, ...);
|
||||
|
||||
akerr_ErrorContext AKERR_NOIGNORE *aksl_atoi(const char *nptr, int *dest);
|
||||
akerr_ErrorContext AKERR_NOIGNORE *aksl_atol(const char *nptr, long *dest);
|
||||
akerr_ErrorContext AKERR_NOIGNORE *aksl_atoll(const char *nptr, long long *dest);
|
||||
|
||||
akerr_ErrorContext AKERR_NOIGNORE *aksl_realpath(const char *restrict path, char *restrict resolved_path);
|
||||
|
||||
#endif
|
||||
|
||||
37
src/stdlib.c
37
src/stdlib.c
@@ -126,3 +126,40 @@ akerr_ErrorContext AKERR_NOIGNORE *aksl_sprintf(int *count, char *restrict str,
|
||||
FAIL_NONZERO_RETURN(e, (*count == -1), errno, "Short write");
|
||||
SUCCEED_RETURN(e);
|
||||
}
|
||||
|
||||
akerr_ErrorContext AKERR_NOIGNORE *aksl_atoi(const char *nptr, int *dest)
|
||||
{
|
||||
PREPARE_ERROR(e);
|
||||
FAIL_ZERO_RETURN(e, nptr, AKERR_NULLPOINTER, "nptr=%p, dest=%p", (void *)nptr, (void *)dest);
|
||||
FAIL_ZERO_RETURN(e, dest, AKERR_NULLPOINTER, "nptr=%p, dest=%p", (void *)nptr, (void *)dest);
|
||||
*dest = atoi(nptr);
|
||||
SUCCEED_RETURN(e);
|
||||
}
|
||||
|
||||
akerr_ErrorContext AKERR_NOIGNORE *aksl_atol(const char *nptr, long *dest)
|
||||
{
|
||||
PREPARE_ERROR(e);
|
||||
FAIL_ZERO_RETURN(e, nptr, AKERR_NULLPOINTER, "nptr=%p, dest=%p", (void *)nptr, (void *)dest);
|
||||
FAIL_ZERO_RETURN(e, dest, AKERR_NULLPOINTER, "nptr=%p, dest=%p", (void *)nptr, (void *)dest);
|
||||
*dest = atol(nptr);
|
||||
SUCCEED_RETURN(e);
|
||||
}
|
||||
|
||||
akerr_ErrorContext AKERR_NOIGNORE *aksl_atoll(const char *nptr, long long *dest)
|
||||
{
|
||||
PREPARE_ERROR(e);
|
||||
FAIL_ZERO_RETURN(e, nptr, AKERR_NULLPOINTER, "nptr=%p, dest=%p", (void *)nptr, (void *)dest);
|
||||
FAIL_ZERO_RETURN(e, dest, AKERR_NULLPOINTER, "nptr=%p, dest=%p", (void *)nptr, (void *)dest);
|
||||
*dest = atoll(nptr);
|
||||
SUCCEED_RETURN(e);
|
||||
}
|
||||
|
||||
akerr_ErrorContext AKERR_NOIGNORE *aksl_realpath(const char *restrict path, char *restrict resolved_path)
|
||||
{
|
||||
char *result = NULL;
|
||||
PREPARE_ERROR(e);
|
||||
FAIL_ZERO_RETURN(e, path, AKERR_NULLPOINTER, "path=%p, dest=%p", (void *)path, (void *)resolved_path);
|
||||
result = realpath(path, resolved_path);
|
||||
FAIL_ZERO_RETURN(e, result, errno, "Error");
|
||||
SUCCEED_RETURN(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user