(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 2.10 and 2.11

version 2.10, 2005/02/27 08:31:36 version 2.11, 2005/02/27 09:37:56
Line 21 
Line 21 
 #include <stdlib.h> #include <stdlib.h>
 #include <string.h> #include <string.h>
 #include <sys/stat.h> #include <sys/stat.h>
   #include <stdarg.h>
  
 #ifndef STANDALONE #ifndef STANDALONE
 #include <wine/test.h> #include <wine/test.h>
Line 42 
Line 43 
                 exit(1);         \                 exit(1);         \
         } } while(0)         } } while(0)
 #define todo_wine #define todo_wine
 #endif  
  
 #define TVFS  static void trace(const char *s, ...)
   {
       va_list elipsis;
       va_start (elipsis, s);
       vprintf(s, elipsis);
       va_end(elipsis);
   }
   
   #endif
  
 #include <winerror.h> #include <winerror.h>
 #include <fdi.h> #include <fdi.h>
Line 54 
Line 62 
  
 /* Do malloc and free output debug messages? /* Do malloc and free output debug messages?
 #define DEBUG_ALLOC #define DEBUG_ALLOC
   #define VERBOSE
 */ */
  
 #ifndef DEBUG_ALLOC #ifndef DEBUG_ALLOC
Line 66 
Line 75 
 } }
 #else #else
 FNALLOC(final_alloc) { FNALLOC(final_alloc) {
         printf("   FNALLOC just called with %d\n",cb);      trace("   FNALLOC just called with %d\n",cb);
         return malloc(cb);         return malloc(cb);
 } }
 FNFREE(final_free) { FNFREE(final_free) {
         printf("   FNFREE just called with %d\n",pv);      trace("   FNFREE just called with %d\n",pv);
         free(pv);         free(pv);
         return;         return;
 } }
 #endif #endif
   
   
 FNOPEN(dummy_open) {  
         printf("  FNOPEN (dummy) just called with %d, %d, %d\n",pszFile, oflag, pmode);  
         return 0;  
 }  
   
 FNREAD(dummy_read) {  
         printf("   FNREAD (dummy) just called with %d, %d, %d\n",hf, pv, cb);  
         return 0;  
 }  
   
 FNCLOSE(dummy_close) {  
         printf("   FNCLOSE (dummy) just called with %d - returning %d\n",hf,0);  
         return 0;  
 }  
   
 FNWRITE(dummy_write) {  
         printf("   FNWRITE just called with %d, %d, %d\n",hf, pv, cb);  
         return 0;  
 }  
   
 FNSEEK(dummy_seek) {  
         printf("   FNSEEK just called with %d, %d, %d\n",hf, dist, seektype);  
         return 0;  
 }  
   
   
 /*Possible non trivial addition: /*Possible non trivial addition:
 Notify receives some information about the cab file(see FDI documentation). Notify receives some information about the cab file(see FDI documentation).
 Since this info is different depending on the value of fdint, and Notify should Since this info is different depending on the value of fdint, and Notify should
Line 110 
Line 91 
 */ */
 FNFDINOTIFY(notification_function) FNFDINOTIFY(notification_function)
 { {
       #ifdef VERBOSE
       trace("   FNFDINOTIFY real just called with %d, %d \n",fdint,pfdin);
       #endif
         switch (fdint)         switch (fdint)
         {         {
                 case fdintCABINET_INFO:                 case fdintCABINET_INFO:
                 {                 {
               #ifdef VERBOSE
               trace(
                   "fdintCABINET_INFO:\n"
                   "-next cab name: %s\n"
                   "-next disk: %s\n"
                   "-path name: %s\n"
                   "-set ID: %d\n"
                   "-number in set: %d\n",
                   pfdin->psz1,
                   pfdin->psz2,
                   pfdin->psz3,
                   pfdin->setID,
                   pfdin->iCabinet
               );
               #endif
                         return 0;                         return 0;
                 }                 }
                 case fdintPARTIAL_FILE:                 case fdintPARTIAL_FILE:
                 {                 {
               #ifdef VERBOSE
               trace("dintPARTIAL_FILE\n");
               #endif
   
                         return 0;                         return 0;
                 }                 }
                 case fdintCOPY_FILE:                 case fdintCOPY_FILE:
                 {                 {
                         int fih = 0;                         int fih = 0;
                         char target[256];                         char target[256];
               #ifdef VERBOSE
               trace(
                   "fdintCOPY_FILE:\n"
                   "-name: %s\n"
                   "-uncompressed size: %d\n"
                   "-date: %d\n"
                   "-time: %d\n"
                   "-attributes: %d\n"
                   "-file's folder index: %d\n",
                   pfdin->psz1,
                   pfdin->cb,
                   pfdin->date,
                   pfdin->time,
                   pfdin->attribs,
                   pfdin->iFolder
               );
               #endif
                         sprintf(target, "./%s",pfdin->psz1);                         sprintf(target, "./%s",pfdin->psz1);
                         fih = tvfs_open (target,                         fih = tvfs_open (target,
                                         _O_BINARY | _O_CREAT | _O_WRONLY | _O_SEQUENTIAL,                                         _O_BINARY | _O_CREAT | _O_WRONLY | _O_SEQUENTIAL,
Line 135 
Line 155 
                 {                 {
                         char filebuf[256];                         char filebuf[256];
                         int result;                         int result;
               #ifdef VERBOSE
               trace(
                   "fdintCLOSE_FILE:\n"
                   "-name: %s\n"
                   "-handle: %d\n"
                   "-date: %d\n"
                   "-time: %d\n"
                   "-attributes: %d\n"
                   "-file's folder index: %d\n"
                   "-run: %d\n",
                   pfdin->psz1,
                   pfdin->hf,
                   pfdin->date,
                   pfdin->time,
                   pfdin->attribs,
                   pfdin->iFolder,
                   pfdin->cb
               );
               #endif
  
 /*  
         printf("Testing direct file compare and lseek of %s\n", name_simple_txt);  
         printf("Reading and comparing file\n");  
         result = tvfs_read(7, filebuf, size_simple_txt);  
         result = tvfs_compare( filebuf , file_simple_txt, size_simple_txt);  
   
 */  
                         tvfs_close(pfdin->hf);                         tvfs_close(pfdin->hf);
                         return TRUE;                         return TRUE;
                 }                 }
                 case fdintNEXT_CABINET:                 case fdintNEXT_CABINET:
                 {                 {
               #ifdef VERBOSE
               trace("fdintNEXT_CABINET\n");
               #endif
                         return 0;                         return 0;
                 }                 }
                 case fdintENUMERATE:                 case fdintENUMERATE:
                 {                 {
               #ifdef VERBOSE
               trace("fdintENUMERATE\n");
               #endif
                         return 0;                         return 0;
                 }                 }
         }         }
Line 159 
Line 197 
 } }
  
 static void printCabInfo(FDICABINETINFO  cabinfo){ static void printCabInfo(FDICABINETINFO  cabinfo){
                 printf("   Cabinet Data : cbC %d cF %d cFi %d si %d iC %d fr %d hp %d hn %d\n",      #ifdef VERBOSE
       trace("   Cabinet Data : cbC %d cF %d cFi %d si %d iC %d fr %d hp %d hn %d\n",
                 cabinfo.cbCabinet,                 cabinfo.cbCabinet,
                 cabinfo.cFolders ,                 cabinfo.cFolders ,
                 cabinfo.cFiles ,                 cabinfo.cFiles ,
Line 168 
Line 207 
                 cabinfo.fReserve ,                 cabinfo.fReserve ,
                 cabinfo.hasprev ,                 cabinfo.hasprev ,
                 cabinfo.hasnext );                 cabinfo.hasnext );
 }  
 #ifndef TVFS  
 FNREAD(real_read) {  
         int szBuffer = _read(hf,pv,cb);  
         printf("   FNREAD (read) just called with %d, %d, %d\n",hf, pv, cb);  
         printf("   FNREAD (read) returning size (%d)\n",szBuffer);  
         return szBuffer;  
 }  
 FNCLOSE(real_close) {  
         int closevalue = _close(hf);  
         printf("   FNCLOSE (real) just called with %d - returning %d\n",hf,closevalue);  
         return closevalue;  
 }  
   
 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(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;  
 }  
   
 FNOPEN(real_open) {  
         int handler = _open(pszFile,oflag,pmode);  
         printf("   FNOPEN (real) just called with %s, %d, %d\n",pszFile, oflag, pmode);  
         printf("   FNOPEN (real) returning handler (%d)\n",handler);  
         return handler;  
 }  
 #endif #endif
   }
  
 static void CheckCabInfo(char *  cabname, static void CheckCabInfo(char *  cabname,
                                                  FDICABINETINFO cabinfo,                                                  FDICABINETINFO cabinfo,
Line 221 
Line 229 
         ok2 ( cabinfo.hasprev == Thasprev, "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);         ok2 ( cabinfo.hasnext == Thasnext, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname);
                                                 }                                                 }
 HFDI hfdi_unknown_dummy, hfdi_unknown_tvfs;  
   static HFDI hfdi_unknown;
 /* yes its global and ugly */ /* yes its global and ugly */
  
 /* Is CPU386 or Unknown more commonly used? */ /* Is CPU386 or Unknown more commonly used? */
Line 230 
Line 239 
  
         ERF error_structure;         ERF error_structure;
  
         printf("Starting TestCreate()\n");      trace("Starting TestCreate()\n");
  
         hfdi_unknown_dummy = FDICreate(      hfdi_unknown = FDICreate(
                 final_alloc,                 final_alloc,
                 final_free,                 final_free,
                 dummy_open,  
                 dummy_read,  
                 dummy_write,  
                 dummy_close,  
                 dummy_seek,  
                 cpuUNKNOWN,  
                 &error_structure  
         );  
         ok(hfdi_unknown_dummy != NULL,"FDICreate (CPU = unknown) (functions=dummy) failed!\n");  
   
         hfdi_unknown_tvfs = FDICreate(  
                 final_alloc,  
                 final_free,  
 #ifdef TVFS  
                 tvfs_open, tvfs_read, tvfs_write, tvfs_close, tvfs_lseek,                 tvfs_open, tvfs_read, tvfs_write, tvfs_close, tvfs_lseek,
 #else  
                 real_open, real_read, real_write, real_close,real_seek,  
 #endif  
                 cpuUNKNOWN,                 cpuUNKNOWN,
                 &error_structure                 &error_structure
         );         );
         ok(hfdi_unknown_tvfs != NULL,"FDICreate (CPU = unknown) (functions=tvfs) failed!\n");  
  
         printf("Ending TestCreate()\n");      ok(hfdi_unknown != NULL,"FDICreate (CPU = unknown) (functions=tvfs) failed!\n");
   
       trace("Ending TestCreate()\n");
 } }
  
 static void TestInfo(void) { static void TestInfo(void) {
 #ifdef TVFS  
         int fd;  
  
         FDICABINETINFO  fdi_cabinfo_dummy, fdi_cabinfo_simple, fdi_cabinfo_complex;      int fd;
   
         printf("Starting TestInfo()\n");  
  
         /* TEST : ERR filehandle associated, dummy functions should return FALSE */      FDICABINETINFO  fdi_cabinfo_simple, fdi_cabinfo_complex;
         ok ( FDIIsCabinet( hfdi_unknown_dummy, -1, &fdi_cabinfo_dummy) == FALSE,  
                         "FDIIsCabinet (File = Error) failed!\n");  
  
       trace("Starting TestInfo()\n");
  
         tvfs_create( name_simple_cab, file_simple_cab, size_simple_cab);         tvfs_create( name_simple_cab, file_simple_cab, size_simple_cab);
         fd = tvfs_open( name_simple_cab, _O_BINARY, 0 );         fd = tvfs_open( name_simple_cab, _O_BINARY, 0 );
  
         ok( FDIIsCabinet( hfdi_unknown_tvfs, fd, &fdi_cabinfo_simple) == TRUE,      ok( FDIIsCabinet( hfdi_unknown, fd, &fdi_cabinfo_simple) == TRUE,
                         "FDIIsCabinet (Virtual File = Simple.cab) failed!\n");                         "FDIIsCabinet (Virtual File = Simple.cab) failed!\n");
  
         printCabInfo(fdi_cabinfo_simple);         printCabInfo(fdi_cabinfo_simple);
Line 285 
Line 273 
  
         tvfs_close(fd);         tvfs_close(fd);
  
   
         tvfs_create( name_complex_cab, file_complex_cab, size_complex_cab);         tvfs_create( name_complex_cab, file_complex_cab, size_complex_cab);
         fd = tvfs_open( name_complex_cab, _O_BINARY, 0 );         fd = tvfs_open( name_complex_cab, _O_BINARY, 0 );
  
         ok( FDIIsCabinet( hfdi_unknown_tvfs, fd, &fdi_cabinfo_complex) == TRUE,      ok( FDIIsCabinet( hfdi_unknown, fd, &fdi_cabinfo_complex) == TRUE,
                         "FDIIsCabinet (Virtual File = Complex.cab) failed!\n");                         "FDIIsCabinet (Virtual File = Complex.cab) failed!\n");
  
         printCabInfo(fdi_cabinfo_complex);         printCabInfo(fdi_cabinfo_complex);
Line 298 
Line 285 
         tvfs_close(fd);         tvfs_close(fd);
         tvfs_free();         tvfs_free();
  
         printf("Ending TestInfo()\n");      trace("Ending TestInfo()\n");
 #endif  
 } }
  
 static void TestCopy(void){ static void TestCopy(void){
Line 307 
Line 293 
         char name_file_path[256];         char name_file_path[256];
         int result;         int result;
  
         printf("Starting TestCopy()\n");      trace("Starting TestCopy()\n");
         printf("---simple.cab\n");      trace("---simple.cab\n");
 #ifdef TVFS  
         tvfs_create( name_simple_cab, file_simple_cab, size_simple_cab);         tvfs_create( name_simple_cab, file_simple_cab, size_simple_cab);
 #endif      FDICopy(hfdi_unknown,
         FDICopy(hfdi_unknown_tvfs,  
                         "simple.cab",                         "simple.cab",
                         "",                         "",
                         0,                         0,
Line 320 
Line 305 
                         NULL,                         NULL,
                         NULL);                         NULL);
  
 #ifdef TVFS  
         /* Filename when extracted is ./<filename> */         /* Filename when extracted is ./<filename> */
         sprintf(name_file_path, "./%s", name_simple_txt);         sprintf(name_file_path, "./%s", name_simple_txt);
         result = tvfs_compare(name_file_path, file_simple_txt, size_simple_txt);         result = tvfs_compare(name_file_path, file_simple_txt, size_simple_txt);
         if (result)         if (result)
                 printf ("File compare failed!\n");          trace ("File %s compare failed!\n",name_file_path);
         tvfs_free();         tvfs_free();
 #endif  
   
  
         printf("---complex.cab\n");      trace("---complex.cab\n");
 #ifdef TVFS  
         tvfs_create( name_complex_cab, file_complex_cab, size_complex_cab);         tvfs_create( name_complex_cab, file_complex_cab, size_complex_cab);
 #endif      FDICopy(hfdi_unknown,
         FDICopy(hfdi_unknown_tvfs,  
                         "complex.cab",                         "complex.cab",
                         "",                         "",
                         0,                         0,
Line 342 
Line 322 
                         NULL,                         NULL,
                         NULL);                         NULL);
  
 #ifdef TVFS  
         /* Filename when extracted is ./<filename> */         /* Filename when extracted is ./<filename> */
         sprintf(name_file_path, "./%s", name_README);         sprintf(name_file_path, "./%s", name_README);
         result = tvfs_compare(name_file_path, file_README, size_README);         result = tvfs_compare(name_file_path, file_README, size_README);
         if (result)         if (result)
                 printf ("File compare failed!\n");          trace ("File %s compare failed!\n",name_file_path);
         tvfs_free();  
 #endif  
  
       sprintf(name_file_path, "./%s", name_lgpl_txt);
       result = tvfs_compare(name_file_path, file_lgpl_txt, size_lgpl_txt);
       if (result)
           trace ("File %s compare failed!\n",name_file_path);
  
       tvfs_free();
  
         printf("Ending TestCopy()\n");      trace("Ending TestCopy()\n");
 } }
  
 static void TestDestroy(void) { static void TestDestroy(void) {
         printf("Starting TestDestroy()\n");      trace("Starting TestDestroy()\n");
       ok(FDIDestroy(hfdi_unknown), "FDIDestroy (CPU = unknown) (functions=tvfs) failed!\n");
         ok(FDIDestroy(hfdi_unknown_dummy), "FDIDestroy (CPU = unknown) (functions=fake) failed!\n");      trace("Ending TestDestroy()\n");
         ok(FDIDestroy(hfdi_unknown_tvfs), "FDIDestroy (CPU = unknown) (functions=tvfs) failed!\n");  
         printf("Ending TestDestroy()\n");  
 } }
  
 START_TEST(paths) START_TEST(paths)


Legend:
Removed from v.2.10  
changed lines
  Added in v.2.11

Rizwan Kassim
Powered by
ViewCVS 0.9.2