/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. * History:
  26. * ================================================================
  27. * 2008-12-10 Li XianJing <xianjimli@hotmail.com> created.
  28. *
  29. */
  30. #include <stdio.h>
  31. #include <assert.h>
  32. #include <stdlib.h>
  33. #include <string.h>
  34. #include <unistd.h>
  35. #ifndef TYPEDEF_H
  36. #define TYPEDEF_H
  37. typedef enum _Ret
  38. {
  39. RET_OK,
  40. RET_OOM,
  41. RET_STOP,
  42. RET_FOUND,
  43. RET_INVALID_PARAMS,
  44. RET_FAIL
  45. }Ret;
  46. typedef void (*DataDestroyFunc)(void* ctx, void* data);
  47. typedef int (*DataCompareFunc)(void* ctx, void* data);
  48. typedef Ret (*DataVisitFunc)(void* ctx, void* data);
  49. typedef int (*DataHashFunc)(void* data);
  50. #ifdef __cplusplus
  51. #define DECLS_BEGIN extern "C" {
  52. #define DECLS_END }
  53. #else
  54. #define DECLS_BEGIN
  55. #define DECLS_END
  56. #endif/*__cplusplus*/
  57. #define return_if_fail(p) if(!(p)) \
  58. {printf("%s:%d Warning: "#p" failed.\n", \
  59. __func__, __LINE__); return;}
  60. #define return_val_if_fail(p, ret) if(!(p)) \
  61. {printf("%s:%d Warning: "#p" failed.\n",\
  62. __func__, __LINE__); return (ret);}
  63. #define SAFE_FREE(p) if(p != NULL) {free(p); p = NULL;}
  64. typedef Ret (*SortFunc)(void** array, size_t nr, DataCompareFunc cmp);
  65. #define ftk_strncpy strncpy
  66. #endif/*TYPEDEF_H*/