(file) Return to cabinet_fdi.c CVS log (file) (dir) Up to [RizwankCVS] / group3 / wine / dlls / cabinet / tests

Diff for /group3/wine/dlls/cabinet/tests/cabinet_fdi.c between version 1.7 and 2.4

version 1.7, 2005/02/11 08:50:58 version 2.4, 2005/02/15 09:34:28
Line 19 
Line 19 
  */  */
  
 #include <stdlib.h> #include <stdlib.h>
   #include <string.h>
   #include <sys/stat.h>
  
 #ifndef STANDALONE #ifndef STANDALONE
 #include <wine/test.h> #include <wine/test.h>
Line 45 
Line 47 
 #include <winerror.h> #include <winerror.h>
 #include <fdi.h> #include <fdi.h>
 #include <fcntl.h> #include <fcntl.h>
   #include "cabinet_files.h"
  
 static int fakeFD = 12;  /* Do malloc and free output debug messages?
   #define DEBUG_ALLOC
   */
  
 /* This is the hex string representation of the file created by compressing  /* What is our "Fake" Filedescriptors? */
    a simple text file with the contents "This is a test file."  static int fakeFD_simple = 22881;
   static int fakeFD_complexzip2 = 22882;
   static int fakeFD_complexlzw2 = 22883;
   static int fakeFD_broken = 22884;
  
    The file was created using COMPRESS.EXE from the Windows Server 2003  /*
    Resource Kit from Microsoft.  The resource kit was retrieved from the     This hex data is the output of makecab.exe (Windows Cabinet SDK/bin)
    following URL:     ****** IS USING THE OUTPUT OF A NON LGPL program okay ******
   
    http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en  
  */  
  
      The cab file is mirrored in the file system as simple.cab
  
 static unsigned char compressed_file[] =     The 'test.txt' in the cab file contains the string 'So long, and thanks for all the fish.'
    {0x4D,0x53,0x43,0x46,0x00,0x00,0x00,0x00,0x75,0x00,  
         0x00,0x00,0x00,0x00,0x00,0x00,0x2C,0x00,0x00,0x00,  
         0x00,0x00,0x00,0x00,0x03,0x01,0x01,0x00,0x01,0x00,  
         0x00,0x00,0x39,0x30,0x00,0x00,0x45,0x00,0x00,0x00,  
         0x01,0x00,0x01,0x00,0x26,0x00,0x00,0x00,0x00,0x00,  
         0x00,0x00,0x00,0x00,0x4A,0x32,0xB2,0xBE,0x20,0x00,  
         0x74,0x65,0x73,0x74,0x2E,0x74,0x78,0x74,0x00,0x9C,  
         0x74,0xD0,0x75,0x28,0x00,0x26,0x00,0x43,0x4B,0x0B,  
         0xCE,0x57,0xC8,0xC9,0xCF,0x4B,0xD7,0x51,0x48,0xCC,  
         0x4B,0x51,0x28,0xC9,0x48,0xCC,0xCB,0x2E,0x56,0x48,  
         0xCB,0x2F,0x52,0x48,0xCC,0xC9,0x01,0x72,0x53,0x15,  
         0xD2,0x32,0x8B,0x33,0xF4,0xB8,0x00};  
 static int szcompressed_file = sizeof(compressed_file);  
  
      The files in the "cabinet_files.h" were created with hexify.sh
   */
  /*  /*
 static const char uncompressed_data[] = "This is a test file.";          Multiple File Cabs are included, as cabinet.dll supports multiple file archive types.
 static const DWORD uncompressed_data_size = sizeof(uncompressed_data) - 1;          The compressed file size had to be greater than 50k, cabarc restricts 'diskette spanning' to
             archives above 50k.
           The peculiar options were selected specifically to test cabinet.dll more throughly.
  
 static char *buf;          complex_lzw.cab         cabarc -m LZX:16 -pr -i 32356 N complex_lzw.cab amontillado.txt lgpl.txt gpl.txt midsummer\*
 */          complex_lzw2.cab        cabarc -m LZX:17 -d 50000 -pr -i 32356 N complex_lzw*.cab amontillado.txt + lgpl.txt gpl.txt midsummer\*
   
           complex_zip.cab         cabarc -m MSZIP -pr -i 32356 N complex_lzw.cab amontillado.txt lgpl.txt gpl.txt midsummer\*
           complex_zip2.cab        cabarc -m MSZIP -d 50000 -pr -i 32356 N complex_zip*.cab amontillado.txt + lgpl.txt gpl.txt midsummer\*
  
 /*      To do in FDI:                           -from wine/include/fdi.h          complex_none.cab        cabarc -m NONE -pr -i 32356 N complex_none.cab amontillado.txt midsummer\act1*
   
   /*
           To do in FDI:                           -from wine/include/fdi.h
         FDICreate         FDICreate
                 File Open                               -FNOPEN(pszFile,oflag,pmode)  
                 File Read                               -FNREAD(hf, pv, cb)  
                 File Write                              -FNWRITE(hf, pv, cb)                 File Write                              -FNWRITE(hf, pv, cb)
                 File Close                              -FNCLOSE(hf)  
                 File Seek                               -FNSEEK(hf,dist,seektype)                 File Seek                               -FNSEEK(hf,dist,seektype)
                 Error Structure                 Error Structure
         FDIlsCabinet  
                 FDICabinetInfo Structure  
         FDICopy         FDICopy
                 Notification function                 Notification function
                 Decryption function                 Decryption function
         FDIDestroy         FDIDestroy
 */ */
  
         FDICABINETINFO  fdici;  #ifndef DEBUG_ALLOC
   FNALLOC(final_alloc) {
           return malloc(cb);
 /* Currently mostly dummy function pointers */  }
   FNFREE(final_free) {
 FNALLOC(debug_alloc) {          free(pv);
           return;
   }
   #else
   FNALLOC(final_alloc) {
         printf("   FNALLOC just called with %d\n",cb);         printf("   FNALLOC just called with %d\n",cb);
         return malloc(cb);         return malloc(cb);
 } }
   FNFREE(final_free) {
 FNFREE(debug_free) {  
         printf("   FNFREE just called with %d\n",pv);         printf("   FNFREE just called with %d\n",pv);
         free(pv);         free(pv);
         return;         return;
 } }
   #endif
  
 /*  
         It is not necessary for these functions to actually call _open etc.;  
         these functions could instead call fopen, fread, fwrite, fclose, and fseek,  
         or CreateFile, ReadFile, WriteFile, CloseHandle, and SetFilePointer, etc.  
         However, the parameters and return codes will have to be translated  
         appropriately (e.g. the file open mode passed in to pfnopen).  
  
   /*
         Match i/o specs of _open, _read, _write, _close, and _lseek.         Match i/o specs of _open, _read, _write, _close, and _lseek.
   
 */ */
  
 /* /*
         http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__open.2c_._wopen.asp          http://msdn.microsoft.com/library/en-us/vclib/html/_crt__open.2c_._wopen.asp
         _open           I: const char *filename, int oflag, int pmode   O: int (handler), -1 for err.         _open           I: const char *filename, int oflag, int pmode   O: int (handler), -1 for err.
           DUMMY  : FUNCTIONAL             FAKE : FUNCTIONAL               REAL : FUNCTIONAL
 */ */
  
 FNOPEN(dummy_open) { FNOPEN(dummy_open) {
Line 135 
Line 132 
 } }
  
 FNOPEN(fake_open) { FNOPEN(fake_open) {
          printf("  FNOPEN (fake) just called with %d, %d, %d\n",pszFile, oflag, pmode);          printf("  FNOPEN (virtual) just called with %d, %d, %d\n",pszFile, oflag, pmode);
          printf("  Returning %d as file descriptor\n",fakeFD);          printf("  Returning %d as file descriptor\n",12);
         return 12;         return 12;
 } }
  
