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.

107 lines
3.2 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(void);
  37. CSTR strReplace( CSTR orig, CSTR rep, CSTR with );
  38. //#define EPOCH_DIFF 11644473600LL
  39. #define UNIX_TimeStamp_2_WINDOWS_FileTime_SHIFT 116444736000000000
  40. #ifdef __linux__
  41. unsigned long long getSHTimeValue( void );
  42. #else
  43. unsigned __int64 getSHTimeValue( void );
  44. #endif
  45. CSTR getSHDTimeStamp(void);
  46. #ifdef __linux__
  47. inline PF_TIMESTAMP * getPFTS( PF_TIMESTAMP * ptr = NULL ){
  48. struct timeval tData;
  49. struct timezone tTZ;
  50. if( ptr == NULL ) {
  51. PF_TIMESTAMP *retVal;
  52. retVal = (PF_TIMESTAMP *) malloc(sizeof(PF_TIMESTAMP));
  53. if( retVal != NULL ) {
  54. if( gettimeofday( &tData, &tTZ ) == -1 ){
  55. free(retVal);
  56. retVal = NULL;
  57. } else {
  58. retVal->seconds = tData.tv_sec;
  59. retVal->milliseconds = ( tData.tv_usec / 1000 );
  60. };
  61. };
  62. return retVal;
  63. } else {
  64. if( gettimeofday( &tData, &tTZ ) == -1 ){
  65. ptr->seconds = 0;
  66. ptr->milliseconds = 0;
  67. } else {
  68. ptr->seconds = tData.tv_sec;
  69. ptr->milliseconds = ( tData.tv_usec / 1000 );
  70. };
  71. return ptr;
  72. };
  73. };
  74. pid_t gettid( void );
  75. #define SLEEP(X) usleep(X*1000)
  76. long long getMilliseconds( void );
  77. #else
  78. #ifndef WIN_XP
  79. #include <VersionHelpers.h>
  80. #endif
  81. #define SLEEP(X) Sleep(X)
  82. unsigned __int64 getMilliseconds( void );
  83. #endif
  84. int getIP4( if_info **arrParam, int max_ifs = 10 );
  85. #ifdef __linux__
  86. long long getTotalSpace( CSTR DirName );
  87. long long getFreeSpace( CSTR DirName );
  88. bool enumerateDevices( enumeratorInfo *mlist, const char *dTemplate = "video" );
  89. #else
  90. __int64 getTotalSpace( CSTR DirName );
  91. __int64 getFreeSpace( CSTR DirName );
  92. bool enumerateDevices(enumeratorInfo *mlist, REFGUID category);
  93. #endif
  94. localIpAddresses *getLocalIP();
  95. #endif