git.fiddlerwoaroof.com
sys_unistd.h
189f062b
 /* Copyright (C) CJ Affiliate
  *
  * You may use, distribute and modify this code under  the
  * terms of the  GNU General Public License  version 2  or
  * later.
  *
  * You should have received a copy of the license with this
  * file. If not, you will find a copy in the "LICENSE" file
  * at https://github.com/cjdev/dual-control.
  */
 
a8b53afd
 #ifndef _SYS_UNISTD_H_
 #define _SYS_UNISTD_H_
 
 #include <memory>
 
d8adc881
 #include <unistd.h>
 
189f062b
 class unistd_ifc
 {
 public:
4d825470
     virtual ~unistd_ifc() {}
bf756dea
     virtual long int sysconf (int name) const
189f062b
     {
         return -1;
     }
7d075ab4
     virtual const char *getlogin() const
     {
bf756dea
         return "";
     }
0d8b9a17
     virtual int seteuid (uid_t euid) const
8b49c701
     {
         return -1;
     };
 
a8b53afd
 };
 
3ae0e083
 class unistd
189f062b
 {
 public:
     typedef std::shared_ptr<unistd_ifc> delegate;
 
 private:
     delegate delegate_;
 
 public:
     unistd (delegate delegate): delegate_ (delegate) {}
     unistd() : delegate_ (delegate (new unistd_ifc)) {}
bf756dea
     long int sysconf (int name) const
189f062b
     {
         return delegate_->sysconf (name);
     }
7d075ab4
     const char *getlogin() const
     {
bf756dea
         return delegate_->getlogin();
     }
0d8b9a17
     int seteuid (uid_t euid) const
8b49c701
     {
0d8b9a17
         return delegate_->seteuid (euid);
8b49c701
     };
da1b9b25
     static unistd create();
a8b53afd
 };
 
194e6869
 template class std::shared_ptr<unistd_ifc>;
189f062b
 
194e6869
 #endif
0d8b9a17