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.6KB

  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. /**
  39. * gets the current time in micro seconds.
  40. */
  41. int64_t av_gettime(void)
  42. {
  43. #if defined(CONFIG_WINCE)
  44. return timeGetTime() * INT64_C(1000);
  45. #elif defined(__MINGW32__)
  46. struct timeb tb;
  47. _ftime(&tb);
  48. return ((int64_t)tb.time * INT64_C(1000) + (int64_t)tb.millitm) * INT64_C(1000);
  49. #else
  50. struct timeval tv;
  51. gettimeofday(&tv,NULL);
  52. return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
  53. #endif
  54. }
  55. #if !defined(CONFIG_WINCE) && !defined(HAVE_LOCALTIME_R)
  56. struct tm *localtime_r(const time_t *t, struct tm *tp)
  57. {
  58. struct tm *l;
  59. l = localtime(t);
  60. if (!l)
  61. return 0;
  62. *tp = *l;
  63. return tp;
  64. }
  65. #endif /* !defined(CONFIG_WINCE) && !defined(HAVE_LOCALTIME_R) */
  66. #if !defined(HAVE_INET_ATON) && defined(CONFIG_NETWORK)
  67. #include <stdlib.h>
  68. #include <strings.h>
  69. #include "barpainet.h"
  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) && defined(CONFIG_NETWORK) */