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.

123 lines
3.7 KiB

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