utils.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. utils.h -- header file for utils.c
  3. Copyright (C) 1999-2005 Ivo Timmermans <zarq@iname.com>
  4. 2000-2006 Guus Sliepen <guus@tinc-vpn.org>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17. #ifndef __TINC_UTILS_H__
  18. #define __TINC_UTILS_H__
  19. #ifdef ENABLE_TRACING
  20. extern volatile int cp_line[];
  21. extern volatile char *cp_file[];
  22. extern volatile int cp_index;
  23. extern void cp_trace(void);
  24. #define cp() { cp_line[cp_index] = __LINE__; cp_file[cp_index] = __FILE__; cp_index++; cp_index %= 16; }
  25. #define ecp() { fprintf(stderr, "Explicit checkpoint in %s line %d\n", __FILE__, __LINE__); }
  26. #else
  27. #define cp()
  28. #define ecp()
  29. #define cp_trace()
  30. #endif
  31. extern void hex2bin(char *src, char *dst, int length);
  32. extern void bin2hex(char *src, char *dst, int length);
  33. #ifdef HAVE_MINGW
  34. extern char *winerror(int);
  35. #define strerror(x) ((x)>0?strerror(x):winerror(GetLastError()))
  36. #endif
  37. #endif /* __TINC_UTILS_H__ */