1/*	$NetBSD: alldig.c,v 1.2 2022/10/08 16:12:50 christos Exp $	*/
2
3/*++
4/* NAME
5/*	alldig 3
6/* SUMMARY
7/*	predicate if string is all numerical
8/* SYNOPSIS
9/*	#include <stringops.h>
10/*
11/*	int	alldig(string)
12/*	const char *string;
13/*
14/*	int	allalnum(string)
15/*	const char *string;
16/* DESCRIPTION
17/*	alldig() determines if its argument is an all-numerical string.
18/*
19/*	allalnum() determines if its argument is an all-alphanumerical
20/*	string.
21/* SEE ALSO
22/*	An alldig() routine appears in Brian W. Kernighan, P.J. Plauger:
23/*	"Software Tools", Addison-Wesley 1976.
24/* LICENSE
25/* .ad
26/* .fi
27/*	The Secure Mailer license must be distributed with this software.
28/* AUTHOR(S)
29/*	Wietse Venema
30/*	IBM T.J. Watson Research
31/*	P.O. Box 704
32/*	Yorktown Heights, NY 10598, USA
33/*
34/*	Wietse Venema
35/*	Google, Inc.
36/*	111 8th Avenue
37/*	New York, NY 10011, USA
38/*--*/
39
40/* System library. */
41
42#include <sys_defs.h>
43#include <ctype.h>
44
45/* Utility library. */
46
47#include <stringops.h>
48
49/* alldig - return true if string is all digits */
50
51int     alldig(const char *string)
52{
53    const char *cp;
54
55    if (*string == 0)
56	return (0);
57    for (cp = string; *cp != 0; cp++)
58	if (!ISDIGIT(*cp))
59	    return (0);
60    return (1);
61}
62
63/* allalnum - return true if string is all alphanum */
64
65int allalnum(const char *string)
66{
67    const char *cp;
68
69    if (*string == 0)
70        return (0);
71    for (cp = string; *cp != 0; cp++)
72        if (!ISALNUM(*cp))
73            return (0);
74    return (1);
75}
76