]> git.sur5r.net Git - openldap/blob - include/ac/unistd.h
e5b3eb3300b2ebc2a3d26e5c619ee3529de1bc1a
[openldap] / include / ac / unistd.h
1 /* Generic unistd.h */
2 /*
3  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted only
7  * as authorized by the OpenLDAP Public License.  A copy of this
8  * license is available at http://www.OpenLDAP.org/license.html or
9  * in file LICENSE in the top-level directory of the distribution.
10  */
11
12 #ifndef _AC_UNISTD_H
13 #define _AC_UNISTD_H
14
15 #if HAVE_SYS_TYPES_H
16 #       include <sys/types.h>
17 #endif
18
19 #if HAVE_UNISTD_H
20 #       include <unistd.h>
21 #endif
22
23 /* crypt() may be defined in a separate include file */
24 #if HAVE_CRYPT_H
25 #       include <crypt.h>
26 #else
27         extern char *crypt();
28 #endif
29
30 #ifndef HAVE_GETPASS
31 extern char* getpass LDAP_P((const char *getpass));
32 #endif
33
34 /* getopt() defines may be in separate include file */
35 #if HAVE_GETOPT_H
36 #       include <getopt.h>
37
38 #elif !defined(HAVE_GETOPT)
39         /* no getopt, assume we need getopt-compat.h */
40 #       include <getopt-compat.h>
41
42 #else
43         /* assume we need to declare these externs */
44         extern char *optarg;
45         extern int optind, opterr, optopt;
46 #endif
47
48 #ifndef HAVE_TEMPNAM
49         extern char *tempnam(const char *tmpdir, const char *prefix);
50 #endif
51 #ifndef HAVE_MKTEMP
52         extern char *mktemp(char *);
53 #endif
54
55 /* Setup file locking macros */
56 #if !defined( ldap_lockf ) && HAVE_LOCKF && defined( F_LOCK )
57 #       define ldap_lockf(x)    lockf(fileno(x), F_LOCK, 0)
58 #       define ldap_unlockf(x)  lockf(fileno(x), F_ULOCK, 0)
59 #endif
60
61 #if !defined( ldap_lockf ) && HAVE_FCNTL
62 #       ifdef HAVE_FCNTL_H
63 #               include <fcntl.h>
64 #       endif
65
66 #       ifdef F_WRLCK
67 #               ifndef  NEED_FCNTL_LOCKING
68 #                       define NEED_FCNTL_LOCKING
69 #               endif
70 #               include <lutil_lockf.h>
71 #               define ldap_lockf(x)    lutil_lockf(x)
72 #               define ldap_unlockf(x)  lutil_unlockf(x)
73 #       endif
74 #endif
75
76 #if !defined( ldap_lockf ) && HAVE_FLOCK
77 #       if HAVE_SYS_FILE_H
78 #               include <sys/file.h>
79 #       endif
80 #       ifdef LOCK_EX
81 #               define ldap_lockf(x)    flock(fileno(x), LOCK_EX)
82 #               define ldap_unlockf(x)  flock(fileno(x), LOCK_UN)
83 #       endif
84 #endif
85
86 #if !defined( ldap_lockf )
87         /* use some simplistic locking method */
88 #       define NEED_SIMPLE_LOCKING
89 #       include <lutil_lockf.h>
90 #       define ldap_lockf(x)    lutil_lockf(x)
91 #       define ldap_unlockf(x)  lutil_unlockf(x)
92 #endif
93
94 #endif /* _AC_UNISTD_H */