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.

110 lines
3.3 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 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. #ifndef WIN32_LEAN_AND_MEAN
  19. #define WIN32_LEAN_AND_MEAN
  20. #endif
  21. #include <atlbase.h>
  22. #include <windows.h>
  23. #include <VersionHelpers.h>
  24. #include <dshow.h>
  25. #endif
  26. bool fileExist( const char *strFilename );
  27. CSTR trim( CSTR string );
  28. uint8_t checksum8( uint8_t *Buffer, size_t BufferSize );
  29. uint16_t checksum16( uint8_t *Buffer, size_t BufferSize );
  30. uint8_t checksumLGS( uint8_t *Buffer, size_t BufferSize );
  31. CArray * explode( char Delim, CSTR S_Str );
  32. CSTR implode( CArray *Data, CSTR S_Str, U8 Start, U8 End );
  33. CSTR getTStr( CSTR Fmt = NULL );
  34. CSTR getUniqID_SHA256(void);
  35. CSTR getUniqID_MD5(void);
  36. CSTR getUniqID_UUID( uint32_t SEED = 0);
  37. CSTR strReplace( CSTR orig, CSTR rep, CSTR with );
  38. //#define EPOCH_DIFF 11644473600LL
  39. #define UNIX_TimeStamp_2_WINDOWS_FileTime_SHIFT 116444736000000000
  40. bool correctSysTime( int diff );
  41. bool correctSoftTime( int diff );
  42. #ifdef __linux__
  43. unsigned long long getTimeValue( void );
  44. #else
  45. unsigned __int64 getTimeValue( void );
  46. #endif
  47. CSTR getTimeStamp(void);
  48. #ifdef __linux__
  49. inline PF_TIMESTAMP * getPFTS( PF_TIMESTAMP * ptr = NULL ){
  50. struct timeval tData;
  51. struct timezone tTZ;
  52. if( ptr == NULL ) {
  53. PF_TIMESTAMP *retVal;
  54. retVal = (PF_TIMESTAMP *) malloc(sizeof(PF_TIMESTAMP));
  55. if( retVal != NULL ) {
  56. if( gettimeofday( &tData, &tTZ ) == -1 ){
  57. free(retVal);
  58. retVal = NULL;
  59. } else {
  60. retVal->seconds = tData.tv_sec;
  61. retVal->milliseconds = ( tData.tv_usec / 1000 );
  62. };
  63. };
  64. return retVal;
  65. } else {
  66. if( gettimeofday( &tData, &tTZ ) == -1 ){
  67. ptr->seconds = 0;
  68. ptr->milliseconds = 0;
  69. } else {
  70. ptr->seconds = tData.tv_sec;
  71. ptr->milliseconds = ( tData.tv_usec / 1000 );
  72. };
  73. return ptr;
  74. };
  75. };
  76. pid_t gettid( void );
  77. #define SLEEP(X) usleep(X*1000)
  78. long long getMilliseconds( void );
  79. #else
  80. #ifndef WIN_XP
  81. #include <VersionHelpers.h>
  82. #endif
  83. #define SLEEP(X) Sleep(X)
  84. unsigned __int64 getMilliseconds( void );
  85. #endif
  86. int getIP4( if_info **arrParam, int max_ifs = 10 );
  87. #ifdef __linux__
  88. long long getTotalSpace( CSTR DirName );
  89. long long getFreeSpace( CSTR DirName );
  90. bool enumerateDevices( enumeratorInfo *mlist, const char *dTemplate = "video" );
  91. #else
  92. __int64 getTotalSpace( CSTR DirName );
  93. __int64 getFreeSpace( CSTR DirName );
  94. bool enumerateDevices(enumeratorInfo *mlist, REFGUID category);
  95. #endif
  96. localIpAddresses *getLocalIP();
  97. #endif