8a91cf36b28ba68bf09f3d7b7015d7139b784543
[yaz-moved-to-github.git] / comstack / waislen.c
1 /*
2  * Copyright (c) 1995-1999, Index Data.
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: waislen.c,v $
7  * Revision 1.4  1999-01-08 11:23:15  adam
8  * Added const modifier to some of the BER/ODR encoding routines.
9  *
10  * Revision 1.3  1996/02/29 14:23:13  adam
11  * Bug fix.
12  *
13  * Revision 1.2  1996/02/26  18:34:44  adam
14  * Bug fix.
15  *
16  * Revision 1.1  1996/02/20  13:02:58  quinn
17  * Wais length.
18  *
19  *
20  */
21
22 #include <stdio.h>
23 #include <comstack.h>
24 #include <tcpip.h>
25 /*
26  * Return length of WAIS package or 0
27  */
28 int completeWAIS(const unsigned char *buf, int len)
29 {
30     int i, lval = 0;
31
32     if (len < 25)
33         return 0;
34     if (*buf != '0')
35         return 0;
36     /* calculate length */
37     for (i = 0; i < 10; i++)
38         lval = lval * 10 + (buf[i] - '0');
39     lval += 25;
40     if (len >= lval)
41         return lval;
42     return 0;
43 }