Commit bfa1a192 authored by Per Cederqvist's avatar Per Cederqvist

Code cleanup.

Improve documentation.
Start using the Local_to_global structure.
Fixes and improvements to the Local_to_global structure.
Improve the test suite with new tests of the Local_to_global structure.
parent 2f3a75d9
1998-07-26 Per Cederqvist <ceder@lysator.liu.se>
Code cleanup.
* src/server/aux-item-def.y: Fixed indentation of include statements.
* src/server/aux-item-def.lex.c: No longer kept under version
control.
Improve documentation.
* doc/server.extend: Updated.
Start using the Local_to_global structure.
* doc/lyskomd-database-format (DATABASE VERSION 2): CONF-RECORD
and PERS-RECORD uses the Local_to_global structure.
* configure.in: Added AC_C_INLINE.
* src/server/text.c (add_text_in_conf): Adjusted to the fact that
the texts member of Conference is now a l2g.
(do_sub_recpt): Likewise.
(set_loc_no): Removed.
(adjust_text_list): Removed.
(do_delete_text): Adjusted to the fact that the created_texts
member of Person is now a l2g.
(do_create_text): Likewise.
(get_map): The result argument now points to a
l2g_iterator_as_text_list instead of a Text_list. Adjusted to the
fact that the texts member of Conference is now a l2g.
* src/server/simple-cache.c (mark_conference_as_changed): Adjusted
to the fact that the texts member of Conference is now a l2g.
(setup_small_conf): Likewise.
* src/server/ram-parse.h (fparse_text_list): Removed.
* src/server/ram-parse.c (fparse_conference_2): Use l2g_read
instead of fparse_text_list.
(fparse_person_2): Likewise.
(fparse_text_list): The result argument now points to a
Local_to_global instead of a Text_list.
* src/server/ram-output.h (foutput_text_list): The text_list
argument is now a pointer to Local_to_global instead of a
Text_list.
* src/server/ram-output.c (foutput_person_0): Adjusted to new API
of foutput_text_list.
(foutput_person_2): Use l2g_write instead of foutput_text_list.
(foutput_conference_2): Likewise.
(foutput_conference_1): Adjusted to new API of foutput_text_list.
(foutput_conference_0): Likewise.
(foutput_text_list): The text_list argument is now a pointer to
Local_to_global instead of a Text_list. The generated output is
still the same.
(foutput_ulong): Eliminated a future buffer overrun. Cleaned up
the code.
* src/server/prot-a.c (prot_a_reply): Handle
rt_l2g_iterator_as_text_list.
* src/server/prot-a-output.h
(prot_a_output_l2g_iterator_as_text_list): New function.
* src/server/prot-a-output.c (prot_a_output_person): Adjusted to
the fact that the created_texts member of Person is now a l2g.
(prot_a_output_conference): Adjusted to the fact that the texts
member of Conference is now a l2g.
(prot_a_output_conference_old): Likewise.
(prot_a_output_l2g_iterator_as_text_list): New function which
emulates a Text_list.
* src/server/person.c (do_delete_pers): Adjusted to the fact that
the created_texts member of Person is now a l2g.
(get_created_texts): The return value is now an
l2g_iterator_as_text_list, not a Text_list. Adjusted to the fact
that the created_texts member of Person is now a l2g.
* src/server/memory.c (clear_text_list): Removed.
(copy_text_list): Removed.
(clear_conference): Adjusted to the fact that the texts member of
Conference is now a l2g.
(init_conference): Likewise.
(copy_conference): Likewise. Added const qualifier to the
argument.
(clear_person): Adjusted to the fact that the created_texts member
of Person is now a l2g.
(copy_person): Likewise.
(init_person): Likewise.
(init_text_list): Removed.
(copy_aux_item_list): Added const qualifier to the src argument.
* src/server/membership.c (add_rec_time): Adjusted to the fact
that the texts member of Conference is now a l2g.
(adjust_read): Likewise.
(mark_as_read): Likewise.
(check_membership): Likewise.
(set_unread): Likewise.
(set_last_read): Likewise.
* src/server/kom-memory.h (copy_conference): The argument is const.
(copy_aux_item_list): Likewise.
(init_text_list): Removed.
* src/server/fncdef.txt (get_map): Changed return type from
text_list to l2g_iterator_as_text_list.
(get_created_texts): Likewise.
* src/server/dbck.c (struct delete_list): New struct.
(delete_list_append): New static function.
(execute_deletions): New static function.
(check_misc_infos): Adjusted to the fact that the texts member of
Conference is now a l2g.
(adjust_text_list): Deleted.
(check_created_texts): The "created" argument now points to a
Local_to_global. Removed the check for "bad created_texts array"
since it can no longer be bad in that way.
(check_membership): Adjusted to the fact that the texts member of
Conference is now a l2g.
(check_texts_in_conf): The "tlist" argument now points to a
Local_to_global. Removed the check for "bad created_texts array"
since it can no longer be bad in that way.
* src/server/dbck-cache.c (cached_get_highest_local_no): Adjusted
to the fact that the texts member is now a l2g.
(cache_sync): Fixed type in some printf format strings.
* src/server/connections.h (Res_type): Added
rt_l2g_iterator_as_text_list.
(Result_holder): Added l2g_iterator_as_text_list.
* src/server/conference.c: (do_delete_conf): Adjusted to the fact
that the texts member is now a l2g.
* src/server/Makefile.am (DBCK): Added local-to-global.c.
(all-recursive, check-recursive): Require libcheck.a to be built.
* src/include/services.h (get_created_texts): Changed type of
the result to L2g_iterator_as_text_list.
(get_map): Likewise.
* src/include/kom-types.h (struct l2g_block_info): New forward
declaration.
(Local_to_global): New type.
(L2g_iterator): New type.
(L2g_iterator_as_text_list): New type.
(Conference): The texts member is now a Local_to_global, not a
Text_list.
(Person): The created_texts member is now a Local_to_global, not a
Text_list.
Fixes and improvements to the Local_to_global structure.
* src/server/local-to-global.h (L2G_BLOCKSIZE): Moved to
local-to-global.c.
(L2g_block_info): Likewise.
(Local_to_global): Likewise.
(l2g_copy): Switched placement of src and dest to match other copy
functions in the lyskomd code. Added const qualifier.
(l2g_lookup): Added const qualifier to the l2g argument.
(l2g_next_key): Likewise.
(l2g_compact): Removed.
(l2g_first_appendable_key): New function.
(l2g_delete_global_in_sorted): New function.
(l2g_dump): Switch placement of l2g and file arguments to match
other similar functions in the lyskomd code. Added const
qualifier.
(l2g_write): Likewise.
(l2g_read): Likewise.
(l2g_searchall): Added const qualifier.
(L2g_iterator): Moved to kom-types.h.
(l2gi_searchsome): Added const qualifier.
(l2gi_begin): New function.
(l2gi_end): New function.
* src/server/local-to-global.c: Include assert.h. Only include
stdlib.h if HAVE_STDLIB_H. Include stdio.h if we didn't get NULL
from stdlib.h. Inlucd lyskomd.h and server/smalloc.h.
(L2G_BLOCKSIZE): Moved here from local-to-global.h.
(struct l2g_block_info): Likewise.
(is_dense): New static function.
(is_empty): New static function.
(key_value): New static function.
(sparse_skip_deleted): New static function.
(sparse_locate_value): New static function.
(sparse_compact): New static function.
(add_block): Use srealloc instead of realloc. Don't initialize
start -- the caller is responsible for doing so.
(delete_block): Use sfree instead of free, and srealloc instead of
realloc.
(make_sparse): Don't change the value of start, since there is no
need to, and make_sparse may now be called on an empty block,
which would cause start to be set to a garbage value.
(find_block): Added a const qualifier to the return value and l2g
argument. Use key_value to simplify code.
(find_block_index_key): Added a const qualifier to the l2g
argument. Use helper functions to simplify the code. Use
sparse_skip_deleted so that the function never returns a deleted
key. Never return deleted keys in dense blocks either.
(join_range): New static function.
(join_blocks): New static function.
(l2g_init): Set first_unused to 1.
(l2g_clear): Use sfree instead of free. Set first_unused to 1.
(l2g_copy): Added const qualifier to the src argument. Simplified
code by using helper functions and relying on the fact that
calling l2g_append with a Text_no=0 is a no-op. Set first_unused
of the copy.
(l2g_append): Send a log message and do nothing if an attempt to
set a local number lower than first_unused is detected. Set
first_unused. Fixed the logic about when to add a new block, when
to compact the last block, and when to make it sparse. Simplify
code by using the helper functions.
(l2g_delete): Don't increase the zeroes counter if a zero is
deleted. Delete the entire block if it became empty. Attempt to
join this block to its neighbors. Compact the block if it was
sparse and contained too many deleted entries.
(l2g_lookup): Added const qualifier to the l2g argument. Don't
return uninitialized data. Use helper functions to simplify code
and make it slightly faster.
(l2g_next_key): Added const qualifier to the l2g argument.
(l2g_first_appendable_key): New function.
(l2g_delete_global_in_sorted): New function.
(l2g_compact): Removed.
(l2g_dump): Switch placement of l2g and file arguments to match
other similar functions in the lyskomd code. Added const
qualifier. Dump first_unused. Use helper functions to simplify
code.
(l2g_read): Switch placement of l2g and file arguments to match
other similar functions in the lyskomd code. Read first_unused.
Return a success indicator. Detect unexpected EOF conditions.
(l2g_write): Switch placement of l2g and file arguments to match
other similar functions in the lyskomd code. Write first_unused.
Use helper functions to simplify code.
(l2gi_searchall): Added const qualifier to the l2g argument.
Simplify code by calling l2gi_searchsome instead of duplicating
the code.
(l2gi_searchsome): Added const qualifier to the l2g argument.
Complain if the begin argument is less than 1. Don't forget to
initialize search_ended. Set beginval. Giving end==0 means that
the iterator should continue to the end of the set. Use helper
functions to simplify the code.
(l2gi_next): Use helper functions to simplify code. The iterator
is unlimited if endval==0.
(l2gi_begin): New function.
(l2gi_end): New function.
Improve the test suite with new tests of the Local_to_global
structure.
* src/server/testsuite/l2g.0/00.exp: The "C" command now takes the
arguments the other way around. Adjust the test case. Comments
added. Expect the "u" command to print first_unused.
* src/server/testsuite/l2g.0/02.exp: New file.
* src/server/testsuite/l2g.0/03.exp: New file.
* src/server/testsuite/l2g.0/04.exp: New file.
* src/server/testsuite/l2g.0/05.exp: New file.
* src/server/testsuite/l2g.0/06.exp: New file.
* src/server/testsuite/l2g.0/07.exp: New file.
* src/server/testsuite/l2g.0/08.exp: New file.
* src/server/testsuite/l2g.0/09.exp: New file.
* src/server/testsuite/config/unix.exp (l2g_stop): Added a wait
statement to avoid creating zombies.
(simple_expect): Added a missing space in a prompt regexp.
* src/server/testsuite/test-l2g.c (main): Removed the 'c' command
since l2g_compact no longer exists. Added the 'i' command that
tests iterators. Adjusted to the new API of l2g_dump, l2g_read
and l2g_write. Require an extra trailing newline after the
representation l2g_read expects when the 'r' command is used, and
produce a corresponding newline with the 'w' command. Renamed the
'p' command to 'w'.
1998-07-12 Per Cederqvist <ceder@lysator.liu.se>
Build the program in the test suite.
......
Markdown is supported
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