Browse Source

Merge branch 'master' of github.com:pczajkowski/bom

Piotr Czajkowski 5 years ago
parent
commit
83815c51ae
2 changed files with 7 additions and 10 deletions
  1. 3 3
      bom.c
  2. 4 7
      bom.h

+ 3 - 3
bom.c

@@ -3,7 +3,7 @@
 #define BOMSIZE 3
 unsigned char bom[] = { 0xEF, 0xBB, 0xBF };
 
-int checkBOM(char *filePath) {
+int checkBOM(const char *filePath) {
 	FILE *inputFile = fopen(filePath, "r");
 	if (inputFile == NULL) return ERROR;
 
@@ -20,7 +20,7 @@ int checkBOM(char *filePath) {
 
 char *tempFileName = "tempFile";
 
-int removeBOM(char *filePath) {
+int removeBOM(const char *filePath) {
 	if (NOBOM == checkBOM(filePath)) return SUCCESS;
 
 	FILE *inputFile = fopen(filePath, "r");
@@ -45,7 +45,7 @@ int removeBOM(char *filePath) {
 	return SUCCESS;
 }
 
-int addBOM(char *filePath) {
+int addBOM(const char *filePath) {
 	if (HASBOM == checkBOM(filePath)) return SUCCESS;
 
 	FILE *inputFile = fopen(filePath, "r");

+ 4 - 7
bom.h

@@ -1,11 +1,8 @@
 #include <stdio.h>
 #include <string.h>
 
-#define NOBOM 0
-#define HASBOM 1
-#define ERROR 2
-#define SUCCESS 3
+enum { NOBOM, HASBOM, ERROR, SUCCESS };
 
-int checkBOM(char *filePath);
-int removeBOM(char *filePath);
-int addBOM(char *filePath);
+int checkBOM(const char *filePath);
+int removeBOM(const char *filePath);
+int addBOM(const char *filePath);