Skip to content

Commit

Permalink
1.10: define ICONV_IMPLEMENTATION
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Jan 19, 2023
1 parent 3dbc8b0 commit f40f7b0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PROJECT := torrentcheck
CFLAGS := -O
CFLAGS := -O -DICONV_IMPLEMENTATION
OBJS := src/torrentcheck.o src/sha1.o
RM := rm -f

Expand Down
32 changes: 21 additions & 11 deletions src/torrentcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#include <malloc.h>
#include <string.h>

#ifdef ICONV_IMPLEMENTATION
#include <iconv.h>
#endif

// Begin required for SHA1
typedef unsigned char *POINTER;
Expand Down Expand Up @@ -163,17 +165,17 @@ int beParseString(BYTE* benstr,int benstrLen,int benstrOffset,BYTE** stringBegin

//// Return offset of an element in a list, or -1 if not found
//int beFindInList(BYTE* benstr,int benstrLen,int benstrOffset,int listIndex) {
// int i;
// if ((benstrOffset < 0)||(benstrOffset >= benstrLen)) return (-1);
// if (benstr[benstrOffset] != 'l') return (-1);
// benstrOffset++;
// if (benstr[benstrOffset] == 'e') return (-1);
// for(i=0;i<listIndex;i++) {
// benstrOffset = beStepOver(benstr,benstrLen,benstrOffset);
// if ((benstrOffset < 0)||(benstrOffset >= benstrLen)) return (-1);
// }
// if (benstr[benstrOffset] == 'e') return (-1);
// return (benstrOffset);
// int i;
// if ((benstrOffset < 0)||(benstrOffset >= benstrLen)) return (-1);
// if (benstr[benstrOffset] != 'l') return (-1);
// benstrOffset++;
// if (benstr[benstrOffset] == 'e') return (-1);
// for(i=0;i<listIndex;i++) {
// benstrOffset = beStepOver(benstr,benstrLen,benstrOffset);
// if ((benstrOffset < 0)||(benstrOffset >= benstrLen)) return (-1);
// }
// if (benstr[benstrOffset] == 'e') return (-1);
// return (benstrOffset);
//}


Expand Down Expand Up @@ -442,7 +444,9 @@ int main(int argc,char* argv[])
SHA_CTX sha1ctx;
//
char* encoding = NULL;
#ifdef ICONV_IMPLEMENTATION
iconv_t convDescriptor;
#endif
char *inPtr, *outPtr;
size_t inBytesLeft, outBytesLeft;
char filePathUTF8[1024];
Expand Down Expand Up @@ -709,6 +713,7 @@ int main(int argc,char* argv[])
{
inPtr = filePath, outPtr = filePathUTF8;
inBytesLeft = strlen(filePath), outBytesLeft = 1024;
#ifdef ICONV_IMPLEMENTATION
if((convDescriptor = iconv_open("utf-8", encoding)) == (iconv_t)-1)
{
return -1;
Expand Down Expand Up @@ -738,6 +743,11 @@ int main(int argc,char* argv[])
}
memcpy(filePath, filePathUTF8, filePathUTF8Len);
filePath[filePathUTF8Len] = '\0';
#else
outBytesLeft = inBytesLeft;
outPtr = inPtr;
filePathUTF8Len = filePath;
#endif
}

fileRecordList[currentFile].filePath = malloc(strlen(filePath)+1);
Expand Down

0 comments on commit f40f7b0

Please sign in to comment.