- 论坛徽章:
- 0
|
That 9% of putative inefficiency buys us a lot. It avoids putting an arbitrary limit on the range of the
numeric fields. It gives us the ability to modify the password file with any old text editor of our choice,
rather than having to build a specialized tool to edit a binary format (though in the case of the password file
itself, we have to be extra careful about concurrent edits). And it gives us the ability to do ad-hoc searches
and filters and reports on the user account information with text-stream tools such as grep(1).
The fact that structural information is conveyed by field position rather than an explicit tag makes this
format faster to read and write, but a bit rigid. If the set of properties associated with a key is expected to
change with any frequency, one of the tagged formats described below might be a better choice.
Economy is not a major issue with password files to begin with, as they're normally read only once per user
session at login time and infrequently modified. Interoperability is not an issue, since various data in the
file (notably user and group numbers) are not portable off the originating machine. For password files, it's
therefore quite clear that going where the transparency criterion leads was the right thing.
Case study: .newsrc format
Usenet news is a worldwide distributed bulletin-board system that anticipated today's P2P networking by
two decades. It uses a message format very similar to that of RFC822 electronic-mail messages, except that
instead of personal recipients messages are sent to topic groups. Articles posted at any participating site are
broadcast to each site that it has registered as a neighbor, and eventually flood-fill to all news sites.
Almost all Usenet news readers understand the .newsrc file, which records which Usenet messages have
been seen by the calling user. Though it is named like a run-control file, it is not only read at startup but
typically updated at the end of the newsreader run. The .newsrc format has been fixed since the first
newsreaders around 1980. Example 5.2 is a representative section from a .newsrc file.
Example 5.2. A .newsrc example
rec.arts.sf.misc! 1-14774,14786,14789rec.arts.sf.reviews! 1-2534rec.arts.sf.written: 1-876513news.answers! 1-199359,213516,215735news.announce.newusers! 1-4399news.newusers.questions! 1-645661news.groups.questions! 1-32676news.software.readers! 1-95504,137265,137268,137274,140059,140091,140117alt.test! 1-1441498
Each line sets properties for the newsgroup named in the first field. The name is immediately followed by a
character which indicates whether the owning user has subscribed to the group or not; a colon indicates
subscription, and an exclamation mark indicates non-subscription. The remainder of the line is a sequence
of comma-separated article numbers or ranges of article numbers, indicating which articles the user has
seen. |
|