Fixed bug #2068: pkg-config trouble.
[yaz-moved-to-github.git] / src / waislen.c
1 /*
2  * Copyright (C) 1995-2007, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: waislen.c,v 1.6 2007-10-09 06:00:56 adam Exp $
6  */
7 /**
8  * \file waislen.c
9  * \brief Implements WAIS package handling
10  */
11
12 #include <stdio.h>
13 #include <yaz/comstack.h>
14 /*
15  * Return length of WAIS package or 0
16  */
17 int completeWAIS(const char *buf, int len)
18 {
19     int i, lval = 0;
20
21     if (len < 25)
22         return 0;
23     if (*buf != '0')
24         return 0;
25     /* calculate length */
26     for (i = 0; i < 10; i++)
27         lval = lval * 10 + (buf[i] - '0');
28     lval += 25;
29     if (len >= lval)
30         return lval;
31     return 0;
32 }
33 /*
34  * Local variables:
35  * c-basic-offset: 4
36  * indent-tabs-mode: nil
37  * End:
38  * vim: shiftwidth=4 tabstop=8 expandtab
39  */
40