mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
Add ssh_strerror function
- strerror_r for linux - strerror_s for windows Keep in mind that strerror_r has two versions: - XSI - GNU see manpage for more information Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Jakub Jelen
parent
b6a4330fe4
commit
738cedb8be
@@ -429,4 +429,6 @@ void ssh_agent_state_free(void *data);
|
|||||||
|
|
||||||
bool is_ssh_initialized(void);
|
bool is_ssh_initialized(void);
|
||||||
|
|
||||||
|
char *ssh_strerror(int err_num, char *buf, size_t buflen);
|
||||||
|
|
||||||
#endif /* _LIBSSH_PRIV_H */
|
#endif /* _LIBSSH_PRIV_H */
|
||||||
|
|||||||
24
src/misc.c
24
src/misc.c
@@ -1941,4 +1941,28 @@ char *ssh_strreplace(const char *src, const char *pattern, const char *replace)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
|
* @brief Processes errno into error string
|
||||||
|
*
|
||||||
|
* @param[in] err_num The errno value
|
||||||
|
* @param[out] buf Pointer to a place where the string could be saved
|
||||||
|
* @param[in] buflen The allocated size of buf
|
||||||
|
*
|
||||||
|
* @return error string
|
||||||
|
*/
|
||||||
|
char *ssh_strerror(int err_num, char *buf, size_t buflen)
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
strerror_s(buf, buflen, err_num);
|
||||||
|
return buf;
|
||||||
|
#elif !defined(_GNU_SOURCE)
|
||||||
|
strerror_r(err_num, buf, buflen);
|
||||||
|
return buf;
|
||||||
|
#else
|
||||||
|
return strerror_r(err_num, buf, buflen);
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|||||||
Reference in New Issue
Block a user