]> git.sur5r.net Git - openldap/blob - clients/rcpt500/help.c
clients build under FreeBSD
[openldap] / clients / rcpt500 / help.c
1 /*
2  * help.c: for rcpt500 (X.500 email query responder)
3  *
4  * 16 June 1992 by Mark C Smith
5  * Copyright (c) 1992 The Regents of The University of Michigan
6  * All Rights Reserved
7  */
8
9 #include "portable.h"
10
11 #include <stdio.h>
12
13 #include <ac/syslog.h>
14 #include <ac/string.h>
15
16 #ifdef HAVE_FCNTL_H
17 #include <fcntl.h>
18 #endif
19
20 #include "ldapconfig.h"
21 #include "rcpt500.h"
22
23 extern int dosyslog;
24
25
26 int
27 help_cmd( msgp, reply )
28     struct msginfo      *msgp;
29     char                *reply;
30 {
31     int         fd, len;
32
33     if (( fd = open( RCPT500_HELPFILE, O_RDONLY )) == -1 ) {
34         if ( dosyslog ) {
35             syslog( LOG_ERR, "open help file: %m" );
36         }
37         strcat( reply, "Unable to access the help file.  Sorry!\n" );
38         return( 0 );
39     }
40
41     len = read( fd, reply + strlen( reply ), MAXSIZE );
42     close( fd );
43
44     if ( len == -1 ) {
45         if ( dosyslog ) {
46             syslog( LOG_ERR, "read help file: %m" );
47         }
48         strcat( reply, "Unable to read the help file.  Sorry!\n" );
49         return( 0 );
50     }
51
52     *(reply + len ) = '\0';
53     return( 0 );
54 }