summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeffrey Altman <jaltman@secure-endpoints.com>2007-08-24 14:41:52 +0000
committerJeffrey Altman <jaltman@secure-endpoints.com>2007-08-24 14:41:52 +0000
commit28c335b522782510953ebd8280901496488dcb8a (patch)
treef78ec05ced5c49c3c3315fe0bc251efaba1a4ff8 /src
parentab684f9ac376b20649c4fb286da636861876089f (diff)
downloadkrb5-28c335b522782510953ebd8280901496488dcb8a.tar.gz
krb5-28c335b522782510953ebd8280901496488dcb8a.tar.xz
krb5-28c335b522782510953ebd8280901496488dcb8a.zip
NIM: support include files in schemas
The ccsv.pl and csvschema.cfg scripts are used to generate "C" source code from CSV files containing tabular data. In particular, these are used to define the configuration schema for Network Identity Manager and some of its plug-ins. It is desirable to be able to include arbitrary header files and define macros in the generated C code so that the schema definition can use them. This patch allows the CSV files to contain headers that define lines of text that will be included literally in the generated C code. Lines at the start of schema CSV file that begin with '#@' will be stripped of the '#@' prefix and inserted into the C code. E.g: The following line at the start of a schema CSV file: #@#include<windows.h> ,will result in the following text in the C code: #include<windows.h> Then the schema definition can use macros of the form: ClrHeaderExpSel, KC_INT32, "RGB(195, 94, 94)" ,which use macros such as RGB that are defined in the included header file. ticket: new component: windows git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19862 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src')
-rw-r--r--src/windows/identity/config/ccsv.pl258
-rw-r--r--src/windows/identity/config/csvschema.cfg132
2 files changed, 201 insertions, 189 deletions
diff --git a/src/windows/identity/config/ccsv.pl b/src/windows/identity/config/ccsv.pl
index a3777975ae..f231793638 100644
--- a/src/windows/identity/config/ccsv.pl
+++ b/src/windows/identity/config/ccsv.pl
@@ -1,124 +1,134 @@
-#!/usr/bin/perl
-
-#
-# Copyright (c) 2004 Massachusetts Institute of Technology
-#
-# Permission is hereby granted, free of charge, to any person
-# obtaining a copy of this software and associated documentation
-# files (the "Software"), to deal in the Software without
-# restriction, including without limitation the rights to use, copy,
-# modify, merge, publish, distribute, sublicense, and/or sell copies
-# of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-
-# This is a simple script that is used for generating C code from CSV
-#files. We expect three arguments, the <input> which is the .csv file
-#to be parsed, a <config> which is a configuration file and the
-#<output>.
-
-# The configuration file is a perl file which defines the following
-#variables :
-
-# $skip_lines : the number of lines to skip in the csv. The default is 0
-
-# @pquote : an array of boolean integers that specify whether or not
-# to quote the specific field using double quotes. The default is to
-# not quote anything.
-
-# $file_prefix : the prefix for the file
-
-# $record_prefix : the prefix for each record
-
-# $field_sep : the field separator. The default is ','
-
-# $record_postfix : the postfix for each record
-
-# $record_sep : A record separator. Only shows up between records.
-
-# $file_postfix : the postfix for the entire file
-
-use Text::ParseWords;
-
-sub do_nothingus {
-}
-
-if($#ARGV != 2) {
- print "Usage: ccsv.pl <input-filename> <config-filename> <output-filename>\n";
- die;
-}
-
-$infn=$ARGV[0];
-$cfgfn=$ARGV[1];
-$outfn=$ARGV[2];
-
-$skip_lines = 0;
-@pquote = {};
-$file_prefix = "";
-$record_prefix = "";
-$field_sep = ",";
-$record_postfix = "";
-$record_sep = "\n";
-$file_postfix = "";
-$record_parser = \&do_nothingus;
-
-($inbase) = ($infn =~ m/^(\w*)/);
-
-do $cfgfn;
-
-open(IN, "<".$infn) or die "Can't open input file:".$infn;
-open(OUT, ">".$outfn) or die "Can't open output file:".$outfn;
-
-print OUT $file_prefix;
-
-$first_line = 1;
-
-while(<IN>) {
- chomp $_;
- if (m/^\#/) {
- # ignore
- } elsif ($skip_lines > 0) {
- $skip_lines--;
- } else {
- if($first_line == 0){
- print OUT $record_sep;
- } else {
- $first_line = 0;
- }
-
- @fields = &parse_line(',',0,$_);
- for(@fields) {
- chomp;
- s/^\s*//;
- }
-
- &$record_parser(\@fields);
-
- print OUT $record_prefix;
- for(my $i=0; $i <= $#fields; $i++) {
- print OUT $field_sep if $i != 0;
- print OUT 'L"' if $pquote[$i] == 1;
- print OUT $fields[$i];
- print OUT '"' if $pquote[$i] == 1;
- }
- print OUT $record_postfix;
- }
-}
-
-print OUT $file_postfix;
-
-close INF;
-close OUT;
+#!/usr/bin/perl
+
+#
+# Copyright (c) 2004 Massachusetts Institute of Technology
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use, copy,
+# modify, merge, publish, distribute, sublicense, and/or sell copies
+# of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+
+
+# This is a simple script that is used for generating C code from CSV
+#files. We expect three arguments, the <input> which is the .csv file
+#to be parsed, a <config> which is a configuration file and the
+#<output>.
+
+# The configuration file is a perl file which defines the following
+#variables :
+
+# $skip_lines : the number of lines to skip in the csv. The default is 0
+
+# @pquote : an array of boolean integers that specify whether or not
+# to quote the specific field using double quotes. The default is to
+# not quote anything.
+
+# $file_prefix : the prefix for the file
+
+# $record_prefix : the prefix for each record
+
+# $field_sep : the field separator. The default is ','
+
+# $record_postfix : the postfix for each record
+
+# $record_sep : A record separator. Only shows up between records.
+
+# $file_postfix : the postfix for the entire file
+
+use Text::ParseWords;
+
+sub do_nothingus {
+}
+
+if($#ARGV != 2) {
+ print "Usage: ccsv.pl <input-filename> <config-filename> <output-filename>\n";
+ die;
+}
+
+$infn=$ARGV[0];
+$cfgfn=$ARGV[1];
+$outfn=$ARGV[2];
+
+$skip_lines = 0;
+@pquote = {};
+$file_prefix = "";
+$record_prefix = "";
+$finc = "";
+$field_sep = ",";
+$record_postfix = "";
+$record_sep = "\n";
+$file_postfix = "";
+$record_parser = \&do_nothingus;
+
+($inbase) = ($infn =~ m/^(\w*)/);
+
+do $cfgfn;
+
+open(IN, "<".$infn) or die "Can't open input file:".$infn;
+open(OUT, ">".$outfn) or die "Can't open output file:".$outfn;
+
+$first_line = 1;
+
+while(<IN>) {
+ chomp $_;
+ if (m/^\#/) {
+ if (m/^\#\@/) {
+ ($inc) = m/^\#\@(.*)/;
+ $finc = $finc.$inc."\n";
+ } else {
+ # ignore
+ }
+ } elsif ($skip_lines > 0) {
+ $skip_lines--;
+ } else {
+ if($first_line == 0){
+ print OUT $record_sep;
+ } else {
+ $file_prefix =~ s/\$finc/$finc/;
+ print OUT $file_prefix;
+ $first_line = 0;
+ }
+
+ @fields = &parse_line(',',0,$_);
+ for(@fields) {
+ chomp;
+ s/^\s*//;
+ }
+
+ &$record_parser(\@fields);
+
+ print OUT $record_prefix;
+ for(my $i=0; $i <= $#fields; $i++) {
+ print OUT $field_sep if $i != 0;
+ print OUT 'L"' if $pquote[$i] == 1;
+ print OUT $fields[$i];
+ print OUT '"' if $pquote[$i] == 1;
+ }
+ print OUT $record_postfix;
+ }
+}
+
+if ($first_line == 1) {
+ print OUT $file_prefix;
+}
+
+print OUT $file_postfix;
+
+close INF;
+close OUT;
diff --git a/src/windows/identity/config/csvschema.cfg b/src/windows/identity/config/csvschema.cfg
index cc8acd26bc..a21c83c5b9 100644
--- a/src/windows/identity/config/csvschema.cfg
+++ b/src/windows/identity/config/csvschema.cfg
@@ -1,65 +1,67 @@
-#
-# Copyright (c) 2004 Massachusetts Institute of Technology
-#
-# Permission is hereby granted, free of charge, to any person
-# obtaining a copy of this software and associated documentation
-# files (the "Software"), to deal in the Software without
-# restriction, including without limitation the rights to use, copy,
-# modify, merge, publish, distribute, sublicense, and/or sell copies
-# of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-$file_prefix = <<EOS;
-/*
-This file was autogenerated from:
- $cfgfn
- $infn
-
-Do not modify directly.
-*/
-#include<kconfig.h>
-
-kconf_schema schema_$inbase\[] = {
-EOS
-
-$record_prefix = "{";
-
-$record_sep = ",\n";
-
-$record_postfix = "}";
-
-$file_postfix = <<EOS;
-
-};
-
-
-EOS
-
-$skip_lines = 1;
-
-@pquote = (1,0,0,1);
-
-sub rec_handler {
- $arr = shift;
- if($$arr[1] =~ "KC_STRING") {
- $$arr[2] =~ s/\[\~\]/\\0/g;
- $$arr[2] = "(khm_int64) L\"".$$arr[2]."\"";
- }
-
- $$arr[3] = "";
-}
-
-$record_parser = \&rec_handler;
+#
+# Copyright (c) 2004 Massachusetts Institute of Technology
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use, copy,
+# modify, merge, publish, distribute, sublicense, and/or sell copies
+# of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+
+$file_prefix = <<EOS;
+/*
+This file was autogenerated from:
+ $cfgfn
+ $infn
+
+Do not modify directly.
+*/
+#include<kconfig.h>
+
+\$finc
+
+kconf_schema schema_$inbase\[] = {
+EOS
+
+$record_prefix = "{";
+
+$record_sep = ",\n";
+
+$record_postfix = "}";
+
+$file_postfix = <<EOS;
+
+};
+
+
+EOS
+
+$skip_lines = 1;
+
+@pquote = (1,0,0,1);
+
+sub rec_handler {
+ $arr = shift;
+ if($$arr[1] =~ "KC_STRING") {
+ $$arr[2] =~ s/\[\~\]/\\0/g;
+ $$arr[2] = "(khm_int64) L\"".$$arr[2]."\"";
+ }
+
+ $$arr[3] = "";
+}
+
+$record_parser = \&rec_handler;