bomToolkit.c 954 B

12345678910111213141516171819202122232425262728
  1. #include "bom.h"
  2. void usage(char *executable) {
  3. printf("Usage: %s <filePath> c - to check for BOM.\n", executable);
  4. printf("%s <filePath> r - to remove BOM.\n", executable);
  5. printf("%s <filePath> a - to add BOM.\n", executable);
  6. }
  7. int main(int argc, char **argv) {
  8. if (argc < 3) {
  9. usage(argv[0]);
  10. return 1;
  11. }
  12. char *inputFileName = argv[1];
  13. if (strcmp(argv[2], "c") == 0) {
  14. checkBOM(inputFileName) == HASBOM ? printf("%s has BOM.\n", inputFileName) : printf("%s has no BOM.\n", inputFileName);
  15. }
  16. if (strcmp(argv[2], "r") == 0) {
  17. removeBOM(inputFileName) == SUCCESS ? printf("BOM removed from %s.\n", inputFileName) : printf("Error removing BOM from %s!\n", inputFileName);
  18. }
  19. if (strcmp(argv[2], "a") == 0) {
  20. addBOM(inputFileName) == SUCCESS ? printf("BOM added to %s.\n", inputFileName) : printf("Error adding BOM to %s!\n", inputFileName);
  21. }
  22. return 0;
  23. }