/[winpt]/trunk/Src/wptFileCBS.cpp
ViewVC logotype

Diff of /trunk/Src/wptFileCBS.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 218 by twoaday, Mon Apr 10 07:38:06 2006 UTC revision 219 by twoaday, Sat May 27 08:56:00 2006 UTC
# Line 26  Line 26 
26  #include <windows.h>  #include <windows.h>
27  #include <stdio.h>  #include <stdio.h>
28  #include <errno.h>  #include <errno.h>
 #include <malloc.h>  
29    
 #include "gpgme.h"  
30  #include "wptListView.h"  #include "wptListView.h"
31  #include "wptGPG.h"  #include "wptGPG.h"
32  #include "wptFileManager.h"  #include "wptFileManager.h"
33  #include "wptErrors.h"  #include "wptErrors.h"
34  #include "wptTypes.h"  #include "wptTypes.h"
35    #include "wptW32API.h"
36    
37  void progress_callback (void *opaque, const char *what, int type,  void progress_callback (void *opaque, const char *what, int type,
38                          int off, int max);                          int off, int max);
# Line 50  read_cb (void *handle, void *buffer, siz Line 49  read_cb (void *handle, void *buffer, siz
49      if (cb->error)      if (cb->error)
50          return -1;          return -1;
51    
52      if (!ReadFile (cb->handle, buffer, size, &nread, NULL)) {      if (!ReadFile (cb->handle, buffer, size, &nread, NULL)) {  
53          cb->error = (int)GetLastError ();          cb->error = (int)GetLastError ();
54            log_debug ("read_cb: ReadFile() error=%d\r\n", cb->error);
55          return -1;          return -1;
56      }      }
57    
# Line 83  write_cb (void *handle, const void *buff Line 83  write_cb (void *handle, const void *buff
83                                   &sec_attr, CREATE_ALWAYS, 0, NULL);                                   &sec_attr, CREATE_ALWAYS, 0, NULL);
84          if (cb->handle == INVALID_HANDLE_VALUE) {          if (cb->handle == INVALID_HANDLE_VALUE) {
85              cb->error = (int)GetLastError ();              cb->error = (int)GetLastError ();
86                log_debug ("write_cb: CreateFile() error=%d\r\n", cb->error);
87              return -1;              return -1;
88          }          }
89      }      }
90    
91      if (!WriteFile (cb->handle, buffer, size, &nwritten, NULL)) {      if (!WriteFile (cb->handle, buffer, size, &nwritten, NULL)) {
92          cb->error = (int)GetLastError ();          cb->error = (int)GetLastError ();
93            log_debug ("write_cb: WriteFile() error=%d\r\n", cb->error);
94          return -1;          return -1;
95      }      }
96      return (long)nwritten;      return (long)nwritten;
# Line 115  gpg_file_data_new (const char *fname, in Line 117  gpg_file_data_new (const char *fname, in
117      if (flags & F_DATA_READ) {      if (flags & F_DATA_READ) {
118          fd = CreateFile (fname, GENERIC_READ, FILE_SHARE_READ,          fd = CreateFile (fname, GENERIC_READ, FILE_SHARE_READ,
119                           &sec_attr, OPEN_EXISTING, 0, NULL);                           &sec_attr, OPEN_EXISTING, 0, NULL);
120          if (fd == INVALID_HANDLE_VALUE)          if (fd == INVALID_HANDLE_VALUE) {
121                log_debug ("gpg_file_data_new: CreateFile() error=%d\r\n",
122                           (int)GetLastError ());
123              return gpgme_err_code_from_errno (ENOENT);              return gpgme_err_code_from_errno (ENOENT);
124            }
125      }      }
126      cb = (file_data_t)calloc (1, sizeof *cb);      cb = new file_data_s;
127      if (!cb)      if (!cb)
128          BUG (NULL);          BUG (NULL);
129      cb->name = strdup (fname);      memset (cb, 0, sizeof *cb);
130      if (!cb->name)      cb->name = m_strdup (fname);
         BUG (NULL);  
131      cb->cbs.read = read_cb;      cb->cbs.read = read_cb;
132      cb->cbs.write = write_cb;      cb->cbs.write = write_cb;
133      if (flags & F_DATA_READ) {      if (flags & F_DATA_READ) {
# Line 135  gpg_file_data_new (const char *fname, in Line 139  gpg_file_data_new (const char *fname, in
139      err = gpgme_data_new_from_cbs  (&cb->dat, &cb->cbs, cb);      err = gpgme_data_new_from_cbs  (&cb->dat, &cb->cbs, cb);
140      if (err) {      if (err) {
141          CloseHandle (fd);          CloseHandle (fd);
142          free (cb);          free_if_alloc (cb);
143          return err;          return err;
144      }      }
145    
# Line 164  gpg_file_data_release (file_data_t cb) Line 168  gpg_file_data_release (file_data_t cb)
168      }      }
169      if (cb->dat)      if (cb->dat)
170          gpgme_data_release (cb->dat);          gpgme_data_release (cb->dat);
171      safe_free (cb->name);      free_if_alloc (cb->name);
172      safe_free (cb);      free_if_alloc (cb);
173  }  }

Legend:
Removed from v.218  
changed lines
  Added in v.219

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26