Autor Beitrag
omega123
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Fr 27.12.02 00:44 
hi

hat jemand einen code, mit dem man die known.met datei auslesen kann?

schonmal danke für die hilfe
Millo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 147



BeitragVerfasst: Fr 27.12.02 15:32 
Moin,

sowas wissen die leutz bei emule.de sicher besser. Aber Emule ist Open Source und du kannst dir ja mal den Source runterladen da steht das ja sicher drin.
DaFox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 189



BeitragVerfasst: Fr 27.12.02 15:36 
Hi!

Die known.met ist vom Aufbau her nicht so wild.
Daher empfehle ich Dir im Internet den Aufbau der Datei zu suchen und Dir meinen Beispielcode bzgl. der server.met (eDonkeys Server.met) anzuschauen.

Gruß,
Markus
omega123 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Sa 28.12.02 13:30 
hi

habe mir den code angesehen, un bekomme auch so die version und die anzahl der files ausgelesen.

jetzt habe ich mir mal den code von emule runtergeladen und mir mal angesehn, wie re die known met einliest nur irgentwie steig ich da nicht so richtig durch.

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
// parts of this file are based on work from pan One (http://home-3.tiscali.nl/~meost/pms/)

//this file is part of eMule
//Copyright (C)2002 Merkur ( merkur-@users.sourceforge.net / http://www.emule-project.net )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


#include "StdAfx.h"
#include "knownfile.h"
#include "opcodes.h"
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "emule.h"
  
void CFileStatistic::AddRequest(){
  requested++;
  alltimerequested++;
  theApp.knownfiles->requested++;
  theApp.sharedfiles->UpdateItem(fileParent);
}
  
void CFileStatistic::AddAccepted(){
  accepted++;
  alltimeaccepted++;
  theApp.knownfiles->accepted++;
  theApp.sharedfiles->UpdateItem(fileParent);
}
  
void CFileStatistic::AddTransferd(uint32 bytes){
  transfered += bytes;
  alltimetransfered += bytes;
  theApp.knownfiles->transfered += bytes;
  theApp.sharedfiles->UpdateItem(fileParent);
}

CKnownFile::CKnownFile(){
  filetype = 2;
  directory = 0;
  filename = 0;
  filesize = 0;
  date = 0;
  m_iPriority = PR_NORMAL;
  m_iPermissions = PERM_ALL;
  statistic.fileParent=this;
}

CKnownFile::~CKnownFile(){
  for (int i = 0; i != hashlist.GetSize(); i++)
    if (hashlist[i])
      delete[] hashlist[i];
  for (int i = 0; i != taglist.GetSize(); i++)
    safe_delete(taglist[i]);
//  if (filename)  // done by CAbstractFile destructor
//    delete[] filename;
  if (directory)
    delete[] directory;
}

void CKnownFile::SetPath(char* path){
  if (directory)
    delete[] directory;
  directory = nstrdup(path);
}

bool CKnownFile::CreateFromFile(char* in_directory,char* in_filename){
  // TODO Errorhandling
  //first create the filehashset
  // open file
  directory = nstrdup(in_directory);
  char* namebuffer = new char[strlen(in_directory)+strlen(in_filename)+2];
  sprintf(namebuffer,"%s\\%s",in_directory,in_filename);
  FILE* file = fopen(namebuffer,"rbS");
  delete namebuffer;
  if (!file)
    return false;
  // set filesize + name
  filename = nstrdup(in_filename);
  filesize =_filelength(file->_file);
  // create hashset
  uint32 togo = filesize;
  for (uint16 hashcount = 0;togo >= PARTSIZE;) {
    uchar* newhash = new uchar[16];
    CreateHashFromFile(file,PARTSIZE,newhash);
    hashlist.Add(newhash);
    togo -= PARTSIZE;
    hashcount++;
  }
  uchar* lasthash = new uchar[16];
  memset(lasthash,0,16);
  CreateHashFromFile(file,togo,lasthash);
  if (!hashcount)
    memcpy(filehash,lasthash,16);
  else {
    hashlist.Add(lasthash);
    uchar* buffer = new uchar[hashlist.GetCount()*16];
    for (int i = 0;i != hashlist.GetCount();i++)
      memcpy(buffer+(i*16),hashlist[i],16);
    CreateHashFromString(buffer,hashlist.GetCount()*16,filehash);
    delete[] buffer;
  }
  // TODO: Add filetags

  // set lastwrite date
  struct _stat fileinfo;
  _fstat(file->_file,&fileinfo);
  date = fileinfo.st_mtime;
  //finished
  fclose(file);
  return true;  
}


