xref: /trunk/main/sw/inc/poolfmt.awk (revision e76eebc6)
1*e76eebc6SAndrew Rist#**************************************************************
2*e76eebc6SAndrew Rist#
3*e76eebc6SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
4*e76eebc6SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
5*e76eebc6SAndrew Rist#  distributed with this work for additional information
6*e76eebc6SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
7*e76eebc6SAndrew Rist#  to you under the Apache License, Version 2.0 (the
8*e76eebc6SAndrew Rist#  "License"); you may not use this file except in compliance
9*e76eebc6SAndrew Rist#  with the License.  You may obtain a copy of the License at
10*e76eebc6SAndrew Rist#
11*e76eebc6SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12*e76eebc6SAndrew Rist#
13*e76eebc6SAndrew Rist#  Unless required by applicable law or agreed to in writing,
14*e76eebc6SAndrew Rist#  software distributed under the License is distributed on an
15*e76eebc6SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e76eebc6SAndrew Rist#  KIND, either express or implied.  See the License for the
17*e76eebc6SAndrew Rist#  specific language governing permissions and limitations
18*e76eebc6SAndrew Rist#  under the License.
19*e76eebc6SAndrew Rist#
20*e76eebc6SAndrew Rist#**************************************************************
21cdf0e10cSrcweir
22cdf0e10cSrcweir#
23cdf0e10cSrcweir# Dieses awk-script generiert ein cxx-file, das alle PoolIds der Vorlage dumpt.
24cdf0e10cSrcweir# wird fuer den HelpPI gebraucht.
25cdf0e10cSrcweir# Aufruf:  awk -f poolid.awk poolfmt.hxx > poolid.cxx
26cdf0e10cSrcweir#          cl poolid.cxx
27cdf0e10cSrcweir#          poolid.exe > ???.hrc
28cdf0e10cSrcweir#
29cdf0e10cSrcweir
30cdf0e10cSrcweirfunction Header() {
31cdf0e10cSrcweir    print "// This is an outputfile of an awk-script: $Workfile:   poolfmt.awk  $"
32cdf0e10cSrcweir    print "#include <solar.h> "
33cdf0e10cSrcweir    print
34cdf0e10cSrcweir    print  "#include <stdio.h>"
35cdf0e10cSrcweir    print  "#include <stdlib.h>"
36cdf0e10cSrcweir    print
37cdf0e10cSrcweir    print  "#pragma hdrstop"
38cdf0e10cSrcweir    print
39cdf0e10cSrcweir    print "#include <iostream.hxx> "
40cdf0e10cSrcweir    print "#include \"poolfmt.hxx\""
41cdf0e10cSrcweir    print
42cdf0e10cSrcweir}
43cdf0e10cSrcweir
44cdf0e10cSrcweirfunction Main() {
45cdf0e10cSrcweir	print
46cdf0e10cSrcweir    print  "void main( int , char *[] ) {"
47cdf0e10cSrcweir    sStr = "#define"
48cdf0e10cSrcweir    print  "    int nSize = (sizeof(ppPoolIds) / sizeof(PoolFmtIds)) - 1;"
49cdf0e10cSrcweir    print  "    for( int n = 0; n < nSize; n++ )"
50cdf0e10cSrcweir    print  "        printf( \"" sStr " %s\\t%8d\\n\", ppPoolIds[ n ].pStr, ppPoolIds[ n ].nId );"
51cdf0e10cSrcweir    print  "}"
52cdf0e10cSrcweir}
53cdf0e10cSrcweir
54cdf0e10cSrcweirfunction TableHead() {
55cdf0e10cSrcweir	print
56cdf0e10cSrcweir    print "struct PoolFmtIds { int nId; const char* pStr; };"
57cdf0e10cSrcweir    print "static PoolFmtIds ppPoolIds[] = {"
58cdf0e10cSrcweir}
59cdf0e10cSrcweir
60cdf0e10cSrcweirfunction TableTail() {
61cdf0e10cSrcweir    print  " 0, \"\" };"
62cdf0e10cSrcweir    print
63cdf0e10cSrcweir}
64cdf0e10cSrcweir
65cdf0e10cSrcweirBEGIN {
66cdf0e10cSrcweir    Header();
67cdf0e10cSrcweir    TableHead();
68cdf0e10cSrcweir}
69cdf0e10cSrcweir
70cdf0e10cSrcweir/^[ \t]*RES_/ && !index( $1, "_BEGIN" ) && !index( $1, "_END" ) && !index( $1, "_POOL_" ) {
71cdf0e10cSrcweir    sStr = $1;
72cdf0e10cSrcweir	split( $1, sStr, "," );
73cdf0e10cSrcweir    print  "    " sStr[1] ", \"" sStr[1] "\","
74cdf0e10cSrcweir}
75cdf0e10cSrcweir
76cdf0e10cSrcweirEND {
77cdf0e10cSrcweir    TableTail();
78cdf0e10cSrcweir    Main();
79cdf0e10cSrcweir}
80cdf0e10cSrcweir
81