Updated information about YAZ.
[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.5  1999-11-30 13:47:11  adam
8  * Improved installation. Moved header files to include/yaz.
9  *
10  * Revision 1.4  1999/01/08 11:23:15  adam
11  * Added const modifier to some of the BER/ODR encoding routines.
12  *
13  * Revision 1.3  1996/02/29 14:23:13  adam
14  * Bug fix.
15  *
16  * Revision 1.2  1996/02/26  18:34:44  adam
17  * Bug fix.
18  *
19  * Revision 1.1  1996/02/20  13:02:58  quinn
20  * Wais length.
21  *
22  *
23  */
24
25 #include <stdio.h>
26 #include <yaz/comstack.h>
27 #include <yaz/tcpip.h>
28 /*
29  * Return length of WAIS package or 0
30  */
31 int completeWAIS(const unsigned char *buf, int len)
32 {
33     int i, lval = 0;
34
35     if (len < 25)
36         return 0;
37     if (*buf != '0')
38         return 0;
39     /* calculate length */
40     for (i = 0; i < 10; i++)
41         lval = lval * 10 + (buf[i] - '0');
42     lval += 25;
43     if (len >= lval)
44         return lval;
45     return 0;
46 }