|
16 | 16 | #include <malloc.h> |
17 | 17 | #include <string.h> |
18 | 18 |
|
| 19 | +#ifdef ICONV_IMPLEMENTATION |
19 | 20 | #include <iconv.h> |
| 21 | +#endif |
20 | 22 |
|
21 | 23 | // Begin required for SHA1 |
22 | 24 | typedef unsigned char *POINTER; |
@@ -163,17 +165,17 @@ int beParseString(BYTE* benstr,int benstrLen,int benstrOffset,BYTE** stringBegin |
163 | 165 |
|
164 | 166 | //// Return offset of an element in a list, or -1 if not found |
165 | 167 | //int beFindInList(BYTE* benstr,int benstrLen,int benstrOffset,int listIndex) { |
166 | | -// int i; |
167 | | -// if ((benstrOffset < 0)||(benstrOffset >= benstrLen)) return (-1); |
168 | | -// if (benstr[benstrOffset] != 'l') return (-1); |
169 | | -// benstrOffset++; |
170 | | -// if (benstr[benstrOffset] == 'e') return (-1); |
171 | | -// for(i=0;i<listIndex;i++) { |
172 | | -// benstrOffset = beStepOver(benstr,benstrLen,benstrOffset); |
173 | | -// if ((benstrOffset < 0)||(benstrOffset >= benstrLen)) return (-1); |
174 | | -// } |
175 | | -// if (benstr[benstrOffset] == 'e') return (-1); |
176 | | -// return (benstrOffset); |
| 168 | +// int i; |
| 169 | +// if ((benstrOffset < 0)||(benstrOffset >= benstrLen)) return (-1); |
| 170 | +// if (benstr[benstrOffset] != 'l') return (-1); |
| 171 | +// benstrOffset++; |
| 172 | +// if (benstr[benstrOffset] == 'e') return (-1); |
| 173 | +// for(i=0;i<listIndex;i++) { |
| 174 | +// benstrOffset = beStepOver(benstr,benstrLen,benstrOffset); |
| 175 | +// if ((benstrOffset < 0)||(benstrOffset >= benstrLen)) return (-1); |
| 176 | +// } |
| 177 | +// if (benstr[benstrOffset] == 'e') return (-1); |
| 178 | +// return (benstrOffset); |
177 | 179 | //} |
178 | 180 |
|
179 | 181 |
|
@@ -442,7 +444,9 @@ int main(int argc,char* argv[]) |
442 | 444 | SHA_CTX sha1ctx; |
443 | 445 | // |
444 | 446 | char* encoding = NULL; |
| 447 | +#ifdef ICONV_IMPLEMENTATION |
445 | 448 | iconv_t convDescriptor; |
| 449 | +#endif |
446 | 450 | char *inPtr, *outPtr; |
447 | 451 | size_t inBytesLeft, outBytesLeft; |
448 | 452 | char filePathUTF8[1024]; |
@@ -709,6 +713,7 @@ int main(int argc,char* argv[]) |
709 | 713 | { |
710 | 714 | inPtr = filePath, outPtr = filePathUTF8; |
711 | 715 | inBytesLeft = strlen(filePath), outBytesLeft = 1024; |
| 716 | +#ifdef ICONV_IMPLEMENTATION |
712 | 717 | if((convDescriptor = iconv_open("utf-8", encoding)) == (iconv_t)-1) |
713 | 718 | { |
714 | 719 | return -1; |
@@ -738,6 +743,11 @@ int main(int argc,char* argv[]) |
738 | 743 | } |
739 | 744 | memcpy(filePath, filePathUTF8, filePathUTF8Len); |
740 | 745 | filePath[filePathUTF8Len] = '\0'; |
| 746 | +#else |
| 747 | + outBytesLeft = inBytesLeft; |
| 748 | + outPtr = inPtr; |
| 749 | + filePathUTF8Len = filePath; |
| 750 | +#endif |
741 | 751 | } |
742 | 752 |
|
743 | 753 | fileRecordList[currentFile].filePath = malloc(strlen(filePath)+1); |
|
0 commit comments