#include "listserv.h"

static char rcsid[] = "$Header: /usr/local/src/mail/listserv/RCS/info.c,v 1.1 92/09/14 11:03:52 andy Exp Locker: andy $";

extern FILE *msg;
extern FILE *mailer;

infoindex(from,request)
char *from, *request;
	{
	printf("called sendhelp with %s %s\n", from, request);
	callmailer("", from, request);
	mailcat(INFOFILE,"");
	pclose(mailer);
	return;
	}

sendinfo(from, command)
char *from, *command;
	{
	int i;
	char *p;
	char doc[256], 
	     tmp[512],
	     buf[BUFSIZ];

	printf("called sendfaq with %s %s\n", from, command);
	/* Grab filenames trailing after word "info" */
	strcpy(buf, command);
	while(p = index(buf, ' ')) 
		{
		/* Get rid of extra blanks 
		   and return if only trailing whitespace remains */
		while(*(++p) == ' ')
			;
		if(!strlen(p))
			return;

		strcpy(buf, p);
		sscanf(buf, "%s", doc);
		if (index(doc, '*'))
			{
			callmailer("", from, command);
			sprintf(tmp, "%s/INFOHELP", SERVDIR);
			mailcat(tmp, "\t");
			fflush(mailer);
			pclose(mailer);
			continue;
			}
		sprintf(tmp, "%s/%s", INFODIR, doc);
		callmailer("", from, command);
		if(access(tmp,R_OK) == 0)
			{
			mailcat(tmp, "\t");
			fflush(mailer);
			pclose(mailer);
			}
		else
			{
			fprintf(mailer, "File %s does not exist.", doc);
			fflush(mailer);
			pclose(mailer);
			}
		}

	}
