File: asc-num-to-list

package info (click to toggle)
diskscan 0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,656 kB
  • sloc: ansic: 11,136; python: 338; xml: 138; sh: 41; makefile: 34
file content (35 lines) | stat: -rwxr-xr-x 776 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/env python

import sys

def nn_str(name):
    return name.replace('NN', '%u')

# Skip the header
for line in sys.stdin:
    if line[0] == '-':
        break

# Read the raw data
print('#ifndef LIBSCSICMD_ASC_NUM_LIST_H')
print('#define LIBSCSICMD_ASC_NUM_LIST_H')
print('#define ASC_NUM_LIST \\')
for line in sys.stdin:
    line = line.strip()
    asc = int(line[0:2], 16)
    ascq_str = line[4:6]
    if ascq_str == 'NN':
        ascq = 'NN'
    else:
        ascq = int(ascq_str, 16)
    name = line[24:]
    if name == '':
        continue

    if ascq == 'NN':
        name_nn = nn_str(name)
        print('SENSE_CODE_KEYED(0x%x, "%s") \\' % (asc, name_nn))
    else:
        print('SENSE_CODE(0x%x, 0x%x, "%s") \\' % (asc, ascq, name))
print()
print('#endif')