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.

125 lines
3.7 KiB

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