-
Notifications
You must be signed in to change notification settings - Fork 277
Initial XZZ .pcb file support #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution.
I wrote some comments in relation with some parts of the code.
Additionally, please fix the indentation. OpenBoardView's code base uses a single tab for each indent level, as configured by the EditorConfig file. There is also a clang-format configuration to fix the styling automatically, but please double check its effect on the code.
For the FZ format, we had decided not to include the decryption key in the source code due to possible intellectual property infringement (see previous legal issues regarding keys in the multimedia and video game copy protection world), and once it is included in the Git history, it cannot be removed easily. To stay consistent, we would need to do the same here.
#include <cstdio> // For fprintf | ||
#include <cstdint> // For uint64_t | ||
#include <iostream> | ||
#include <iomanip> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clean up redundant/unnecessary includes.
}; | ||
|
||
static unsigned char hexconv[256]={ | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove unnecessary backslashes.
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \ | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the above arrays should be const.
Also could be a better idea to use std::array for static bound checks/iterator.
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \ | ||
}; | ||
|
||
uint64_t XZZPCBFile::des(uint64_t input, uint64_t key, char mode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reference the original source of this implementation and make sure the license is compatible since this is not original work.
Alternatively, it might be a better idea to use a widely available and portable cryptographic library with a compatible license instead, if there is no deviation from the standard algorithm.
return inv_init_perm_res; | ||
} | ||
|
||
void XZZPCBFile::des_decrypt(std::vector<char> &buf) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be commented and clarified, as the string manipulation happening there is surprising and almost looks like obfuscated code.
} | ||
|
||
pins.push_back(pin); | ||
pin = blank_pin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can assign {}
instead of having to declare blank_pin
.
} | ||
default: | ||
if (sub_type_identifier != 0x00) { | ||
printf("Unknown sub block type: 0x%02X at %d in %s\n", sub_type_identifier, current_pointer, part_name.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use SDL_Log…
to log messages to the console (without aborting file loading, otherwise ENSURE_OR_FAIL should be used).
pin.pos.y = static_cast<double>(y_origin) / 10000; | ||
if (net_dict.find(net_index) != net_dict.end()) { | ||
if (net_dict[net_index] == "UNCONNECTED" || net_dict[net_index] == "NC") { | ||
pin.net = strdup(""); // As the part already gets the kPinTypeTestPad type if "UNCONNECTED" is used type will be changed to kPinTypeNotConnected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for strdup()
since it is a constant.
} | ||
} | ||
|
||
char XZZPCBFile::read_utf8_char(char c) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code?
} | ||
} | ||
|
||
std::string XZZPCBFile::read_cb2312_string(const std::string &str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it GB2312? Maybe it's possible to use std::codecvt
to convert properly?
Basic file format support for XinZhiZao's .pcb format
Also I have added a comment data type to the pin struct which is used to display diode readings when hovering
Notes on the format: