Subject: format of .addressbook

From: Mike Miller <[email-masked]>
Date: Sun, 11 Apr 1999 11:54:01 -0500 (CDT)

I'm trying to understand the format of the .addressbook file that pine
produces.  I've written some scripts that can grab lines out of the
file for me, but they don't always work correctly.  What is being used
to delimit a record?

I wanted to be able to search for a string in the comment field and
show every matching record.  What I've done (below) usually works well
for me, but it misses some records.  It seems that the Comments are
usually on a second line beginning with three spaces, but sometimes
they are at the end of the first line of the record preceeded by two
tabs.  It seems like this is determined by the length of strings in
the name and address fields.

Any help will be appreciated!

Regards,

Mike

-- 
Michael B. Miller
University of Missouri--Columbia
http://taxa.psyc.missouri.edu/~mbmiller/

----------------------------------------------------------------------

To grab records with some string in the comment field:

#!/usr/local/bin/tcsh -f
foreach N ( `egrep -n "$1" ~/.addressbook | egrep ':   ' | awk -F: '{print $1 - 1}'` )
tail +$N ~/.addressbook | head -2 | fmt -w 75
echo ""
end

----------------------------------------------------------------------

To grab records with some string in another (non-comment) field:

#!/usr/local/bin/tcsh -f
foreach N ( `egrep -n "$1" ~/.addressbook | egrep -v ':   ' | awk -F: '{print $1}'` )
tail +$N ~/.addressbook | head -1 | fmt -w 75
tail +$N ~/.addressbook | tail +2 | head -1 | egrep '^   ' | fmt -w 75
echo ""
end

-- 
-----------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/pine/pine-info/
-----------------------------------------------------------------

---

From: Jessica Rasku <[email-masked]>
Date: Sun, 11 Apr 1999 14:48:15 -0700 (PDT)

> file for me, but they don't always work correctly.  What is being used

	This is what I have figured out

nickname^Ifullname^Iaddresses^Ifcc^Icomment

If it is longer than 1 line it seems to be split with the next line
begining with white space (spaces).  Address lists are indicated by
parenthisis.  It would be good if you could parse all fields out for your
basic parser.  That way you can maximise your capabilities....

							Jessica

-- 
Jessica Rasku, Box 270, Rossland, B.C., V0G 1Y0, (250) 362-5701, 
LinuxBox: (250) 362-9668.

List manager: [email-masked] 
     send command help ---- To get help with majordomo
               or lists ---- To get a list of all lists on server.

WWW: <http://www.geocities.com/RainForest/Andes/8749>

---

From: Mike Miller <[email-masked]>
Date: Sun, 11 Apr 1999 22:18:46 -0500 (CDT)

On Sun, 11 Apr 1999, Jessica Rasku wrote:

JR> On Sun, 11 Apr 1999, Mike Miller wrote:
JR> 
JR> > I'm trying to understand the format of the .addressbook file
JR> > that pine produces.  I've written some scripts that can grab
JR> > lines out of the file for me, but they don't always work
JR> > correctly.  What is being used to delimit a record?
JR> 
JR> 	This is what I have figured out
JR> 
JR> nickname^Ifullname^Iaddresses^Ifcc^Icomment
JR> 
JR> If it is longer than 1 line it seems to be split with the next line
JR> begining with white space (spaces).  Address lists are indicated by
JR> parenthisis.  It would be good if you could parse all fields out for your
JR> basic parser.  That way you can maximise your capabilities....

Thanks for looking into this.  It seems to me that .addressbook is using
two kinds of field separators: a simple tab, or a
tab-newline-SPACE-SPACE-SPACE combination.  With this mixed format,
records may be on one line, or two lines or three lines depending on
several unimportant things like the number of characters in the e-mail
address.

Is there a good reason for this choice of format?  If not, I would greatly
prefer to have one line per record, tab delimited.  Then we could easily
use programs like awk to work with our .addressbook file.  It is a pretty
useful thing to be able to store lots of stuff in there and easily access
it.

On the other hand, I'm not an awk wizard and I don't know if awk can
handle the file as it is.  If anyone can figure it out, I'd love to hear
about it.

Regards,

Mike

---

From: Jessica Rasku <[email-masked]>
Date: Mon, 12 Apr 1999 11:03:03 -0700 (PDT)

> several unimportant things like the number of characters in the e-mail

	I would say that my estimation is that the
newline-space-space-space is NOT part of the delimiter.  My feeling is
that the reasoning behind the insertion of it is to get Pine to get the
address book to fit into 80 columns.  So, if you wish to make it one line,
I would think that you could strip the LF-SPACE-SPACE-SPACE from the file
(at least for parsing), without any problem...

							Jessica

---

From: Mike Miller <[email-masked]>
Date: Tue, 13 Apr 1999 13:04:13 -0500 (CDT)

> (at least for parsing), without any problem...

Well, in effect, it is part of the delimiter because it lies between
fields and is not part of the fields on either side.  It doesn't cause
the addressbook to fit into 80 columns because the comment line can be
very long.  But you must be right that it has to do with keeping lines
short.  It just seems haphazard.

Thank you for your ideas.  I hope one of the pine team will tell us
why it is designed this way.

Regards,

Mike