Updated footer comment
[yaz-moved-to-github.git] / src / atoin.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2009 Index Data
3  * See the file LICENSE for details.
4  */
5
6 /** 
7  * \file atoin.c
8  * \brief Implements atoi_n function.
9  */
10
11 #if HAVE_CONFIG_H
12 #include <config.h>
13 #endif
14
15 #include <string.h>
16 #include <ctype.h>
17 #include <yaz/marcdisp.h>
18
19 /**
20  * atoi_n: like atoi but reads at most len characters.
21  */
22 int atoi_n (const char *buf, int len)
23 {
24     int val = 0;
25
26     while (--len >= 0)
27     {
28         if (isdigit (*(const unsigned char *) buf))
29             val = val*10 + (*buf - '0');
30         buf++;
31     }
32     return val;
33 }
34
35 /*
36  * Local variables:
37  * c-basic-offset: 4
38  * c-file-style: "Stroustrup"
39  * indent-tabs-mode: nil
40  * End:
41  * vim: shiftwidth=4 tabstop=8 expandtab
42  */
43