Postfix3.3.1
allascii.c
[詳解]
1 /*++
2 /* NAME
3 /* allascii 3
4 /* SUMMARY
5 /* predicate if string is all ASCII
6 /* SYNOPSIS
7 /* #include <stringops.h>
8 /*
9 /* int allascii(buffer)
10 /* const char *buffer;
11 /*
12 /* int allascii_len(buffer, len)
13 /* const char *buffer;
14 /* ssize_t len;
15 /* DESCRIPTION
16 /* allascii() determines if its argument is an all-ASCII string.
17 /*
18 /* Arguments:
19 /* .IP buffer
20 /* The null-terminated input string.
21 /* .IP len
22 /* The string length, -1 to determine the length dynamically.
23 /* LICENSE
24 /* .ad
25 /* .fi
26 /* The Secure Mailer license must be distributed with this software.
27 /* AUTHOR(S)
28 /* Wietse Venema
29 /* IBM T.J. Watson Research
30 /* P.O. Box 704
31 /* Yorktown Heights, NY 10598, USA
32 /*
33 /* Wietse Venema
34 /* Google, Inc.
35 /* 111 8th Avenue
36 /* New York, NY 10011, USA
37 /*--*/
38 
39 /* System library. */
40 
41 #include <sys_defs.h>
42 #include <ctype.h>
43 #include <string.h>
44 
45 /* Utility library. */
46 
47 #include "stringops.h"
48 
49 /* allascii_len - return true if string is all ASCII */
50 
51 int allascii_len(const char *string, ssize_t len)
52 {
53  const char *cp;
54  int ch;
55 
56  if (len < 0)
57  len = strlen(string);
58  if (len == 0)
59  return (0);
60  for (cp = string; cp < string + len
61  && (ch = *(unsigned char *) cp) != 0; cp++)
62  if (!ISASCII(ch))
63  return (0);
64  return (1);
65 }
#define ISASCII(c)
Definition: sys_defs.h:1743
int allascii_len(const char *string, ssize_t len)
Definition: allascii.c:51