[Winpt-commits] r310 - trunk/Src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat Apr 7 13:07:21 CEST 2007


Author: twoaday
Date: 2007-04-07 13:07:20 +0200 (Sat, 07 Apr 2007)
New Revision: 310

Modified:
   trunk/Src/wptErrors.cpp
   trunk/Src/wptFileStatDlg.cpp
   trunk/Src/wptHTTP.cpp
   trunk/Src/wptKeyPropsDlg.cpp
Log:


Modified: trunk/Src/wptErrors.cpp
===================================================================
--- trunk/Src/wptErrors.cpp	2007-04-07 11:07:07 UTC (rev 309)
+++ trunk/Src/wptErrors.cpp	2007-04-07 11:07:20 UTC (rev 310)
@@ -12,12 +12,7 @@
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License 
- * along with WinPT; if not, write to the Free Software Foundation, 
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
  */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -43,8 +38,6 @@
     char *path;
 
     path = get_gnupg_path ();
-    if (!path)
-	BUG (NULL);
     switch (errid) {
     case WPTERR_GPG_EXEFILE:
 	_snprintf (buf, DIM (buf) - 1, 
@@ -63,7 +56,7 @@
 
 
 static void 
-w32_fmt_msg (char *buf, size_t buflen)
+w32_fmt_msg (char *buf, DWORD buflen)
 {
     FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (), 
 		   MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), 

Modified: trunk/Src/wptFileStatDlg.cpp
===================================================================
--- trunk/Src/wptFileStatDlg.cpp	2007-04-07 11:07:07 UTC (rev 309)
+++ trunk/Src/wptFileStatDlg.cpp	2007-04-07 11:07:20 UTC (rev 310)
@@ -24,6 +24,7 @@
 #include <windows.h>
 #include <time.h>
 #include <sys/types.h>
+#include <assert.h>
 
 #include "resource.h"
 #include "wptTypes.h"
@@ -42,7 +43,7 @@
 const char*
 get_fmt_date (long timest)
 {
-    static char buf[64];
+    static char buf[128];
 
     get_locale_date (timest, buf, DIM (buf)-1);
     return buf;
@@ -275,8 +276,7 @@
     switch (msg) {
     case WM_INITDIALOG:        
         file = (const char*)lparam;
-	if (!file)
-	    BUG (0);
+	assert (file != NULL);
 	if (do_list_packets (GetDlgItem (dlg, IDC_FILE_STAT_LIST), file) < 1) {
 	    msg_box (dlg, _("No valid OpenPGP data found."), 
 		     _("File Status"), MB_ERR);

Modified: trunk/Src/wptHTTP.cpp
===================================================================
--- trunk/Src/wptHTTP.cpp	2007-04-07 11:07:07 UTC (rev 309)
+++ trunk/Src/wptHTTP.cpp	2007-04-07 11:07:20 UTC (rev 310)
@@ -62,8 +62,13 @@
 int
 wHTTP::open (const char *_url)
 {
-    releaseMem ();
+    /* In case the function is used more than once, we
+       need to release the old structures first. */
+    releaseHeaders ();
     
+    safe_free (this->host);
+    safe_free (this->url);
+    
     if (extractHostInfo (_url, &this->host, &this->url))
 	return -1;
     
@@ -101,9 +106,9 @@
     err = extractHostInfo (_url, &this->host, &this->url);
     if (err)
 	return err;
+    
     method = HTTP_HEAD;
-
-    if (!sendRequest (host, port, url))
+    if (!sendRequest (this->host, this->port, this->url))
 	parseResponse (&statcode);
 
     return 0;
@@ -116,8 +121,8 @@
 {
     int err;
 
-    safe_free (host);
-    safe_free (url);
+    safe_free (this->host);
+    safe_free (this->url);
 
     err = extractHostInfo (_url, &this->host, &this->url);
     if (err)
@@ -552,40 +557,37 @@
 	resp_headers = n;
     }
     resp_headers = NULL;
-    rc = parseHeaders (&resp_headers);
-    if (rc)
-	return rc;
-    return 0;
+    return parseHeaders (&resp_headers);
 }
 
 
 /* Release all used structures. */
 void
-wHTTP::releaseMem (void)
+wHTTP::releaseHeaders (void)
 {
     http_head_t h;
     
-    while (resp_headers) {
+    while (resp_headers != NULL) {
 	h = resp_headers->next;
 	free (resp_headers);
 	resp_headers = h;
     }
     resp_headers = NULL;
-    while (req_headers) {
+    while (req_headers != NULL) {
 	h = req_headers->next;
 	free (req_headers);
 	req_headers = h;
     }
     req_headers = NULL;
-    safe_free (url);
-    safe_free (host);
 }
 
 
 /* Destroy HTTP object. */
 wHTTP::~wHTTP (void)
 {
-    releaseMem ();
+    releaseHeaders();
+    safe_free (host);
+    safe_free (url);
     if (fd != 0) {
 	closesocket (fd);
 	fd = 0;

Modified: trunk/Src/wptKeyPropsDlg.cpp
===================================================================
--- trunk/Src/wptKeyPropsDlg.cpp	2007-04-07 11:07:07 UTC (rev 309)
+++ trunk/Src/wptKeyPropsDlg.cpp	2007-04-07 11:07:20 UTC (rev 310)
@@ -115,8 +115,7 @@
     winpt_key_s k;
     FILE *fp;
     const BYTE *img;
-    DWORD imglen = 0;
-    int pos=0;
+    DWORD imglen;
 
     if (winpt_get_pubkey (key->subkeys->keyid, &k))
 	BUG (0);
@@ -134,7 +133,7 @@
 
     fp = fopen (get_photo_tmpname (dlg), "wb");
     if (fp) {
-	pos += 16;
+	const int pos = 16;
 	fwrite (img + pos, 1, imglen - pos, fp);
 	fclose (fp);
     }
@@ -291,6 +290,7 @@
     gpgme_validity_t valid;
 
     winpt_key_t k = (winpt_key_t)lparam;
+    assert (k != NULL);
     SetWindowText (dlg, _("Key Properties"));
     SetDlgItemText (dlg, IDC_KEYPROPS_OT_CHANGE, _("&Change"));
     SetDlgItemText (dlg, IDC_KEYPROPS_REVOKERS, _("&Revokers"));



More information about the Winpt-commits mailing list