// needed for memfiles. its probably better to switch everything to CFile...
bool CKnownFile::LoadHashsetFromFile(CFile* file, bool checkhash){
  uchar checkid[16];
  file->Read(&checkid,16);
  uint16  parts;
  file->Read(&parts,2);
  for (int i = 0; i != parts; i++){
    uchar* cur_hash = new uchar[16];
    file->Read(cur_hash,16);
    hashlist.Add(cur_hash);
  }
  if (!checkhash){
    memcpy(filehash,checkid,16);
    return true;
  }
  // trust noone ;-)

  if (!hashlist.IsEmpty()){
    uchar* buffer = new uchar[hashlist.GetCount()*16];
    for (int i = 0;i != hashlist.GetCount();i++)
      memcpy(buffer+(i*16),hashlist[i],16);
    CreateHashFromString(buffer,hashlist.GetCount()*16,checkid);
    delete[] buffer;
  }
  if (!memcmp(filehash,checkid,16))
    return true;
  else{
    for (int i = 0; i != hashlist.GetSize(); i++)
      delete[] hashlist[i];
    hashlist.RemoveAll();
    return false;
  }
}

bool CKnownFile::LoadTagsFromFile(CFile* file){
  uint32 tagcount;
  file->Read(&tagcount,4);
  for (uint32 j = 0; j != tagcount;j++){
    CTag* newtag = new CTag(file);
    switch(newtag->tag->specialtag){
      case FT_FILENAME:{
        filename = nstrdup(newtag->tag->stringvalue);
        delete newtag;
        break;
      }
      case FT_FILESIZE:{
        filesize = newtag->tag->intvalue;
        delete newtag;
        break;
      }
      case FT_ATTRANSFERED:{
        statistic.alltimetransfered = newtag->tag->intvalue;
        delete newtag;
        break;
      }
      case FT_ATREQUESTED:{
        statistic.alltimerequested = newtag->tag->intvalue;
        delete newtag;
        break;
      }
       case FT_ATACCEPTED:{
        statistic.alltimeaccepted = newtag->tag->intvalue;
        delete newtag;
        break;
      }
      case FT_PRIORITY:{
        m_iPriority = newtag->tag->intvalue;
        delete newtag;
        break;
      }
      case FT_PERMISSIONS:{
        m_iPermissions = newtag->tag->intvalue;
        delete newtag;
        break;
      }
      default:
        taglist.Add(newtag);
    }  
  }
  return true;
}

bool CKnownFile::LoadDateFromFile(CFile* file){
  file->Read(&date,4);
  return true;
}

bool CKnownFile::LoadFromFile(CFile* file){
  return (LoadDateFromFile(file) && LoadHashsetFromFile(file,false) && LoadTagsFromFile(file)); 
}

