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.

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