/*
 *	Edit the password file to "up" everybody's core limits from
 *	1/2 a meg to 1 meg.
 *
 *	Default settings are 512K and 512K+512
 *
 *	If this is the setting, up it to 1024k and 1024k+1024
 *
 *	This program reads stdin and writes stdout.
 */

#include <stdio.h>
#include <pwd.h>

#define K * 1024		/* ugh */

main()
{
	struct ukc_u u;

	while (fread((char *)&u, sizeof(u), 1, stdin) == 1) {
		int haveprintedname = 0;
		if (u.ukc_p.ukc_name == NULL ||
		    u.ukc_p.ukc_name[0] == '\0') {
			/* No such user */
			break;
		} else
		if (u.ukc_p.ukc_plimit[PLIMIT_DATA].plim_cur >= 512 K
		 && u.ukc_p.ukc_plimit[PLIMIT_DATA].plim_cur < 1024 K ) {
			u.ukc_p.ukc_plimit[PLIMIT_DATA].plim_cur = 1024 K;
			fprintf(stderr, "%.8s", u.ukc_p.ukc_name);
			haveprintedname = 1;
			putc('s', stderr);
		} else
		if (u.ukc_p.ukc_plimit[PLIMIT_DATA].plim_max >= 512 K + 512
		 && u.ukc_p.ukc_plimit[PLIMIT_DATA].plim_max < 1024 K + 1024) {
			u.ukc_p.ukc_plimit[PLIMIT_DATA].plim_max = 1024 K + 1024;
			if (!haveprintedname) {
				fprintf(stderr, "%.8s", u.ukc_p.ukc_name);
				haveprintedname = 1;
			}
			putc('h', stderr);
		}
		if (haveprintedname) putc(' ', stderr);
		fwrite((char *)&u, sizeof(u), 1, stdout);
	}
	exit(0);
}
