Blame view

3rdparty/jrtplib-3.11.2/src/reformaterrors.py 757 Bytes
3d2ab595   Hu Chunming   支持gb28181
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
  #!/usr/bin/env python
  
  from __future__ import print_function
  
  lines = [ l for l in open("rtperrors.h").readlines() if "ERR_RTP" in l ]
  tgtcode = 0
  
  defines = [ ]
  
  for l in lines:
      tgtcode -= 1
      l = l.strip()
      parts = l.split()
      n = parts[1]
      code = int(parts[2])
  
      if not n.startswith("ERR_RTP"):
          raise Exception("Unexpected line: " + l)
      if tgtcode != code:
          print("WARNING: mismatch in error code for line (expected {}): {}".format(tgtcode, l))
  
      defines.append([ n, tgtcode])
  
  maxlen = 0
  for n,c in defines:
      maxlen = max(maxlen,len(n + " "))
  
  boundary = 8
  if maxlen%boundary != 0:
      maxlen = ((maxlen//boundary)+1)*boundary
  
  for n,c in defines:
      print("#define {} {} {}".format(n, " "*(maxlen-len(n)), c))