Mercurial > hg > xemacs-beta
annotate modules/ldap/eldap.c @ 2720:6fa9919a9a0b
[xemacs-hg @ 2005-04-08 23:10:01 by crestani]
ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
New configure flag: `MC_ALLOC':
* configure.ac (XE_COMPLEX_ARG_ENABLE): Add `--enable-mc-alloc' as
a new configure flag.
* configure.in (AC_INIT_PARSE_ARGS): Add `--mc-alloc' as a new
configure flag.
* configure.usage: Add description for `mc-alloc'.
DUMP_IN_EXEC:
* Makefile.in.in: Condition the installation of a separate dump
file on !DUMP_ON_EXEC.
* configure.ac (XE_COMPLEX_ARG_ENABLE): Add
`--enable-dump-in-exec' as a new configure flag.
* configure.ac: DUMP_IN_EXEC is define as default for PDUMP but
not default for MC_ALLOC.
* configure.in (AC_INIT_PARSE_ARGS): Add `--dump-in-exec' as a
new configure flag.
* configure.in: DUMP_IN_EXEC is define as default for PDUMP but
not default for MC_ALLOC.
* configure.usage: Add description for `dump-in-exec'.
lib-src/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
DUMP_IN_EXEC:
* Makefile.in.in: Only compile insert-data-in-exec if
DUMP_IN_EXEC is defined.
lisp/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
MEMORY_USAGE_STATS
* diagnose.el: Add new lisp function to pretty print statistics
about the new allocator.
* diagnose.el (show-mc-alloc-memory-usage): New.
modules/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
Remove Lcrecords:
* postgresql/postgresql.c (allocate_pgconn): Allocate with new
allocator.
* postgresql/postgresql.c (allocate_pgresult): Allocate PGresult
with new allocator.
* postgresql/postgresql.h (struct Lisp_PGconn): Add
lrecord_header.
* postgresql/postgresql.h (struct Lisp_PGresult): Add
lrecord_header.
* ldap/eldap.c (allocate_ldap): Allocate with new allocator.
* ldap/eldap.h (struct Lisp_LDAP): Add lrecord_header.
nt/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
New configure flag: `MC_ALLOC':
* config.inc.samp: Add new flag `MC_ALLOC'.
* xemacs.mak: Add flag and configuration output for `MC_ALLOC'.
New files:
* xemacs.dsp: Add source files mc-alloc.c and mc-alloc.h.
* xemacs.mak: Add new object file mc-alloc.obj to dependencies.
src/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
New configure flag: `MC_ALLOC':
* config.h.in: Add new flag `MC_ALLOC'.
New files:
* Makefile.in.in: Add new object file mc-alloc.o.
* depend: Add new files to dependencies.
* mc-alloc.c: New.
* mc-alloc.h: New.
Running the new allocator from XEmacs:
* alloc.c (deadbeef_memory): Moved to mc-alloc.c.
* emacs.c (main_1): Initialize the new allocator and add
syms_of_mc_alloc.
* symsinit.h: Add syms_of_mc_alloc.
New lrecord allocation and free functions:
* alloc.c (alloc_lrecord): New. Allocates an lrecord, includes
type checking and initializing of the lrecord_header.
* alloc.c (noseeum_alloc_lrecord): Same as above, but increments
the NOSEEUM cons counter.
* alloc.c (free_lrecord): New. Calls the finalizer and frees the
lrecord.
* lrecord.h: Add lrecord allocation prototypes and comments.
Remove old lrecord FROB block allocation:
* alloc.c (allocate_lisp_storage): Former function to expand
heap. Not needed anymore, remove.
* alloc.c: Completely remove `Fixed-size type macros'
* alloc.c (release_breathing_space): Remove.
* alloc.c (memory_full): Remove release_breathing_space.
* alloc.c (refill_memory_reserve): Remove.
* alloc.c (TYPE_ALLOC_SIZE): Remove.
* alloc.c (DECLARE_FIXED_TYPE_ALLOC): Remove.
* alloc.c (ALLOCATE_FIXED_TYPE_FROM_BLOCK): Remove.
* alloc.c (ALLOCATE_FIXED_TYPE_1): Remove.
* alloc.c (ALLOCATE_FIXED_TYPE): Remove.
* alloc.c (NOSEEUM_ALLOCATE_FIXED_TYPE): Remove.
* alloc.c (struct Lisp_Free): Remove.
* alloc.c (LRECORD_FREE_P): Remove.
* alloc.c (MARK_LRECORD_AS_FREE): Remove.
* alloc.c (MARK_LRECORD_AS_NOT_FREE): Remove.
* alloc.c (PUT_FIXED_TYPE_ON_FREE_LIST): Remove.
* alloc.c (FREE_FIXED_TYPE): Remove.
* alloc.c (FREE_FIXED_TYPE_WHEN_NOT_IN_GC): Remove.
Allocate old lrecords with new allocator:
* alloc.c: DECLARE_FIXED_TYPE_ALLOC removed for all lrecords
defined in alloc.c.
* alloc.c (Fcons): Allocate with new allocator.
* alloc.c (noseeum_cons): Allocate with new allocator.
* alloc.c (make_float): Allocate with new allocator.
* alloc.c (make_bignum): Allocate with new allocator.
* alloc.c (make_bignum_bg): Allocate with new allocator.
* alloc.c (make_ratio): Allocate with new allocator.
* alloc.c (make_ratio_bg): Allocate with new allocator.
* alloc.c (make_ratio_rt): Allocate with new allocator.
* alloc.c (make_bigfloat): Allocate with new allocator.
* alloc.c (make_bigfloat_bf): Allocate with new allocator.
* alloc.c (make_compiled_function): Allocate with new allocator.
* alloc.c (Fmake_symbol): Allocate with new allocator.
* alloc.c (allocate_extent): Allocate with new allocator.
* alloc.c (allocate_event): Allocate with new allocator.
* alloc.c (make_key_data): Allocate with new allocator.
* alloc.c (make_button_data): Allocate with new allocator.
* alloc.c (make_motion_data): Allocate with new allocator.
* alloc.c (make_process_data): Allocate with new allocator.
* alloc.c (make_timeout_data): Allocate with new allocator.
* alloc.c (make_magic_data): Allocate with new allocator.
* alloc.c (make_magic_eval_data): Allocate with new allocator.
* alloc.c (make_eval_data): Allocate with new allocator.
* alloc.c (make_misc_user_data): Allocate with new allocator.
* alloc.c (Fmake_marker): Allocate with new allocator.
* alloc.c (noseeum_make_marker): Allocate with new allocator.
* alloc.c (make_uninit_string): Allocate with new allocator.
* alloc.c (resize_string): Allocate with new allocator.
* alloc.c (make_string_nocopy): Allocate with new allocator.
Garbage Collection:
* alloc.c (GC_CHECK_NOT_FREE): Remove obsolete assertions.
* alloc.c (SWEEP_FIXED_TYPE_BLOCK): Remove.
* alloc.c (SWEEP_FIXED_TYPE_BLOCK_1): Remove.
* alloc.c (sweep_conses): Remove.
* alloc.c (free_cons): Use new allocator to free.
* alloc.c (sweep_compiled_functions): Remove.
* alloc.c (sweep_floats): Remove.
* alloc.c (sweep_bignums): Remove.
* alloc.c (sweep_ratios): Remove.
* alloc.c (sweep_bigfloats): Remove.
* alloc.c (sweep_symbols): Remove.
* alloc.c (sweep_extents): Remove.
* alloc.c (sweep_events): Remove.
* alloc.c (sweep_key_data): Remove.
* alloc.c (free_key_data): Use new allocator to free.
* alloc.c (sweep_button_data): Remove.
* alloc.c (free_button_data): Use new allocator to free.
* alloc.c (sweep_motion_data): Remove.
* alloc.c (free_motion_data): Use new allocator to free.
* alloc.c (sweep_process_data): Remove.
* alloc.c (free_process_data): Use new allocator to free.
* alloc.c (sweep_timeout_data): Remove.
* alloc.c (free_timeout_data): Use new allocator to free.
* alloc.c (sweep_magic_data): Remove.
* alloc.c (free_magic_data): Use new allocator to free.
* alloc.c (sweep_magic_eval_data): Remove.
* alloc.c (free_magic_eval_data): Use new allocator to free.
* alloc.c (sweep_eval_data): Remove.
* alloc.c (free_eval_data): Use new allocator to free.
* alloc.c (sweep_misc_user_data): Remove.
* alloc.c (free_misc_user_data): Use new allocator to free.
* alloc.c (sweep_markers): Remove.
* alloc.c (free_marker): Use new allocator to free.
* alloc.c (garbage_collect_1): Remove release_breathing_space.
* alloc.c (gc_sweep): Remove all the old lcrecord and lrecord
related stuff. Sweeping now works like this: compact string
chars, finalize, sweep.
* alloc.c (common_init_alloc_early): Remove old lrecord
initializations, remove breathing_space.
* emacs.c (Fdump_emacs): Remove release_breathing_space.
* lisp.h: Remove prototype for release_breathing_space.
* lisp.h: Adjust the special cons mark makros.
Lrecord Finalizer:
* alloc.c: Add finalizer to lrecord definition.
* alloc.c (finalize_string): Add finalizer for string.
* bytecode.c: Add finalizer to lrecord definition.
* bytecode.c (finalize_compiled_function): Add finalizer for
compiled function.
* marker.c: Add finalizer to lrecord definition.
* marker.c (finalize_marker): Add finalizer for marker.
These changes build the interface to mc-alloc:
* lrecord.h (MC_ALLOC_CALL_FINALIZER): Tell mc-alloc how to
finalize lrecords.
* lrecord.h (MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE): Tell
mc-alloc how to finalize for disksave.
Unify lrecords and lcrecords:
* lisp.h (struct Lisp_String): Adjust string union hack to
new lrecord header.
* lrecord.h: Adjust comments.
* lrecord.h (struct lrecord_header): The new lrecord header
includes type, lisp-readonly, free, and uid.
* lrecord.h (set_lheader_implementation): Adjust to new
lrecord_header.
* lrecord.h (struct lrecord_implementation): The field basic_p
for indication of an old lrecord is not needed anymore, remove.
* lrecord.h (MAKE_LRECORD_IMPLEMENTATION): Remove basic_p.
* lrecord.h (MAKE_EXTERNAL_LRECORD_IMPLEMENTATION): Remove
basic_p.
* lrecord.h (copy_sized_lrecord): Remove distinction between
old lrecords and lcrecords.
* lrecord.h (copy_lrecord): Remove distinction between old
lrecords and lcrecords.
* lrecord.h (zero_sized_lrecord): Remove distinction between
old lrecords and lcrecords.
* lrecord.h (zero_lrecord): Remove distinction between old
lrecords and lcrecords.
Remove lcrecords and lcrecord lists:
* alloc.c (basic_alloc_lcrecord): Not needed anymore, remove.
* alloc.c (very_old_free_lcrecord): Not needed anymore, remove.
* alloc.c (copy_lisp_object): No more distinction between
lrecords and lcrecords.
* alloc.c (all_lcrecords): Not needed anymore, remove.
* alloc.c (make_vector_internal): Allocate as lrecord.
* alloc.c (make_bit_vector_internal): Allocate as lrecord.
* alloc.c: Completely remove `lcrecord lists'.
* alloc.c (free_description): Remove.
* alloc.c (lcrecord_list_description): Remove.
* alloc.c (mark_lcrecord_list): Remove.
* alloc.c (make_lcrecord_list): Remove.
* alloc.c (alloc_managed_lcrecord): Remove.
* alloc.c (free_managed_lcrecord): Remove.
* alloc.c (alloc_automanaged_lcrecord): Remove.
* alloc.c (free_lcrecord): Remove.
* alloc.c (lcrecord_stats): Remove.
* alloc.c (tick_lcrecord_stats): Remove.
* alloc.c (disksave_object_finalization_1): Add call to
mc_finalize_for_disksave. Remove the lcrecord way to visit all
objects.
* alloc.c (kkcc_marking): Remove XD_FLAG_FREE_LISP_OBJECT
* alloc.c (sweep_lcrecords_1): Remove.
* alloc.c (common_init_alloc_early): Remove everything related
to lcrecords, remove old lrecord initializations,
* alloc.c (init_lcrecord_lists): Not needed anymore, remove.
* alloc.c (reinit_alloc_early): Remove everything related to
lcrecords.
* alloc.c (init_alloc_once_early): Remove everything related to
lcrecords.
* buffer.c (allocate_buffer): Allocate as lrecord.
* buffer.c (nuke_all_buffer_slots): Use lrecord functions.
* buffer.c (common_init_complex_vars_of_buffer): Allocate as
lrecord.
* buffer.h (struct buffer): Add lrecord_header.
* casetab.c (allocate_case_table): Allocate as lrecord.
* casetab.h (struct Lisp_Case_Table): Add lrecord_header.
* charset.h (struct Lisp_Charset): Add lrecord_header.
* chartab.c (fill_char_table): Use lrecord functions.
* chartab.c (Fmake_char_table): Allocate as lrecord.
* chartab.c (make_char_table_entry): Allocate as lrecord.
* chartab.c (copy_char_table_entry): Allocate as lrecord.
* chartab.c (Fcopy_char_table): Allocate as lrecord.
* chartab.c (put_char_table): Use lrecord functions.
* chartab.h (struct Lisp_Char_Table_Entry): Add lrecord_header.
* chartab.h (struct Lisp_Char_Table): Add lrecord_header.
* console-impl.h (struct console): Add lrecord_header.
* console-msw-impl.h (struct Lisp_Devmode): Add lrecord_header.
* console-msw-impl.h (struct mswindows_dialog_id): Add
lrecord_header.
* console.c (allocate_console): Allocate as lrecord.
* console.c (nuke_all_console_slots): Use lrecord functions.
* console.c (common_init_complex_vars_of_console): Allocate as
lrecord.
* data.c (make_weak_list): Allocate as lrecord.
* data.c (make_weak_box): Allocate as lrecord.
* data.c (make_ephemeron): Allocate as lrecord.
* database.c (struct Lisp_Database): Add lrecord_header.
* database.c (allocate_database): Allocate as lrecord.
* device-impl.h (struct device): Add lrecord_header.
* device-msw.c (allocate_devmode): Allocate as lrecord.
* device.c (nuke_all_device_slots): Use lrecord functions.
* device.c (allocate_device): Allocate as lrecord.
* dialog-msw.c (handle_question_dialog_box): Allocate as lrecord.
* elhash.c (struct Lisp_Hash_Table): Add lrecord_header.
* elhash.c (make_general_lisp_hash_table): Allocate as lrecord.
* elhash.c (Fcopy_hash_table): Allocate as lrecord.
* event-stream.c: Lcrecord lists Vcommand_builder_free_list and
Vtimeout_free_list are no longer needed. Remove.
* event-stream.c (allocate_command_builder): Allocate as lrecord.
* event-stream.c (free_command_builder): Use lrecord functions.
* event-stream.c (event_stream_generate_wakeup): Allocate as
lrecord.
* event-stream.c (event_stream_resignal_wakeup): Use lrecord
functions.
* event-stream.c (event_stream_disable_wakeup): Use lrecord
functions.
* event-stream.c (reinit_vars_of_event_stream): Lcrecord lists
remove.
* events.h (struct Lisp_Timeout): Add lrecord_header.
* events.h (struct command_builder): Add lrecord_header.
* extents-impl.h (struct extent_auxiliary): Add lrecord_header.
* extents-impl.h (struct extent_info): Add lrecord_header.
* extents.c (allocate_extent_auxiliary): Allocate as lrecord.
* extents.c (allocate_extent_info): Allocate as lrecord.
* extents.c (copy_extent): Allocate as lrecord.
* faces.c (allocate_face): Allocate as lrecord.
* faces.h (struct Lisp_Face): Add lrecord_header.
* file-coding.c (allocate_coding_system): Allocate as lrecord.
* file-coding.c (Fcopy_coding_system): Allocate as lrecord.
* file-coding.h (struct Lisp_Coding_System): Add lrecord_header.
* fns.c (Ffillarray): Allocate as lrecord.
* frame-impl.h (struct frame): Add lrecord_header.
* frame.c (nuke_all_frame_slots): Use lrecord functions.
* frame.c (allocate_frame_core): Allocate as lrecord.
* glyphs.c (allocate_image_instance): Allocate as lrecord.
* glyphs.c (Fcolorize_image_instance): Allocate as lrecord.
* glyphs.c (allocate_glyph): Allocate as lrecord.
* glyphs.h (struct Lisp_Image_Instance): Add lrecord_header.
* glyphs.h (struct Lisp_Glyph): Add lrecord_header.
* gui.c (allocate_gui_item): Allocate as lrecord.
* gui.h (struct Lisp_Gui_Item): Add lrecord_header.
* keymap.c (struct Lisp_Keymap): Add lrecord_header.
* keymap.c (make_keymap): Allocate as lrecord.
* lisp.h (struct Lisp_Vector): Add lrecord_header.
* lisp.h (struct Lisp_Bit_Vector): Add lrecord_header.
* lisp.h (struct weak_box): Add lrecord_header.
* lisp.h (struct ephemeron): Add lrecord_header.
* lisp.h (struct weak_list): Add lrecord_header.
* lrecord.h (struct lcrecord_header): Not used, remove.
* lrecord.h (struct free_lcrecord_header): Not used, remove.
* lrecord.h (struct lcrecord_list): Not needed anymore, remove.
* lrecord.h (lcrecord_list): Not needed anymore, remove.
* lrecord.h: (enum data_description_entry_flags): Remove
XD_FLAG_FREE_LISP_OBJECT.
* lstream.c: Lrecord list Vlstream_free_list remove.
* lstream.c (Lstream_new): Allocate as lrecord.
* lstream.c (Lstream_delete): Use lrecod functions.
* lstream.c (reinit_vars_of_lstream): Vlstream_free_list
initialization remove.
* lstream.h (struct lstream): Add lrecord_header.
* emacs.c (main_1): Remove lstream initialization.
* mule-charset.c (make_charset): Allocate as lrecord.
* objects-impl.h (struct Lisp_Color_Instance): Add
lrecord_header.
* objects-impl.h (struct Lisp_Font_Instance): Add lrecord_header.
* objects.c (Fmake_color_instance): Allocate as lrecord.
* objects.c (Fmake_font_instance): Allocate as lrecord.
* objects.c (reinit_vars_of_objects): Allocate as lrecord.
* opaque.c: Lcreord list Vopaque_ptr_list remove.
* opaque.c (make_opaque): Allocate as lrecord.
* opaque.c (make_opaque_ptr): Allocate as lrecord.
* opaque.c (free_opaque_ptr): Use lrecord functions.
* opaque.c (reinit_opaque_early):
* opaque.c (init_opaque_once_early): Vopaque_ptr_list
initialization remove.
* opaque.h (Lisp_Opaque): Add lrecord_header.
* opaque.h (Lisp_Opaque_Ptr): Add lrecord_header.
* emacs.c (main_1): Remove opaque variable initialization.
* print.c (default_object_printer): Use new lrecord_header.
* print.c (print_internal): Use new lrecord_header.
* print.c (debug_p4): Use new lrecord_header.
* process.c (make_process_internal): Allocate as lrecord.
* procimpl.h (struct Lisp_Process): Add lrecord_header.
* rangetab.c (Fmake_range_table): Allocate as lrecord.
* rangetab.c (Fcopy_range_table): Allocate as lrecord.
* rangetab.h (struct Lisp_Range_Table): Add lrecord_header.
* scrollbar.c (create_scrollbar_instance): Allocate as lrecord.
* scrollbar.h (struct scrollbar_instance): Add lrecord_header.
* specifier.c (make_specifier_internal): Allocate as lrecord.
* specifier.h (struct Lisp_Specifier): Add lrecord_header.
* symbols.c:
* symbols.c (Fmake_variable_buffer_local): Allocate as lrecord.
* symbols.c (Fdontusethis_set_symbol_value_handler): Allocate
as lrecord.
* symbols.c (Fdefvaralias): Allocate as lrecord.
* symeval.h (struct symbol_value_magic): Add lrecord_header.
* toolbar.c (update_toolbar_button): Allocate as lrecord.
* toolbar.h (struct toolbar_button): Add lrecord_header.
* tooltalk.c (struct Lisp_Tooltalk_Message): Add lrecord_header.
* tooltalk.c (make_tooltalk_message): Allocate as lrecord.
* tooltalk.c (struct Lisp_Tooltalk_Pattern): Add lrecord_header.
* tooltalk.c (make_tooltalk_pattern): Allocate as lrecord.
* ui-gtk.c (allocate_ffi_data): Allocate as lrecord.
* ui-gtk.c (allocate_emacs_gtk_object_data): Allocate as lrecord.
* ui-gtk.c (allocate_emacs_gtk_boxed_data): Allocate as lrecord.
* ui-gtk.h (structs): Add lrecord_header.
* window-impl.h (struct window): Add lrecord_header.
* window-impl.h (struct window_mirror): Add lrecord_header.
* window.c (allocate_window): Allocate as lrecord.
* window.c (new_window_mirror): Allocate as lrecord.
* window.c (make_dummy_parent): Allocate as lrecord.
MEMORY_USAGE_STATS
* alloc.c (fixed_type_block_overhead): Not used anymore, remove.
* buffer.c (compute_buffer_usage): Get storage size from new
allocator.
* marker.c (compute_buffer_marker_usage): Get storage size from
new allocator.
* mule-charset.c (compute_charset_usage): Get storage size from
new allocator.
* scrollbar-gtk.c (gtk_compute_scrollbar_instance_usage): Get
storage size from new allocator.
* scrollbar-msw.c (mswindows_compute_scrollbar_instance_usage):
Get storage size from new allocator.
* scrollbar-x.c (x_compute_scrollbar_instance_usage): Get
storage size from new allocator.
* scrollbar.c (compute_scrollbar_instance_usage): Get storage
size from new allocator.
* unicode.c (compute_from_unicode_table_size_1): Get storage
size from new allocator.
* unicode.c (compute_to_unicode_table_size_1): Get storage size
from new allocator.
* window.c (compute_window_mirror_usage): Get storage size from
new allocator.
* window.c (compute_window_usage): Get storage size from new
allocator.
MC_ALLOC_TYPE_STATS:
* alloc.c (alloc_lrecord): Bump lrecord count.
* alloc.c (noseeum_alloc_lrecord): Bump lrecord count.
* alloc.c (struct lrecord_stats): Storage for counts.
* alloc.c (init_lrecord_stats): Zero statistics.
* alloc.c (inc_lrecord_stats): Increase the statistic.
* alloc.c (dec_lrecord_stats): Decrease the statistic.
* alloc.c (gc_plist_hack): Used to print the information.
* alloc.c (Fgarbage_collect): Return the collected information.
* mc-alloc.c (remove_cell): Decrease lrecord count.
* mc-alloc.h: Set flag MC_ALLOC_TYPE_STATS.
* emacs.c (main_1): Init lrecord statistics.
* lrecord.h: Add prototypes for *_lrecord_stats.
Strings:
* alloc.c (Fmake_string): Initialize ascii_begin to zero.
* alloc.c (gc_count_num_short_string_in_use): Remove.
* alloc.c (gc_count_string_total_size): Remove.
* alloc.c (gc_count_short_string_total_size): Remove.
* alloc.c (debug_string_purity): Remove.
* alloc.c (debug_string_purity_print): Remove.
* alloc.c (sweep_strings): Remove.
Remove static C-readonly Lisp objects:
* alloc.c (c_readonly): Not needed anymore, remove.
* alloc.c (GC_CHECK_LHEADER_INVARIANTS): Remove some obsolete
lheader invariants assertions.
* buffer.c (DEFVAR_BUFFER_LOCAL_1): Allocate dynamically.
* console.c (DEFVAR_CONSOLE_LOCAL_1): Allocate dynamically.
* gpmevent.c: Indirection via MC_ALLOC_Freceive_gpm_event.
* gpmevent.c (Fgpm_enable): Allocate dynamically.
* gpmevent.c (syms_of_gpmevent): Allocate dynamically.
* lisp.h (C_READONLY): Not needed anymore, remove.
* lisp.h (DEFUN): Allocate dynamically.
* lrecord.h (C_READONLY_RECORD_HEADER_P): Not needed anymore,
remove.
* lrecord.h (SET_C_READONLY_RECORD_HEADER): Not needed anymore,
remove.
* symbols.c (guts_of_unbound_marker):
* symeval.h (defsubr): Allocate dynamically.
* symeval.h (DEFSUBR_MACRO): Allocate dynamically.
* symeval.h (DEFVAR_ SYMVAL_FWD): Allocate dynamically.
* tests.c (TESTS_DEFSUBR): Allocate dynamically.
Definition of mcpro:
* lisp.h: Add mcpro prototypes.
* alloc.c (common_init_alloc_early): Add initialization for
mcpros.
* alloc.c (mcpro_description_1): New.
* alloc.c (mcpro_description): New.
* alloc.c (mcpros_description_1): New.
* alloc.c (mcpros_description): New.
* alloc.c (mcpro_one_name_description_1): New.
* alloc.c (mcpro_one_name_description): New.
* alloc.c (mcpro_names_description_1): New.
* alloc.c (mcpro_names_description): New.
* alloc.c (mcpros): New.
* alloc.c (mcpro_names): New.
* alloc.c (mcpro_1): New.
* alloc.c (mc_pro): New.
* alloc.c (garbage_collect_1): Add mcpros to root set.
Usage of mcpro:
* alloc.c (make_string_nocopy): Add string to root set.
* symbols.c (init_symbols_once_early): Add Qunbound to root set.
Changes to the Portable Dumper:
* alloc.c (FREE_OR_REALLOC_BEGIN): Since dumped objects can be
freed with the new allocator, remove assertion for !DUMPEDP.
* dumper.c: Adjust comments, increase PDUMP_HASHSIZE.
* dumper.c (pdump_make_hash): Shift address only 2 bytes, to
avoid collisions.
* dumper.c (pdump_objects_unmark): No more mark bits within
the object, remove.
* dumper.c (mc_addr_elt): New. Element data structure for mc
hash table.
* dumper.c (pdump_mc_hash): New hash table: `lookup table'.
* dumper.c (pdump_get_mc_addr): New. Lookup for hash table.
* dumper.c (pdump_get_indirect_mc_addr): New. Lookup for
convertibles.
* dumper.c (pdump_put_mc_addr): New. Putter for hash table.
* dumper.c (pdump_dump_mc_data): New. Writes the table for
relocation at load time to the dump file.
* dumper.c (pdump_scan_lisp_objects_by_alignment): New.
Visits all dumped Lisp objects.
* dumper.c (pdump_scan_non_lisp_objects_by_alignment): New.
Visits all other dumped objects.
* dumper.c (pdump_reloc_one_mc): New. Updates all pointers
of an object by using the hash table pdump_mc_hash.
* dumper.c (pdump_reloc_one): Replaced by pdump_reloc_one_mc.
* dumper.c (pdump): Change the structure of the dump file, add
the mc post dump relocation table to dump file.
* dumper.c (pdump_load_finish): Hand all dumped objects to the
new allocator and use the mc post dump relocation table for
relocating the dumped objects at dump file load time, free not
longer used data structures.
* dumper.c (pdump_load): Free the dump file.
* dumper.h: Remove pdump_objects_unmark.
* lrecord.h (DUMPEDP): Dumped objects can be freed, remove.
DUMP_IN_EXEC:
* Makefile.in.in: Linking for and with dump in executable only if
DUMP_IN_EXEC is defined.
* config.h.in: Add new flag `DUMP_IN_EXEC'
* emacs.c: Condition dump-data.h on DUMP_IN_EXEC.
* emacs.c (main_1): Flag `-si' only works if dump image is
written into executable.
Miscellanious
* lrecord.h (enum lrecord_type): Added numbers to all types,
very handy for debugging.
* xemacs.def.in.in: Add mc-alloc functions to make them visible
to the modules.
author | crestani |
---|---|
date | Fri, 08 Apr 2005 23:11:35 +0000 |
parents | 7ee6ea4ff5c0 |
children | b7f26b2f78bd |
rev | line source |
---|---|
428 | 1 /* LDAP client interface for XEmacs. |
2 Copyright (C) 1998 Free Software Foundation, Inc. | |
2367 | 3 Copyright (C) 2004 Ben Wing. |
4 | |
428 | 5 |
6 This file is part of XEmacs. | |
7 | |
8 XEmacs is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
10 Free Software Foundation; either version 2, or (at your option) any | |
11 later version. | |
12 | |
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with XEmacs; see the file COPYING. If not, write to | |
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 Boston, MA 02111-1307, USA. */ | |
22 | |
23 /* Synched up with: Not in FSF. */ | |
24 | |
996 | 25 /* Author: Oscar Figueiredo with lots of support from Hrvoje Niksic */ |
428 | 26 |
27 /* This file provides lisp primitives for access to an LDAP library | |
28 conforming to the API defined in RFC 1823. | |
29 It has been tested with: | |
30 - UMich LDAP 3.3 (http://www.umich.edu/~dirsvcs/ldap/) | |
996 | 31 - OpenLDAP 1.2 (http://www.openldap.org/) |
32 - Netscape's LDAP SDK (http://developer.netscape.com/) */ | |
33 | |
428 | 34 |
996 | 35 #include <config.h> |
36 #include "lisp.h" | |
37 #include "opaque.h" | |
38 #include "sysdep.h" | |
39 #include "buffer.h" | |
40 #include "process.h" /* for report_process_error */ | |
1632 | 41 #ifdef HAVE_SHLIB |
42 # include "emodules.h" | |
43 #endif | |
428 | 44 |
996 | 45 #include <errno.h> |
428 | 46 |
47 #include "eldap.h" | |
996 | 48 |
49 static Fixnum ldap_default_port; | |
50 static Lisp_Object Vldap_default_base; | |
51 | |
52 static Lisp_Object Qeldap; | |
428 | 53 |
996 | 54 /* Needed by the lrecord definition */ |
55 Lisp_Object Qldapp; | |
428 | 56 |
996 | 57 /* ldap-open plist keywords */ |
58 static Lisp_Object Qport, Qauth, Qbinddn, Qpasswd, Qderef, Qtimelimit, Qsizelimit; | |
428 | 59 /* Search scope limits */ |
60 static Lisp_Object Qbase, Qonelevel, Qsubtree; | |
61 /* Authentication methods */ | |
996 | 62 static Lisp_Object Qkrbv41, Qkrbv42; |
428 | 63 /* Deref policy */ |
64 static Lisp_Object Qnever, Qalways, Qfind; | |
996 | 65 /* Modification types (Qdelete is defined in general.c) */ |
66 static Lisp_Object Qadd, Qreplace; | |
428 | 67 |
996 | 68 |
69 /************************************************************************/ | |
70 /* Utility Functions */ | |
71 /************************************************************************/ | |
72 | |
2268 | 73 static DECLARE_DOESNT_RETURN (signal_ldap_error (LDAP *, LDAPMessage *, int)); |
74 | |
75 static DOESNT_RETURN | |
2286 | 76 signal_ldap_error (LDAP *ld, |
77 #if defined HAVE_LDAP_PARSE_RESULT || defined HAVE_LDAP_RESULT2ERROR | |
78 LDAPMessage *res, | |
79 #else | |
80 LDAPMessage *UNUSED (res), | |
81 #endif | |
82 int ldap_err) | |
996 | 83 { |
84 if (ldap_err <= 0) | |
85 { | |
86 #if defined HAVE_LDAP_PARSE_RESULT | |
87 int err; | |
88 ldap_err = ldap_parse_result (ld, res, | |
89 &err, | |
90 NULL, NULL, NULL, NULL, 0); | |
91 if (ldap_err == LDAP_SUCCESS) | |
92 ldap_err = err; | |
93 #elif defined HAVE_LDAP_GET_LDERRNO | |
94 ldap_err = ldap_get_lderrno (ld, NULL, NULL); | |
95 #elif defined HAVE_LDAP_RESULT2ERROR | |
96 ldap_err = ldap_result2error (ld, res, 0); | |
97 #else | |
98 ldap_err = ld->ld_errno; | |
99 #endif | |
100 } | |
101 invalid_operation ("LDAP error", | |
2367 | 102 build_ext_string (ldap_err2string (ldap_err), Qnative)); |
996 | 103 } |
104 | |
105 | |
106 /************************************************************************/ | |
107 /* ldap lrecord basic functions */ | |
108 /************************************************************************/ | |
109 | |
110 static Lisp_Object | |
111 make_ldap (Lisp_LDAP *ldap) | |
112 { | |
113 return wrap_ldap (ldap); | |
114 } | |
115 | |
1220 | 116 static const struct memory_description ldap_description [] = { |
996 | 117 { XD_LISP_OBJECT, offsetof (struct Lisp_LDAP, host) }, |
118 { XD_END } | |
119 }; | |
120 | |
121 static Lisp_Object | |
122 mark_ldap (Lisp_Object obj) | |
123 { | |
124 return XLDAP (obj)->host; | |
125 } | |
126 | |
127 static void | |
2286 | 128 print_ldap (Lisp_Object obj, Lisp_Object printcharfun, int UNUSED (escapeflag)) |
996 | 129 { |
130 Lisp_LDAP *ldap = XLDAP (obj); | |
131 | |
132 if (print_readably) | |
133 printing_unreadable_object ("#<ldap %s>", XSTRING_DATA (ldap->host)); | |
134 | |
135 write_fmt_string_lisp (printcharfun, "#<ldap %S", 1, ldap->host); | |
136 if (!ldap->ld) | |
137 write_c_string (printcharfun,"(dead) "); | |
138 write_fmt_string (printcharfun, " 0x%lx>", (long)ldap); | |
139 } | |
140 | |
141 static Lisp_LDAP * | |
142 allocate_ldap (void) | |
143 { | |
2720 | 144 #ifdef MC_ALLOC |
145 Lisp_LDAP *ldap = alloc_lrecord_type (Lisp_LDAP, &lrecord_ldap); | |
146 #else /* not MC_ALLOC */ | |
996 | 147 Lisp_LDAP *ldap = alloc_lcrecord_type (Lisp_LDAP, &lrecord_ldap); |
2720 | 148 #endif /* not MC_ALLOC */ |
996 | 149 |
150 ldap->ld = NULL; | |
151 ldap->host = Qnil; | |
152 return ldap; | |
153 } | |
154 | |
155 static void | |
156 finalize_ldap (void *header, int for_disksave) | |
157 { | |
158 Lisp_LDAP *ldap = (Lisp_LDAP *) header; | |
159 | |
160 if (for_disksave) | |
161 invalid_operation ("Can't dump an emacs containing LDAP objects", | |
162 make_ldap (ldap)); | |
163 | |
164 if (ldap->ld) | |
165 ldap_unbind (ldap->ld); | |
166 ldap->ld = NULL; | |
167 } | |
168 | |
1220 | 169 DEFINE_LRECORD_IMPLEMENTATION ("ldap", ldap, 0, |
996 | 170 mark_ldap, print_ldap, finalize_ldap, |
171 NULL, NULL, ldap_description, Lisp_LDAP); | |
172 | |
173 | |
174 /************************************************************************/ | |
175 /* Basic ldap accessors */ | |
176 /************************************************************************/ | |
177 | |
178 /* ###autoload */ | |
179 DEFUN ("ldapp", Fldapp, 1, 1, 0, /* | |
180 Return t if OBJECT is a LDAP connection. | |
181 */ | |
182 (object)) | |
183 { | |
184 return LDAPP (object) ? Qt : Qnil; | |
185 } | |
186 | |
187 DEFUN ("ldap-host", Fldap_host, 1, 1, 0, /* | |
188 Return the server host of the connection LDAP, as a string. | |
189 */ | |
190 (ldap)) | |
191 { | |
192 CHECK_LDAP (ldap); | |
193 return (XLDAP (ldap))->host; | |
194 } | |
195 | |
196 DEFUN ("ldap-live-p", Fldap_live_p, 1, 1, 0, /* | |
197 Return t if LDAP is an active LDAP connection. | |
198 */ | |
199 (ldap)) | |
200 { | |
201 CHECK_LDAP (ldap); | |
202 return (XLDAP (ldap))->ld ? Qt : Qnil; | |
203 } | |
204 | |
205 /************************************************************************/ | |
206 /* Opening/Closing a LDAP connection */ | |
207 /************************************************************************/ | |
208 | |
209 | |
210 /* ###autoload */ | |
211 DEFUN ("ldap-open", Fldap_open, 1, 2, 0, /* | |
212 Open a LDAP connection to HOST. | |
213 PLIST is a plist containing additional parameters for the connection. | |
428 | 214 Valid keys in that list are: |
996 | 215 `port' the TCP port to use for the connection if different from |
216 `ldap-default-port'. | |
428 | 217 `auth' is the authentication method to use, possible values depend on |
218 the LDAP library XEmacs was compiled with: `simple', `krbv41' and `krbv42'. | |
219 `binddn' is the distinguished name of the user to bind as (in RFC 1779 syntax). | |
220 `passwd' is the password to use for simple authentication. | |
221 `deref' is one of the symbols `never', `always', `search' or `find'. | |
222 `timelimit' is the timeout limit for the connection in seconds. | |
223 `sizelimit' is the maximum number of matches to return. | |
224 */ | |
996 | 225 (host, plist)) |
428 | 226 { |
996 | 227 /* This function can GC */ |
228 Lisp_LDAP *ldap; | |
428 | 229 LDAP *ld; |
996 | 230 int ldap_port = 0; |
428 | 231 int ldap_auth = LDAP_AUTH_SIMPLE; |
2367 | 232 Extbyte *ldap_binddn = NULL; |
233 Extbyte *ldap_password = NULL; | |
428 | 234 int ldap_deref = LDAP_DEREF_NEVER; |
235 int ldap_timelimit = 0; | |
236 int ldap_sizelimit = 0; | |
996 | 237 int err; |
428 | 238 |
996 | 239 CHECK_STRING (host); |
428 | 240 |
996 | 241 { |
242 EXTERNAL_PROPERTY_LIST_LOOP_3 (keyword, value, plist) | |
243 { | |
244 /* TCP Port */ | |
245 if (EQ (keyword, Qport)) | |
246 { | |
247 CHECK_INT (value); | |
248 ldap_port = XINT (value); | |
249 } | |
250 /* Authentication method */ | |
251 if (EQ (keyword, Qauth)) | |
252 { | |
253 if (EQ (value, Qsimple)) | |
254 ldap_auth = LDAP_AUTH_SIMPLE; | |
428 | 255 #ifdef LDAP_AUTH_KRBV41 |
996 | 256 else if (EQ (value, Qkrbv41)) |
257 ldap_auth = LDAP_AUTH_KRBV41; | |
428 | 258 #endif |
259 #ifdef LDAP_AUTH_KRBV42 | |
996 | 260 else if (EQ (value, Qkrbv42)) |
261 ldap_auth = LDAP_AUTH_KRBV42; | |
428 | 262 #endif |
996 | 263 else |
264 invalid_constant ("Invalid authentication method", value); | |
265 } | |
266 /* Bind DN */ | |
267 else if (EQ (keyword, Qbinddn)) | |
268 { | |
269 CHECK_STRING (value); | |
270 LISP_STRING_TO_EXTERNAL (value, ldap_binddn, Qnative); | |
271 } | |
272 /* Password */ | |
273 else if (EQ (keyword, Qpasswd)) | |
274 { | |
275 CHECK_STRING (value); | |
2272 | 276 LISP_STRING_TO_EXTERNAL (value, ldap_password, Qnative); |
996 | 277 } |
278 /* Deref */ | |
279 else if (EQ (keyword, Qderef)) | |
280 { | |
281 if (EQ (value, Qnever)) | |
282 ldap_deref = LDAP_DEREF_NEVER; | |
283 else if (EQ (value, Qsearch)) | |
284 ldap_deref = LDAP_DEREF_SEARCHING; | |
285 else if (EQ (value, Qfind)) | |
286 ldap_deref = LDAP_DEREF_FINDING; | |
287 else if (EQ (value, Qalways)) | |
288 ldap_deref = LDAP_DEREF_ALWAYS; | |
289 else | |
290 invalid_constant ("Invalid deref value", value); | |
291 } | |
292 /* Timelimit */ | |
293 else if (EQ (keyword, Qtimelimit)) | |
294 { | |
295 CHECK_INT (value); | |
296 ldap_timelimit = XINT (value); | |
297 } | |
298 /* Sizelimit */ | |
299 else if (EQ (keyword, Qsizelimit)) | |
300 { | |
301 CHECK_INT (value); | |
302 ldap_sizelimit = XINT (value); | |
303 } | |
304 } | |
305 } | |
306 | |
307 if (ldap_port == 0) | |
308 { | |
309 ldap_port = ldap_default_port; | |
428 | 310 } |
311 | |
996 | 312 /* Connect to the server and bind */ |
313 slow_down_interrupts (); | |
2367 | 314 ld = ldap_open (NEW_LISP_STRING_TO_EXTERNAL (host, Qnative), ldap_port); |
996 | 315 speed_up_interrupts (); |
428 | 316 |
996 | 317 if (ld == NULL ) |
318 report_process_error ("Failed connecting to host", host); | |
428 | 319 |
996 | 320 #ifdef HAVE_LDAP_SET_OPTION |
321 if ((err = ldap_set_option (ld, LDAP_OPT_DEREF, | |
322 (void *)&ldap_deref)) != LDAP_SUCCESS) | |
323 signal_ldap_error (ld, NULL, err); | |
324 if ((err = ldap_set_option (ld, LDAP_OPT_TIMELIMIT, | |
325 (void *)&ldap_timelimit)) != LDAP_SUCCESS) | |
326 signal_ldap_error (ld, NULL, err); | |
327 if ((err = ldap_set_option (ld, LDAP_OPT_SIZELIMIT, | |
328 (void *)&ldap_sizelimit)) != LDAP_SUCCESS) | |
329 signal_ldap_error (ld, NULL, err); | |
330 if ((err = ldap_set_option (ld, LDAP_OPT_REFERRALS, | |
331 LDAP_OPT_ON)) != LDAP_SUCCESS) | |
332 signal_ldap_error (ld, NULL, err); | |
333 if ((err = ldap_set_option (ld, LDAP_OPT_RESTART, | |
334 LDAP_OPT_ON)) != LDAP_SUCCESS) | |
335 signal_ldap_error (ld, NULL, err); | |
336 #else /* not HAVE_LDAP_SET_OPTION */ | |
428 | 337 ld->ld_deref = ldap_deref; |
338 ld->ld_timelimit = ldap_timelimit; | |
339 ld->ld_sizelimit = ldap_sizelimit; | |
340 #ifdef LDAP_REFERRALS | |
341 ld->ld_options = LDAP_OPT_REFERRALS; | |
996 | 342 #else /* not LDAP_REFERRALS */ |
428 | 343 ld->ld_options = 0; |
996 | 344 #endif /* not LDAP_REFERRALS */ |
345 /* XEmacs uses interrupts (SIGIO,SIGALRM), LDAP calls need to ignore them */ | |
346 ld->ld_options |= LDAP_OPT_RESTART; | |
347 #endif /* not HAVE_LDAP_SET_OPTION */ | |
348 | |
2272 | 349 err = ldap_bind_s (ld, ldap_binddn, ldap_password, ldap_auth); |
996 | 350 if (err != LDAP_SUCCESS) |
351 { | |
352 signal_error (Qprocess_error, "Failed binding to the server", | |
2367 | 353 build_ext_string (ldap_err2string (err), Qnative)); |
996 | 354 } |
355 | |
356 ldap = allocate_ldap (); | |
357 ldap->ld = ld; | |
358 ldap->host = host; | |
359 | |
360 return make_ldap (ldap); | |
361 } | |
362 | |
363 | |
364 | |
365 DEFUN ("ldap-close", Fldap_close, 1, 1, 0, /* | |
366 Close an LDAP connection. | |
367 */ | |
368 (ldap)) | |
369 { | |
370 Lisp_LDAP *lldap; | |
371 CHECK_LIVE_LDAP (ldap); | |
372 lldap = XLDAP (ldap); | |
373 ldap_unbind (lldap->ld); | |
374 lldap->ld = NULL; | |
375 return Qnil; | |
376 } | |
377 | |
378 | |
379 | |
380 /************************************************************************/ | |
381 /* Working on a LDAP connection */ | |
382 /************************************************************************/ | |
383 struct ldap_unwind_struct | |
384 { | |
385 LDAPMessage *res; | |
386 struct berval **vals; | |
387 }; | |
388 | |
389 static Lisp_Object | |
390 ldap_search_unwind (Lisp_Object unwind_obj) | |
391 { | |
392 struct ldap_unwind_struct *unwind = | |
393 (struct ldap_unwind_struct *) get_opaque_ptr (unwind_obj); | |
394 if (unwind->res) | |
395 ldap_msgfree (unwind->res); | |
396 if (unwind->vals) | |
397 ldap_value_free_len (unwind->vals); | |
398 return Qnil; | |
399 } | |
400 | |
401 /* The following function is called `ldap-search-basic' instead of */ | |
402 /* plain `ldap-search' to maintain compatibility with the XEmacs 21.1 */ | |
403 /* API where `ldap-search' was the name of the high-level search */ | |
404 /* function */ | |
428 | 405 |
996 | 406 DEFUN ("ldap-search-basic", Fldap_search_basic, 2, 8, 0, /* |
407 Perform a search on an open LDAP connection. | |
408 LDAP is an LDAP connection object created with `ldap-open'. | |
409 FILTER is a filter string for the search as described in RFC 1558. | |
410 BASE is the distinguished name at which to start the search. | |
411 SCOPE is one of the symbols `base', `onelevel' or `subtree' indicating | |
412 the scope of the search. | |
413 ATTRS is a list of strings indicating which attributes to retrieve | |
414 for each matching entry. If nil return all available attributes. | |
415 If ATTRSONLY is non-nil then only the attributes are retrieved, not | |
416 the associated values. | |
417 If WITHDN is non-nil each entry in the result will be prepended with | |
418 its distinguished name DN. | |
419 If VERBOSE is non-nil progress messages will be echoed. | |
420 The function returns a list of matching entries. Each entry is itself | |
421 an alist of attribute/value pairs optionally preceded by the DN of the | |
422 entry according to the value of WITHDN. | |
423 */ | |
424 (ldap, filter, base, scope, attrs, attrsonly, withdn, verbose)) | |
425 { | |
426 /* This function can GC */ | |
427 | |
428 /* Vars for query */ | |
429 LDAP *ld; | |
430 LDAPMessage *e; | |
431 BerElement *ptr; | |
2367 | 432 Extbyte *a, *dn; |
996 | 433 int i, rc; |
434 int matches; | |
435 struct ldap_unwind_struct unwind; | |
436 | |
437 int ldap_scope = LDAP_SCOPE_SUBTREE; | |
2367 | 438 Extbyte **ldap_attributes = NULL; |
996 | 439 |
440 int speccount = specpdl_depth (); | |
441 | |
442 Lisp_Object list = Qnil; | |
443 Lisp_Object entry = Qnil; | |
444 Lisp_Object result = Qnil; | |
445 struct gcpro gcpro1, gcpro2, gcpro3; | |
446 | |
447 GCPRO3 (list, entry, result); | |
448 | |
449 unwind.res = NULL; | |
450 unwind.vals = NULL; | |
451 | |
452 /* Do all the parameter checking */ | |
453 CHECK_LIVE_LDAP (ldap); | |
454 ld = XLDAP (ldap)->ld; | |
455 | |
456 /* Filter */ | |
457 CHECK_STRING (filter); | |
458 | |
459 /* Search base */ | |
460 if (NILP (base)) | |
461 { | |
462 base = Vldap_default_base; | |
463 } | |
464 if (!NILP (base)) | |
465 { | |
466 CHECK_STRING (base); | |
467 } | |
468 | |
469 /* Search scope */ | |
470 if (!NILP (scope)) | |
471 { | |
472 if (EQ (scope, Qbase)) | |
473 ldap_scope = LDAP_SCOPE_BASE; | |
474 else if (EQ (scope, Qonelevel)) | |
475 ldap_scope = LDAP_SCOPE_ONELEVEL; | |
476 else if (EQ (scope, Qsubtree)) | |
477 ldap_scope = LDAP_SCOPE_SUBTREE; | |
478 else | |
479 invalid_constant ("Invalid scope", scope); | |
480 } | |
481 | |
482 /* Attributes to search */ | |
483 if (!NILP (attrs)) | |
484 { | |
485 CHECK_CONS (attrs); | |
486 ldap_attributes = alloca_array (char *, 1 + XINT (Flength (attrs))); | |
487 | |
488 i = 0; | |
2367 | 489 { |
490 EXTERNAL_LIST_LOOP_2 (current, attrs) | |
491 { | |
492 CHECK_STRING (current); | |
493 LISP_STRING_TO_EXTERNAL (current, ldap_attributes[i], Qnative); | |
494 ++i; | |
495 } | |
496 } | |
996 | 497 ldap_attributes[i] = NULL; |
498 } | |
499 | |
500 /* Attributes only ? */ | |
501 CHECK_SYMBOL (attrsonly); | |
428 | 502 |
503 /* Perform the search */ | |
996 | 504 if (ldap_search (ld, |
2367 | 505 NILP (base) ? "" : |
506 NEW_LISP_STRING_TO_EXTERNAL (base, Qnative), | |
996 | 507 ldap_scope, |
2367 | 508 NILP (filter) ? "" : |
509 NEW_LISP_STRING_TO_EXTERNAL (filter, Qnative), | |
996 | 510 ldap_attributes, |
511 NILP (attrsonly) ? 0 : 1) | |
512 == -1) | |
428 | 513 { |
996 | 514 signal_ldap_error (ld, NULL, 0); |
428 | 515 } |
516 | |
996 | 517 /* Ensure we don't exit without cleaning up */ |
518 record_unwind_protect (ldap_search_unwind, | |
519 make_opaque_ptr (&unwind)); | |
520 | |
428 | 521 /* Build the results list */ |
522 matches = 0; | |
523 | |
996 | 524 rc = ldap_result (ld, LDAP_RES_ANY, 0, NULL, &unwind.res); |
525 | |
526 while (rc == LDAP_RES_SEARCH_ENTRY) | |
428 | 527 { |
996 | 528 QUIT; |
428 | 529 matches ++; |
996 | 530 e = ldap_first_entry (ld, unwind.res); |
531 /* #### This call to message() is pretty fascist, because it | |
532 destroys the current echo area contents, even when invoked | |
533 from Lisp. It should use echo_area_message() instead, and | |
534 restore the old echo area contents later. */ | |
535 if (! NILP (verbose)) | |
536 message ("Parsing ldap results... %d", matches); | |
428 | 537 entry = Qnil; |
996 | 538 /* Get the DN if required */ |
539 if (! NILP (withdn)) | |
540 { | |
541 dn = ldap_get_dn (ld, e); | |
542 if (dn == NULL) | |
543 signal_ldap_error (ld, e, 0); | |
544 entry = Fcons (build_ext_string (dn, Qnative), Qnil); | |
545 } | |
2367 | 546 for (a = ldap_first_attribute (ld, e, &ptr); |
428 | 547 a != NULL; |
2367 | 548 a = ldap_next_attribute (ld, e, ptr)) |
428 | 549 { |
996 | 550 list = Fcons (build_ext_string (a, Qnative), Qnil); |
551 unwind.vals = ldap_get_values_len (ld, e, a); | |
552 if (unwind.vals != NULL) | |
428 | 553 { |
996 | 554 for (i = 0; unwind.vals[i] != NULL; i++) |
428 | 555 { |
996 | 556 list = Fcons (make_ext_string ((Extbyte *) unwind.vals[i]->bv_val, |
557 unwind.vals[i]->bv_len, | |
558 Qnative), | |
428 | 559 list); |
560 } | |
561 } | |
562 entry = Fcons (Fnreverse (list), | |
563 entry); | |
996 | 564 ldap_value_free_len (unwind.vals); |
565 unwind.vals = NULL; | |
428 | 566 } |
567 result = Fcons (Fnreverse (entry), | |
568 result); | |
996 | 569 ldap_msgfree (unwind.res); |
570 unwind.res = NULL; | |
428 | 571 |
996 | 572 rc = ldap_result (ld, LDAP_RES_ANY, 0, NULL, &(unwind.res)); |
428 | 573 } |
574 | |
996 | 575 #if defined HAVE_LDAP_PARSE_RESULT |
576 { | |
577 int rc2 = ldap_parse_result (ld, unwind.res, | |
578 &rc, | |
579 NULL, NULL, NULL, NULL, 0); | |
580 if (rc2 != LDAP_SUCCESS) | |
581 rc = rc2; | |
582 } | |
428 | 583 #else |
996 | 584 if (rc == 0) |
585 signal_ldap_error (ld, NULL, LDAP_TIMELIMIT_EXCEEDED); | |
586 | |
587 if (rc == -1) | |
588 signal_ldap_error (ld, unwind.res, (unwind.res==NULL) ? ld->ld_errno : 0); | |
589 | |
590 #if defined HAVE_LDAP_RESULT2ERROR | |
591 rc = ldap_result2error (ld, unwind.res, 0); | |
592 #endif | |
428 | 593 #endif |
996 | 594 |
595 if (rc != LDAP_SUCCESS) | |
596 signal_ldap_error (ld, NULL, rc); | |
597 | |
598 ldap_msgfree (unwind.res); | |
599 unwind.res = (LDAPMessage *)NULL; | |
600 | |
601 /* #### See above for calling message(). */ | |
602 if (! NILP (verbose)) | |
603 message ("Parsing ldap results... done"); | |
604 | |
605 unbind_to (speccount); | |
606 UNGCPRO; | |
607 return Fnreverse (result); | |
608 } | |
609 | |
610 DEFUN ("ldap-add", Fldap_add, 3, 3, 0, /* | |
611 Add an entry to an LDAP directory. | |
612 LDAP is an LDAP connection object created with `ldap-open'. | |
613 DN is the distinguished name of the entry to add. | |
614 ENTRY is an entry specification, i.e., a list of cons cells | |
615 containing attribute/value string pairs. | |
616 */ | |
617 (ldap, dn, entry)) | |
618 { | |
619 LDAP *ld; | |
620 LDAPMod *ldap_mods, **ldap_mods_ptrs; | |
621 struct berval *bervals; | |
622 int rc; | |
623 int i, j; | |
624 Elemcount len; | |
625 | |
626 Lisp_Object current = Qnil; | |
627 Lisp_Object values = Qnil; | |
2367 | 628 struct gcpro gcpro1; |
996 | 629 |
2367 | 630 GCPRO1 (values); |
996 | 631 |
632 /* Do all the parameter checking */ | |
633 CHECK_LIVE_LDAP (ldap); | |
634 ld = XLDAP (ldap)->ld; | |
635 | |
636 /* Check the DN */ | |
637 CHECK_STRING (dn); | |
638 | |
639 /* Check the entry */ | |
640 CHECK_CONS (entry); | |
641 if (NILP (entry)) | |
642 invalid_operation ("Cannot add void entry", entry); | |
428 | 643 |
996 | 644 /* Build the ldap_mods array */ |
645 len = (Elemcount) XINT (Flength (entry)); | |
646 ldap_mods = alloca_array (LDAPMod, len); | |
647 ldap_mods_ptrs = alloca_array (LDAPMod *, 1 + len); | |
648 i = 0; | |
2367 | 649 |
650 { | |
651 EXTERNAL_LIST_LOOP_2 (current, entry) | |
652 { | |
653 CHECK_CONS (current); | |
654 CHECK_STRING (XCAR (current)); | |
655 ldap_mods_ptrs[i] = &(ldap_mods[i]); | |
656 LISP_STRING_TO_EXTERNAL (XCAR (current), ldap_mods[i].mod_type, | |
657 Qnative); | |
658 ldap_mods[i].mod_op = LDAP_MOD_ADD | LDAP_MOD_BVALUES; | |
659 values = XCDR (current); | |
660 if (CONSP (values)) | |
661 { | |
662 len = (Elemcount) XINT (Flength (values)); | |
663 bervals = alloca_array (struct berval, len); | |
664 ldap_mods[i].mod_vals.modv_bvals = | |
665 alloca_array (struct berval *, 1 + len); | |
666 j = 0; | |
667 { | |
668 EXTERNAL_LIST_LOOP_2 (cur2, values) | |
669 { | |
670 CHECK_STRING (cur2); | |
671 ldap_mods[i].mod_vals.modv_bvals[j] = &(bervals[j]); | |
672 TO_EXTERNAL_FORMAT (LISP_STRING, cur2, | |
673 ALLOCA, (bervals[j].bv_val, | |
674 bervals[j].bv_len), | |
675 Qnative); | |
676 j++; | |
677 } | |
678 } | |
679 ldap_mods[i].mod_vals.modv_bvals[j] = NULL; | |
680 } | |
681 else | |
682 { | |
683 CHECK_STRING (values); | |
684 bervals = alloca_array (struct berval, 1); | |
685 ldap_mods[i].mod_vals.modv_bvals = alloca_array (struct berval *, | |
686 2); | |
687 ldap_mods[i].mod_vals.modv_bvals[0] = &(bervals[0]); | |
688 TO_EXTERNAL_FORMAT (LISP_STRING, values, | |
689 ALLOCA, (bervals[0].bv_val, | |
690 bervals[0].bv_len), | |
691 Qnative); | |
692 ldap_mods[i].mod_vals.modv_bvals[1] = NULL; | |
693 } | |
694 i++; | |
695 } | |
696 } | |
996 | 697 ldap_mods_ptrs[i] = NULL; |
2367 | 698 rc = ldap_add_s (ld, NEW_LISP_STRING_TO_EXTERNAL (dn, Qnative), |
699 ldap_mods_ptrs); | |
996 | 700 if (rc != LDAP_SUCCESS) |
701 signal_ldap_error (ld, NULL, rc); | |
428 | 702 |
703 UNGCPRO; | |
996 | 704 return Qnil; |
705 } | |
706 | |
707 DEFUN ("ldap-modify", Fldap_modify, 3, 3, 0, /* | |
708 Add an entry to an LDAP directory. | |
709 LDAP is an LDAP connection object created with `ldap-open'. | |
710 DN is the distinguished name of the entry to modify. | |
711 MODS is a list of modifications to apply. | |
712 A modification is a list of the form (MOD-OP ATTR VALUE1 VALUE2 ...) | |
713 MOD-OP and ATTR are mandatory, VALUEs are optional depending on MOD-OP. | |
714 MOD-OP is the type of modification, one of the symbols `add', `delete' | |
715 or `replace'. ATTR is the LDAP attribute type to modify. | |
716 */ | |
717 (ldap, dn, mods)) | |
718 { | |
719 LDAP *ld; | |
720 LDAPMod *ldap_mods, **ldap_mods_ptrs; | |
721 struct berval *bervals; | |
722 int i, j, rc; | |
723 Lisp_Object mod_op; | |
724 Elemcount len; | |
725 | |
726 Lisp_Object values = Qnil; | |
727 struct gcpro gcpro1, gcpro2; | |
728 | |
729 /* Do all the parameter checking */ | |
730 CHECK_LIVE_LDAP (ldap); | |
731 ld = XLDAP (ldap)->ld; | |
732 | |
733 /* Check the DN */ | |
734 CHECK_STRING (dn); | |
735 | |
736 /* Check the entry */ | |
737 CHECK_CONS (mods); | |
738 if (NILP (mods)) | |
739 return Qnil; | |
740 | |
741 /* Build the ldap_mods array */ | |
742 len = (Elemcount) XINT (Flength (mods)); | |
743 ldap_mods = alloca_array (LDAPMod, len); | |
744 ldap_mods_ptrs = alloca_array (LDAPMod *, 1 + len); | |
745 i = 0; | |
746 | |
2367 | 747 GCPRO1 (values); |
748 { | |
749 EXTERNAL_LIST_LOOP_2 (current, mods) | |
750 { | |
751 CHECK_CONS (current); | |
752 CHECK_SYMBOL (XCAR (current)); | |
753 mod_op = XCAR (current); | |
754 ldap_mods_ptrs[i] = &(ldap_mods[i]); | |
755 ldap_mods[i].mod_op = LDAP_MOD_BVALUES; | |
756 if (EQ (mod_op, Qadd)) | |
757 ldap_mods[i].mod_op |= LDAP_MOD_ADD; | |
758 else if (EQ (mod_op, Qdelete)) | |
759 ldap_mods[i].mod_op |= LDAP_MOD_DELETE; | |
760 else if (EQ (mod_op, Qreplace)) | |
761 ldap_mods[i].mod_op |= LDAP_MOD_REPLACE; | |
762 else | |
763 invalid_constant ("Invalid LDAP modification type", mod_op); | |
764 current = XCDR (current); | |
765 CHECK_STRING (XCAR (current)); | |
766 LISP_STRING_TO_EXTERNAL (XCAR (current), ldap_mods[i].mod_type, | |
767 Qnative); | |
768 values = XCDR (current); | |
769 len = (Elemcount) XINT (Flength (values)); | |
770 bervals = alloca_array (struct berval, len); | |
771 ldap_mods[i].mod_vals.modv_bvals = | |
772 alloca_array (struct berval *, 1 + len); | |
773 j = 0; | |
2387 | 774 { |
775 EXTERNAL_LIST_LOOP_2 (cur2, values) | |
776 { | |
777 CHECK_STRING (cur2); | |
778 ldap_mods[i].mod_vals.modv_bvals[j] = &(bervals[j]); | |
779 TO_EXTERNAL_FORMAT (LISP_STRING, cur2, | |
780 ALLOCA, (bervals[j].bv_val, | |
781 bervals[j].bv_len), | |
782 Qnative); | |
783 j++; | |
784 } | |
785 ldap_mods[i].mod_vals.modv_bvals[j] = NULL; | |
786 i++; | |
787 } | |
2367 | 788 } |
789 } | |
996 | 790 ldap_mods_ptrs[i] = NULL; |
2367 | 791 rc = ldap_modify_s (ld, NEW_LISP_STRING_TO_EXTERNAL (dn, Qnative), |
792 ldap_mods_ptrs); | |
996 | 793 if (rc != LDAP_SUCCESS) |
794 signal_ldap_error (ld, NULL, rc); | |
795 | |
796 UNGCPRO; | |
797 return Qnil; | |
798 } | |
799 | |
800 | |
801 DEFUN ("ldap-delete", Fldap_delete, 2, 2, 0, /* | |
802 Delete an entry to an LDAP directory. | |
803 LDAP is an LDAP connection object created with `ldap-open'. | |
804 DN is the distinguished name of the entry to delete. | |
805 */ | |
806 (ldap, dn)) | |
807 { | |
808 LDAP *ld; | |
809 int rc; | |
810 | |
811 /* Check parameters */ | |
812 CHECK_LIVE_LDAP (ldap); | |
813 ld = XLDAP (ldap)->ld; | |
814 CHECK_STRING (dn); | |
815 | |
2367 | 816 rc = ldap_delete_s (ld, NEW_LISP_STRING_TO_EXTERNAL (dn, Qnative)); |
996 | 817 if (rc != LDAP_SUCCESS) |
818 signal_ldap_error (ld, NULL, rc); | |
819 | |
820 return Qnil; | |
428 | 821 } |
822 | |
823 void | |
996 | 824 syms_of_eldap (void) |
428 | 825 { |
996 | 826 INIT_LRECORD_IMPLEMENTATION (ldap); |
428 | 827 |
996 | 828 DEFSYMBOL (Qeldap); |
829 DEFSYMBOL (Qldapp); | |
830 DEFSYMBOL (Qport); | |
831 DEFSYMBOL (Qauth); | |
832 DEFSYMBOL (Qbinddn); | |
833 DEFSYMBOL (Qpasswd); | |
834 DEFSYMBOL (Qderef); | |
835 DEFSYMBOL (Qtimelimit); | |
836 DEFSYMBOL (Qsizelimit); | |
837 DEFSYMBOL (Qbase); | |
838 DEFSYMBOL (Qonelevel); | |
839 DEFSYMBOL (Qsubtree); | |
840 DEFSYMBOL (Qkrbv41); | |
841 DEFSYMBOL (Qkrbv42); | |
842 DEFSYMBOL (Qnever); | |
843 DEFSYMBOL (Qalways); | |
844 DEFSYMBOL (Qfind); | |
845 DEFSYMBOL (Qadd); | |
846 DEFSYMBOL (Qreplace); | |
847 | |
848 DEFSUBR (Fldapp); | |
849 DEFSUBR (Fldap_host); | |
850 DEFSUBR (Fldap_live_p); | |
851 DEFSUBR (Fldap_open); | |
852 DEFSUBR (Fldap_close); | |
853 DEFSUBR (Fldap_search_basic); | |
854 DEFSUBR (Fldap_add); | |
855 DEFSUBR (Fldap_modify); | |
856 DEFSUBR (Fldap_delete); | |
428 | 857 } |
858 | |
859 void | |
996 | 860 vars_of_eldap (void) |
428 | 861 { |
996 | 862 |
863 Fprovide (Qeldap); | |
428 | 864 |
996 | 865 ldap_default_port = LDAP_PORT; |
866 Vldap_default_base = Qnil; | |
867 | |
868 DEFVAR_INT ("ldap-default-port", &ldap_default_port /* | |
869 Default TCP port for LDAP connections. | |
870 Initialized from the LDAP library. Default value is 389. | |
428 | 871 */ ); |
872 | |
873 DEFVAR_LISP ("ldap-default-base", &Vldap_default_base /* | |
874 Default base for LDAP searches. | |
875 This is a string using the syntax of RFC 1779. | |
876 For instance, "o=ACME, c=US" limits the search to the | |
877 Acme organization in the United States. | |
878 */ ); | |
879 | |
880 } | |
881 | |
996 | 882 #ifdef HAVE_SHLIB |
1706 | 883 EXTERN_C void unload_eldap (void); |
996 | 884 void |
885 unload_eldap (void) | |
886 { | |
887 /* Remove defined types */ | |
888 UNDEF_LRECORD_IMPLEMENTATION (ldap); | |
889 | |
890 /* Remove staticpro'ing of symbols */ | |
891 unstaticpro_nodump (&Qeldap); | |
892 unstaticpro_nodump (&Qldapp); | |
893 unstaticpro_nodump (&Qport); | |
894 unstaticpro_nodump (&Qauth); | |
895 unstaticpro_nodump (&Qbinddn); | |
896 unstaticpro_nodump (&Qpasswd); | |
897 unstaticpro_nodump (&Qderef); | |
898 unstaticpro_nodump (&Qtimelimit); | |
899 unstaticpro_nodump (&Qsizelimit); | |
900 unstaticpro_nodump (&Qbase); | |
901 unstaticpro_nodump (&Qonelevel); | |
902 unstaticpro_nodump (&Qsubtree); | |
903 unstaticpro_nodump (&Qkrbv41); | |
904 unstaticpro_nodump (&Qkrbv42); | |
905 unstaticpro_nodump (&Qnever); | |
906 unstaticpro_nodump (&Qalways); | |
907 unstaticpro_nodump (&Qfind); | |
908 unstaticpro_nodump (&Qadd); | |
909 unstaticpro_nodump (&Qreplace); | |
910 } | |
911 #endif /* HAVE_SHLIB */ |