Bug fix.
[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.2  1996-02-26 18:34:44  adam
8  * Bug fix.
9  *
10  * Revision 1.1  1996/02/20  13:02:58  quinn
11  * Wais length.
12  *
13  *
14  */
15
16 #include <stdio.h>
17 /*
18  * Return length of WAIS package or 0
19  */
20 int completeWAIS(unsigned char *buf, int len)
21 {
22     int i, lval = 0;
23
24     if (*buf != '0')
25         return 0;
26     if (len < 25)
27         return 0;
28     /* calculate length */
29     for (i = 0; i < 10; i++)
30         lval = lval * 10 + (buf[i] - '0');
31     lval += 25;
32     if (len >= lval)
33         return lval;
34     return 0;
35 }