+o(c, 0, "#include \"$prefix.h\"\n");
+
+o(h, 0,
+ "#ifndef INCLUDED_\U${prefix}_H\n".
+ "#define INCLUDED_\U${prefix}_H\n\n".
+ "#include <tcl.h>\n");
+
+o(h, 400,
+ "void setstringresult(Tcl_Interp*, const char*);\n".
+ "int pat_enum(Tcl_Interp*, Tcl_Obj*, const void**,".
+ " const void*, size_t, const char *what);\n");
+
+o(h, 999,
+ "#endif /*INCLUDED_\U${prefix}_H*/\n");
+
+if (defined $output) {
+ $oh= new IO::File "$output.tmp", 'w' or die "$output.tmp: $!\n";
+} else {
+ $oh= 'STDOUT';
+}
+
+print $oh "/* AUTOGENERATED - DO NOT EDIT */\n" or die $!;
+foreach $pr (sort keys %{ $o{$write} }) {
+ print $oh "\n" or die $!;
+ print $oh $o{$write}{$pr} or die $!;
+}
+
+die if $oh->error;
+die $! unless $oh->close;
+
+if (defined $output) {
+ rename "$output.tmp", $output or die $!;
+}
+
+sub o ($$) {
+ my ($wh,$pr,$s) = @_;
+ $o{$wh}{sprintf "%010d", $pr} .= $s;
+}
+
+sub make_decl_init ($$$$) {
+ my ($n, $t, $a, $initcode) = @_;
+ my ($o,$init);
+ $o= make_decl($n,$t,$a);
+ if (exists $type_init{$t}) {
+ $init= $type_init{$t};
+ $$initcode .= " ".subst_in("$n", $init)."\n"
+ if length $init;
+ } else {
+ $o .= ' =0';
+ }
+ return " ".$o.";\n";
+}
+