[Winpt-commits] r308 - trunk/Src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Mar 23 15:26:31 CET 2007
Author: twoaday
Date: 2007-03-23 15:26:30 +0100 (Fri, 23 Mar 2007)
New Revision: 308
Modified:
trunk/Src/ChangeLog
trunk/Src/wptHTTP.cpp
trunk/Src/wptKeyManager.cpp
Log:
More cleanups.
Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog 2007-03-23 14:14:02 UTC (rev 307)
+++ trunk/Src/ChangeLog 2007-03-23 14:26:30 UTC (rev 308)
@@ -2,6 +2,7 @@
* wptCardDlg.cpp (card_keygen_dlg_proc): Use dynamic
variables to avoid heap operations.
+ * wptKeyManager.cpp (km_http_import): Adjust the http class.
2007-03-21 Timo Schulz <twoaday at gmx.net>
Modified: trunk/Src/wptHTTP.cpp
===================================================================
--- trunk/Src/wptHTTP.cpp 2007-03-23 14:14:02 UTC (rev 307)
+++ trunk/Src/wptHTTP.cpp 2007-03-23 14:26:30 UTC (rev 308)
@@ -1,5 +1,5 @@
/* wptHTTP.cpp - Generic HTTP support
- * Copyright (C) 2004, 2005, 2006 Timo Schulz
+ * Copyright (C) 2004, 2005, 2006, 2007 Timo Schulz
*
* This file is part of WinPT.
*
@@ -54,13 +54,23 @@
wHTTP::wHTTP (const char *_url)
{
reset ();
+ open (_url);
+}
+
+/* Open a connection to the given URL. */
+int
+wHTTP::open (const char *_url)
+{
+ releaseMem ();
+
if (extractHostInfo (_url, &this->host, &this->url))
- return;
-
- /* FIXME: we should throw an exception in case of an error. */
+ return -1;
+
if (!sendRequest (this->host, this->port, this->url))
- parseResponse (&statcode);
+ return parseResponse (&statcode);
+
+ return 0;
}
@@ -549,8 +559,9 @@
}
-/* Destroy HTTP object. */
-wHTTP::~wHTTP (void)
+/* Release all used structures. */
+void
+wHTTP::releaseMem (void)
{
http_head_t h;
@@ -559,13 +570,22 @@
free (resp_headers);
resp_headers = h;
}
+ resp_headers = NULL;
while (req_headers) {
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 ();
if (fd != 0) {
closesocket (fd);
fd = 0;
Modified: trunk/Src/wptKeyManager.cpp
===================================================================
--- trunk/Src/wptKeyManager.cpp 2007-03-23 14:14:02 UTC (rev 307)
+++ trunk/Src/wptKeyManager.cpp 2007-03-23 14:26:30 UTC (rev 308)
@@ -468,7 +468,7 @@
km_http_import (HWND dlg, const char *url)
{
FILE *fp;
- wHTTP *hd;
+ wHTTP hd;
char tmpfile[MAX_PATH+64];
int rc = 0, err = 0;
@@ -486,9 +486,8 @@
}
op_begin ();
- hd = new wHTTP (url);
- if (hd->getStatusCode () == HTTP_STAT_200)
- err = hd->readData (fp);
+ if (!hd.open (url) && hd.getStatusCode () == HTTP_STAT_200)
+ err = hd.readData (fp);
else
err = WPTERR_KEYSERVER_NOTFOUND;
op_end ();
@@ -498,7 +497,6 @@
rc = WPTERR_GENERAL;
}
- delete hd;
fclose (fp);
if (!rc)
km_file_import (dlg, tmpfile, NULL, NULL);
More information about the Winpt-commits
mailing list