libqi  1.14.5
qi/os.hpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012 Aldebaran Robotics. All rights reserved.
00003  * Use of this source code is governed by a BSD-style license that can be
00004  * found in the COPYING file.
00005  */
00006 
00007 /*
00008  * Various cross-platform OS related functions
00009  *
00010  * \note Every path taken in parameter MUST be encoded in UTF8.
00011  * \note Every path returned are encoded in UTF8.
00012  */
00013 
00014 #pragma once
00015 #ifndef _LIBQI_QI_OS_HPP_
00016 #define _LIBQI_QI_OS_HPP_
00017 
00018 # include <string>
00019 # include <map>
00020 # include <vector>
00021 # include <qi/config.hpp>
00022 
00023 struct stat;
00024 
00025 namespace qi {
00026 
00027   namespace os {
00028 
00029     QI_API FILE* fopen(const char *filename, const char *mode);
00030     QI_API int stat(const char *filename, struct stat *pstat);
00031     QI_API int checkdbg();
00032     QI_API std::string home();
00033     QI_API std::string mktmpdir(const char *prefix = "");
00034     QI_API std::string tmp();
00035     QI_API std::string gethostname();
00036 
00037     // env
00038     QI_API std::string getenv(const char *var);
00039     QI_API int setenv(const char *var, const char *value);
00040 
00041     // time
00042     QI_API void sleep(unsigned int seconds);
00043     QI_API void msleep(unsigned int milliseconds);
00044     struct QI_API timeval {
00045       long tv_sec;
00046       long tv_usec;
00047     };
00048     QI_API int gettimeofday(qi::os::timeval *tp);
00049 
00050     // shared library
00051     QI_API void *dlopen(const char *filename, int flag = -1);
00052     QI_API int dlclose(void *handle);
00053     QI_API void *dlsym(void *handle, const char *symbol);
00054     QI_API const char *dlerror(void);
00055 
00056     // process management
00057     QI_API int spawnvp(char *const argv[]);
00058     QI_API int spawnlp(const char* argv, ...);
00059     QI_API int system(const char *command);
00060     QI_API int getpid();
00061     QI_API int waitpid(int pid, int* status);
00062     QI_API int kill(int pid, int sig);
00063 
00064     QI_API unsigned short findAvailablePort(unsigned short port);
00065     QI_API bool hostIPAddrs(std::map<std::string, std::vector<std::string> >& ifsMap);
00066 
00067     //since 1.12.1
00068     QI_API_DEPRECATED QI_API std::string tmpdir(const char *prefix = "");
00069   }
00070 }
00071 
00072 
00073 #endif  // _LIBQI_QI_OS_HPP_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines