help.c 989 Bytes
Newer Older
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1
2
3
4
5
6
7
8
/*
 * help.c: for rcpt500 (X.500 email query responder)
 *
 * 16 June 1992 by Mark C Smith
 * Copyright (c) 1992 The Regents of The University of Michigan
 * All Rights Reserved
 */

Kurt Zeilenga's avatar
Kurt Zeilenga committed
9
10
#include "portable.h"

Kurt Zeilenga's avatar
Kurt Zeilenga committed
11
#include <stdio.h>
Kurt Zeilenga's avatar
Kurt Zeilenga committed
12
13
14
15
16

#include <ac/syslog.h>
#include <ac/string.h>

#ifdef HAVE_FCNTL_H
Kurt Zeilenga's avatar
Kurt Zeilenga committed
17
#include <fcntl.h>
Kurt Zeilenga's avatar
Kurt Zeilenga committed
18
#endif
Kurt Zeilenga's avatar
Kurt Zeilenga committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

#include "ldapconfig.h"
#include "rcpt500.h"

extern int dosyslog;


int
help_cmd( msgp, reply )
    struct msginfo	*msgp;
    char		*reply;
{
    int		fd, len;

    if (( fd = open( RCPT500_HELPFILE, O_RDONLY )) == -1 ) {
	if ( dosyslog ) {
	    syslog( LOG_ERR, "open help file: %m" );
	}
	strcat( reply, "Unable to access the help file.  Sorry!\n" );
	return( 0 );
    }

    len = read( fd, reply + strlen( reply ), MAXSIZE );
    close( fd );

    if ( len == -1 ) {
	if ( dosyslog ) {
	    syslog( LOG_ERR, "read help file: %m" );
	}
	strcat( reply, "Unable to read the help file.  Sorry!\n" );
	return( 0 );
    }

    *(reply + len ) = '\0';
    return( 0 );
}