libqi-api
2.0.6.8
|
00001 #pragma once 00002 /* 00003 * Copyright (c) 2012, 2013 Aldebaran Robotics. All rights reserved. 00004 * Use of this source code is governed by a BSD-style license that can be 00005 * found in the COPYING file. 00006 */ 00007 00008 #ifndef _QI_OS_HPP_ 00009 #define _QI_OS_HPP_ 00010 00011 # include <cstdio> 00012 # include <string> 00013 # include <map> 00014 # include <vector> 00015 # include <qi/api.hpp> 00016 # include <qi/types.hpp> 00017 00018 struct stat; 00019 00020 namespace qi { 00021 00022 namespace os { 00023 00024 QI_API FILE* fopen(const char *filename, const char *mode); 00025 QI_API int stat(const char *filename, struct stat *pstat); 00026 QI_API int checkdbg(); 00027 QI_API std::string home(); 00028 QI_API std::string mktmpdir(const char *prefix = ""); 00029 QI_API std::string tmp(); 00030 QI_API std::string gethostname(); 00031 QI_API int isatty(int fd = 1); 00032 00036 QI_API bool fnmatch(const std::string &pattern, const std::string &string); 00037 00038 // lib C 00039 QI_API char* strdup(const char *src); 00040 QI_API int snprintf(char *str, size_t size, const char *format, ...); 00041 00042 // env 00043 QI_API std::string getenv(const char *var); 00044 QI_API int setenv(const char *var, const char *value); 00045 QI_API std::string timezone(); 00046 00047 // time 00048 QI_API void sleep(unsigned int seconds); 00049 QI_API void msleep(unsigned int milliseconds); 00050 struct QI_API timeval { 00051 qi::int64_t tv_sec; 00052 qi::int64_t tv_usec; 00053 }; 00054 QI_API int gettimeofday(qi::os::timeval *tp); 00055 QI_API qi::int64_t ustime(); 00056 QI_API std::pair<int64_t, int64_t> cputime(); 00057 00058 QI_API qi::os::timeval operator+(const qi::os::timeval &lhs, 00059 const qi::os::timeval &rhs); 00060 QI_API qi::os::timeval operator+(const qi::os::timeval &lhs, 00061 long us); 00062 QI_API qi::os::timeval operator-(const qi::os::timeval &lhs, 00063 const qi::os::timeval &rhs); 00064 QI_API qi::os::timeval operator-(const qi::os::timeval &lhs, 00065 long us); 00066 00067 // shared library 00068 QI_API void *dlopen(const char *filename, int flag = -1); 00069 QI_API int dlclose(void *handle); 00070 QI_API void *dlsym(void *handle, const char *symbol); 00071 QI_API const char *dlerror(void); 00072 00073 // process management 00074 QI_API int spawnvp(char *const argv[]); 00075 QI_API int spawnlp(const char* argv, ...); 00076 QI_API int system(const char *command); 00077 QI_API int getpid(); 00078 QI_API int gettid(); 00079 QI_API int waitpid(int pid, int* status); 00080 QI_API int kill(int pid, int sig); 00081 00082 QI_API unsigned short findAvailablePort(unsigned short port); 00083 QI_API std::map<std::string, std::vector<std::string> > hostIPAddrs(bool ipv6Addr = false); 00084 00085 QI_API void setCurrentThreadName(const std::string &name); 00086 QI_API std::string currentThreadName(); 00087 QI_API bool setCurrentThreadCPUAffinity(const std::vector<int> &cpus); 00088 QI_API long numberOfCPUs(); 00089 QI_API std::string getMachineId(); 00090 QI_API std::string generateUuid(); 00091 // in kB 00092 QI_API size_t memoryUsage(unsigned int pid); 00093 00094 //since 1.12.1 00095 QI_API_DEPRECATED QI_API std::string tmpdir(const char *prefix = ""); 00096 } 00097 } 00098 00099 00100 #endif // _QI_OS_HPP_