Centralize macros used for hiding GCC-specific attributes.

Use attributes for publicly exported functions.

Submitted by:	"Dmitry V. Levin" <ldv@altlinux.org>


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@318 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
Dag-Erling Smørgrav 2005-09-20 15:58:54 +00:00
parent 842343cb04
commit 4243d0384f
5 changed files with 98 additions and 36 deletions

View file

@ -1,5 +1,5 @@
#
# $P4: //depot/projects/openpam/MANIFEST#21 $
# $P4: //depot/projects/openpam/MANIFEST#22 $
#
CREDITS
HISTORY
@ -90,6 +90,7 @@ include/security/Makefile.in
include/security/openpam.h
include/security/openpam_version.h
include/security/pam_appl.h
include/security/pam_attributes.h
include/security/pam_constants.h
include/security/pam_modules.h
include/security/pam_types.h

View file

@ -1,4 +1,4 @@
# $P4: //depot/projects/openpam/include/security/Makefile.am#3 $
# $P4: //depot/projects/openpam/include/security/Makefile.am#4 $
openpamdir = $(includedir)/security
@ -6,6 +6,7 @@ openpam_HEADERS = \
openpam.h \
openpam_version.h \
pam_appl.h \
pam_attributes.h \
pam_constants.h \
pam_modules.h \
pam_types.h

View file

