error.h revision ef421f66f47224a42073deaf087378c5d0c9952e
e09cdbac087b88524ac40e943d040e2a032c48f2Mark Andrews/*
d3498432822fb487e58f8f72bb5f880dd8307d7dMichael Sawyer * Automated Testing Framework (atf)
6bb1560124ce99fe50b9847ce29fcaed52564900Automatic Updater *
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * All rights reserved.
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater *
d3498432822fb487e58f8f72bb5f880dd8307d7dMichael Sawyer * Redistribution and use in source and binary forms, with or without
d3498432822fb487e58f8f72bb5f880dd8307d7dMichael Sawyer * modification, are permitted provided that the following conditions
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * are met:
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * 1. Redistributions of source code must retain the above copyright
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * notice, this list of conditions and the following disclaimer.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * 2. Redistributions in binary form must reproduce the above copyright
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * notice, this list of conditions and the following disclaimer in the
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * documentation and/or other materials provided with the distribution.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews *
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
c73d8c1b72ddc3330cfc21e2070dffabca324bf7Mark Andrews * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
813d6c9781d1fb48bb5c1d6d3415e65f7be5eeb0Andreas Gustafsson * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
813d6c9781d1fb48bb5c1d6d3415e65f7be5eeb0Andreas Gustafsson * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
813d6c9781d1fb48bb5c1d6d3415e65f7be5eeb0Andreas Gustafsson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
e6e0dadd30fc794b4b75f36ab8d1edb074fd5babMichael Sawyer * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
e6e0dadd30fc794b4b75f36ab8d1edb074fd5babMichael Sawyer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson#if !defined(ATF_C_ERROR_H)
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson#define ATF_C_ERROR_H
02b4e9aef28c1e1d261f49f88a6cf389d117948bAndreas Gustafsson
e09cdbac087b88524ac40e943d040e2a032c48f2Mark Andrews#include <stdbool.h>
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt#include <stddef.h>
473ca0bf8c73e5fc3132df074b2d4e14be5eaa1eAndreas Gustafsson
553ead32ff5b00284e574dcabc39115d4d74ec66Evan Hunt#include <atf-c/error_fwd.h>
473ca0bf8c73e5fc3132df074b2d4e14be5eaa1eAndreas Gustafsson
d98372394fd6253336e9c9d580f48bd6ff9710f7Michael Sawyer/* ---------------------------------------------------------------------
c6d2578fd67bc1a427d13fd0699b25a187feec8aMark Andrews * The "atf_error" type.
c6d2578fd67bc1a427d13fd0699b25a187feec8aMark Andrews * --------------------------------------------------------------------- */
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstruct atf_error {
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson bool m_free;
2534a73a5914470f7ffe00663b6bbaff5e411e57Mark Andrews const char *m_type;
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson void *m_data;
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉 void (*m_format)(struct atf_error *, char *, size_t);
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉};
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉atf_error_t atf_error_new(const char *, void *, size_t,
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉 void (*)(const atf_error_t, char *, size_t));
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉void atf_error_free(atf_error_t);
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉atf_error_t atf_no_error(void);
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉bool atf_is_error(const atf_error_t);
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉bool atf_error_is(const atf_error_t, const char *);
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉const void *atf_error_data(const atf_error_t);
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉void atf_error_format(const atf_error_t, char *, size_t);
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉/* ---------------------------------------------------------------------
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉 * Common error types.
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉 * --------------------------------------------------------------------- */
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉atf_error_t atf_libc_error(int, const char *, ...);
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉int atf_libc_error_code(const atf_error_t);
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉const char *atf_libc_error_msg(const atf_error_t);
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉atf_error_t atf_no_memory_error(void);
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉#endif /* ATF_C_ERROR_H */
d8680445d6212d5552ea8a22fd2f9951b11c4b10Tatuya JINMEI 神明達哉