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.

89 lines
2.6 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
7 years ago
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __BASIC_FUNCTIONALITY_HEADER__
  2. #define __BASIC_FUNCTIONALITY_HEADER__
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <sys/types.h>
  6. #include <time.h>
  7. #include "basicTypes.h"
  8. #ifdef __linux__
  9. #include <ifaddrs.h>
  10. #include <sys/socket.h>
  11. #include <netinet/in.h>
  12. #include <arpa/inet.h>
  13. #include <sys/statvfs.h>
  14. #include "basicBuildTimeStamp.h"
  15. #else
  16. //#include <winsock2.h>
  17. //#include <ws2tcpip.h>
  18. #define WIN32_LEAN_AND_MEAN
  19. #include <atlbase.h>
  20. #include <windows.h>
  21. #include <VersionHelpers.h>
  22. #include <dshow.h>
  23. #endif
  24. bool fileExist( const char *strFilename );
  25. CSTR trim( CSTR string );
  26. uint8_t checksum8( uint8_t *Buffer, size_t BufferSize );
  27. uint16_t checksum16( uint8_t *Buffer, size_t BufferSize );
  28. uint8_t checksumLGS( uint8_t *Buffer, size_t BufferSize );
  29. CArray * explode( char Delim, CSTR S_Str );
  30. CSTR implode( CArray *Data, CSTR S_Str, U8 Start, U8 End );
  31. CSTR getTStr( CSTR Fmt = NULL );
  32. #ifdef __linux__
  33. inline PF_TIMESTAMP * getPFTS( PF_TIMESTAMP * ptr = NULL ){
  34. struct timeval tData;
  35. struct timezone tTZ;
  36. if( ptr == NULL ) {
  37. PF_TIMESTAMP *retVal;
  38. retVal = (PF_TIMESTAMP *) malloc(sizeof(PF_TIMESTAMP));
  39. if( retVal != NULL ) {
  40. if( gettimeofday( &tData, &tTZ ) == -1 ){
  41. free(retVal);
  42. retVal = NULL;
  43. } else {
  44. retVal->seconds = tData.tv_sec;
  45. retVal->milliseconds = ( tData.tv_usec / 1000 );
  46. };
  47. };
  48. return retVal;
  49. } else {
  50. if( gettimeofday( &tData, &tTZ ) == -1 ){
  51. ptr->seconds = 0;
  52. ptr->milliseconds = 0;
  53. } else {
  54. ptr->seconds = tData.tv_sec;
  55. ptr->milliseconds = ( tData.tv_usec / 1000 );
  56. };
  57. return ptr;
  58. };
  59. };
  60. pid_t gettid( void );
  61. #define SLEEP(X) usleep(X*1000)
  62. long long getMilliseconds( void );
  63. #else
  64. #ifndef WIN_XP
  65. #include <VersionHelpers.h>
  66. #endif
  67. #define SLEEP(X) Sleep(X)
  68. unsigned __int64 getMilliseconds( void );
  69. #endif
  70. int getIP4( if_info **arrParam, int max_ifs = 10 );
  71. #ifdef __linux__
  72. long long getTotalSpace( CSTR DirName );
  73. long long getFreeSpace( CSTR DirName );
  74. bool enumerateDevices( enumeratorInfo *mlist, const char *dTemplate = "video" );
  75. #else
  76. __int64 getTotalSpace( CSTR DirName );
  77. __int64 getFreeSpace( CSTR DirName );
  78. bool enumerateDevices(enumeratorInfo *mlist, REFGUID category);
  79. #endif
  80. localIpAddresses *getLocalIP();
  81. #endif