Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 3, the unsupported old release. You're almost certainly looking for [[/eggref/4/stream-ldif|the CHICKEN 4 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-4.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. [[tags:ldif streams eggs parsing]] [[toc:]] == Introduction Parser and generator for LDIF (LDAP Data Interchange Format) files. The parser returns a stream of hashes, one for each entry in the file. Each hash has as keys names of attributes and as values lists of the values for the given keys. The generator expects information in exactly the same format (which makes it easy to perform transformations in LDIF files, for example). == Examples ... === Getting an attribute of all objects The following example prints all the values for the {{cn}} attributes for all objects in the LDIF file: <enscript highlight=scheme> (use stream-ldif format-modular) (stream-for-each (lambda (hash) (for-each (lambda (value) (format #t "~A~%" (stream->string value))) (hash-table-ref/default hash 'cn '()))) (stream->ldif (port->stream (current-input-port)))) </enscript> == Authors The stream-ldif egg was created by [[Alejandro Forero Cuervo]]. == Requirements * [[srfi-1]] (compile-time) * [[srfi-40]] (compile-time) * [[stream-ext]] * [[stream-base64]] == Parsing an LDIF file <enscript highlight=scheme> (stream->ldif stream) </enscript> Given a stream of characters corresponding to a file in the LDIF format, returns a stream of hash tables. Each hash table corresponds to one of the entries in the LDIF file. The hash tables are indexed by the names of the attributes in lowercase (as symbols); each value is a list with all the values (as streams of characters). The parsing of the LDIF stream is done in a lazy file, reading entries only as required (as the stream of hash table is built). == Generating an LDIF file <enscript highlight=scheme> (ldif->stream stream) </enscript> Performs the opposite function of {{stream->ldif}}: given a stream with hashes corresponding to changes, produces an LDIF file and returns it as a stream of characters. Each hash should be indexed by the names of the attribute as symbols; the value for each entry must be a list with the values for the attributes as streams of characters encoded in UTF-8. Note that each hash table must always contain a {{dn}} entry having its distinguished name as its first element. == License The stream LDIF egg for Chicken Scheme is in the public domain and may be reproduced or copied without permission from its author. Citation of the source is appreciated. == Version history ; 1.1 : Adapted to SRFI-69-compatible hash-tables ; 1.0 : First public release
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you subtract 24 from 6?