Line 147 
Line 144 
         return handler;         return handler;
 } }
  
   
 /* /*
         http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__open.2c_._wopen.asp          http://msdn.microsoft.com/library/en-us/vclib/html/_CRT__read.asp
         _read           I: int fd, void *buffer, unsigned int count             O:      int (szBuffer)         _read           I: int fd, void *buffer, unsigned int count             O:      int (szBuffer)
           DUMMY  : FUNCTIONAL             FAKE : FUNCTIONAL, INCOMPLETE           REAL : FUNCTIONAL
 */ */
  
 FNREAD(dummy_read) { FNREAD(dummy_read) {
Line 158 
Line 155 
         return 0;         return 0;
 } }
  
   /* Doesn't keep virtual file location pointer */
 FNREAD(fake_read) { FNREAD(fake_read) {
          printf("   FNREAD (fake) just called with %d, %d, %d\n",hf, pv, cb);          printf("   FNREAD (virtual) just called with %d, %d, %d\n",hf, pv, cb);
          if (hf == fakeFD) {          switch (hf)
                  printf ("   Called with fake file descriptor, populating buffer and size (%d)\n",szcompressed_file);          {
                  memcpy (pv, compressed_file ,cb);                  /* Const int doesnt count as constant for cases --- why? */
                  /* TODO */                  case 22881:
                           {
                                   printf ("   Called fake file descriptor %d (file_simple_cab),\n\tpopulating buffer and size (%d)\n",hf,cb);
                                   memcpy (pv, file_simple_cab ,cb);
                                   break;
                           }
                   case 22882:
                           {
                                   printf ("   Called fake file descriptor %d (file_complex_zip2_cab),\n\tpopulating buffer and size (%d)\n",hf,cb);
                                   memcpy (pv, file_complex_zip2_cab ,cb);
                                   break;
                           }
                   case 22883:
                           {
                                   printf ("   Called fake file descriptor %d (file_complex_lzw2_cab),\n\tpopulating buffer and size (%d)\n",hf,cb);
                                   memcpy (pv, file_complex_lzw2_cab ,cb);
                                   break;
                           }
                   case 22884:
                           {
                                   printf ("   Called fake file descriptor %d (file_broken_cab),\n\tpopulating buffer and size (%d)\n",hf,cb);
                                   memcpy (pv, file_broken_cab ,cb);
                                   break;
                           }
                   default:
                           {
                                   printf ("   FNREAD (virtual) was called with the unknown file handler. Failed!\n",hf);
                                   return -1;
                  }                  }
          else {  
                  printf ("   FNREAD (fake) was called with the unknown file handler. Failed!\n",hf);  
          }          }
         return szcompressed_file;          printf("     Returning %d\n",cb);
           return cb;
 } }
  
   
 FNREAD(real_read) { FNREAD(real_read) {
         int szBuffer = _read(hf,pv,cb);         int szBuffer = _read(hf,pv,cb);
         printf("   FNREAD (read) just called with %d, %d, %d\n",hf, pv, cb);         printf("   FNREAD (read) just called with %d, %d, %d\n",hf, pv, cb);
Line 178 
Line 203 
         return szBuffer;         return szBuffer;
 } }
  
   /*
           http://msdn.microsoft.com/library/en-us/vclib/html/_CRT__close.asp
           _close          I: int fd   O:  int (0=success 1=failure)
           DUMMY  : FUNCTIONAL             FAKE : FUNCTIONAL               REAL : FUNCTIONAL
   */
  
   FNCLOSE(dummy_close) {
           printf("   FNCLOSE (dummy) just called with %d - returning %d\n",hf,0);
           return 0;
   }
  
 FNWRITE(dummy_write) {  FNCLOSE(fake_close) {
          printf("   FNWRITE just called with %d, %d, %d\n",hf, pv, cb);          printf("   FNCLOSE (virtual) just called with %d - returning %d\n",hf,0);
         return 0;         return 0;
 } }
  
   FNCLOSE(real_close) {
           int closevalue = _close(hf);
           printf("   FNCLOSE (real) just called with %d - returning %d\n",hf,closevalue);
           return closevalue;
   }
  
 FNCLOSE(dummy_close) {  
          printf("   FNCLOSE just called with %d\n",hf);  
   
   
   FNWRITE(dummy_write) {
           printf("   FNWRITE just called with %d, %d, %d\n",hf, pv, cb);
         return 0;         return 0;
 } }
  
   FNWRITE(real_write) {
           int write_value = _write(hf, pv, cb);
           printf("   FNWRITE just called with %d, %d, %d - returning %d\n",hf, pv, cb, write_value);
           return write_value;
   }
   
   
   
   
 FNSEEK(dummy_seek) { FNSEEK(dummy_seek) {
          printf("   FNSEEK just called with %d, %d, %d\n",hf, dist, seektype);          printf("   FNSEEK just called with %d, %d, %d\n",hf, dist, seektype);
         return 0;         return 0;
 } }
  
   FNSEEK(real_seek) {
           long lseek_value = _lseek(hf, dist, seektype);
           printf("   FNSEEK just called with %d, %d, %d - returning %d\n",hf, dist, seektype,lseek_value);
           return lseek_value;
   }
   
   
   
   
   
   FNFDINOTIFY(dummy_notification){
           printf("   FNFDINOTIFY just called with %d, %d \n",fdint,pfdin);
           return 0;
   }
   
   FNFDINOTIFY(notification_function)
   {
           printf("   FNFDINOTIFY real just called with %d, %d \n",fdint,pfdin);
           switch (fdint)
           {
                   case fdintCABINET_INFO:
                   {
                           printf("fdintCABINET_INFO\n");
                           return 0;
                   }
                   case fdintPARTIAL_FILE:
                   {
                           printf("dintPARTIAL_FILE\n");
                           return 0;
                   }
                   case fdintCOPY_FILE:
                   {
                           int fih = 0;
                           char target[256];
   
                           printf("fdintCOPY_FILE\n");
                           printf("  file name: %s\n",     pfdin->psz1);
                           sprintf(target, "./%s",pfdin->psz1);
                           printf("%s\n",target);
   
                                   fih = real_open(
                                           target,
                                           _O_BINARY | _O_CREAT | _O_WRONLY | _O_SEQUENTIAL,
                                           _S_IREAD | _S_IWRITE
                                           );
   
                           return fih;
                   }
   
   
                   case fdintCLOSE_FILE_INFO:
                   {
   
                           printf("fdintCLOSE_FILE_INFO\n");
                           return 0;
                   }
                   case fdintNEXT_CABINET:
                   {
   
                           printf("fdintNEXT_CABINET\n");
                           return 0;
                   }
                   case fdintENUMERATE:
                   {
                                   printf("fdintENUMERATE\n");
                                   return 0;
                   }
           }
           return 0;
   }
   
   
   
   
   static void printCabInfo(FDICABINETINFO  cabinfo){
           //printf("INSIDE PRINT CABINFO\n");
                   printf("   Cabinet Data : cbC %d cF %d cFi %d si %d iC %d fr %d hp %d hn %d\n",
                   cabinfo.cbCabinet,
                   cabinfo.cFolders ,
                   cabinfo.cFiles ,
                   cabinfo.setID,
                   cabinfo.iCabinet,
                   cabinfo.fReserve ,
                   cabinfo.hasprev ,
                   cabinfo.hasnext );
   }
   
   
   static void CheckCabInfo(char *  cabname,
                                                    FDICABINETINFO cabinfo,
                                                    long        TcbCabinet,
                                                    USHORT      TcFolders,
                                                    USHORT      TcFiles,
                                                    USHORT      TsetID,
                                                    USHORT      TiCabinet,
                                                    BOOL        TfReserve,
                                                    BOOL        Thasprev,
                                                    BOOL        Thasnext){
                                                            ok2 ( cabinfo.cbCabinet == TcbCabinet, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname);
                                                            ok2 ( cabinfo.cFolders == TcFolders, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname);
                                                            ok2 ( cabinfo.cFiles == TcFiles, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname);
                                                            ok2 ( cabinfo.setID == TsetID, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname);
                                                            ok2 ( cabinfo.iCabinet == TiCabinet, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname);
                                                            ok2 ( cabinfo.fReserve == TfReserve, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname);
                                                            ok2 ( cabinfo.hasprev == Thasprev, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname);
                                                            ok2 ( cabinfo.hasnext == Thasnext, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname);
                                                   }
   
   
   /* Tried to enhance functionality with :
   
   
           ok4 ( cabinfo.cbCabinet == TcbCabinet, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n\tExpected %d, got %d for cbCabinet\n", cabname, TcbCabinet, cabinfo.cbCabinet );
            ok4 ( cabinfo.cFolders == TcFolders, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n\tExpected %d, got %d for cFolders\n", cabname,TcFolders,cabinfo.cFolders);
            ok4 ( cabinfo.cFiles == TcFiles, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n\tExpected %d, got %d for cFiles\n", cabname,TcFiles,cabinfo.cFiles);
            ok4 ( cabinfo.setID == TsetID, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n\tExpected %d, got %d for setID\n", cabname,TsetID.cabinfo.setID);
            ok4 ( cabinfo.iCabinet == TiCabinet, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n\tExpected %d, got %d for iCabinet\n", cabname,TiCabinet,cabinfo.iCabinet);
            ok4 ( cabinfo.fReserve == TfReserve, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n\tExpected %d, got %d for fReserve\n", cabname,TfReserve,cabinfo.fReserve);
            ok4 ( cabinfo.hasprev == Thasprev, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n\tExpected %d, got %d for hasprev\n", cabname,Thasprev,cabinfo.hasprev );
            ok4 ( cabinfo.hasnext == Thasnext, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n\tExpected %d, got %d for Thasnext\n", cabname,Thasnext,cabinfo.hasnext);
           #define ok4(condition, msg, arg, arb, arc) \
           do { if(!(condition)) {  \
                   fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__, arg, arb, arc); \
                   exit(1);         \
           } } while(0)
   
   
            But it didn't really work, and its too late to fix it for now */
   
   
   
 HFDI hfdi_unknown_dummy, hfdi_unknown_fake,hfdi_unknown_real; HFDI hfdi_unknown_dummy, hfdi_unknown_fake,hfdi_unknown_real;
 FDICABINETINFO  fdi_cabinfo;  
 /* yes its global and ugly */ /* yes its global and ugly */
  
   /* Is CPU386 or Unknown more commonly used? */
  
 static void TestCreate(void) { static void TestCreate(void) {
  
Line 208 
Line 391 
         printf("Starting TestCreate()\n");         printf("Starting TestCreate()\n");
  
         hfdi_unknown_dummy = FDICreate(         hfdi_unknown_dummy = FDICreate(
                 debug_alloc,                  final_alloc,
                 debug_free,                  final_free,
                 dummy_open,                 dummy_open,
                 dummy_read,                 dummy_read,
                 dummy_write,                 dummy_write,
Line 221 
Line 404 
         ok(hfdi_unknown_dummy != NULL,"FDICreate (CPU = unknown) (functions=dummy) failed!\n");         ok(hfdi_unknown_dummy != NULL,"FDICreate (CPU = unknown) (functions=dummy) failed!\n");
  
         hfdi_unknown_fake = FDICreate(         hfdi_unknown_fake = FDICreate(
                 debug_alloc,                  final_alloc,
                 debug_free,                  final_free,
                 fake_open,                 fake_open,
                 fake_read,                 fake_read,
                 dummy_write,                 dummy_write,
Line 234 
Line 417 
         ok(hfdi_unknown_fake != NULL,"FDICreate (CPU = unknown) (functions=fake) failed!\n");         ok(hfdi_unknown_fake != NULL,"FDICreate (CPU = unknown) (functions=fake) failed!\n");
  
         hfdi_unknown_real = FDICreate(         hfdi_unknown_real = FDICreate(
                 debug_alloc,                  final_alloc,
                 debug_free,                  final_free,
                 real_open,                 real_open,
                 real_read,                 real_read,
                 dummy_write,                  real_write,
                 dummy_close,                  real_close,
                 dummy_seek,                  real_seek,
                 cpuUNKNOWN,                 cpuUNKNOWN,
                 &error_structure                 &error_structure
         );         );
Line 249 
Line 432 
         printf("Ending TestCreate()\n");         printf("Ending TestCreate()\n");
 } }
  
   
   
   
 static void TestInfo(void) { static void TestInfo(void) {
           /* Noticed Behavior :
                   FDIIsCabinet does not open the file on its own, it requires a file open/close to be done externally.
                           WHY?
                   The only functions in HFDI that FDIIsCabinet directly accesses is FNREAD
                   Important cases to check :
                           If the filedescriptor == ERR, does it FAIL?                                                     (dummy_read)
                           If the filedescriptor == NOTCABINET, does it FAIL?                                      (fake_read, real_read)
                           If the filedescriptor == CABINET, does it SUCCEED?                                      (fake_read, real_read)
                           If the filedescriptor == CABINET, does it populate FDICABINETINFO?      (fake_read, real_read)
           */
   
         int realfd;         int realfd;
         int sizer;         int sizer;
         char *buffer = malloc(szcompressed_file);          FDICABINETINFO  fdi_cabinfo_dummy, fdi_cabinfo_simple, fdi_cabinfo_complex;
  
         printf("Starting TestInfo()\n");         printf("Starting TestInfo()\n");
                 /*  
                 1=> Does it return T (and fill FDICABINETINFO) if the file descriptor=>cabinet?          /* TEST : ERR filehandle associated, dummy functions should return FALSE */
                 2=> Does it return F (and ignore FDICABINETINFO) if the file descriptor != cabinet?          ok ( FDIIsCabinet( hfdi_unknown_dummy, -1, &fdi_cabinfo_dummy) == FALSE,
                 3=> Does it return F (and ignore FDICABINETINFO) if the file descriptor == error?  
                                 */  
         ok ( FDIIsCabinet( hfdi_unknown_dummy, -1, &fdi_cabinfo) == FALSE,  
                         "FDIIsCabinet (File = Error) failed!\n");                         "FDIIsCabinet (File = Error) failed!\n");
  
         ok ( FDIIsCabinet( hfdi_unknown_fake, fakeFD, &fdi_cabinfo) == FALSE,          /* TEST : Fake filehandle associated, memory manually copied, should return TRUE */
                         "FDIIsCabinet (File = WrongType) failed!\n");          ok ( FDIIsCabinet( hfdi_unknown_fake, fakeFD_simple, &fdi_cabinfo_simple) == TRUE,
                           "FDIIsCabinet (Virtual File = Cabinet) failed!\n");
  
         sizer = fake_read ( 12,buffer,szcompressed_file );                  CheckCabInfo("simple.cab",fdi_cabinfo_simple,117,1,1,12345,0,0,0,0);
         printf(buffer);  
           /*
              Is it ok to reuse the same hfdi_unknown_real ? */
  
         realfd = real_open( "TEST1.cab" , _O_BINARY | _O_RDONLY | _O_SEQUENTIAL, 0);          /* TEST : Opened filehandle associated, corrupted cab loaded, should return FALSE */
         ok ( FDIIsCabinet( hfdi_unknown_real, realfd, &fdi_cabinfo) == TRUE,          /* We can see that the Windows implementation only reads the first 36 bytes - what if we corrupted a CAB after 36 bytes?*/
                         "FDIIsCabinet (File = Cabinet) failed!\n");  
  
  
           /* Testing broken cab - using virtual file reads */
           ok ( FDIIsCabinet( hfdi_unknown_fake, fakeFD_broken, &fdi_cabinfo_simple) == FALSE,
                           "FDIIsCabinet (Virtual File = Bad-Cabinet) failed!\n");
   
           realfd = real_open( "cabinet_fdi.c" , _O_BINARY | _O_RDONLY | _O_SEQUENTIAL, 0);
   
           ok ( FDIIsCabinet( hfdi_unknown_real, realfd, &fdi_cabinfo_complex) == FALSE,
                           "FDIIsCabinet (File = Non-Cabinet) cabinet_fdi.c failed!\n");
           real_close(realfd);
   
   
                   CheckCabInfo("simple.cab",fdi_cabinfo_simple,117,1,1,12345,0,0,0,0);
   
   
           /* TEST : Opened filehandle associated, valid cab loaded, should return TRUE */
           realfd = real_open( "complex_lzw.cab" , _O_BINARY | _O_RDONLY | _O_SEQUENTIAL, 0);
   
           ok ( FDIIsCabinet( hfdi_unknown_real, realfd, &fdi_cabinfo_complex) == TRUE,
                           "FDIIsCabinet (File = Cabinet) complex_lzw.cab failed!\n");
           real_close(realfd);
   
           printCabInfo(fdi_cabinfo_complex);
   
   
           ok ( FDIIsCabinet( hfdi_unknown_fake, fakeFD_complexlzw2, &fdi_cabinfo_complex) == TRUE,
                   "FDIIsCabinet (Virtual File = Cabinet) complex_lzw2.cab failed!\n");
   
           printCabInfo(fdi_cabinfo_complex);
   
           CheckCabInfo("complex_lzw2",fdi_cabinfo_complex,3513,1,1,32356,1,0,1,0);
   
   
   
           realfd = real_open( "complex_zip.cab" , _O_BINARY | _O_RDONLY | _O_SEQUENTIAL, 0);
   
           ok ( FDIIsCabinet( hfdi_unknown_real, realfd, &fdi_cabinfo_complex) == TRUE,
                           "FDIIsCabinet (File = Cabinet) complex_zip.cab failed!\n");
           real_close(realfd);
   
           printCabInfo(fdi_cabinfo_complex);
   
   
           ok ( FDIIsCabinet( hfdi_unknown_fake, fakeFD_complexzip2, &fdi_cabinfo_complex) == TRUE,
                   "FDIIsCabinet (Virtual File = Cabinet) complex_zip2.cab failed!\n");
   
           printCabInfo(fdi_cabinfo_complex);
   
           CheckCabInfo("complex_zip2",fdi_cabinfo_complex,6995,1,4,32356,1,0,1,0);
   
   
           realfd = real_open( "complex_none.cab" , _O_BINARY | _O_RDONLY | _O_SEQUENTIAL, 0);
   
           ok ( FDIIsCabinet( hfdi_unknown_real, realfd, &fdi_cabinfo_complex) == TRUE,
                           "FDIIsCabinet (File = Cabinet) complex_zip.cab failed!\n");
           real_close(realfd);
   
   
           printCabInfo(fdi_cabinfo_complex);
   
   
   }
   
   /* Peer cooment : really_shouldn't use relative paths in FDICopy call --- doing // doesn't work as a comment in C fyi
      */
   
   static void TestCopy(void){
           printf("Starting TestCopy()\n");
           printf("---simple.cab\n");
           FDICopy(hfdi_unknown_real,
                           "simple.cab",
                           "./",
                           //"C:\\cygwin\\home\\Administrator\\group3\\wine\\dlls\\cabinet\\tests\\",
                           0,
                           notification_function,
                           NULL,
                           NULL);
           /*printf("---complex_none.cab\n");
           FDICopy(hfdi_unknown_real,
                   "complex_none.cab",
                   "C:\\cygwin\\home\\Administrator\\group3\\wine\\dlls\\cabinet\\tests\\",
                   0,
                   notification_function,
                   NULL,
                   NULL);
           printf("---complex_zip.cab\n");
       FDICopy(hfdi_unknown_real,
                   "complex_zip.cab",
                   "C:\\cygwin\\home\\Administrator\\group3\\wine\\dlls\\cabinet\\tests\\",
                   0,
                   notification_function,
                   NULL,
                   NULL);
           printf("---complex_lzw.cab\n");
           FDICopy(hfdi_unknown_real,
                   "complex_lzw.cab",
                   "C:\\cygwin\\home\\Administrator\\group3\\wine\\dlls\\cabinet\\tests\\",
                   0,
                   notification_function,
                   NULL,
                   NULL);
           */
   
           printf("Ending TestCopy()\n");
 } }
  
  
 static void TestDestroy(void) { static void TestDestroy(void) {
         printf("Starting TestDestroy()\n");         printf("Starting TestDestroy()\n");
                 /* Only two things to check in FDIDestroy                  /* Should return TRUE if given a valid hfdi, else FALSE (only due to context errors?) */
            1=> Does it return T if its passed an hfdi  
            2=> Does it return F if its passed a non hfdi  
                 EDIT : Causes GPL if FDIDestroy is called on an invalid pointer.  
                 ok( 0 == FDIDestroy(0), "Return true incorrectly in TestDestroy()!\n");  
                 */  
  
         ok(FDIDestroy(hfdi_unknown_dummy), "FDIDestroy (CPU = unknown) (functions=fake) failed!\n");         ok(FDIDestroy(hfdi_unknown_dummy), "FDIDestroy (CPU = unknown) (functions=fake) failed!\n");
         ok(FDIDestroy(hfdi_unknown_fake), "FDIDestroy (CPU = unknown) (functions=fake) failed!\n");         ok(FDIDestroy(hfdi_unknown_fake), "FDIDestroy (CPU = unknown) (functions=fake) failed!\n");
           ok(FDIDestroy(hfdi_unknown_real), "FDIDestroy (CPU = unknown) (functions=real) failed!\n");
         printf("Ending TestDestroy()\n");         printf("Ending TestDestroy()\n");
  
 } }
  
   
 START_TEST(paths) START_TEST(paths)
 { {
   
         TestCreate();         TestCreate();
         TestInfo();         TestInfo();
         /*  
         TestCopy();         TestCopy();
         */  
         TestDestroy();         TestDestroy();
   
 } }


Legend:
Removed from v.1.7  
changed lines
  Added in v.2.4

Rizwan Kassim
Powered by
ViewCVS 0.9.2