PageRenderTime 298ms CodeModel.GetById 180ms app.highlight 10ms RepoModel.GetById 102ms app.codeStats 0ms

/tools/fontextract/typedef.h

http://ftk.googlecode.com/
C++ Header | 75 lines | 37 code | 9 blank | 29 comment | 4 complexity | cb9b9239ee08151385d8ebe903c88327 MD5 | raw file
 1/*
 2 * File:    typedef.h
 3 * Author:  Li XianJing <xianjimli@hotmail.com>
 4 * Brief:   common types definition.
 5 *
 6 * Copyright (c) Li XianJing
 7 *
 8 * Licensed under the Academic Free License version 2.1
 9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 */
24
25/*
26 * History:
27 * ================================================================
28 * 2008-12-10 Li XianJing <xianjimli@hotmail.com> created.
29 *
30 */
31
32#include <stdio.h>
33#include <assert.h>
34#include <stdlib.h>
35#include <string.h>
36#include <unistd.h>
37#ifndef TYPEDEF_H
38#define TYPEDEF_H
39
40typedef enum _Ret
41{
42	RET_OK,
43	RET_OOM,
44	RET_STOP,
45	RET_FOUND,
46	RET_INVALID_PARAMS,
47	RET_FAIL
48}Ret;
49
50typedef void     (*DataDestroyFunc)(void* ctx, void* data);
51typedef int      (*DataCompareFunc)(void* ctx, void* data);
52typedef Ret      (*DataVisitFunc)(void* ctx, void* data);
53typedef int       (*DataHashFunc)(void* data);
54
55#ifdef __cplusplus
56#define DECLS_BEGIN extern "C" {
57#define DECLS_END   }
58#else
59#define DECLS_BEGIN
60#define DECLS_END
61#endif/*__cplusplus*/
62
63#define return_if_fail(p) if(!(p)) \
64	{printf("%s:%d Warning: "#p" failed.\n", \
65		__func__, __LINE__); return;}
66#define return_val_if_fail(p, ret) if(!(p)) \
67	{printf("%s:%d Warning: "#p" failed.\n",\
68	__func__, __LINE__); return (ret);}
69
70#define SAFE_FREE(p) if(p != NULL) {free(p); p = NULL;}
71
72typedef Ret (*SortFunc)(void** array, size_t nr, DataCompareFunc cmp);
73#define ftk_strncpy strncpy
74#endif/*TYPEDEF_H*/
75