 #include	<stdio.h>
 #include	<stdlib.h>
 #include	<string.h>
 #include	<ctype.h>
 #include	<time.h> 
 #include	<process.h>
 #define MAXLINE 255
 
 int	main(int argc, char *argv[])
 { 
 	FILE	*fpin,*fpout;
 	char	line[MAXLINE];
 	char	rstr[95];
 	char    seedhdr[] = "SQLNET.CRYPTO_SEED = \"";
 	void	randstr(char*); 
 	
 	if (--argc != 2) {
 		printf("Format is: ORARAND infile outfile\n");
 	    return 1;
 	};
 	printf("%s %s\n",argv[1],argv[2]);
 	printf("Generating SQLNET.CRYPTO_SEED\n");
 	if ((fpin = fopen(argv[1], "r")) == NULL) {
 		printf("can't open %s\n",argv[1]);
 		return 1;
 	};
 	if ((fpout = fopen(argv[2], "w")) == NULL) {
 		printf("can't open %s\n",argv[2]);
 		return 1;
 	};
 	strcpy(rstr,"");
 	while(fgets(line,MAXLINE,fpin)) {
 		if (!strncmp(line,seedhdr,18)) {
 			strcpy(line,seedhdr);
 			randstr(rstr);
 			strcat(line,rstr);
 			strcat(line,"\"\n");
 		};
 		fputs(line,fpout);
 	};
 	fclose(fpin);
 	fclose(fpout);
 	
 	return 0;
 };           
 
void  randstr(char *rstr)
{
	int		n;
	char	rchr;

	n = _getpid();
	srand(time(NULL) ^ n ^ 325986743 );
	for (n=1;n<66;n++) {
		rchr = rand() % 128;
		while (!isgraph(rchr))
			rchr = rand() % 128;
		if (rchr == '"')
			rchr = '\'';
		rstr[n-1] = rchr;
	};
	rstr[n-1] = '\0';
	return;
};   
		  
 