Generate a Sendmail 8.12-compatible queue ID, and create a locked qf file with that name. If $lock_both is true, we lock the file using both fcntl and flock-style locking.

See Bat Book 3rd edition, section 11.2.1 for information on how the queue file name is generated.

Note that we create the qf file directly, rather than creating an intermediate tf file and renaming aftewards. This is all good and well for creating /new/ qf files -- sendmail does it that way as well -- but if we ever want to rewrite one, it's not safe.

For future reference, Sendmail queuefile creation in queueup() inside sendmail/queue.c does things in the same way -- newly-created queue files are created directly with the qf prefix, then locked, then written.