#include <stdio.h>
#include <string.h>
/* This is the NEW version for 4.00 and above */
/*               July 22, 1987                */
main()
	{
	FILE *inbuf, *outbuf;
	int code;
	int count;
	char infile[99], outfile[99];
	char u_fname[99], u_lname[99], u_password[99], u_time1[99];
	char u_date1[99], u_time2[99], u_date2[99], u_city[99];
	char l_f_base[4], l_m_base[4], xprt[4], toggl[4];
	printf("\nInput the old user file name: ");
	scanf("%s", infile);
	printf("\n");
	strcpy(outfile, infile);
	strcat(outfile,".OLD");
	(void)unlink(outfile);
	(void)link(infile,outfile);
	(void)unlink(infile);
	if((inbuf = fopen(outfile, "r" )) == NULL)
		{
		printf("\n\rError opening old users file.\n\r");
		exit(1);
		}
	if((outbuf = fopen(infile, "w" )) == NULL)
		{
		printf("\n\rError opening new users file.\n\r");
		exit(1);
		}
	while(1)
		{
		code = fscanf(inbuf,"%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~\n",
			u_fname, u_lname, u_password, u_time1, u_date1,
			u_time2, u_date2, u_city,l_f_base,l_m_base,xprt,toggl);
		if(code < 12 ) break;
		code = fprintf(outbuf,"%s~%s~%s~%s~%s~%s~%s~%s~%s~%s~%s~%s~\n",
			u_fname, u_lname, u_password, u_time1, u_date1,
			u_time2, u_date2, u_city,l_f_base,l_m_base,xprt,toggl);
		}
		fclose(inbuf);
		fclose(outbuf);
		strcpy(outfile,"chmod 660 ");
		strcat(outfile, infile);
		(void)system(outfile);
		strcpy(outfile,"chown bbs ");
		strcat(outfile, infile);
		(void)system(outfile);
	}
