Von C nach Java, Teil 4: Datenkompression und Verschlüsselung
Seite 9: Listing 5
Inhaltsverzeichnis
Listing 5: processBlock() ist die Startroutine des Threads
Weiterlesen nach der Anzeige
int processBlock(PBP_S pbp_s) { DWORD dwTid;
/** * given is the inputBlock with inputSize bytes length * and an outputBlock which is at least allocated with 2 times * of inputSize length the processed outputBlock length will * be returned in *outputSize */ int ret, outputSize=2*pbp_s->inputSize; uchar *outputBlock=malloc(outputSize);
if ((ret=compress2(outputBlock, (ulong *)&outputSize, pbp_s->inputBlock, pbp_s->inputSize, Z_BEST_COMPRESSION))!=Z_OK) { fprintf(stderr,"compress2() returned %d and failed\n",ret); return -1; } if (isCrypt) { #ifdef WIN32 /** * to be thread - safe it is necessary to initialize an * own context for each thread */ bool bResult; DWORD dwSize; HCRYPTPROV hProv; HCRYPTHASH hHash; HCRYPTKEY hKey;