#! /bin/sh

if [ "$1" = "--version" ]
then
cat << EOF
ccs-patternize 1.8.0

Copyright (C) 2005-2010 NTT DATA CORPORATION.

This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
EOF
elif [ "$1" = "--help" ]
then
cat << EOF
Usage: ccs-patternize [configfile] < old_domain_policy > new_domain_policy

This program reads domain policy from standard input and replaces pathnames with patterns if the pathname matches to patterns and writes to standard output.

Pathnames for domainnames won't be replaced.

 configfile  Get rules from specified file. Default is /etc/ccs/tools/patternize.conf .

Rules are defined in configfile. Only first matching rule is used. If none matched, it is not patternized.

Examples:

 # Replace (e.g.) proc:/self/fd/0 with proc:/self/fd/\\$ .

 rewrite path_pattern proc:/self/fd/\\$

 # Replace (e.g.) proc:/123/status with proc:/\\$/status .

 rewrite head_pattern proc:/\\$/

 # Replace (e.g.) dev(8,1):/etc/mtab~456 with dev(8,1):/etc/mtab~\\$ .

 rewrite tail_pattern /etc/mtab~\\$

 # Replace (e.g.) /tmp/phpZjk1k3 with @GROUP1 .

 rewrite path_pattern /tmp/php\\?\\?\\?\\?\\?\\? @GROUP1

 # Replace integers between 0-100 or 100-200 with @GROUP2 .

 rewrite number_pattern 0-100 @GROUP2

 rewrite number_pattern 100-200 @GROUP2

 # Replace ip addresses 127.0.0.1 or 0:0:0:0:0:0:0:1 with @LOCALHOST .

 rewrite address_pattern 127.0.0.1 @LOCALHOST

 rewrite address_pattern 0:0:0:0:0:0:0:1 @LOCALHOST

EOF
else
cat << EOF | help2man -i - -N -s 8 -n "Convert TOMOYO Linux's pathnames into patterns" $0 | gzip -9 > man8/ccs-patternize.8.gz
[SEE ALSO]

 ccs-findtemp (8)
 ccs-diffpolicy(8)

[AUTHORS]

 penguin-kernel _at_ I-love.SAKURA.ne.jp

EOF
fi
exit 0
