home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fs.zip / octave / octave-2.1.23 / liboctave / oct-group.h < prev    next >
C/C++ Source or Header  |  2000-01-15  |  3KB  |  120 lines

  1. /*
  2.  
  3. Copyright (C) 1996, 1997 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_group_h)
  24. #define octave_group_h 1
  25.  
  26. #include <string>
  27.  
  28. #ifdef HAVE_SYS_TYPES_H
  29. #include <sys/types.h>
  30. #endif
  31.  
  32. #include "str-vec.h"
  33.  
  34. class
  35. octave_group
  36. {
  37. public:
  38.  
  39.   octave_group (void)
  40.     : gr_name (), gr_passwd (), gr_gid (0), gr_mem (), valid (false)
  41.   { }
  42.  
  43.   octave_group (const octave_group& gr)
  44.     : gr_name (gr.gr_name), gr_passwd (gr.gr_passwd),
  45.       gr_gid (gr.gr_gid), gr_mem (gr.gr_mem), valid (gr.valid) 
  46.   { }
  47.  
  48.   octave_group& operator = (const octave_group& gr)
  49.   {
  50.     if (this != &gr)
  51.       {
  52.     gr_name  = gr.gr_name;
  53.     gr_passwd = gr.gr_passwd;
  54.     gr_gid = gr.gr_gid;
  55.     gr_mem = gr.gr_mem;
  56.     valid = gr.valid;
  57.       }
  58.  
  59.     return *this;
  60.   }
  61.  
  62.   string name (void) const;
  63.  
  64.   string passwd (void) const;
  65.  
  66.   gid_t gid (void) const;
  67.  
  68.   string_vector mem (void) const;
  69.  
  70.   bool ok (void) const { return valid; }
  71.  
  72.   operator bool () const { return ok (); }
  73.  
  74.   static octave_group getgrent (void);
  75.   static octave_group getgrent (string& msg);
  76.  
  77.   static octave_group getgrgid (gid_t gid);
  78.   static octave_group getgrgid (gid_t gid, string& msg);
  79.  
  80.   static octave_group getgrnam (const string& nm);
  81.   static octave_group getgrnam (const string& nm, string& msg);
  82.  
  83.   static int setgrent (void);
  84.   static int setgrent (string& msg);
  85.  
  86.   static int endgrent (void);
  87.   static int endgrent (string& msg);
  88.  
  89. private:
  90.  
  91.   // The group name.
  92.   string gr_name;
  93.  
  94.   // The group password.
  95.   string gr_passwd;
  96.  
  97.   // The numeric group id.
  98.   gid_t gr_gid;
  99.  
  100.   // The members of the group;
  101.   string_vector gr_mem;
  102.  
  103.   // Flag that says whether we have been properly initialized.
  104.   bool valid;
  105.  
  106.   // This is how we will create an octave_group object from a pointer
  107.   // to a struct group.
  108.   octave_group (void *p, string& msg);
  109.  
  110.   void gripe_invalid (void) const;
  111. };
  112.  
  113. #endif
  114.  
  115. /*
  116. ;;; Local Variables: ***
  117. ;;; mode: C++ ***
  118. ;;; End: ***
  119. */
  120.