Commit 42d72389 authored by Brett Sheffield's avatar Brett Sheffield Committed by Ondřej Kuzník
Browse files

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.
parent 58c97882
...@@ -863,6 +863,7 @@ dnl ---------------------------------------------------------------- ...@@ -863,6 +863,7 @@ dnl ----------------------------------------------------------------
dnl Checks for libraries dnl Checks for libraries
AC_CHECK_FUNCS( sigaction sigset ) AC_CHECK_FUNCS( sigaction sigset )
AC_CHECK_FUNCS( fmemopen )
dnl HP-UX requires -lV3 dnl HP-UX requires -lV3
dnl this is not needed on newer versions of HP-UX dnl this is not needed on newer versions of HP-UX
......
...@@ -99,6 +99,10 @@ typedef struct LDIFFP { ...@@ -99,6 +99,10 @@ typedef struct LDIFFP {
LDAP_LDIF_F( LDIFFP * ) LDAP_LDIF_F( LDIFFP * )
ldif_open LDAP_P(( LDAP_CONST char *file, LDAP_CONST char *mode )); 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 ) LDAP_LDIF_F( void )
ldif_close LDAP_P(( LDIFFP * )); ldif_close LDAP_P(( LDIFFP * ));
......
...@@ -740,6 +740,28 @@ ldif_open( ...@@ -740,6 +740,28 @@ ldif_open(
return lfp; 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 void
ldif_close( ldif_close(
LDIFFP *lfp LDIFFP *lfp
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment