Task
This assignment requires attention to detail and it exercises several different knowledge areas. In particular, it requires a bit of command-line option parsing, reading a kernel data structure (the wtmp file), and manipulating time values.
This assignment is specified by a man page. Your job is to write a program that satisfies the requirements of the following man page. The information regarding program submission is at the end of the assignment. I have written this man page to look like a “real one.”
NAME
logdata — print various statistics of login data of one or more users
SYNOPSIS logdata [options] username …
DESCRIPTION
Without options, logdata prints one line for each username argument, containing the total time that the user has spent logged into the system since record-keeping was last started. If no
usernames are listed, it displays this time for the current user. If there is no wtmp file, it prints a message on the standard error stream that there is no record-keeping. Otherwise, for each user to be reported, it displays the username followed by the total login time, accurate to the second, in days, hours, minutes, and seconds, as needed. If the total time is less than a day, the days field is omitted. If it is less than an hour, the hours and days are omitted, and if it’s less than a minute, only the seconds are displayed. If a username is given but there are no logins for the user, “0 seconds” is listed for that username. If any value is zero, the units for that value are not displayed.
The definition of total login time for this command includes:
• all time in completed login sessions, meaning those that have logouts associated with the logins, and
• all time in login sessions that were terminated without a corresponding logout because there was a shutdown or a system reboot.
The command excludes in the total reported time any time for which the login session is in progress at the time the command is invoked, meaning those that are still running.
All times are in whole, non-negative decimal integers. Usernames are not sorted alphabetically.
OUTPUT
Output units are day(s) for the number of days, hour(s) for the number of hours, min(s) for the number of minutes, and sec(s) for the number of seconds. For example:
boromir 1 day 9 hours 39 mins 51 secs
frodo 14 hours 1 sec
gandalf 22 days 42 mins
The plural form of the unit should be used for any amount other than 1. In the second case, it is an implicit time of 14 hours, 0 minutes and 1 second. In the third, it is 22 days, 0 hours, 42 minutes and 0 seconds.
OPTIONS
The behavior of the command can be modified with the following option:
-a
Show the log times for all users that have entries in the file _PATH_WTMP.
-s
Produce a line of output at the end showing the totals for all users listed.
-f <file>
Use <file> instead of _PATH_WTMP.
EXIT STATUS
0 If it succeeded.
1 If it failed.
FILES
/var/log/wtmp
SEE ALSO last (1), utmp (5), wtmp (5)
Error Handling
The program should detect missing command-line arguments and report the error and correct usage.
Code Re-Use and Program Structure
You are free to use any of the code in the class’s repository. All of it has GNU General Public Licenses. If you do use any of that code, the documentation should indicate which parts are not written by you. The program should be a single source code file. All functions other than main() should precede main() in the file.
Instructions for Submitting the Assignment
1. Use the submithwk_cs49366 program to submit your program. To submit, if your file is ~/logdata.c, you’d enter
$ cd ~
$ submithwk_cs49366 -t 3 logdata.c
The program will copy day2date.c into the directory
/data/biocs/b/student.accounts/cs493.66/hwks/hwk3/
and if it is successful, it will display the message, “File hwk3_username.c successfully submitted.” where username is your username. You will not be able to read this file, nor will anyone else except for me. But you can double-check that the command succeeded by typing the command ls -l /data/biocs/b/student.accounts/cs493.66/hwks/hwk3
2. You can do step 1 as many times as you want. Newer versions of the file will overwrite older ones.
Grading Rubric
This assignment is 20% of your final grade. The output must be correct and the program must conform to the rules written in the Programming Rules document on the class’s webpage. It must be thoroughly documented.
Assignment, CSCI493.66, Login, solved, Statistics
[SOLVED] Csci493.66 assignment 3- login statistics p0
$25
File Name: Csci493_66_assignment_3__login_statistics_p0.zip
File Size: 414.48 KB
Only logged in customers who have purchased this product may leave a review.

![[SOLVED] Csci493.66 assignment 3- login statistics p0](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[SOLVED] MongoDB CRUD Faculty](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.