/src/os/windows/ftk_win32.h

http://ftk.googlecode.com/ · C Header · 113 lines · 62 code · 22 blank · 29 comment · 0 complexity · 476e8b9cc51768ca3cfdd2357bfada47 MD5 · raw file

  1. /*
  2. * File: ftk_win32.h
  3. * Author: Li XianJing <xianjimli@hotmail.com>
  4. * Brief: win32 specific functions.
  5. *
  6. * Copyright (c) 2009 - 2010 Li XianJing <xianjimli@hotmail.com>
  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. * 2009-11-22 Li XianJing <xianjimli@hotmail.com> created
  28. *
  29. */
  30. #ifndef FTK_WIN32_H
  31. #define FTK_WIN32_H
  32. #ifdef WIN32
  33. #define FTK_HAS_LOAD_LIBRARY 1
  34. #define _CRT_SECURE_NO_WARNINGS 1
  35. #define FTK_HAS_L
  36. #include <io.h>
  37. #include <time.h>
  38. #include <stdio.h>
  39. #include <windows.h>
  40. #include <sys/stat.h>
  41. #include <sys/types.h>
  42. #define HAVE_BOOLEAN
  43. #define inline
  44. char* ftk_get_root_dir(void);
  45. char* ftk_get_data_dir(void);
  46. char* ftk_get_testdata_dir(void);
  47. #define __func__ __FILE__
  48. #define FTK_ROOT_DIR ftk_get_root_dir()
  49. #define FTK_FONT "\\gb2312.fnt"
  50. #define DATA_DIR ftk_get_root_dir()
  51. #define LOCAL_DATA_DIR ftk_get_root_dir()
  52. #define FTK_DATA_ROOT ftk_get_data_dir()
  53. #define TESTDATA_DIR ftk_get_testdata_dir()
  54. #define _CRT_SECURE_NO_WARNINGS 1
  55. #define usleep Sleep
  56. #define ftk_getcwd _getcwd
  57. #define ftk_sscanf sscanf
  58. #define stat _stat
  59. #define strcasecmp _stricmp
  60. #define S_IFDIR _S_IFDIR
  61. #define S_IFREG _S_IFREG
  62. #define S_ISDIR(a) ((a) & S_IFDIR)
  63. struct dirent
  64. {
  65. unsigned char d_type;
  66. char d_name[256];
  67. };
  68. typedef struct _DIR
  69. {
  70. long handle;
  71. struct dirent dir;
  72. }DIR;
  73. #define rmdir _rmdir
  74. #define mkdir _mkdir
  75. #define chdir _chdir
  76. DIR *opendir(const char *name);
  77. struct dirent *readdir(DIR *dir);
  78. int closedir(DIR *dir);
  79. char* ftk_strncpy(char *dest, const char *src, size_t n);
  80. int ftk_snprintf(char *str, size_t size, const char *format, ...);
  81. int ftk_vsnprintf(char *str, size_t size, const char *format, va_list ap);
  82. size_t ftk_get_relative_time(void);
  83. int win32_socketpair(SOCKET socks[2]);
  84. #define ftk_pipe_pair(fds) win32_socketpair(fds)
  85. #define ftk_pipe_close(fd) closesocket(fd)
  86. #define ftk_pipe_recv(fd, buf, length) recv(fd, buf, length, 0)
  87. #define ftk_pipe_send(fd, buf, length) send(fd, buf, length, 0)
  88. #define FTK_PATH_DELIM '\\'
  89. #define USE_FTK_MAIN 1
  90. #endif
  91. #endif/*FTK_WIN32_H*/