style
[RRG-proxmark3.git] / client / atr_scrap_pcsctools.py
blob10471e597667152a19298c4733093c3abd8434af
1 #!/usr/bin/env python3
3 #-----------------------------------------------------------------------------
4 # Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # See LICENSE.txt for the text of the license.
17 #-----------------------------------------------------------------------------
19 # python3 -m pip install urllib unidecode
21 import urllib.request
22 import unidecode
24 ATR_URL='https://raw.githubusercontent.com/LudovicRousseau/pcsc-tools/master/smartcard_list.txt'
26 C_HEADER="""//-----------------------------------------------------------------------------
27 // Borrowed initially from
28 // """ + ATR_URL + """
29 // Copyright (C) 2002-2021 Ludovic Rousseau
30 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
32 // This program is free software: you can redistribute it and/or modify
33 // it under the terms of the GNU General Public License as published by
34 // the Free Software Foundation, either version 3 of the License, or
35 // (at your option) any later version.
37 // This program is distributed in the hope that it will be useful,
38 // but WITHOUT ANY WARRANTY; without even the implied warranty of
39 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 // GNU General Public License for more details.
42 // See LICENSE.txt for the text of the license.
43 //-----------------------------------------------------------------------------
44 // *DO NOT EDIT MANUALLY*
45 // Autogenerated with atr_scrap_pcsctools.py
46 //-----------------------------------------------------------------------------
47 #ifndef ATRS_H__
49 #define ATRS_H__
50 #include <stddef.h>
52 typedef struct atr_s {
53 const char *bytes;
54 const char *desc;
55 } atr_t;
57 const char *getAtrInfo(const char *atr_str);
59 // atr_t array is expected to be NULL terminated
60 const static atr_t AtrTable[] = {
61 { "3BDF18FFC080B1FE751F033078464646462026204963656D616E1D", "Cardhelper by 0xFFFF and Iceman" },
62 { "3B90969181B1FE551FC7D4", "IClass SE Processor (Other) https://www.hidglobal.com/products/embedded-modules/iclass-se/sio-processor"},
63 """
65 C_FOOTER=""" {NULL, "n/a"}
68 #endif
69 """
71 def main():
72 with open('src/atrs.h','w') as fatr:
73 s = urllib.request.urlopen(ATR_URL).read().decode()
74 atr = None
75 desc = ''
76 fatr.write(C_HEADER)
77 for line in s.split('\n'):
78 if len(line) == 0 or line[0] == '#':
79 continue
80 if line[0] == '\t':
81 desc += ['\\n',''][len(desc)==0] + unidecode.unidecode(line[1:]).replace('"',"'").replace('\\','\\\\')
82 else:
83 if atr is not None:
84 fatr.write(f' {{ "{atr}", "{desc}" }},\n')
85 atr = line.replace(' ','')
86 desc = ''
87 fatr.write(f' {{ "{atr}", "{desc}" }},\n')
88 fatr.write(C_FOOTER)
90 if __name__ == "__main__":
91 main()