bool CKnownFile::WriteToFile(FILE* file){
  // date
  fwrite(&date,4,1,file); 
  // hashset
  fwrite(&filehash,16,1,file);
  uint16 parts = hashlist.GetCount();
  fwrite(&parts,2,1,file);
  for (int i = 0; i != parts; i++)
    fwrite(hashlist[i],16,1,file);
  //tags
  uint32 tagcount = taglist.GetCount()+7;
  // standard tags
  fwrite(&tagcount,4,1,file);
  CTag* nametag = new CTag(FT_FILENAME,filename);
  nametag->WriteTagToFile(file);
  delete nametag;
  CTag* sizetag = new CTag(FT_FILESIZE,filesize);
  sizetag->WriteTagToFile(file);
  delete sizetag;
  // statistic
  CTag attag1(FT_ATTRANSFERED,statistic.GetAllTimeTransfered());
  attag1.WriteTagToFile(file);
  CTag attag2(FT_ATREQUESTED,statistic.GetAllTimeRequests());
  attag2.WriteTagToFile(file);
  CTag attag3(FT_ATACCEPTED,statistic.GetAllTimeAccepts());
  attag3.WriteTagToFile(file);
  // priority N permission
  CTag priotag(FT_PRIORITY, m_iPriority);
  priotag.WriteTagToFile(file);
  CTag permtag(FT_PERMISSIONS, m_iPermissions);
  permtag.WriteTagToFile(file);
    //other tags
  for (uint32 j = 0; j != tagcount-7;j++)
    taglist[j]->WriteTagToFile(file);
  return ferror(file);
}

void CKnownFile::CreateHashFromInput(FILE* file,CFile* file2, int Length, uchar* Output, uchar* in_string) { 
  // time critial
  bool PaddingStarted = false;
  uint32 Hash[4];
  Hash[0] = 0x67452301;
  Hash[1] = 0xEFCDAB89;
  Hash[2] = 0x98BADCFE;
  Hash[3] = 0x10325476;
  CFile* data = 0;
  if (in_string)
    data = new CMemFile(in_string,Length);
  uint32 Required = Length;
  uchar  X[64];
  while (Required >= 64){
    if (in_string)
      data->Read(&X,64);
    else if (file)
      fread(&X,64,1,file);
    else if (file2)
      file2->Read(&X,64);
    MD4Transform(Hash, (uint32*)X);
    Required -= 64;
  }
  // bytes to read
  Required = Length % 64;
  if (Required != 0){
    if (in_string)
      data->Read(&X,Required);
    else if (file)
      fread(&X,Required,1,file);
    else if (file2)
      file2->Read(&X,Required);
  }
  // in byte scale 512 = 64, 448 = 56
  if (Required >= 56){
    X[Required] = 0x80;
    PaddingStarted = TRUE;
    memset(&X[Required + 1], 0, 63 - Required);
    MD4Transform(Hash, (uint32*)X);
    Required = 0;
  }
  if (!PaddingStarted)
    X[Required++] = 0x80;
  memset(&X[Required], 0, 64 - Required);
  // add size (convert to bits)
  uint32 Length2 = Length >> 29;
  Length <<= 3;
  memcpy(&X[56], &Length, 4);
  memcpy(&X[60], &Length2, 4);
  MD4Transform(Hash, (uint32*)X);
  memcpy(Output, Hash, 16);
  safe_delete(data);
}
uchar* CKnownFile::GetPartHash(uint16 part){
  if (part >= hashlist.GetCount())
    return 0;
  return hashlist[part];
}

uint16 CKnownFile::GetPartCount(){
  return (filesize/PARTSIZE) + ((filesize % PARTSIZE)? 1:0);
}

