1 /** ************************************************************************* 2 \fn ADM_misc.h 3 \brief Handle string/log/... related functions 4 5 copyright : (C) 2008 by mean 6 7 ***************************************************************************/ 8 9 #ifndef ADM_MISC_H 10 #define ADM_MISC_H 11 12 #include "ADM_core6_export.h" 13 #include "ADM_coreConfig.h" 14 #include "ADM_inttype.h" 15 #include <string> 16 17 typedef struct 18 { 19 uint32_t hours,minutes,seconds; 20 } ADM_date; 21 22 ADM_CORE6_EXPORT const ADM_date ADM_getCurrentDate(); 23 // /dir/file.ext -> /dir/file and ext returned values are copies 24 ADM_CORE6_EXPORT void ADM_PathSplit(const std::string &in,std::string &root, std::string &ext); 25 // Returns path only /foo/bar.avi -> /foo , INPLACE! 26 ADM_CORE6_EXPORT std::string ADM_extractPath(const std::string &str); 27 // Get the filename without path. /foo/bar.avi -> bar.avi 28 ADM_CORE6_EXPORT const std::string ADM_getFileName(const std::string &str); 29 // Canonize the path, returns a copy of the absolute path given as parameter 30 ADM_CORE6_EXPORT char *ADM_PathCanonize(const char *tmpname); 31 // change to lower case in place the string 32 ADM_CORE6_EXPORT void ADM_lowerCase(std::string &st); 33 // 34 ADM_CORE6_EXPORT uint64_t ADM_getSecondsSinceEpoch(void); 35 ADM_CORE6_EXPORT const char *ADM_epochToString(uint64_t epoch); 36 ADM_CORE6_EXPORT const std::string &ADM_getTimeDateAsString(const char *format=NULL); 37 38 #ifdef HAVE_GETTIMEOFDAY 39 #include <sys/time.h> 40 41 #define TIMZ struct timezone 42 #else 43 # ifdef _WIN32 44 # include <WinSock.h> 45 # endif 46 47 # ifndef HAVE_STRUCT_TIMESPEC 48 # define HAVE_STRUCT_TIMESPEC 49 50 # ifndef _TIMESPEC_DEFINED 51 # define _TIMESPEC_DEFINED 52 #ifndef _MSC_VER 53 54 extern "C" 55 { 56 typedef struct timespec 57 { 58 time_t tv_sec; 59 long int tv_nsec; 60 }; 61 }; 62 #endif 63 # endif 64 65 # define TIMZ int 66 # endif 67 68 extern "C" void gettimeofday(struct timeval *p, TIMZ *tz); 69 #endif 70 71 #ifdef _WIN32 72 #define PRIO_MIN -20 73 #define PRIO_MAX 20 74 #define PRIO_PROCESS 0 75 76 ADM_CORE6_EXPORT int getpriority(int which, int who); 77 ADM_CORE6_EXPORT int setpriority(int which, int who, int value); 78 #else 79 #include <sys/resource.h> 80 #endif 81 82 ADM_CORE6_EXPORT bool ADM_shutdown(void); 83 84 #ifdef ADM_BIG_ENDIAN 85 #define R64 ADM_swap64 86 #define R32 ADM_swap32 87 #define R16 ADM_swap16 88 #else 89 #define R64(x) (x) 90 #define R32(x) (x) 91 #define R16(x) (x) 92 #endif 93 #endif 94