// Name: usrinfo(UNIX + web version) // Version: .10 // Description: Displays information about a user // Created 17 January 2004 // Last Modified 25 June 2004 // Copyright (c) 2004, Aaron Myles Landwehr // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. // //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //includes #include "../include/usrinfo.h" using namespace std; //globals char* linebreak ="\n"; //default break style: unix char* usage ="usrinfo [-wtnpugdso]"; //the commandline usage information char* usage2 ="usrinfo [-wtnpugdso] [user]"; //the commandline usage information char* usage3 ="usrinfo [-iwtnpugdso] [uid]"; //the commandline usage information char* usage4 ="usrinfo [-v]"; //the commandline usage information char* usage5 ="usrinfo [-h]"; //the commandline usage information char* version =".10(25 June 2004)"; //version number bool pref =0; //used to determine if to display topics bool pwnam =1; //used to determine if username or uid is used struct passwd *pwd; //passwd structure void argtest(int argc, char** argv)//test the arguments for correctness { if(argc<2||argc>3)//should be 2 || 3 arguments entered { argdisplay();//display error } if(argv[1][0]!='-')//argument 2 should begin with '-' { argdisplay();//display error } if(argc==2) { pwd=getpwuid(getuid());//no user was specified so current user is used. } for(int i=1;i<=strlen(argv[1]);i++)//cycle through arguments { if(argv[1][i]=='v')//if found display the version information { cout<<"usrinfo-"<pw_name<pw_passwd<pw_uid<pw_gid<pw_dir<pw_shell<pw_gecos<