static void MD4Transform(uint32 Hash[4], uint32 x[16])
{
  uint32 a = Hash[0];
  uint32 b = Hash[1];
  uint32 c = Hash[2];
  uint32 d = Hash[3];

  /* Round 1 */
  MD4_FF(a, b, c, d, x[ 0], S11); // 01
  MD4_FF(d, a, b, c, x[ 1], S12); // 02
  MD4_FF(c, d, a, b, x[ 2], S13); // 03
  MD4_FF(b, c, d, a, x[ 3], S14); // 04
  MD4_FF(a, b, c, d, x[ 4], S11); // 05
  MD4_FF(d, a, b, c, x[ 5], S12); // 06
  MD4_FF(c, d, a, b, x[ 6], S13); // 07
  MD4_FF(b, c, d, a, x[ 7], S14); // 08
  MD4_FF(a, b, c, d, x[ 8], S11); // 09
  MD4_FF(d, a, b, c, x[ 9], S12); // 10
  MD4_FF(c, d, a, b, x[10], S13); // 11
  MD4_FF(b, c, d, a, x[11], S14); // 12
  MD4_FF(a, b, c, d, x[12], S11); // 13
  MD4_FF(d, a, b, c, x[13], S12); // 14
  MD4_FF(c, d, a, b, x[14], S13); // 15
  MD4_FF(b, c, d, a, x[15], S14); // 16

  /* Round 2 */
  MD4_GG(a, b, c, d, x[ 0], S21); // 17
  MD4_GG(d, a, b, c, x[ 4], S22); // 18
  MD4_GG(c, d, a, b, x[ 8], S23); // 19
  MD4_GG(b, c, d, a, x[12], S24); // 20
  MD4_GG(a, b, c, d, x[ 1], S21); // 21
  MD4_GG(d, a, b, c, x[ 5], S22); // 22
  MD4_GG(c, d, a, b, x[ 9], S23); // 23
  MD4_GG(b, c, d, a, x[13], S24); // 24
  MD4_GG(a, b, c, d, x[ 2], S21); // 25
  MD4_GG(d, a, b, c, x[ 6], S22); // 26
  MD4_GG(c, d, a, b, x[10], S23); // 27
  MD4_GG(b, c, d, a, x[14], S24); // 28
  MD4_GG(a, b, c, d, x[ 3], S21); // 29
  MD4_GG(d, a, b, c, x[ 7], S22); // 30
  MD4_GG(c, d, a, b, x[11], S23); // 31
  MD4_GG(b, c, d, a, x[15], S24); // 32

  /* Round 3 */
  MD4_HH(a, b, c, d, x[ 0], S31); // 33
  MD4_HH(d, a, b, c, x[ 8], S32); // 34
  MD4_HH(c, d, a, b, x[ 4], S33); // 35
  MD4_HH(b, c, d, a, x[12], S34); // 36
  MD4_HH(a, b, c, d, x[ 2], S31); // 37
  MD4_HH(d, a, b, c, x[10], S32); // 38
  MD4_HH(c, d, a, b, x[ 6], S33); // 39
  MD4_HH(b, c, d, a, x[14], S34); // 40
  MD4_HH(a, b, c, d, x[ 1], S31); // 41
  MD4_HH(d, a, b, c, x[ 9], S32); // 42
  MD4_HH(c, d, a, b, x[ 5], S33); // 43
  MD4_HH(b, c, d, a, x[13], S34); // 44
  MD4_HH(a, b, c, d, x[ 3], S31); // 45
  MD4_HH(d, a, b, c, x[11], S32); // 46
  MD4_HH(c, d, a, b, x[ 7], S33); // 47
  MD4_HH(b, c, d, a, x[15], S34); // 48

  Hash[0] += a;
  Hash[1] += b;
  Hash[2] += c;
  Hash[3] += d;
}

// Adde by Tarod [Juanjo]
void CAbstractFile::SetFileName(char* NewName) 

   if (filename != NULL) { 
      delete[] filename; 
      filename = new char[strlen(NewName) + 1]; 
      sprintf(filename, "%s", NewName);
   } 

//End by Tarod


ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
//this file is part of eMule
//Copyright (C)2002 Merkur ( merkur-@users.sourceforge.net / http://www.emule-project.net )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#pragma once
#include "otherstructs.h"
#include "packets.h"
#include "types.h"
#include <afxcoll.h>
#include <afxtempl.h>
#include <afxcmn.h>

class CFileStatistic{
  friend class CKnownFile;
public:
  CFileStatistic()          {requested = transfered = accepted = alltimerequested= alltimetransfered = alltimeaccepted = 0;}
  void  AddRequest();
  void  AddAccepted();
  void  AddTransferd(uint32 bytes);
  uint16  GetRequests()        {return requested;}
  uint16  GetAccepts()        {return accepted;}
  uint32  GetTransfered()        {return transfered;}
  uint16  GetAllTimeRequests()    {return alltimerequested;}
  uint16  GetAllTimeAccepts()      {return alltimeaccepted;}
  uint32  GetAllTimeTransfered()    {return alltimetransfered;}
  CKnownFile* fileParent;

private:
  uint16 requested;
  uint32 transfered;
  uint16 accepted;
  uint32 alltimerequested;
  uint32 alltimetransfered;
  uint32 alltimeaccepted;
};

/*
             CPartFile
           /
      CKnownFile
    /
CAbstractFile 
    \ 
      CSearchFile
*/
class CAbstractFile
{
public:
  CAbstractFile()
  {
    filename = NULL;
    filesize = 0;
    filetype = 2;
  }
  virtual ~CAbstractFile()
  {
    if( filename != NULL )
      delete[] filename;
  }
  char*  GetFileName()      {return filename;}
  uchar*  GetFileHash()      {return filehash;}
  uint32  GetFileSize()      {return filesize;}
  uint32*  GetFileTypePtr()    {return &filetype;}
  uint32  GetFileType()      {return filetype;}
  void  SetFileName(char* NewName); // Added by Tarod [Juanjo]
  
protected:
  char*  filename;
  uchar  filehash[16];
  uint32  filesize;
  uint32  filetype;
};

class CKnownFile : public CAbstractFile
{
public:
  CKnownFile();
  ~CKnownFile();
  virtual bool  CreateFromFile(char* directory,char* filename); // create date, hashset and tags from a file
  uint32*  GetFileTypePtr()    {return &filetype;}
  char*  GetPath()        {return directory;}
  void  SetPath(char* path);
  virtual  bool  IsPartFile()  {return false;}
  virtual bool  LoadFromFile(CFile* file);  //load date, hashset and tags from a .met file
  bool  WriteToFile(FILE* file);  
  uint32  GetFileDate()      {return date;}
  uint16  GetHashCount()      {return hashlist.GetCount();}
  uchar*  GetPartHash(uint16 part);
  uint16  GetPartCount();
  uint32  date;
  // file upload priority
  uint8  m_iPriority;
  uint8  GetPriority(void)        {return m_iPriority;};
  void  SetPriority(uint8 iNewPriority) {m_iPriority = iNewPriority;};
  // shared file view permissions (all, only friends, no one)
  uint8  m_iPermissions;
  uint8  GetPermissions(void)      {return m_iPermissions;};
  void  SetPermissions(uint8 iNewPermissions) {m_iPermissions = iNewPermissions;};

  bool  LoadHashsetFromFile(CFile* file, bool checkhash);
  CFileStatistic statistic;
protected:
  bool  LoadTagsFromFile(CFile* file);
  bool  LoadDateFromFile(CFile* file);
  void  CreateHashFromFile(FILE* file, int Length, uchar* Output)  {CreateHashFromInput(file,0,Length,Output,0);}
  void  CreateHashFromFile(CFile* file, int Length, uchar* Output)  {CreateHashFromInput(0,file,Length,Output,0);}
  void  CreateHashFromString(uchar* in_string, int Length, uchar* Output)  {CreateHashFromInput(0,0,Length,Output,in_string);}
  CArray<uchar*,uchar*> hashlist;
  CArray<CTag*,CTag*> taglist;
  char*  directory;
private:
  void  CreateHashFromInput(FILE* file,CFile* file2, int Length, uchar* Output, uchar* = 0);
};

// permission values for shared files
#define PERM_ALL    0
#define PERM_FRIENDS  1
#define PERM_NOONE    2

// constants for MD4Transform
#define S11 3
#define S12 7
#define S13 11
#define S14 19
#define S21 3
#define S22 5
#define S23 9
#define S24 13
#define S31 3
#define S32 9
#define S33 11
#define S34 15

