Exemplo n.º 1
0
/// Invokes kyua_text_vprintf() based on a set of variable arguments.
///
/// \param [out] output Output pointer of kyua_text_vprintf().
/// \param format Formatting string to use.
/// \param ... Variable arguments to pack in a va_list to use.
///
/// \return The return value of the wrapped function.
static kyua_error_t
call_vprintf(char** output, const char* format, ...)
{
    va_list ap;
    va_start(ap, format);
    kyua_error_t error = kyua_text_vprintf(output, format, ap);
    va_end(ap);
    return error;
}
Exemplo n.º 2
0
/// Generates a path and checks if it exists.
///
/// \param format Formatting string for the path to generate.
/// \param ... Arguments to the formatting string.
///
/// \return A dynamically-allocated string containing the generated path if
/// there were no errors and the file pointed to by such path exists; NULL
/// otherwise.  The returned string must be relesed with free() by the caller.
static char*
try_core(const char* format, ...)
{
    char* path;
    va_list ap;

    va_start(ap, format);
    kyua_error_t error = kyua_text_vprintf(&path, format, ap);
    va_end(ap);
    if (kyua_error_is_set(error)) {
        // Something went really wrong (and should not have happened).  Ignore
        // this core file candidate.
        kyua_error_free(error);
        return NULL;
    }

    if (access(path, F_OK) == -1) {
        free(path);
        return NULL;
    } else {
        return path;
    }
}