13925e856SFilipe David Borba Manana/*
23925e856SFilipe David Borba Manana * Copyright 2010, Lloyd Hilaiel.
33925e856SFilipe David Borba Manana *
43925e856SFilipe David Borba Manana * Redistribution and use in source and binary forms, with or without
53925e856SFilipe David Borba Manana * modification, are permitted provided that the following conditions are
63925e856SFilipe David Borba Manana * met:
73925e856SFilipe David Borba Manana *
83925e856SFilipe David Borba Manana *  1. Redistributions of source code must retain the above copyright
93925e856SFilipe David Borba Manana *     notice, this list of conditions and the following disclaimer.
103925e856SFilipe David Borba Manana *
113925e856SFilipe David Borba Manana *  2. Redistributions in binary form must reproduce the above copyright
123925e856SFilipe David Borba Manana *     notice, this list of conditions and the following disclaimer in
133925e856SFilipe David Borba Manana *     the documentation and/or other materials provided with the
143925e856SFilipe David Borba Manana *     distribution.
153925e856SFilipe David Borba Manana *
163925e856SFilipe David Borba Manana *  3. Neither the name of Lloyd Hilaiel nor the names of its
173925e856SFilipe David Borba Manana *     contributors may be used to endorse or promote products derived
183925e856SFilipe David Borba Manana *     from this software without specific prior written permission.
193925e856SFilipe David Borba Manana *
203925e856SFilipe David Borba Manana * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
213925e856SFilipe David Borba Manana * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
223925e856SFilipe David Borba Manana * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
233925e856SFilipe David Borba Manana * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
243925e856SFilipe David Borba Manana * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
253925e856SFilipe David Borba Manana * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
263925e856SFilipe David Borba Manana * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
273925e856SFilipe David Borba Manana * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
283925e856SFilipe David Borba Manana * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
293925e856SFilipe David Borba Manana * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
303925e856SFilipe David Borba Manana * POSSIBILITY OF SUCH DAMAGE.
313925e856SFilipe David Borba Manana */
323925e856SFilipe David Borba Manana
333925e856SFilipe David Borba Manana#ifndef __YAJL_COMMON_H__
343925e856SFilipe David Borba Manana#define __YAJL_COMMON_H__
353925e856SFilipe David Borba Manana
363925e856SFilipe David Borba Manana#ifdef __cplusplus
373925e856SFilipe David Borba Mananaextern "C" {
383925e856SFilipe David Borba Manana#endif
393925e856SFilipe David Borba Manana
403925e856SFilipe David Borba Manana#define YAJL_MAX_DEPTH 128
413925e856SFilipe David Borba Manana
423925e856SFilipe David Borba Manana/* msft dll export gunk.  To build a DLL on windows, you
433925e856SFilipe David Borba Manana * must define WIN32, YAJL_SHARED, and YAJL_BUILD.  To use a shared
443925e856SFilipe David Borba Manana * DLL, you must define YAJL_SHARED and WIN32 */
453925e856SFilipe David Borba Manana#if defined(WIN32) && defined(YAJL_SHARED)
463925e856SFilipe David Borba Manana#  ifdef YAJL_BUILD
473925e856SFilipe David Borba Manana#    define YAJL_API __declspec(dllexport)
483925e856SFilipe David Borba Manana#  else
493925e856SFilipe David Borba Manana#    define YAJL_API __declspec(dllimport)
503925e856SFilipe David Borba Manana#  endif
513925e856SFilipe David Borba Manana#else
523925e856SFilipe David Borba Manana#  define YAJL_API
533925e856SFilipe David Borba Manana#endif
543925e856SFilipe David Borba Manana
553925e856SFilipe David Borba Manana/** pointer to a malloc function, supporting client overriding memory
563925e856SFilipe David Borba Manana *  allocation routines */
573925e856SFilipe David Borba Mananatypedef void * (*yajl_malloc_func)(void *ctx, unsigned int sz);
583925e856SFilipe David Borba Manana
593925e856SFilipe David Borba Manana/** pointer to a free function, supporting client overriding memory
603925e856SFilipe David Borba Manana *  allocation routines */
613925e856SFilipe David Borba Mananatypedef void (*yajl_free_func)(void *ctx, void * ptr);
623925e856SFilipe David Borba Manana
633925e856SFilipe David Borba Manana/** pointer to a realloc function which can resize an allocation. */
643925e856SFilipe David Borba Mananatypedef void * (*yajl_realloc_func)(void *ctx, void * ptr, unsigned int sz);
653925e856SFilipe David Borba Manana
663925e856SFilipe David Borba Manana/** A structure which can be passed to yajl_*_alloc routines to allow the
673925e856SFilipe David Borba Manana *  client to specify memory allocation functions to be used. */
683925e856SFilipe David Borba Mananatypedef struct
693925e856SFilipe David Borba Manana{
703925e856SFilipe David Borba Manana    /** pointer to a function that can allocate uninitialized memory */
713925e856SFilipe David Borba Manana    yajl_malloc_func malloc;
723925e856SFilipe David Borba Manana    /** pointer to a function that can resize memory allocations */
733925e856SFilipe David Borba Manana    yajl_realloc_func realloc;
743925e856SFilipe David Borba Manana    /** pointer to a function that can free memory allocated using
753925e856SFilipe David Borba Manana     *  reallocFunction or mallocFunction */
763925e856SFilipe David Borba Manana    yajl_free_func free;
773925e856SFilipe David Borba Manana    /** a context pointer that will be passed to above allocation routines */
783925e856SFilipe David Borba Manana    void * ctx;
793925e856SFilipe David Borba Manana} yajl_alloc_funcs;
803925e856SFilipe David Borba Manana
813925e856SFilipe David Borba Manana#ifdef __cplusplus
823925e856SFilipe David Borba Manana}
833925e856SFilipe David Borba Manana#endif
843925e856SFilipe David Borba Manana
853925e856SFilipe David Borba Manana#endif
86