OS.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00019 #ifndef COIL_OS_H
00020 #define COIL_OS_H
00021 
00022 #include <string>
00023 #include <sys/utsname.h>
00024 #include <sys/types.h> 
00025 #include <unistd.h> 
00026 #include <stdlib.h>
00027 
00028 extern "C"
00029 {
00030   extern char *optarg;
00031 };
00032 
00033 namespace coil
00034 {
00058   typedef ::utsname utsname;
00059   inline int uname(utsname* name)
00060   {
00061     return ::uname(name);
00062   }
00063 
00083   typedef ::pid_t pid_t;
00084   inline pid_t getpid()
00085   {
00086     return ::getpid();
00087   }
00088 
00108   inline pid_t getppid()
00109   {
00110     return ::getppid();
00111   }
00112 
00136   inline char* getenv(const char *name)
00137   {
00138     return ::getenv(name);
00139   }
00140 
00141 
00142   /* Global Variables for getopt() */
00143 
00157   class GetOpt
00158   {
00159   public:
00179     GetOpt(int argc, char* const argv[], const char* opt, int flag)
00180       : optarg(::optarg), optind(1), opterr(1), optopt(0), m_argc(argc), m_argv(argv), m_opt(opt), m_flag(flag)
00181     {
00182       ::optind = 1;
00183     }
00184 
00200     ~GetOpt()
00201     {
00202       ::optind = 1;
00203     }
00204 
00224     int operator()()
00225     {
00226       ::opterr = opterr;
00227       ::optind = optind;
00228 
00229       int result = getopt(m_argc, m_argv, m_opt);
00230 
00231       optarg = ::optarg;
00232       optind = ::optind;
00233       optopt = ::optopt;
00234 
00235       return result;
00236     }
00237 
00238     char* optarg;     
00239     int optind;       
00240     int opterr;       
00241     int optopt;       
00242 
00243   private:
00244     int m_argc;
00245     char* const * m_argv;
00246     const char* m_opt;
00247     int m_flag;
00248   };
00249     
00250 };
00251 
00252 #endif // COIL_OS_H


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sun Mar 26 2017 03:37:16