mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-27 03:20:22 +08:00
ITS#8603 Add ldif_open_mem()
ldif_open_mem() is the fmemopen(3) equivalent of ldif_open() which opens an ldif steam from memory, rather than from a file.
This commit is contained in:
parent
58c978825c
commit
42d7238925
@ -863,6 +863,7 @@ dnl ----------------------------------------------------------------
|
||||
dnl Checks for libraries
|
||||
|
||||
AC_CHECK_FUNCS( sigaction sigset )
|
||||
AC_CHECK_FUNCS( fmemopen )
|
||||
|
||||
dnl HP-UX requires -lV3
|
||||
dnl this is not needed on newer versions of HP-UX
|
||||
|
@ -99,6 +99,10 @@ typedef struct LDIFFP {
|
||||
LDAP_LDIF_F( LDIFFP * )
|
||||
ldif_open LDAP_P(( LDAP_CONST char *file, LDAP_CONST char *mode ));
|
||||
|
||||
/* ldif_open equivalent that opens ldif stream in memory rather than from file */
|
||||
LDAP_LDIF_F( LDIFFP * )
|
||||
ldif_open_mem LDAP_P(( char *ldif, size_t size, LDAP_CONST char *mode ));
|
||||
|
||||
LDAP_LDIF_F( void )
|
||||
ldif_close LDAP_P(( LDIFFP * ));
|
||||
|
||||
|
@ -740,6 +740,28 @@ ldif_open(
|
||||
return lfp;
|
||||
}
|
||||
|
||||
LDIFFP *
|
||||
ldif_open_mem(
|
||||
char *ldif,
|
||||
size_t size,
|
||||
LDAP_CONST char *mode
|
||||
)
|
||||
{
|
||||
#ifdef HAVE_FMEMOPEN
|
||||
FILE *fp = fmemopen( ldif, size, mode );
|
||||
LDIFFP *lfp = NULL;
|
||||
|
||||
if ( fp ) {
|
||||
lfp = ber_memalloc( sizeof( LDIFFP ));
|
||||
lfp->fp = fp;
|
||||
lfp->prev = NULL;
|
||||
}
|
||||
return lfp;
|
||||
#else /* !HAVE_FMEMOPEN */
|
||||
return NULL;
|
||||
#endif /* !HAVE_FMEMOPEN */
|
||||
}
|
||||
|
||||
void
|
||||
ldif_close(
|
||||
LDIFFP *lfp
|
||||
|
Loading…
Reference in New Issue
Block a user