logread
queries the state of the hospital. It prints which doctors and nurses are in the hospital or its rooms, and allows for various time-based queries of the state of the hospital. The following invocations must be supported:
logread -K <token> -S -F <log>
logread -K <token> -R (-D <name> | -N <name>) -F <log>
As per the above invocations, only one of -S
or -R
may be specified at once.
In what follows, we refer to doctors or nurses who are 'in the hospital'. Each person is expected to first enter the hospital (using logappend
option -A
) prior to entering any particular room of the hospital. Once in the hospital, they may enter and leave various rooms (using logappend
options -A -R
and options -L -R
, respectively). Finally, the person will leave the hospital (using logappend
option -L
). During this whole sequence of events, a person is considered to be 'in the hospital'. See the examples for more information.
When output elements are comma-separated lists, there will be no spaces before or after the commas.
-K
token Token used to authenticate the log. Once a log is created with a specific token, any subsequent appends or reads on that log must use the same token.
-S
Print the current state of the log to stdout. The state should be printed to stdout
on at least two lines, with lines separated by the \n
(newline) character. The first line should be a comma-separated list of doctors currently in the hospital. The second line should be a comma-separated list of nurses currently in the hospital. The remaining lines should provide room-by-room information indicating which nurse or doctor is in which room. Each line should begin with a room ID, printed as a decimal integer, followed by a colon, followed by a space, followed by a comma-separated list of nurses and doctors. Only rooms occupied by a staff member should be listed. Room IDs should be printed in ascending integer order. Names should be printed in ascending lexicographic string order.
-R
Give a list of all rooms entered by an doctor or nurse. Output the list of rooms in chronological order. If this argument is specified, either -D or -N must also be specified. The list is printed to stdout
in one comma-separated list of room identifiers. If the staff member name does not exist in the log, it should print nothing about that staff member (which may result in empty output).
-D
name Name of doctor.
-N
name Name of nurse.
-F
log The path to a log file used by logappend for recording events.
If logread
must exit with an error condition, or if the argument combination is incomplete or contradictory, logread
should print "invalid" to stdout
and exit, returning 255.
If logread
must exit with an integrity violation, logread
should print "integrity violation" to stdout
and exit, returning 255.
logread
should exit with an error condition.logread
cannot authenticate the log with the token, then logread
should should exit with an integrity violation.logread
cannot validate that an entry in the log was created with an invocation of logappend
using a matching token, then logread
should should exit with an integrity violation.Some examples of conditions that would result in printing "invalid" or "integrity violation" (and return 255):
-S
and -R
or -D
and -N
.