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

Diff for /group3/wine/dlls/cabinet/tests/tvfs.c between version 1.11 and 1.12

version 1.11, 2005/03/11 07:38:58 version 1.12, 2005/03/13 12:13:17
Line 19 
Line 19 
 #include <stdio.h> #include <stdio.h>
 #include <stdarg.h> #include <stdarg.h>
  
 /*  
 #define TVFS_MAIN  
 #define TVFS_DEBUG  
 */  
   
 #define SEEK_SET 0 #define SEEK_SET 0
 #define SEEK_CUR 1 #define SEEK_CUR 1
 #define SEEK_END 2 #define SEEK_END 2
Line 32 
Line 27 
 #define _O_BINARY 0 #define _O_BINARY 0
 #endif #endif
  
   
   #undef VERBOSE
   #ifdef TVFS_DEBUG
   #define VERBOSE
   #endif
   
   /*
   Only debug output from tvfs.c IF TVFS_DEBUG is true, not just if VERBOSE is true
   The TVFS debug traces are generally used for debugging TVFS, not cabinet_fdi
   #define TVFS_MAIN
   #define TVFS_DEBUG
   */
   
 #ifndef STANDALONE #ifndef STANDALONE
 #include "wine/test.h" #include "wine/test.h"
 #define ok2 ok #define ok2 ok
 #else #else
 static void trace(const char *s, ...)  #include "standalone.h"
 {  #undef START_TEST
     va_list ellipsis;  
     va_start (ellipsis, s);  
     vprintf(s, ellipsis);  
     va_end(ellipsis);  
 }  
 #endif #endif
  
 struct tvfs_file { struct tvfs_file {
Line 69 
Line 72 
     int inode;     int inode;
     struct tvfs_file *f;     struct tvfs_file *f;
  
 #ifdef TVFS_DEBUG  
     trace("tvfs_create called with %s, %d, %d\n", fname, buf, len);     trace("tvfs_create called with %s, %d, %d\n", fname, buf, len);
 #endif  
  
     if (nfiles >= MAXFILES)     if (nfiles >= MAXFILES)
         return -1;         return -1;
Line 96 
Line 97 
     int inode;     int inode;
     struct tvfs_fcb *handler;     struct tvfs_fcb *handler;
  
 #ifdef TVFS_DEBUG  
     trace("tvfs_open called with %s, %d, %d\n", fname, flags, mode);     trace("tvfs_open called with %s, %d, %d\n", fname, flags, mode);
 #endif  
  
     /* Existing file? */     /* Existing file? */
     for (inode=0; inode<nfiles; inode++) {     for (inode=0; inode<nfiles; inode++) {
Line 112 
Line 111 
         /* File did not exist */         /* File did not exist */
         if ((flags & O_CREAT) == 0) {         if ((flags & O_CREAT) == 0) {
             /* ENOENT */             /* ENOENT */
 #ifdef TVFS_DEBUG  
             trace("tvfs_open returning -1\n");             trace("tvfs_open returning -1\n");
 #endif  
         return -1;         return -1;
         }         }
  
Line 127 
Line 124 
     h = nhandles++;     h = nhandles++;
     handles[h] = handler;     handles[h] = handler;
  
 #ifdef TVFS_DEBUG  
     trace("tvfs_open returning with %d\n", h);     trace("tvfs_open returning with %d\n", h);
 #endif  
  
     return h;     return h;
 } }
Line 140 
Line 135 
     int pos = handles[h]->pos;     int pos = handles[h]->pos;
     int size = files[inode]->bytes_used;     int size = files[inode]->bytes_used;
  
 #ifdef TVFS_DEBUG  
     trace("tvfs_read called with %d, %d, %d\n", h, buf, len);     trace("tvfs_read called with %d, %d, %d\n", h, buf, len);
 #endif  
  
     /* Edge Case 1 : Request beyond boundary of file */     /* Edge Case 1 : Request beyond boundary of file */
     if (pos + len > size) {     if (pos + len > size) {
Line 160 
Line 153 
     int inode;     int inode;
     int handle;     int handle;
  
 #ifdef TVFS_DEBUG  
     trace("tvfs_free\n");     trace("tvfs_free\n");
 #endif  
  
     nfiles=0;     nfiles=0;
     nhandles=0;     nhandles=0;
Line 187 
Line 178 
  
     int inode;     int inode;
  
 #ifdef TVFS_DEBUG  
     trace("tvfs_compare called with %s, %d, %d\n", fname, buf, len);     trace("tvfs_compare called with %s, %d, %d\n", fname, buf, len);
 #endif  
  
     for (inode=0; inode<nfiles; inode++) {     for (inode=0; inode<nfiles; inode++) {
         if (!files[inode])         if (!files[inode])
Line 200 
Line 189 
  
     if (inode == nfiles) {     if (inode == nfiles) {
         /* File did not exist */         /* File did not exist */
 #ifdef TVFS_DEBUG  
         trace("tvfs_compare returning -1 (FAILURE)\n");         trace("tvfs_compare returning -1 (FAILURE)\n");
 #endif  
         return -1;         return -1;
     }     }
  
Line 215 
Line 202 
  
     int inode = handles[h]->inode;     int inode = handles[h]->inode;
     int size = files[inode]->bytes_used;     int size = files[inode]->bytes_used;
 #ifdef TVFS_DEBUG  
     trace("tvfs_lseek called with %d, %d, %d\n", h, whither, whence);     trace("tvfs_lseek called with %d, %d, %d\n", h, whither, whence);
 #endif  
  
 /*  if (whence > size) /*  if (whence > size)
     whence = size;*/     whence = size;*/
Line 240 
Line 225 
     handles[h]->pos = size+whence;     handles[h]->pos = size+whence;
     break;     break;
     }     }
     case 44: {  
     handles[h]->pos = size+whence;  
     break;  
     }  
     default:     default:
     {     {
     trace("lseek was called with an invalid whither %d\n",whither);     trace("lseek was called with an invalid whither %d\n",whither);
Line 253 
Line 234 
     return handles[h]->pos;     return handles[h]->pos;
   }   }
  
 int tvfs_close(int h){  int tvfs_close(int h)
   {
     int inode = handles[h]->inode;     int inode = handles[h]->inode;
 #ifdef TVFS_DEBUG  
     trace("tvfs_close called with %d\n", h);     trace("tvfs_close called with %d\n", h);
 #endif  
     if (!files[inode]){     if (!files[inode]){
     return -1;     return -1;
     }     }
Line 271 
Line 251 
  
     int inode = handles[h]->inode;     int inode = handles[h]->inode;
     int pos = handles[h]->pos;     int pos = handles[h]->pos;
 #ifdef TVFS_DEBUG  
     trace("tvfs_write called with %d, %d, %d\n", h, buf, len);     trace("tvfs_write called with %d, %d, %d\n", h, buf, len);
 #endif  
     memcpy(files[inode]->buf+pos, buf, len);     memcpy(files[inode]->buf+pos, buf, len);
     files[inode]->bytes_used += len;     files[inode]->bytes_used += len;
     handles[h]->pos += len;     handles[h]->pos += len;
Line 294 
Line 272 
 const static char file_test_txt[] = "This is a test. Don't Panic!"; const static char file_test_txt[] = "This is a test. Don't Panic!";
 const static int size_test_txt = sizeof(file_test_txt); const static int size_test_txt = sizeof(file_test_txt);
  
 main(){  main()
   {
     int result;     int result;
     int active_handler;     int active_handler;
  


Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

Rizwan Kassim
Powered by
ViewCVS 0.9.2