(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.13 and 2.15

version 2.13, 2005/03/11 07:38:58 version 2.15, 2005/03/18 00:28:59
Line 21 
Line 21 
 #include <stdio.h> #include <stdio.h>
 #include <stdlib.h> #include <stdlib.h>
 #include <string.h> #include <string.h>
 #include <sys/stat.h>  
 #include <stdarg.h> #include <stdarg.h>
 #include <malloc.h> #include <malloc.h>
  
Line 35 
Line 34 
  
 #ifndef WIN_ENV #ifndef WIN_ENV
 #include <msvcrt/fcntl.h> #include <msvcrt/fcntl.h>
   #include <msvcrt/sys/stat.h>
 #else #else
   #include <sys/stat.h>
 #include <fcntl.h> #include <fcntl.h>
 #endif #endif
  
   #define VERBOSE
   
 #include "tvfs.h" #include "tvfs.h"
 #include "data.h"  #include "simplecab.h"
  
 #ifndef STANDALONE #ifndef STANDALONE
 #include <wine/test.h> #include <wine/test.h>
 #define _S_IREAD  0x0100  
 #define _S_IWRITE 0x0080  
 #define ok2 ok #define ok2 ok
 #else #else
   #include "standalone.h"
 /* To build outside Wine tree, compile with cl -DSTANDALONE -D_X86_ -DWIN_ENV tvfs.c cabinet_fdi.c FDI.lib /* To build outside Wine tree, compile with cl -DSTANDALONE -D_X86_ -DWIN_ENV tvfs.c cabinet_fdi.c FDI.lib
   These are only called if standalone are used, defining ok and START_TEST, which would normally be declared in winetree */    standalone.h is used if standalone are used, defining ok and START_TEST, which would normally be declared in winetree */
 #include <assert.h>  
   
 #define START_TEST(name) main(int argc, char **argv)  
 #define ok(condition, msg)    \  
     do { if(!(condition)) {  \  
         fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__); \  
     exit(1);    \  
     } } while(0)  
 #define ok2(condition, msg, arg) \  
     do { if(!(condition)) {  \  
         fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__, arg); \  
     exit(1);    \  
     } } while(0)  
 #define todo_wine  
   
 static void trace(const char *s, ...)  
 {  
     va_list ellipsis;  
     va_start (ellipsis, s);  
     vprintf(s, ellipsis);  
     va_end(ellipsis);  
 }  
   
 #endif #endif
  
 /* Do malloc and free output debug messages?  
 #define DEBUG_ALLOC  
 #define VERBOSE  
 */  
   
 #ifndef DEBUG_ALLOC  
 FNALLOC(final_alloc) {  
     return malloc(cb);  
 }  
 FNFREE(final_free) {  
     free(pv);  
     return;  
 }  
 #else  
 FNALLOC(final_alloc) { FNALLOC(final_alloc) {
     trace("   FNALLOC just called with %d\n",cb);     trace("   FNALLOC just called with %d\n",cb);
     return malloc(cb);     return malloc(cb);
Line 98 
Line 63 
     free(pv);     free(pv);
     return;     return;
 } }
 #endif  
 /*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 106 
Line 71 
 */ */
 FNFDINOTIFY(notification_function) FNFDINOTIFY(notification_function)
 { {
 #ifdef VERBOSE  
     trace("   FNFDINOTIFY real just called with %d, %d \n",fdint,pfdin);     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(             trace(
                 "fdintCABINET_INFO:\n"                 "fdintCABINET_INFO:\n"
                 "-next cab name: %s\n"                 "-next cab name: %s\n"
Line 121 
Line 83 
                 "-path name: %s\n"                 "-path name: %s\n"
                 "-set ID: %d\n"                 "-set ID: %d\n"
                 "-number in set: %d\n",                 "-number in set: %d\n",
                 pfdin->psz1,                  pfdin->psz1, pfdin->psz2, pfdin->psz3, pfdin->setID, pfdin->iCabinet
                 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");             trace("dintPARTIAL_FILE\n");
 #endif  
  
             return 0;             return 0;
         }         }
Line 142 
Line 97 
         {         {
             int fih = 0;             int fih = 0;
             char target[256];             char target[256];
 #ifdef VERBOSE  
             trace(             trace(
                 "fdintCOPY_FILE:\n"                 "fdintCOPY_FILE:\n"
                 "-name: %s\n"                 "-name: %s\n"
Line 151 
Line 105 
                 "-time: %d\n"                 "-time: %d\n"
                 "-attributes: %d\n"                 "-attributes: %d\n"
                 "-file's folder index: %d\n",                 "-file's folder index: %d\n",
                 pfdin->psz1,                  pfdin->psz1, pfdin->cb, pfdin->date, pfdin->time, pfdin->attribs, pfdin->iFolder
                 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 178 
Line 126 
                 "-attributes: %d\n"                 "-attributes: %d\n"
                 "-file's folder index: %d\n"                 "-file's folder index: %d\n"
                 "-run: %d\n",                 "-run: %d\n",
                 pfdin->psz1,                  pfdin->psz1, pfdin->hf, pfdin->date, pfdin->time, pfdin->attribs, pfdin->iFolder, pfdin->cb
                 pfdin->hf,  
                 pfdin->date,  
                 pfdin->time,  
                 pfdin->attribs,  
                 pfdin->iFolder,  
                 pfdin->cb  
             );             );
 #endif #endif
  
Line 193 
Line 135 
         }         }
         case fdintNEXT_CABINET:         case fdintNEXT_CABINET:
         {         {
 #ifdef VERBOSE  
             trace("fdintNEXT_CABINET\n");             trace("fdintNEXT_CABINET\n");
 #endif  
             return 0;             return 0;
         }         }
         case fdintENUMERATE:         case fdintENUMERATE:
         {         {
 #ifdef VERBOSE  
             trace("fdintENUMERATE\n");             trace("fdintENUMERATE\n");
 #endif  
             return 0;             return 0;
         }         }
     }     }
