Blob


1 /*
2 * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16 #ifdef __NetBSD__
17 # define _OPENBSD_SOURCE
18 #endif
19 #include <stdlib.h>
21 int
22 main(void)
23 {
24 const char *errstr;
26 if (strtonum("1", 0, 2, &errstr) != 1)
27 return 1;
28 if (errstr != NULL)
29 return 2;
30 if (strtonum("1x", 0, 2, &errstr) != 0)
31 return 3;
32 if (errstr == NULL)
33 return 4;
34 if (strtonum("2", 0, 1, &errstr) != 0)
35 return 5;
36 if (errstr == NULL)
37 return 6;
38 if (strtonum("0", 1, 2, &errstr) != 0)
39 return 7;
40 if (errstr == NULL)
41 return 8;
42 return 0;
43 }