Doxyfile file description. Indentation. No change of code.
[yaz-moved-to-github.git] / src / atoin.c
1 /*
2  * Copyright (c) 1997-2004, Index Data
3  * See the file LICENSE for details.
4  *
5  * $Id: atoin.c,v 1.3 2004-10-15 00:18:59 adam Exp $
6  */
7
8 /** 
9  * \file atoin.c
10  * \brief Implements atoi_n function.
11  */
12
13 #if HAVE_CONFIG_H
14 #include <config.h>
15 #endif
16
17 #include <string.h>
18 #include <ctype.h>
19 #include <yaz/yaz-util.h>
20
21 /**
22  * atoi_n: like atoi but reads at most len characters.
23  */
24 int atoi_n (const char *buf, int len)
25 {
26     int val = 0;
27
28     while (--len >= 0)
29     {
30         if (isdigit (*(const unsigned char *) buf))
31             val = val*10 + (*buf - '0');
32         buf++;
33     }
34     return val;
35 }
36