<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic extract info from C header files in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890882#M31909</link>
    <description>I have *.h files that I'd like to process into a configuration file which has fieldname/datatype/size and optionally offset.&lt;BR /&gt;&lt;BR /&gt;I've looked at PERL modules but I can't find anything that does this simply.</description>
    <pubDate>Fri, 11 Mar 2005 16:51:46 GMT</pubDate>
    <dc:creator>Barry McClintock</dc:creator>
    <dc:date>2005-03-11T16:51:46Z</dc:date>
    <item>
      <title>extract info from C header files</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890882#M31909</link>
      <description>I have *.h files that I'd like to process into a configuration file which has fieldname/datatype/size and optionally offset.&lt;BR /&gt;&lt;BR /&gt;I've looked at PERL modules but I can't find anything that does this simply.</description>
      <pubDate>Fri, 11 Mar 2005 16:51:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890882#M31909</guid>
      <dc:creator>Barry McClintock</dc:creator>
      <dc:date>2005-03-11T16:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: extract info from C header files</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890883#M31910</link>
      <description>&lt;BR /&gt;How about using the C compiler to generate a full listing with symbols and just parse that output?&lt;BR /&gt;&lt;BR /&gt;For example a C source with:&lt;BR /&gt;&lt;BR /&gt;$ type tmp.c&lt;BR /&gt;#include &lt;FABDEF&gt;&lt;BR /&gt;#include &lt;RABDEF&gt;&lt;BR /&gt;&lt;BR /&gt;and a perl parser:&lt;BR /&gt;&lt;BR /&gt;$ type h.pl&lt;BR /&gt;print "\n-- $1 --\n" if (/\sTag: (struct \w+)/);&lt;BR /&gt;if (/(\s*)(\S+)\s+\d+\s+(\d+\s\s|\d+\sbits).*Offset=([\.0-9]+).*\)\s+(.*)$/) {&lt;BR /&gt;$union_offset = $4."+" if ($5 eq "union ");&lt;BR /&gt;$union = (length($1) &amp;gt; 1) ? $union_offset : "";&lt;BR /&gt;printf "$1$2/$5/$3/$union$4\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;With the following command:&lt;BR /&gt;&lt;BR /&gt;$ pipe cc/list=sys$output/show=symbols tmp | perl -n h.pl&lt;BR /&gt;&lt;BR /&gt;Will deliver:&lt;BR /&gt;&lt;BR /&gt;-- struct fabdef --&lt;BR /&gt; fab$b_bid/unsigned char /1  /0&lt;BR /&gt; fab$b_bln/unsigned char /1  /1&lt;BR /&gt; fab$r_ifi_overlay/union /2  /2&lt;BR /&gt;  fab$w_ifi/unsigned short /2  /2+0&lt;BR /&gt;&lt;BR /&gt;:&lt;BR /&gt; fabdef$$_fill_9/unsigned int /4  /76&lt;BR /&gt;&lt;BR /&gt;-- struct namdef --&lt;BR /&gt;&lt;BR /&gt;-- struct rab64def --&lt;BR /&gt; rab64$b_bid/unsigned char /1  /0&lt;BR /&gt; rab64$b_bln/unsigned char /1  /1&lt;BR /&gt;:&lt;BR /&gt; rab64$r_rfa_overlay/union /6  /16&lt;BR /&gt;  rab64$w_rfa/array of unsigned short /6  /16+0&lt;BR /&gt;  rab64$r_rfa_fields/struct /6  /16+0&lt;BR /&gt;   rab64$l_rfa0/unsigned int /4  /16+0&lt;BR /&gt;   rab64$w_rfa4/unsigned short /2  /16+4&lt;BR /&gt;:&lt;BR /&gt;&lt;BR /&gt;Now there are may be a few things to potentially fixup, around dealing spaces, and with bits and offsets in unions, but maybe this is all you need already ?!&lt;BR /&gt;&lt;BR /&gt;If you do want more, your first step will probably be to put the 'automatic' $1 .. $5 variables in names variables like:&lt;BR /&gt;&lt;BR /&gt;$spaces=$1; $name=$2; $size=$3; $offset=$4; $type=$5&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;/RABDEF&gt;&lt;/FABDEF&gt;</description>
      <pubDate>Sun, 13 Mar 2005 11:56:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890883#M31910</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-03-13T11:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: extract info from C header files</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890884#M31911</link>
      <description>I really do appreciate your help.  This is a little deep for me so I'll be working on it a bit.&lt;BR /&gt;&lt;BR /&gt;Regards, Barry</description>
      <pubDate>Mon, 14 Mar 2005 10:08:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890884#M31911</guid>
      <dc:creator>Barry McClintock</dc:creator>
      <dc:date>2005-03-14T10:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: extract info from C header files</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890885#M31912</link>
      <description>&lt;BR /&gt;&amp;gt;&amp;gt; This is a little deep for me &lt;BR /&gt;&lt;BR /&gt;Ooops, I read "I've looked at PERL modules" and assumed a certain familirity.&lt;BR /&gt;&lt;BR /&gt;The example given should work. Does it not?&lt;BR /&gt;&lt;BR /&gt;Anyway, let me explain a little bit.&lt;BR /&gt;The C listing file, when /show=symb is active will have entries like:&lt;BR /&gt;&lt;BR /&gt;#fabdef                          399     80  Long Tag: struct fabdef&lt;BR /&gt;# fab$b_bid                      401     1  Byte Member: (Offset=0) unsigned char&lt;BR /&gt;# fab$b_bln                      402     1 Byte Member: (Offset=1) unsigned char&lt;BR /&gt;# fab$r_ifi_overlay              412     2  Byte Member: (Offset=2) union&lt;BR /&gt;#  fab$r_ifi_bits                411     2       Byte                Member: (Of&lt;BR /&gt;fset=0) struct&lt;BR /&gt;&lt;BR /&gt;So now for the script. First the struct name. This is picked up by:&lt;BR /&gt;print "\n-- $1 --\n" if (/\sTag: (struct \w+)/);&lt;BR /&gt;&lt;BR /&gt;Find the text "Tag: "... start remembering "(" if there is "struct " followed by some number of word characters (\w+). Stop remembering ")". Print what was remembered in $1. &lt;BR /&gt;If we wanted the structure size, the change the line to look for decimals (line number), whitspace (\s+) and remember the next set of decimals: ( (\d+) ):&lt;BR /&gt;print "\n-- $2 -- $1 bytes --\n" if (/\d+\s+(\d+).*Tag: (struct \w+)/);&lt;BR /&gt;and it will print:&lt;BR /&gt;-- struct fabdef -- 80 bytes --&lt;BR /&gt; &lt;BR /&gt;The main line is admittedly convoluted.&lt;BR /&gt;&lt;BR /&gt;if (/(\s*)(\S+)\s+\d+\s+(\d+\s\s|\d+\sbits).*Offset=([\.0-9]+).*\)\s+(.*)$/) {&lt;BR /&gt;&lt;BR /&gt;Here are some parts:&lt;BR /&gt;&lt;BR /&gt;(\s*)  = Remember the first whitespace in $1&lt;BR /&gt;(\S+)  = Remember the non-whitespace (name!) in $2&lt;BR /&gt;\s+\d+\s+ = look for, but ignore whitespace-decimal-whitespace&lt;BR /&gt;(\d+\s\s|\d+\sbits) = Look for and remember in $3 (size!) some decimals + whitespace OR decimals plust " bits"&lt;BR /&gt;.*Offset=([\.0-9]+).*\) = 'anything' followed by "Offset=" then remember in $4 (offset) any sequence of numbers or a period&lt;BR /&gt;\s+(.*)$/ = finally look for a space (after those numbers) then remember everything up to the end of line in $5 (type).&lt;BR /&gt;&lt;BR /&gt;The next lines deal with the fact that the listing counts offsets from union starting with 0 in that union.&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Mar 2005 15:48:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890885#M31912</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-03-14T15:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: extract info from C header files</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890886#M31913</link>
      <description>I've been breaking out your REGEX and want to thank you again for your help.&lt;BR /&gt;&lt;BR /&gt;I've worked with regular expressions but have never had the courage to do one this complex...mine are in a million steps!&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Mon, 14 Mar 2005 15:59:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890886#M31913</guid>
      <dc:creator>Barry McClintock</dc:creator>
      <dc:date>2005-03-14T15:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: extract info from C header files</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890887#M31914</link>
      <description>If you want to better understand the regular expressions, test them and so, get a Linux or Windows box, install Python, Pyqt and SIP, and use kodos&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://kodos.sourceforge.net/" target="_blank"&gt;http://kodos.sourceforge.net/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;see an example at &lt;BR /&gt;&lt;A href="http://kodos.sourceforge.net/help/example.html" target="_blank"&gt;http://kodos.sourceforge.net/help/example.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;ps: ignore my attachment</description>
      <pubDate>Tue, 15 Mar 2005 01:24:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890887#M31914</guid>
      <dc:creator>labadie_1</dc:creator>
      <dc:date>2005-03-15T01:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: extract info from C header files</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890888#M31915</link>
      <description>Mr. van Den Heuvel gave a very good suggestion that is working fine.</description>
      <pubDate>Thu, 17 Mar 2005 12:24:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extract-info-from-c-header-files/m-p/4890888#M31915</guid>
      <dc:creator>Barry McClintock</dc:creator>
      <dc:date>2005-03-17T12:24:16Z</dc:date>
    </item>
  </channel>
</rss>

