Fixed bug in inetd code. The server listened on tcp:@:9999 even
[yaz-moved-to-github.git] / comstack / waislen.c
1 /*
2  * Copyright (c) 1995, Index Data.
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: waislen.c,v $
7  * Revision 1.3  1996-02-29 14:23:13  adam
8  * Bug fix.
9  *
10  * Revision 1.2  1996/02/26  18:34:44  adam
11  * Bug fix.
12  *
13  * Revision 1.1  1996/02/20  13:02:58  quinn
14  * Wais length.
15  *
16  *
17  */
18
19 #include <stdio.h>
20 /*
21  * Return length of WAIS package or 0
22  */
23 int completeWAIS(unsigned char *buf, int len)
24 {
25     int i, lval = 0;
26
27     if (len < 25)
28         return 0;
29     if (*buf != '0')
30         return 0;
31     /* calculate length */
32     for (i = 0; i < 10; i++)
33         lval = lval * 10 + (buf[i] - '0');
34     lval += 25;
35     if (len >= lval)
36         return lval;
37     return 0;
38 }