Subject: Creating address book from /etc/passwd

From: [email-masked] (Laszlo Vecsey)
Date: 13 Mar 1996 17:23:13 GMT

I wrote up the following C++ program real quick to parse /etc/passwd. It 
creates an addressbook entry for Pine so that you can mass mail all the 
users on a system!

There are only a couple minor bugs with it, if anyone cares to improve it 
by adding more features or making it more efficient please do so and 
E-Mail an update to me or post it to the mailing list.

// -- CUT HERE
// Password 2 Pine (/etc/passwd)
// Lester Vecsey [3/13/96]
// [email-masked]
//
// Converts all the usernames on a system into an addressbook that works with
// Pine. Typical usage:
//
//	cat /etc/passwd | p2pine >> .addressbook
//
// A stream is used (piping to p2pine) so that you can egrep whatever you want
// out of /etc/passwd first, giving you more flexibility.

#include <iostream.h>

int main(int argc, char *argv[])
	{
	char string[1024];
	int count=20, Length;

	cout << "Mass\tMass Mailing\t(";

	while(!cin.eof())
		{
		// Fetch the username from /etc/passwd style input on stdin
		cin.getline(string, 16, ':');
		cin.ignore(1024, '\n');

		if (!*string) continue;

		// Do some formatting for 80 columns, send it to stdout.
		count+=(Length=strlen(string))+1;
		if (count < (80-Length)) cout << string << ",";
			else { cout << endl << "   "; count=0; }
		}

	cout << ")";

	return 0;
	}
// ---- CUT HERE