You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.5KB

  1. /*
  2. * Various utilities for ffmpeg system
  3. * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  4. * copyright (c) 2002 Francois Revol
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include "config.h"
  23. #include "avformat.h"
  24. #if defined(CONFIG_WINCE)
  25. /* Skip includes on WinCE. */
  26. #elif defined(__MINGW32__)
  27. #include <sys/types.h>
  28. #include <sys/timeb.h>
  29. #elif defined(CONFIG_OS2)
  30. #include <string.h>
  31. #include <sys/time.h>
  32. #else
  33. #include <unistd.h>
  34. #include <fcntl.h>
  35. #include <sys/time.h>
  36. #endif
  37. #include <time.h>
  38. #include <stdlib.h>
  39. #include <strings.h>
  40. #include "barpainet.h"
  41. /**
  42. * gets the current time in micro seconds.
  43. */
  44. int64_t av_gettime(void)
  45. {
  46. #if defined(CONFIG_WINCE)
  47. return timeGetTime() * int64_t_C(1000);
  48. #elif defined(__MINGW32__)
  49. struct timeb tb;
  50. _ftime(&tb);
  51. return ((int64_t)tb.time * int64_t_C(1000) + (int64_t)tb.millitm) * int64_t_C(1000);
  52. #else
  53. struct timeval tv;
  54. gettimeofday(&tv,NULL);
  55. return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
  56. #endif
  57. }
  58. #if !defined(CONFIG_WINCE) && !defined(HAVE_LOCALTIME_R)
  59. struct tm *localtime_r(const time_t *t, struct tm *tp)
  60. {
  61. struct tm *l;
  62. l = localtime(t);
  63. if (!l)
  64. return 0;
  65. *tp = *l;
  66. return tp;
  67. }
  68. #endif /* !defined(CONFIG_WINCE) && !defined(HAVE_LOCALTIME_R) */
  69. #if !defined(HAVE_INET_ATON)
  70. int inet_aton (const char * str, struct in_addr * add)
  71. {
  72. const char * pch = str;
  73. unsigned int add1 = 0, add2 = 0, add3 = 0, add4 = 0;
  74. add1 = atoi(pch);
  75. pch = strpbrk(pch,".");
  76. if (pch == 0 || ++pch == 0) goto done;
  77. add2 = atoi(pch);
  78. pch = strpbrk(pch,".");
  79. if (pch == 0 || ++pch == 0) goto done;
  80. add3 = atoi(pch);
  81. pch = strpbrk(pch,".");
  82. if (pch == 0 || ++pch == 0) goto done;
  83. add4 = atoi(pch);
  84. done:
  85. add->s_addr=(add4<<24)+(add3<<16)+(add2<<8)+add1;
  86. return 1;
  87. }
  88. #endif /* !defined HAVE_INET_ATON */