squareball 0.2.0.50-8649 A general-purpose library for C99

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

sb-error.h
Go to the documentation of this file.
1 /*
2 * squareball: A general-purpose library for C99.
3 * Copyright (C) 2014-2018 Rafael G. Martins <rafael@rafaelmartins.eng.br>
4 *
5 * This program can be distributed under the terms of the BSD License.
6 * See the file LICENSE.
7 */
8
9 #ifndef _SQUAREBALL_ERROR_H
10 #define _SQUAREBALL_ERROR_H
11
12 #include <stdarg.h>
13 #include <stdlib.h>
14 #include "sb-mem.h"
15
42 typedef char* (*sb_error_to_string_func_t) (void *data);
43
49 typedef struct {
50
54 const char *name;
55
59 sb_error_to_string_func_t to_string_func;
60
64 sb_free_func_t free_func;
65
66 } sb_error_type_t;
67
71 typedef struct _sb_error_t sb_error_t;
72
80 sb_error_t* sb_error_new_from_type(sb_error_type_t *type, void *data);
81
88 const char* sb_error_get_type_name(sb_error_t *err);
89
96 const void* sb_error_get_data(sb_error_t *err);
97
105 const char* sb_error_to_string(sb_error_t *err);
106
112 void sb_error_free(sb_error_t *err);
113
116 #endif /* _SQUAREBALL_ERROR_H */
sb_free_func_t
void(* sb_free_func_t)(void *ptr)
Definition: sb-mem.h:31
sb_error_get_data
const void * sb_error_get_data(sb_error_t *err)
sb_error_type_t::free_func
sb_free_func_t free_func
Definition: sb-error.h:64
sb_error_type_t::name
const char * name
Definition: sb-error.h:54
sb_error_get_type_name
const char * sb_error_get_type_name(sb_error_t *err)
sb_error_to_string_func_t
char *(* sb_error_to_string_func_t)(void *data)
Definition: sb-error.h:42
sb_error_free
void sb_error_free(sb_error_t *err)
sb-mem.h
Memory allocation related helpers.
sb_error_type_t
Definition: sb-error.h:49
sb_error_to_string
const char * sb_error_to_string(sb_error_t *err)
sb_error_type_t::to_string_func
sb_error_to_string_func_t to_string_func
Definition: sb-error.h:59
sb_error_new_from_type
sb_error_t * sb_error_new_from_type(sb_error_type_t *type, void *data)
sb_error_t
struct _sb_error_t sb_error_t
Definition: sb-error.h:71