Postfix3.3.1
総合概要
データ構造
ファイル
ファイル一覧
大域各種
postfix-3.3.1
src
util
printable.c
[詳解]
1
/*++
2
/* NAME
3
/* printable 3
4
/* SUMMARY
5
/* mask non-printable characters
6
/* SYNOPSIS
7
/* #include <stringops.h>
8
/*
9
/* int util_utf8_enable;
10
/*
11
/* char *printable(buffer, replacement)
12
/* char *buffer;
13
/* int replacement;
14
/* DESCRIPTION
15
/* printable() replaces non-printable characters
16
/* in its input with the given replacement.
17
/*
18
/* util_utf8_enable controls whether UTF8 is considered printable.
19
/* With util_utf8_enable equal to zero, non-ASCII text is replaced.
20
/*
21
/* Arguments:
22
/* .IP buffer
23
/* The null-terminated input string.
24
/* .IP replacement
25
/* Replacement value for characters in \fIbuffer\fR that do not
26
/* pass the ASCII isprint(3) test or that are not valid UTF8.
27
/* LICENSE
28
/* .ad
29
/* .fi
30
/* The Secure Mailer license must be distributed with this software.
31
/* AUTHOR(S)
32
/* Wietse Venema
33
/* IBM T.J. Watson Research
34
/* P.O. Box 704
35
/* Yorktown Heights, NY 10598, USA
36
/*--*/
37
38
/* System library. */
39
40
#include "
sys_defs.h
"
41
#include <ctype.h>
42
43
/* Utility library. */
44
45
#include "
stringops.h
"
46
47
int
util_utf8_enable
= 0;
48
49
char
*
printable
(
char
*
string
,
int
replacement)
50
{
51
unsigned
char
*cp;
52
int
ch;
53
54
/*
55
* XXX Replace invalid UTF8 sequences (too short, over-long encodings,
56
* out-of-range code points, etc). See valid_utf8_string.c.
57
*/
58
cp = (
unsigned
char
*)
string
;
59
while
((ch = *cp) != 0) {
60
if
(
ISASCII
(ch) &&
ISPRINT
(ch)) {
61
/* ok */
62
}
else
if
(
util_utf8_enable
&& ch >= 194 && ch <= 254
63
&& cp[1] >= 128 && cp[1] < 192) {
64
/* UTF8; skip the rest of the bytes in the character. */
65
while
(cp[1] >= 128 && cp[1] < 192)
66
cp++;
67
}
else
{
68
/* Not ASCII and not UTF8. */
69
*cp = replacement;
70
}
71
cp++;
72
}
73
return
(
string
);
74
}
ISASCII
#define ISASCII(c)
Definition:
sys_defs.h:1743
stringops.h
sys_defs.h
ISPRINT
#define ISPRINT(c)
Definition:
sys_defs.h:1751
util_utf8_enable
int util_utf8_enable
Definition:
printable.c:47
printable
char * printable(char *string, int replacement)
Definition:
printable.c:49
2018年11月10日(土) 18時59分59秒作成 - Postfix3.3.1 / 構成:
1.8.9.1