xref: /titanic_44/usr/src/cmd/refer/refer8.c (revision 11a8fa6cb17403e630122ac19b39a323c6e64142)
1*11a8fa6cSceastha /*
2*11a8fa6cSceastha  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3*11a8fa6cSceastha  * Use is subject to license terms.
4*11a8fa6cSceastha  */
5*11a8fa6cSceastha 
67c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
77c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
87c478bd9Sstevel@tonic-gate 
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
117c478bd9Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
127c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
137c478bd9Sstevel@tonic-gate  */
147c478bd9Sstevel@tonic-gate 
157c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
167c478bd9Sstevel@tonic-gate 
177c478bd9Sstevel@tonic-gate #include "refer..c"
187c478bd9Sstevel@tonic-gate 
197c478bd9Sstevel@tonic-gate static char ahead[1024];
207c478bd9Sstevel@tonic-gate static int peeked = 0;
217c478bd9Sstevel@tonic-gate static char *noteof = (char *)1;
227c478bd9Sstevel@tonic-gate 
237c478bd9Sstevel@tonic-gate char *
input(char * s)24*11a8fa6cSceastha input(char *s)
257c478bd9Sstevel@tonic-gate {
267c478bd9Sstevel@tonic-gate 	if (peeked) {
277c478bd9Sstevel@tonic-gate 		peeked = 0;
287c478bd9Sstevel@tonic-gate 		if (noteof == 0)
297c478bd9Sstevel@tonic-gate 			return (0);
307c478bd9Sstevel@tonic-gate 		strcpy(s, ahead);
317c478bd9Sstevel@tonic-gate 		return (s);
327c478bd9Sstevel@tonic-gate 	}
337c478bd9Sstevel@tonic-gate 	return (fgets(s, 1000, in));
347c478bd9Sstevel@tonic-gate }
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate char *
lookat(void)37*11a8fa6cSceastha lookat(void)
387c478bd9Sstevel@tonic-gate {
397c478bd9Sstevel@tonic-gate 	if (peeked)
407c478bd9Sstevel@tonic-gate 		return (ahead);
417c478bd9Sstevel@tonic-gate 	noteof = input(ahead);
427c478bd9Sstevel@tonic-gate 	peeked = 1;
437c478bd9Sstevel@tonic-gate 	return (noteof);
447c478bd9Sstevel@tonic-gate }
457c478bd9Sstevel@tonic-gate 
46*11a8fa6cSceastha void
addch(char * s,char c)47*11a8fa6cSceastha addch(char *s, char c)
487c478bd9Sstevel@tonic-gate {
497c478bd9Sstevel@tonic-gate 	while (*s)
507c478bd9Sstevel@tonic-gate 		s++;
517c478bd9Sstevel@tonic-gate 	*s++ = c;
527c478bd9Sstevel@tonic-gate 	*s = 0;
537c478bd9Sstevel@tonic-gate }
54