summaryrefslogtreecommitdiff
path: root/include/hubbub/functypes.h
blob: 021c403c93b2fc359baaa99926ce4ca90dbe9664 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * This file is part of Hubbub.
 * Licensed under the MIT License,
 *                http://www.opensource.org/licenses/mit-license.php
 * Copyright 2007-8 John-Mark Bell <jmb@netsurf-browser.org>
 */

#ifndef hubbub_functypes_h_
#define hubbub_functypes_h_

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

#include <hubbub/types.h>

/**
 * Type of allocation function for hubbub 
 *
 * The semantics of this function are the same as for realloc().
 *
 * \param ptr   Pointer to object to reallocate, or NULL for a new allocation
 * \param size  Required length in bytes, or zero to free ::ptr
 * \param pw    Pointer to client data
 * \return Pointer to allocated object, or NULL on failure
 */
typedef void *(*hubbub_allocator_fn)(void *ptr, size_t size, void *pw);

/**
 * Type of token handling function
 *
 * \param token  Pointer to token to handle
 * \param pw     Pointer to client data
 * \return HUBBUB_OK on success, appropriate error otherwise.
 */
typedef hubbub_error (*hubbub_token_handler)(
		const hubbub_token *token, void *pw);

/**
 * Type of parse error handling function
 *
 * \param line     Source line on which error occurred
 * \param col      Column in ::line of start of erroneous input
 * \param message  Error message
 * \param pw       Pointer to client data
 */
typedef void (*hubbub_error_handler)(uint32_t line, uint32_t col,
		const char *message, void *pw);

#endif