diff --git a/src/include/services.h b/src/include/services.h index 469243cc5809cec2f68b1410a9bf6dc8022e312d..d4fcf1496ec40192158a9ca090186733d1e6a1ac 100644 --- a/src/include/services.h +++ b/src/include/services.h @@ -1,5 +1,5 @@ /* - * $Id: services.h,v 0.6 1991/12/16 23:58:14 ceder Exp $ + * $Id: services.h,v 0.7 1991/12/17 23:07:32 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -401,6 +401,17 @@ extern Success KOM_( get_last_text (struct tm *clock, Text_no *result)); #endif +/* + * Return next/previous existing text-no. + */ + +extern Success +KOM_( find_next_text_no (Text_no start, Text_no *result)); + +extern Success +KOM_( find_previous_text_no (Text_no start, Text_no *result)); + + /* * Who is logged on now? */ diff --git a/src/server/ChangeLog b/src/server/ChangeLog index 39626b54de4d7a9f0e4904cb6db8ee5004bec114..92bdc04c3492f06ed0f776fae575efbb20f649e9 100644 --- a/src/server/ChangeLog +++ b/src/server/ChangeLog @@ -1,3 +1,8 @@ +Wed Dec 18 00:05:43 1991 Per Cederqvist (ceder at lysator) + + * fncdef.txt, prot-a.c, text.c (find_next_text_no, + find_previous_text_no): New functions. + Tue Dec 17 00:52:11 1991 Per Cederqvist (ceder at lysator) * prot-a-parse-arg-c.awk: Fixed bogus parsing of argument to diff --git a/src/server/fncdef.txt b/src/server/fncdef.txt index b41e47c98a29eb611790f9db4c49d024c93a643a..d4daa0332a04d7d2a35943807ad9ebbb35bec78d 100644 --- a/src/server/fncdef.txt +++ b/src/server/fncdef.txt @@ -1,5 +1,5 @@ # -# $Id: fncdef.txt,v 0.7 1991/11/11 00:27:41 ceder Exp $ +# $Id: fncdef.txt,v 0.8 1991/12/17 23:07:42 ceder Exp $ # Copyright (C) 1991 Lysator Academic Computer Association. # # This file is part of the LysKOM server. @@ -22,7 +22,7 @@ # # Please mail bug reports to bug-lyskom@lysator.liu.se. # -# $Id: fncdef.txt,v 0.7 1991/11/11 00:27:41 ceder Exp $ +# $Id: fncdef.txt,v 0.8 1991/12/17 23:07:42 ceder Exp $ # # This file is used to describe the functions in services.c. All # functions that are reachable from the clients are listed here, together @@ -95,3 +95,5 @@ success who_am_i : session_no success set_user_area num num success get_last_text time_date : text_no number create_anonymous_text c_string (TEXT_LEN) num c_misc_info_p +success find_next_text_no num : text_no +success find_previous_text_no num : text_no diff --git a/src/server/prot-a.c b/src/server/prot-a.c index 52dc6ac6d433e5bb57f646a44d7f1973e01d5ca8..0690973e6c201406578ea9eb3199326f13fd77d5 100644 --- a/src/server/prot-a.c +++ b/src/server/prot-a.c @@ -1,5 +1,5 @@ /* - * $Id: prot-a.c,v 0.11 1991/11/16 03:30:05 ceder Exp $ + * $Id: prot-a.c,v 0.12 1991/12/17 23:07:40 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -26,7 +26,7 @@ * Protocol A. */ -static char *rcsid = "$Id: prot-a.c,v 0.11 1991/11/16 03:30:05 ceder Exp $"; +static char *rcsid = "$Id: prot-a.c,v 0.12 1991/12/17 23:07:40 ceder Exp $"; #include <stdio.h> @@ -297,6 +297,8 @@ prot_a_is_legal_fnc(Call_header fnc) case call_fnc_set_user_area: case call_fnc_get_last_text: case call_fnc_create_anonymous_text: + case call_fnc_find_next_text_no: + case call_fnc_find_previous_text_no: return TRUE; default: diff --git a/src/server/text.c b/src/server/text.c index 949d19640159eac64058f4885dcbee9857135c50..174846a6de1aa54e7dad6c25771580f787ba2974 100644 --- a/src/server/text.c +++ b/src/server/text.c @@ -1,5 +1,5 @@ /* - * $Id: text.c,v 0.14 1991/12/17 22:20:53 ceder Exp $ + * $Id: text.c,v 0.15 1991/12/17 23:07:38 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -28,7 +28,7 @@ * All atomic calls that deals with texts. */ -static char *rcsid = "$Id: text.c,v 0.14 1991/12/17 22:20:53 ceder Exp $"; +static char *rcsid = "$Id: text.c,v 0.15 1991/12/17 23:07:38 ceder Exp $"; #include <time.h> #include <stdlib.h> @@ -1950,6 +1950,56 @@ get_last_text(time_t time, } +/* + * Return next existing text-no. + */ + +extern Success +find_next_text_no (Text_no start, + Text_no *result) +{ + Text_no highest = query_next_text_num(); + Text_stat *text_s; + + while (++start < highest) + { + text_s = cached_get_text_stat(start); + if (text_s != NULL && text_read_access(start, text_s) == TRUE) + { + *result = start; + return OK; + } + } + + kom_errno = KOM_NO_SUCH_TEXT; + return FAILURE; +} + + +/* + * Return next/previous existing text-no. + */ + +extern Success +find_previous_text_no (Text_no start, + Text_no *result) +{ + Text_stat *text_s; + + while (start-- > 0) + { + text_s = cached_get_text_stat(start); + if (text_s != NULL && text_read_access(start, text_s) == TRUE) + { + *result = start; + return OK; + } + } + + kom_errno = KOM_NO_SUCH_TEXT; + return FAILURE; +} + /* * Add a recipient to a text. */