Line 210 
Line 148 
 } }
  
 static void printCabInfo(FDICABINETINFO  cabinfo){ static void printCabInfo(FDICABINETINFO  cabinfo){
 #ifdef VERBOSE  
     trace("   Cabinet Data : cbC %d cF %d cFi %d si %d iC %d fr %d hp %d hn %d\n",     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 ,
Line 220 
Line 157 
         cabinfo.fReserve ,         cabinfo.fReserve ,
         cabinfo.hasprev ,         cabinfo.hasprev ,
         cabinfo.hasnext );         cabinfo.hasnext );
 #endif  
 } }
  
 static void CheckCabInfo(char *  cabname, static void CheckCabInfo(char *  cabname,
Line 242 
Line 178 
     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);
    }    }
      /* TODO :  Message should contain variable values */
  
 static HFDI hfdi_unknown;  static HFDI hfdi_simple;
 /* 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) {
  
     ERF error_structure;     ERF error_structure;
  
     trace("Starting TestCreate()\n");     trace("Starting TestCreate()\n");
       /* Is CPU386 or Unknown more commonly used? */
     hfdi_unknown = FDICreate(      hfdi_simple = FDICreate(
         final_alloc,         final_alloc,
         final_free,         final_free,
         tvfs_open, tvfs_read, tvfs_write, tvfs_close, tvfs_lseek,         tvfs_open, tvfs_read, tvfs_write, tvfs_close, tvfs_lseek,
Line 262 
Line 198 
         &error_structure         &error_structure
     );     );
  
     ok(hfdi_unknown != NULL,"FDICreate (CPU = unknown) (functions=tvfs) failed!\n");      ok(hfdi_simple != NULL,"FDICreate (CPU = unknown) (functions=tvfs) failed!\n");
  
     trace("Ending TestCreate()\n");     trace("Ending TestCreate()\n");
 } }
Line 271 
Line 207 
  
     int fd;     int fd;
  
     FDICABINETINFO  fdi_cabinfo_simple, fdi_cabinfo_complex;      FDICABINETINFO  fdi_cabinfo_simple;
  
     trace("Starting TestInfo()\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, fd, &fdi_cabinfo_simple) == TRUE,      ok( FDIIsCabinet( hfdi_simple, 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);
     CheckCabInfo("simple.cab",fdi_cabinfo_simple,121,1,1,0,0,0,0,0);     CheckCabInfo("simple.cab",fdi_cabinfo_simple,121,1,1,0,0,0,0,0);
  
     tvfs_close(fd);     tvfs_close(fd);
   
     tvfs_create( name_complex_cab, file_complex_cab, size_complex_cab);  
     fd = tvfs_open( name_complex_cab, _O_BINARY, 0 );  
   
     ok( FDIIsCabinet( hfdi_unknown, fd, &fdi_cabinfo_complex) == TRUE,  
     "FDIIsCabinet (Virtual File = Complex.cab) failed!\n");  
   
     printCabInfo(fdi_cabinfo_complex);  
     CheckCabInfo("complex.cab",fdi_cabinfo_complex,12918,1,2,0,0,0,0,0);  
   
     tvfs_close(fd);  
     tvfs_free();     tvfs_free();
  
     trace("Ending TestInfo()\n");     trace("Ending TestInfo()\n");
Line 310 
Line 235 
     trace("---simple.cab\n");     trace("---simple.cab\n");
  
     tvfs_create( name_simple_cab, file_simple_cab, size_simple_cab);     tvfs_create( name_simple_cab, file_simple_cab, size_simple_cab);
     FDICopy(hfdi_unknown,      FDICopy(hfdi_simple,
         "simple.cab",         "simple.cab",
         "",         "",
         0,         0,
Line 325 
Line 250 
         trace ("File %s compare failed!\n",name_file_path);         trace ("File %s compare failed!\n",name_file_path);
     tvfs_free();     tvfs_free();
  
     trace("---complex.cab\n");  
     tvfs_create( name_complex_cab, file_complex_cab, size_complex_cab);  
     FDICopy(hfdi_unknown,  
         "complex.cab",  
         "",  
         0,  
         notification_function,  
         NULL,  
         NULL);  
   
   
     tvfs_free();  
   
     trace("Ending TestCopy()\n");     trace("Ending TestCopy()\n");
 } }
  
 static void TestDestroy(void) { static void TestDestroy(void) {
     trace("Starting TestDestroy()\n");     trace("Starting TestDestroy()\n");
     ok(FDIDestroy(hfdi_unknown), "FDIDestroy (CPU = unknown) (functions=tvfs) failed!\n");      ok(FDIDestroy(hfdi_simple), "FDIDestroy (CPU = unknown) (functions=tvfs) failed!\n");
     trace("Ending TestDestroy()\n");     trace("Ending TestDestroy()\n");
 } }
  


Legend:
Removed from v.2.13  
changed lines
  Added in v.2.15

Rizwan Kassim
Powered by
ViewCVS 0.9.2