Commit 930a0c46 authored by Linus Tolke Y's avatar Linus Tolke Y
Browse files

New server-call: get_last_text.

parent 56a9e678
/*
* $Id: cache.h,v 0.7 1991/09/15 10:33:05 linus Exp $
* $Id: cache.h,v 0.8 1991/11/10 19:02:48 linus Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -23,7 +23,7 @@
* Please mail bug reports to bug-lyskom@lysator.liu.se.
*/
/*
* $Id: cache.h,v 0.7 1991/09/15 10:33:05 linus Exp $
* $Id: cache.h,v 0.8 1991/11/10 19:02:48 linus Exp $
*
* This file contains the cached data that the server stores.
* .h file created by ceder 1990-04-18
......@@ -252,3 +252,9 @@ dump_cache_stats(FILE *stat_file);
*/
void
dump_cache_mem_usage(FILE *stat_file);
/*
* Export the highest text_no for searching.
*/
int
query_next_text_num(void);
#
# $Id: call-switch.awk,v 0.3 1991/09/15 10:33:01 linus Exp $
# $Id: call-switch.awk,v 0.4 1991/11/10 19:02:43 linus 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: call-switch.awk,v 0.3 1991/09/15 10:33:01 linus Exp $
# $Id: call-switch.awk,v 0.4 1991/11/10 19:02:43 linus Exp $
BEGIN {
printf("/* Don't edit this file - it is generated automatically");
printf(" from\n call-switch.awk and fncdef.txt */\n");
......@@ -61,6 +61,8 @@ $1 != "#" {
printf("client->c_local_text_no_p");
else if ( $i == "c_misc_info_p" )
printf("client->c_misc_info_p");
else if ( $i == "time_date" )
printf("timelocal(&(client->time))");
else
printf("\n#error in file server/fncdef.txt\n");
}
......
/*
* $Id: connections.h,v 0.5 1991/09/15 10:32:44 linus Exp $
* $Id: connections.h,v 0.6 1991/11/10 19:02:39 linus Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -23,7 +23,7 @@
* Please mail bug reports to bug-lyskom@lysator.liu.se.
*/
/*
* $Id: connections.h,v 0.5 1991/09/15 10:32:44 linus Exp $
* $Id: connections.h,v 0.6 1991/11/10 19:02:39 linus Exp $
*
* connections.h -- The top level of the communication packet.
*
......@@ -87,6 +87,7 @@ typedef struct connection {
Local_text_no *c_local_text_no_p; /* Freead by free_parsed(). */
Priv_bits priv_bits;
Conf_type conf_type;
struct tm time;
/* Protocol independent things. */
......@@ -123,7 +124,7 @@ Connection * active_connection;
* This enum describes the result of a function in services.c.
*/
typedef enum {
rt_number, /* E.g. Pers_no, Conf_no, Text_no, time_t.
rt_number, /* E.g. Pers_no, Conf_no, Text_no.
This is somewhat special in that the
function indicates an error by returning
0 and not FAILURE. */
......@@ -147,7 +148,8 @@ typedef enum {
rt_member_list,
rt_time_date,
rt_session_info,
rt_session_no
rt_session_no,
rt_text_no
} Res_type;
/*
......@@ -172,6 +174,7 @@ typedef union {
time_t time_date;
Session_info session_info;
Session_no session_no;
Text_no text_no;
} Result_holder;
......
#
# $Id: fncdef.txt,v 0.5 1991/09/15 10:32:06 linus Exp $
# $Id: fncdef.txt,v 0.6 1991/11/10 19:02:35 linus 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.5 1991/09/15 10:32:06 linus Exp $
# $Id: fncdef.txt,v 0.6 1991/11/10 19:02:35 linus Exp $
#
# This file is used to describe the functions in services.c. All
# functions that are reachable from the clients are listed here, together
......@@ -93,3 +93,4 @@ success get_session_info num : session_info
success disconnect num
success who_am_i : session_no
success set_user_area num num
success get_last_text time_date : text_no
/*
* $Id: internal-connections.c,v 0.6 1991/10/29 03:16:56 ceder Exp $
* $Id: internal-connections.c,v 0.7 1991/11/10 19:02:31 linus Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -28,7 +28,7 @@
* Abstract routines on the data type Connection.
*/
static char *rcsid = "$Id: internal-connections.c,v 0.6 1991/10/29 03:16:56 ceder Exp $";
static char *rcsid = "$Id: internal-connections.c,v 0.7 1991/11/10 19:02:31 linus Exp $";
#include "exp.h"
......@@ -55,7 +55,8 @@ INTERNAL const Connection EMPTY_CONNECTION =
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, EMPTY_STRING_i, EMPTY_STRING_i,
EMPTY_STRING_i, NULL, NULL, DEFAULT_PRIV_BITS_i,
NULL_CONF_TYPE_i, EMPTY_STRING_i, 0, FALSE, NO_TIME,
NULL_CONF_TYPE_i, EMPTY_tm_i, EMPTY_STRING_i, 0, FALSE,
NO_TIME,
0, FALSE});
static int no_of_allocated_connections = 0;
......
/*
* $Id: prot-a-output.c,v 0.5 1991/10/29 14:52:29 linus Exp $
* $Id: prot-a-output.c,v 0.6 1991/11/10 19:02:26 linus Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -28,7 +28,7 @@
* Written by ceder 1990-07-13
*/
static char *rcsid = "$Id: prot-a-output.c,v 0.5 1991/10/29 14:52:29 linus Exp $";
static char *rcsid = "$Id: prot-a-output.c,v 0.6 1991/11/10 19:02:26 linus Exp $";
#include <kom-types.h>
......@@ -526,3 +526,10 @@ prot_a_output_session_no(Connection *fp,
{
mux_printf(fp, " %lu", (u_long) session_no);
}
void
prot_a_output_text_no(Connection *fp,
Text_no text)
{
mux_printf(fp, " %lu", text);
}
#
# $Id: prot-a-parse-arg-c.awk,v 0.3 1991/09/15 10:30:20 linus Exp $
# $Id: prot-a-parse-arg-c.awk,v 0.4 1991/11/10 19:02:22 linus Exp $
# Copyright (C) 1991 Lysator Academic Computer Association.
#
# This file is part of the LysKOM server.
......@@ -22,14 +22,14 @@
#
# Please mail bug reports to bug-lyskom@lysator.liu.se.
#
# $Id: prot-a-parse-arg-c.awk,v 0.3 1991/09/15 10:30:20 linus Exp $
# $Id: prot-a-parse-arg-c.awk,v 0.4 1991/11/10 19:02:22 linus Exp $
BEGIN {
printf("/* Don't edit this file - it is generated automatically");
printf(" from\n prot-a-parse-arg-c.awk and fncdef.txt */\n\n");
printf("#include <setjmp.h>\n");
printf("#include <kom-types.h>\n");
printf("#include \"com.h\"\n");
printf("#include \"isc.h\"\n");
printf("#include \"isc-interface.h\"\n");
printf("#include \"connections.h\"\n");
printf("#include \"isc-parse.h\"\n");
printf("#include <server/smalloc.h>\n");
......@@ -115,6 +115,18 @@ $1 != "#" {
printf("\tif ( parse_nonwhite_char(client) != '}' )\n");
printf("\t longjmp(parse_env, ISC_PROTOCOL_ERR);\n");
}
else if ( $i == "time_date" )
{
printf("\tclient->time.tm_sec = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_min = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_hour = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_mday = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_mon = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_year = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_wday = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_yday = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_isdst = prot_a_parse_long(client);\n");
}
else
printf("#error in prot-a-parse-arg-c.awk: not ready yet.\n");
......
/*
* $Id: prot-a.c,v 0.8 1991/09/21 13:06:53 ceder Exp $
* $Id: prot-a.c,v 0.9 1991/11/10 19:02:18 linus 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.8 1991/09/21 13:06:53 ceder Exp $";
static char *rcsid = "$Id: prot-a.c,v 0.9 1991/11/10 19:02:18 linus Exp $";
#include <stdio.h>
......@@ -290,6 +290,7 @@ prot_a_is_legal_fnc(Call_header fnc)
case call_fnc_disconnect:
case call_fnc_who_am_i:
case call_fnc_set_user_area:
case call_fnc_get_last_text:
return TRUE;
default:
......
/*
* $Id: simple-cache.c,v 0.17 1991/09/21 13:06:45 ceder Exp $
* $Id: simple-cache.c,v 0.18 1991/11/10 19:02:11 linus Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -33,7 +33,7 @@
* New save algorithm by ceder.
*/
static char *rcsid = "$Id: simple-cache.c,v 0.17 1991/09/21 13:06:45 ceder Exp $";
static char *rcsid = "$Id: simple-cache.c,v 0.18 1991/11/10 19:02:11 linus Exp $";
......@@ -844,7 +844,7 @@ cached_create_text( String message)
}
Text_no
EXPORT Text_no
traverse_text(Text_no seed)
{
Cache_node *node;
......@@ -2063,3 +2063,8 @@ dump_cache_stats(FILE *fp)
}
EXPORT int
query_next_text_num(void)
{
return next_text_num;
}
/*
* $Id: text.c,v 0.8 1991/10/21 22:29:33 ceder Exp $
* $Id: text.c,v 0.9 1991/11/10 19:02:05 linus 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.8 1991/10/21 22:29:33 ceder Exp $";
static char *rcsid = "$Id: text.c,v 0.9 1991/11/10 19:02:05 linus Exp $";
#include <time.h>
#include <stdlib.h>
......@@ -1728,6 +1728,53 @@ delete_text( Text_no text_no )
return do_delete_text(text_no, text_s);
}
/*
* Lookup a text according to creation-time.
* The text-no of the text created closest before TIME is returned.
* The text text-no must not be readable
*/
extern Text_no
get_last_text(time_t time, Text_no *text)
{
Text_no lower = 0;
Text_no higher = query_next_text_num();
while (!(lower + 1 == higher))
{
Text_stat * text;
Text_no try = (lower + higher) / 2; /* Binary search */
int step = 0; /* Patch to accept nonexisting texts */
do
{
try += step; /* back and forth around the middle as long */
/* until we find an existing text. */
step = (step + ( step > 0 ? 1 : -1)) * (-1);
text = cached_get_text_stat( try );
} while (text == NULL && try > lower && try < higher);
if (try <= lower || try >= higher)
break; /* We did not find any existing text */
if (time > text->creation_time)
lower = try;
else /* The intervall is "halved" */
higher = try;
}
if (lower != 0)
{
*text = lower;
return OK; /* We found a text */
}
else
{
kom_errno = KOM_NO_SUCH_TEXT; /* We did not find a text at all */
return FAILURE;
}
}
/*
* Add a recipient to a text.
*/
......
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