#!mkcmd
# OK.  I just couldn't take it.  If we are going to make a program	(ksb)
# to produce epass's it should be a well documented program and take
# all the std options.
from '<stdlib.h>'
from '<ctype.h>'
from '<unistd.h>'
from '<errno.h>'

basename "epass" ""
require "std_help.m" "std_version.m"

%i
static char rcsid[] =
	"$Id: epass.m,v 1.3 2005/12/18 02:58:54 ksb Exp $";
extern char *crypt();
%%

string[2] named "acSalt" {
	param "salt"
	init action "(void)RandSalt(acSalt);"
	help "force a specific two character salt for the encrypted password"
}

char* named "pcPass" {
	param "password"
	help "provide the plain text password to encrypt"
}


left "pcPass" ["acSalt"] {
	after "puts(crypt(%1n, %2n));"
}


%c
/* code Mike had to make a random salt					(mm)
 */
static char *
RandSalt(pcSalt)
	char *pcSalt;
{
	register int i, iTemp;
	register int c;

	iTemp = 9 * getpid();		/* HOBBITS */
	pcSalt[0] = iTemp & 077;
	pcSalt[1] = (iTemp>>6) & 077;
	for (i = 0; i < 2; i++) {
		c = pcSalt[i] + '.';
		if (c > '9')
			c += 7;
		if (c > 'Z')
			c += 6;
		pcSalt[i] = c;
	}
	return pcSalt;
}
%%
