Commit cbac3a88 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(prot_a_parse_read_range): New static function.

(prot_a_parse_read_range_list): New function.
parent 2d730e61
/* /*
* $Id: prot-a-parse.c,v 0.54 2002/10/21 08:54:53 ceder Exp $ * $Id: prot-a-parse.c,v 0.55 2002/11/15 17:14:50 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association. * Copyright (C) 1991-2002 Lysator Academic Computer Association.
* *
* This file is part of the LysKOM server. * This file is part of the LysKOM server.
...@@ -703,6 +703,89 @@ prot_a_parse_misc_info(Connection *client, ...@@ -703,6 +703,89 @@ prot_a_parse_misc_info(Connection *client,
} }
} }
static void
prot_a_parse_read_range(Connection *client,
struct read_range *result)
{
switch (client->struct_parse_pos)
{
case 0:
result->first_read = prot_a_parse_long(client);
client->struct_parse_pos = 1;
/* Fall through */
case 1:
result->last_read = prot_a_parse_long(client);
/* Fall through */
default:
client->struct_parse_pos = 0;
}
}
void
prot_a_parse_read_range_list(Connection *client,
struct read_range_list *res,
int maxlen)
{
static unsigned long err_cnt = 0;
struct read_range dummy_read_range;
switch (client->array_parse_pos)
{
case 0:
if ((res->length != 0 || res->ranges != NULL) && err_cnt < 20)
{
kom_log("WNG: prot_a_parse_read_range_list():"
" len = %lu data = %lu\n",
(unsigned long)res->length,
(unsigned long)res->ranges);
res->length = 0;
res->ranges = NULL;
if (++err_cnt == 20)
kom_log("The above warning is now turned off.\n");
}
client->array_parse_parsed_length = prot_a_parse_long(client);
if (client->array_parse_parsed_length < 0)
{
isc_puts("%%Insane array size.\n", client->isc_session);
isc_flush(client->isc_session);
longjmp(parse_env, ISC_LOGOUT);
}
client->array_parse_pos = 1;
/* Fall through */
case 1:
if (parse_nonwhite_char(client) != '{')
longjmp(parse_env, ISC_PROTOCOL_ERR);
res->length = min(maxlen+1, client->array_parse_parsed_length);
res->ranges = smalloc(res->length * sizeof(struct read_range));
client->array_parse_index = 0;
client->array_parse_pos = 2;
case 2:
while(client->array_parse_index < client->array_parse_parsed_length)
{
/* Enter a parsed range into the list only if we
have parsed less than the no_of_misc of the list. */
if (client->array_parse_index < res->length)
prot_a_parse_read_range(
client, &res->ranges[client->array_parse_index]);
else
prot_a_parse_read_range(client, &dummy_read_range);
client->array_parse_index += 1;
}
client->array_parse_pos = 3;
case 3:
/* Read the closing brace */
if ( parse_nonwhite_char(client) != '}' )
longjmp(parse_env, ISC_PROTOCOL_ERR);
default:
client->array_parse_pos = 0;
}
}
void void
prot_a_parse_time_date(Connection *client, prot_a_parse_time_date(Connection *client,
......
Supports Markdown
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