error.h revision 240116
1240116Smarcel/* 2240116Smarcel * Automated Testing Framework (atf) 3240116Smarcel * 4240116Smarcel * Copyright (c) 2008 The NetBSD Foundation, Inc. 5240116Smarcel * All rights reserved. 6240116Smarcel * 7240116Smarcel * Redistribution and use in source and binary forms, with or without 8240116Smarcel * modification, are permitted provided that the following conditions 9240116Smarcel * are met: 10240116Smarcel * 1. Redistributions of source code must retain the above copyright 11240116Smarcel * notice, this list of conditions and the following disclaimer. 12240116Smarcel * 2. Redistributions in binary form must reproduce the above copyright 13240116Smarcel * notice, this list of conditions and the following disclaimer in the 14240116Smarcel * documentation and/or other materials provided with the distribution. 15240116Smarcel * 16240116Smarcel * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 17240116Smarcel * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 18240116Smarcel * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19240116Smarcel * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20240116Smarcel * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 21240116Smarcel * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22240116Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 23240116Smarcel * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24240116Smarcel * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25240116Smarcel * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26240116Smarcel * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27240116Smarcel * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28240116Smarcel */ 29240116Smarcel 30240116Smarcel#if !defined(ATF_C_ERROR_H) 31240116Smarcel#define ATF_C_ERROR_H 32240116Smarcel 33240116Smarcel#include <stdbool.h> 34240116Smarcel#include <stddef.h> 35240116Smarcel 36240116Smarcel#include <atf-c/error_fwd.h> 37240116Smarcel 38240116Smarcel/* --------------------------------------------------------------------- 39240116Smarcel * The "atf_error" type. 40240116Smarcel * --------------------------------------------------------------------- */ 41240116Smarcel 42240116Smarcelstruct atf_error { 43240116Smarcel bool m_free; 44240116Smarcel const char *m_type; 45240116Smarcel void *m_data; 46240116Smarcel 47240116Smarcel void (*m_format)(struct atf_error *, char *, size_t); 48240116Smarcel}; 49240116Smarcel 50240116Smarcelatf_error_t atf_error_new(const char *, void *, size_t, 51240116Smarcel void (*)(const atf_error_t, char *, size_t)); 52240116Smarcelvoid atf_error_free(atf_error_t); 53240116Smarcel 54240116Smarcelatf_error_t atf_no_error(void); 55240116Smarcelbool atf_is_error(const atf_error_t); 56240116Smarcel 57240116Smarcelbool atf_error_is(const atf_error_t, const char *); 58240116Smarcelconst void *atf_error_data(const atf_error_t); 59240116Smarcelvoid atf_error_format(const atf_error_t, char *, size_t); 60240116Smarcel 61240116Smarcel/* --------------------------------------------------------------------- 62240116Smarcel * Common error types. 63240116Smarcel * --------------------------------------------------------------------- */ 64240116Smarcel 65240116Smarcelatf_error_t atf_libc_error(int, const char *, ...); 66240116Smarcelint atf_libc_error_code(const atf_error_t); 67240116Smarcelconst char *atf_libc_error_msg(const atf_error_t); 68240116Smarcel 69240116Smarcelatf_error_t atf_no_memory_error(void); 70240116Smarcel 71240116Smarcel#endif /* ATF_C_ERROR_H */ 72