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