From 9de146e991505c192dbe55945e2e773ca00f405e Mon Sep 17 00:00:00 2001 From: Per Cederqvist <ceder@lysator.liu.se> Date: Tue, 17 Dec 1991 23:08:06 +0000 Subject: [PATCH] Added find_next_text_no and find_previous_text_no. --- src/include/services.h | 13 +++++++++- src/server/ChangeLog | 5 ++++ src/server/fncdef.txt | 6 +++-- src/server/prot-a.c | 6 +++-- src/server/text.c | 54 ++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 77 insertions(+), 7 deletions(-) diff --git a/src/include/services.h b/src/include/services.h index 469243cc5..d4fcf1496 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 39626b54d..92bdc04c3 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 b41e47c98..d4daa0332 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 52dc6ac6d..0690973e6 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 949d19640..174846a6d 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. */ -- GitLab