// basic MD4 functions
#define MD4_F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define MD4_G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
#define MD4_H(x, y, z) ((x) ^ (y) ^ (z))

// rotates x left n bits
#define MD4_ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))

// partial transformations
#define MD4_FF(a, b, c, d, x, s) \
{ \
  (a) += MD4_F((b), (c), (d)) + (x); \
  (a) = MD4_ROTATE_LEFT((a), (s)); \
}

#define MD4_GG(a, b, c, d, x, s) \
{ \
  (a) += MD4_G((b), (c), (d)) + (x) + (uint32)0x5A827999; \
  (a) = MD4_ROTATE_LEFT((a), (s)); \
}

#define MD4_HH(a, b, c, d, x, s) \
{ \
  (a) += MD4_H((b), (c), (d)) + (x) + (uint32)0x6ED9EBA1; \
  (a) = MD4_ROTATE_LEFT((a), (s)); \
}

static void MD4Transform(uint32 Hash[4], uint32 x[16]);

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
//this file is part of eMule
//Copyright (C)2002 Merkur ( merkur-@users.sourceforge.net / http://www.emule-project.net )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#pragma once

#include "types.h"

#pragma pack(1)
//      SERVER TO CLIENT
struct Header_Struct{
  int8  eDonkeyID;
  int32  packetlength;
  int8  command;
};
struct UDP_Header_Struct{
  int8  eDonkeyID;
  int8  command;
};

struct LoginAnswer_Struct {
  uint32  clientid;
};

struct Requested_Block_Struct{
  uint32  StartOffset;
  uint32  EndOffset;
  uint32  packedsize;
  uchar  FileID[16];
};

struct Requested_File_Struct{
  uchar    fileid[16];
  uint32    lastasked;
  uint8    badrequests;
};

struct Pending_Block_Struct{
  Requested_Block_Struct*  block;
  CMemFile*        buffer;
};

struct Gap_Struct{
  uint32 start;
  uint32 end;
};

struct ServerMet_Struct {
  uint32  ip;
  uint16  port;
  uint32  tagcount;
};
nur kann ich nichts anfagen, was heißt uint32?? das es was mit integer zutun hat is mir schon klar aber nur was?
wer kann mir da mal bitte ei wenig auf die sprünge helfen?

(30.12. 09:35 Tino) Code-Tags hinzugefügt.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 28.12.02 14:58 
uint ist ein Windows-Datentyp und ich würde sagen das steht für unsigned integer.
waldmeister
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 136

Win XP
D7 Enterp
BeitragVerfasst: Mo 30.12.02 22:17 
Soweit ich weiß is der ganze emule code in C++ geschrieben...da stellt sich doch die frage ob das hier das richtige forum ist!

_________________
der wald....der meister....der meister des waldes....der waldmeister
omega123 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Di 31.12.02 15:56 
@waldmeister

ich weiß, das emule in c++ geschrieben ist, nur ich kann kein c++!
den code habe ich nur gepostet, weil ich nicht weiß was das alles heißt, und wie ich es übersetzten kann.

@Luckie

was heißt unsigned integer???
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 31.12.02 15:57 
Integer ohne Vorzeichen würde ich mal so tippen.
Brueggendiek
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 304

Win 98, Win98SE, Win XP Home
D5 Std
BeitragVerfasst: Di 31.12.02 16:29 
Hallo!

Bei uint32 vermute ich mal: Unsigned Integer mit 32 Bit.

Das wäre dann eine vorzeichenlose (unsigned) Ganzzahl mit 32 Bit (4 Byte) - kann nur positive Werte annehmen. In Delphi also Longword (siehe OH: Integer-Typen).

Bitte nicht Cardinal verwenden, bei späteren (64-Bit)-Versionen kann sich der Datentyp in Delphi dann ändern und paßt nicht mehr zum C-Code.


Gruß

Dietmar Brüggendiek