posix/coil/OS.h
Go to the documentation of this file.
1 // -*- C++ -*-
19 #ifndef COIL_OS_H
20 #define COIL_OS_H
21 
22 #include <string>
23 #include <sys/utsname.h>
24 #include <sys/types.h>
25 #include <unistd.h>
26 #include <stdlib.h>
27 
28 extern "C"
29 {
30  extern char *optarg;
31 };
32 
33 namespace coil
34 {
59  inline int uname(utsname* name)
60  {
61  return ::uname(name);
62  }
63 
84  inline pid_t getpid()
85  {
87  }
88 
108  inline pid_t getppid()
109  {
111  }
112 
136  inline char* getenv(const char *name)
137  {
138  return ::getenv(name);
139  }
140 
141 
142  /* Global Variables for getopt() */
143 
157  class GetOpt
158  {
159  public:
179  GetOpt(int argc, char* const argv[], const char* opt, int flag)
180  : optarg(::optarg), optind(1), opterr(1), optopt(0), m_argc(argc), m_argv(argv), m_opt(opt), m_flag(flag)
181  {
182  ::optind = 1;
183  }
184 
201  {
202  ::optind = 1;
203  }
204 
225  {
226  ::opterr = opterr;
227  ::optind = optind;
228 
229  int result = getopt(m_argc, m_argv, m_opt);
230 
231  optarg = ::optarg;
232  optind = ::optind;
233  optopt = ::optopt;
234 
235  return result;
236  }
237 
238  char* optarg;
239  int optind;
240  int opterr;
241  int optopt;
242 
243  private:
244  int m_argc;
245  char* const * m_argv;
246  const char* m_opt;
247  int m_flag;
248  };
249 
250 };
251 
252 #endif // COIL_OS_H
int m_argc
オプション文字が足りない時、多い時にセットされる
int operator()()
Parses the command line arguments.
char *const * m_argv
GetOpt class.
const char * m_opt
int optind
オプション引数
pid_t getppid()
Get process ID of the parent process.
Definition: ace/coil/OS.h:43
GetOpt(int argc, char *const argv[], const char *opt, int flag)
Constructor.
char * optarg
::pid_t pid_t
Get process ID of the caller process.
Definition: ace/coil/OS.h:38
int uname(utsname *name)
Get System information.
Definition: ace/coil/OS.h:33
static int getopt(int nargc, char *const *nargv, const char *ostr)
Function of parses the command line arguments.
pid_t getpid()
Definition: ace/coil/OS.h:39
char * getenv(const char *name)
Get environment variable.
Definition: ace/coil/OS.h:48
~GetOpt()
Destructor.
int opterr
処理対象引数
int optopt
エラー表示 0:抑止、1:表示
ACE_utsname utsname
Get System information.
Definition: ace/coil/OS.h:32
Common Object Interface Layer.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:25:59