libqi  1.14
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
os.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Aldebaran Robotics. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the COPYING file.
5  */
6 
7 /*
8  * Various cross-platform OS related functions
9  *
10  * \note Every path taken in parameter MUST be encoded in UTF8.
11  * \note Every path returned are encoded in UTF8.
12  */
13 
14 #pragma once
15 #ifndef _LIBQI_QI_OS_HPP_
16 #define _LIBQI_QI_OS_HPP_
17 
18 # include <string>
19 # include <map>
20 # include <vector>
21 # include <qi/config.hpp>
22 
23 struct stat;
24 
25 namespace qi {
26 
27  namespace os {
28 
29  QI_API FILE* fopen(const char *filename, const char *mode);
30  QI_API int stat(const char *filename, struct stat *pstat);
31  QI_API int checkdbg();
32  QI_API std::string home();
33  QI_API std::string mktmpdir(const char *prefix = "");
34  QI_API std::string tmp();
35  QI_API std::string gethostname();
36 
37  // env
38  QI_API std::string getenv(const char *var);
39  QI_API int setenv(const char *var, const char *value);
40 
41  // time
42  QI_API void sleep(unsigned int seconds);
43  QI_API void msleep(unsigned int milliseconds);
44  struct QI_API timeval {
45  long tv_sec;
46  long tv_usec;
47  };
48  QI_API int gettimeofday(qi::os::timeval *tp);
49 
50  // shared library
51  QI_API void *dlopen(const char *filename, int flag = -1);
52  QI_API int dlclose(void *handle);
53  QI_API void *dlsym(void *handle, const char *symbol);
54  QI_API const char *dlerror(void);
55 
56  // process management
57  QI_API int spawnvp(char *const argv[]);
58  QI_API int spawnlp(const char* argv, ...);
59  QI_API int system(const char *command);
60  QI_API int getpid();
61  QI_API int waitpid(int pid, int* status);
62  QI_API int kill(int pid, int sig);
63 
64  QI_API unsigned short findAvailablePort(unsigned short port);
65  QI_API bool hostIPAddrs(std::map<std::string, std::vector<std::string> >& ifsMap);
66 
67  //since 1.12.1
68  QI_API_DEPRECATED QI_API std::string tmpdir(const char *prefix = "");
69  }
70 }
71 
72 
73 #endif // _LIBQI_QI_OS_HPP_