@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $P4: //depot/projects/openpam/include/security/openpam.h#28 $
* $P4: //depot/projects/openpam/include/security/openpam.h#29 $
*/
#ifndef _SECURITY_OPENPAM_H_INCLUDED
@ -42,6 +42,8 @@
*/
#include <stdarg.h>
#include <security/pam_attributes.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -53,7 +55,8 @@ struct passwd;
*/
int
openpam_borrow_cred(pam_handle_t *_pamh,
const struct passwd *_pwd);
const struct passwd *_pwd)
OPENPAM_NONNULL((1,2));
void
openpam_free_data(pam_handle_t *_pamh,
@ -68,7 +71,8 @@ openpam_get_option(pam_handle_t *_pamh,
const char *_option);
int
openpam_restore_cred(pam_handle_t *_pamh);
openpam_restore_cred(pam_handle_t *_pamh)
OPENPAM_NONNULL((1));
int
openpam_set_option(pam_handle_t *_pamh,
@ -78,48 +82,62 @@ openpam_set_option(pam_handle_t *_pamh,
int
pam_error(pam_handle_t *_pamh,
const char *_fmt,
...);
...)
OPENPAM_FORMAT ((__printf__, 2, 3))
OPENPAM_NONNULL((1,2));
int
pam_get_authtok(pam_handle_t *_pamh,
int _item,
const char **_authtok,
const char *_prompt);
const char *_prompt)
OPENPAM_NONNULL((1,3));
int
pam_info(pam_handle_t *_pamh,
const char *_fmt,
...);
...)
OPENPAM_FORMAT ((__printf__, 2, 3))
OPENPAM_NONNULL((1,2));
int
pam_prompt(pam_handle_t *_pamh,
int _style,
char **_resp,
const char *_fmt,
...);
...)
OPENPAM_FORMAT ((__printf__, 4, 5))
OPENPAM_NONNULL((1,4));
int
pam_setenv(pam_handle_t *_pamh,
const char *_name,
const char *_value,
int _overwrite);
int _overwrite)
OPENPAM_NONNULL((1,2,3));
int
pam_vinfo(pam_handle_t *_pamh,
const char *_fmt,
va_list _ap);
va_list _ap)
OPENPAM_FORMAT ((__printf__, 2, 0))
OPENPAM_NONNULL((1,2));
int
pam_verror(pam_handle_t *_pamh,
const char *_fmt,
va_list _ap);
va_list _ap)
OPENPAM_FORMAT ((__printf__, 2, 0))
OPENPAM_NONNULL((1,2));
int
pam_vprompt(pam_handle_t *_pamh,
int _style,
char **_resp,
const char *_fmt,
va_list _ap);
va_list _ap)
OPENPAM_FORMAT ((__printf__, 4, 0))
OPENPAM_NONNULL((1,4));
/*
* Read cooked lines.
@ -130,7 +148,8 @@ pam_vprompt(pam_handle_t *_pamh,
char *
openpam_readline(FILE *_f,
int *_lineno,
size_t *_lenp);
size_t *_lenp)
OPENPAM_NONNULL((1));
#endif
/*
@ -151,10 +170,8 @@ _openpam_log(int _level,
const char *_func,
const char *_fmt,
...)
#if defined(__GNUC__)
__attribute__((__format__(__printf__, 3, 4)))
#endif
;
OPENPAM_FORMAT ((__printf__, 3, 4))
OPENPAM_NONNULL((3));
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
#define openpam_log(lvl, ...) \
@ -172,7 +189,9 @@ _openpam_log(int _level,
void
openpam_log(int _level,
const char *_format,
...);
...)
OPENPAM_FORMAT ((__printf__, 2, 3))
OPENPAM_NONNULL((2));
#endif
/*

View file

@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $P4: //depot/projects/openpam/include/security/pam_appl.h#14 $
* $P4: //depot/projects/openpam/include/security/pam_appl.h#15 $
*/
#ifndef _PAM_APPL_H_INCLUDED
@ -39,6 +39,7 @@
#include <security/pam_types.h>
#include <security/pam_constants.h>
#include <security/pam_attributes.h>
#ifdef __cplusplus
extern "C" {
@ -50,53 +51,65 @@ extern "C" {
int
pam_acct_mgmt(pam_handle_t *_pamh,
int _flags);
int _flags)
OPENPAM_NONNULL((1));
int
pam_authenticate(pam_handle_t *_pamh,
int _flags);
int _flags)
OPENPAM_NONNULL((1));
int
pam_chauthtok(pam_handle_t *_pamh,
int _flags);
int _flags)
OPENPAM_NONNULL((1));
int
pam_close_session(pam_handle_t *_pamh,
int _flags);
int _flags)
OPENPAM_NONNULL((1));
int
pam_end(pam_handle_t *_pamh,
int _status);
int _status)
OPENPAM_NONNULL((1));
int
pam_get_data(pam_handle_t *_pamh,
const char *_module_data_name,
void **_data);
void **_data)
OPENPAM_NONNULL((1,2,3));
int
pam_get_item(pam_handle_t *_pamh,
int _item_type,
const void **_item);
const void **_item)
OPENPAM_NONNULL((1,3));
int
pam_get_user(pam_handle_t *_pamh,
const char **_user,
const char *_prompt);
const char *_prompt)
OPENPAM_NONNULL((1,2));
const char *
pam_getenv(pam_handle_t *_pamh,
const char *_name);
const char *_name)
OPENPAM_NONNULL((1,2));
char **
pam_getenvlist(pam_handle_t *_pamh);
pam_getenvlist(pam_handle_t *_pamh)
OPENPAM_NONNULL((1));
int
pam_open_session(pam_handle_t *_pamh,
int _flags);
int _flags)
OPENPAM_NONNULL((1));
int
pam_putenv(pam_handle_t *_pamh,
const char *_namevalue);
const char *_namevalue)
OPENPAM_NONNULL((1,2));
int
pam_set_data(pam_handle_t *_pamh,
@ -104,22 +117,26 @@ pam_set_data(pam_handle_t *_pamh,
void *_data,
void (*_cleanup)(pam_handle_t *_pamh,
void *_data,
int _pam_end_status));
int _pam_end_status))
OPENPAM_NONNULL((1,2));
int
pam_set_item(pam_handle_t *_pamh,
int _item_type,
const void *_item);
const void *_item)
OPENPAM_NONNULL((1));
int
pam_setcred(pam_handle_t *_pamh,
int _flags);
int _flags)
OPENPAM_NONNULL((1));
int
pam_start(const char *_service,
const char *_user,
const struct pam_conv *_pam_conv,
pam_handle_t **_pamh);
pam_handle_t **_pamh)
OPENPAM_NONNULL((4));
const char *
pam_strerror(pam_handle_t *_pamh,

View file

@ -0,0 +1,24 @@
#ifndef _PAM_ATTRIBUTES_H_INCLUDED
#define _PAM_ATTRIBUTES_H_INCLUDED
/* GCC attributes */
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__STRICT_ANSI__)
# define OPENPAM_GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
# define OPENPAM_GNUC_PREREQ(maj, min) 0
#endif
#if OPENPAM_GNUC_PREREQ(2,5)
# define OPENPAM_FORMAT(params) __attribute__((__format__ params))
#else
# define OPENPAM_FORMAT(params)
#endif
#if OPENPAM_GNUC_PREREQ(3,3)
# define OPENPAM_NONNULL(params) __attribute__((__nonnull__ params))
#else
# define OPENPAM_NONNULL(params)
#endif
#endif /* _PAM_ATTRIBUTES_H_INCLUDED */