summaryrefslogtreecommitdiffstats
path: root/src/usr/errl/parser/readcomps.rex
blob: 9aad554d8c8b1f3fb65e36136ebe76102848844a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 *  @file readcomps.rex
 *
 *  Input file name is expected to be hbotcompid.H
 *  Output to stdout a snippet of C code that can
 *  be included by errlparser.C
 */

parse arg szInput .

if length( szInput ) = 0 then do
  say 'Give filename on command line.'
  signal halt
end

szRC = stream( szInput, 'C', 'OPEN READ' )
if left( szRC, 5 ) <> 'READY' then do
  say 'File' szInput 'not found.'
  signal halt
end

do while lines( szInput )
  szCompName = ''
  szCompID = ''

  szLine = linein( szInput )
  p1 = pos( "compId_t", szLine );
  p2 = pos( "_COMP_ID", szLine );
  p3 = pos( "MY_COMP_", szLine );
  if p1 > 0 & p2 > p1 & p3=0 then do

    /* interesting COMP_ID line */
    do i = 1 to words( szLine )
      w = translate( word( szLine, i ))
      if pos( "_COMP_ID", w ) > 0  then szCompName = w
      if pos( "0X", w ) > 0 then szCompID = w
    end

    /* clean them up */
    szCompName = left( szCompName, pos( "_", szCompName )-1 )
    szCompID = strip( szCompID, 'B', ';' )

    /* This output will be included by errlparser.C  */
    say "    {" '"'szCompName'",'  szCompID  "},"

  end
end


szRC = stream( szInput, 'C', 'CLOSE' )
if left( szRC, 5 ) <> 'READY' then signal halt

return 0


halt:
say 'Error: readcomps.rex problem'
exit 2
OpenPOWER on IntegriCloud