#include <stdio.h>
#include <ctype.h>

/* wrapper for fgets(), it rips off trailing spaces/newlines/tabs, etc */
char *fgets_strip(char *s, int size, FILE *stream);




char *fgets_strip(char *s, int size, FILE *stream) {
	char *ret;
	char *a;

	ret=fgets(s,size,stream);
	if(ret==NULL) return(NULL);

	/* go to the end of the string */
	for(a=s;*a;a++);

	/* drop back to the first char.. */
	while(!isgraph(*a) && a>=s) a--;

	/* set our new end-of-string */
	*(++a)=0;

	return(ret);
}


