Assignment Quick Links

  1. Overview
  2. Build It
  3. Break It
    1. Infer details
  4. Fix It
  5. Oracle
  6. Program specifications
    1. logappend
    2. logread
  7. Grading
  8. Scoring
  9. Rules

logappend

logappend -T <timestamp> -K <token> (-E <employee-name> | -G <guest-name>) (-A | -L) [-R <room-id>] <log>
logappend -B <file>

Appends data to the log at the specified timestamp using the authentication token. If the log does not exist, logappend will create it. Otherwise it will append to the existing log.

If the data to be appended to the log is not consistent with the current state of the log, logappend should print “invalid” and leave the state of the log unchanged.

After logappend exits, the log specified by log argument should be updated. The added information should be accessible to the logread tool when the token provided to both programs is the same, and not available (e.g., by inspecting the file directly) otherwise. Aside from the log file specified, no other files may be generated or modified!

Return values and error conditions

If logappend must exit due to an error condition, or if the argument combination is incomplete or contradictory, logappend should print “invalid” to stdout and exit, returning a 255.

If the supplied token does not match an existing log, “invalid” should be printed to stdout and 255 returned.

If -B is passed, logappend should return 0 as long as the batch file exists and valid arguments are given to the batch command. If the batch file does not exist, print “invalid” to stdout and exit, returning 255.

Some examples of conditions that would result in printing “invalid” and doing nothing to the log: