core/vul/io/vul_io_user_info.cxx
Go to the documentation of this file.
00001 // This is core/vul/io/vul_io_user_info.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 
00008 #include "vul_io_user_info.h"
00009 #include <vul/vul_user_info.h>
00010 
00011 //=========================================================================
00012 //: Binary save self to stream.
00013 void vsl_b_write(vsl_b_ostream &os, const vul_user_info & p)
00014 {
00015   const short io_version_no = 1;
00016   vsl_b_write(os, io_version_no);
00017   vsl_b_write(os, p.uid);
00018   vsl_b_write(os, p.gid);
00019   vsl_b_write(os, p.name);
00020   vsl_b_write(os, p.home_directory);
00021   vsl_b_write(os, p.full_name);
00022   vsl_b_write(os, p.shell);
00023   vsl_b_write(os, p.passwd);
00024 }
00025 
00026 //=========================================================================
00027 //: Binary load self from stream.
00028 void vsl_b_read(vsl_b_istream &is, vul_user_info & p)
00029 {
00030   if (!is) return;
00031 
00032   short v;
00033   vsl_b_read(is, v);
00034   switch (v)
00035   {
00036    case 1:
00037     vsl_b_read(is, p.uid);
00038     vsl_b_read(is, p.gid);
00039     vsl_b_read(is, p.name);
00040     vsl_b_read(is, p.home_directory);
00041     vsl_b_read(is, p.full_name);
00042     vsl_b_read(is, p.shell);
00043     vsl_b_read(is, p.passwd);
00044     break;
00045 
00046    default:
00047     vcl_cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vul_user_info&)\n"
00048              << "           Unknown version number "<< v << '\n';
00049     is.is().clear(vcl_ios::badbit); // Set an unrecoverable IO error on stream
00050     return;
00051   }
00052 }
00053 
00054 
00055 //=========================================================================
00056 //: Output a human readable summary to the stream
00057 void vsl_print_summary(vcl_ostream& os,const vul_user_info & p)
00058 {
00059   os << "( uid,gid,name,home_directory,full_name,shell,passwd="
00060      << p.uid<<','<<p.gid<<','<<p.name
00061      << " home_directory,full_name,shell="
00062      << p.home_directory<<','<< p.full_name<<','<<p.shell
00063      << " passwd=" << p.passwd<<')';
00064 }