조성현

중간저장2

...@@ -2,11 +2,23 @@ ...@@ -2,11 +2,23 @@
2 #include "curl_processor.h" 2 #include "curl_processor.h"
3 3
4 4
5 +//////////////////////////////////////////////////////////////////
6 +// constructor, destructor
7 +//////////////////////////////////////////////////////////////////
5 curl_processor::curl_processor() 8 curl_processor::curl_processor()
6 { 9 {
10 + curl = curl_easy_init();
11 + if (!curl) {
12 + throw std::exception("failed to make curl object");
13 + }
7 } 14 }
8 15
9 -
10 curl_processor::~curl_processor() 16 curl_processor::~curl_processor()
11 { 17 {
18 + curl_easy_cleanup(curl);
12 } 19 }
20 +
21 +
22 +//////////////////////////////////////////////////////////////////
23 +// methods
24 +//////////////////////////////////////////////////////////////////
......
...@@ -15,7 +15,7 @@ public: ...@@ -15,7 +15,7 @@ public:
15 curl_processor(); 15 curl_processor();
16 ~curl_processor(); 16 ~curl_processor();
17 17
18 - //method 18 + //methods
19 public: 19 public:
20 20
21 }; 21 };
......
...@@ -4,6 +4,29 @@ ...@@ -4,6 +4,29 @@
4 4
5 int main(int argc, char *argv[]) 5 int main(int argc, char *argv[])
6 { 6 {
7 + if (1) {
8 + CURL *curl;
9 + CURLcode res;
10 +
11 + curl = curl_easy_init();
12 + if (curl) {
13 + curl_easy_setopt(curl, CURLOPT_URL, "http://dblp.uni-trier.de/rec/bib/conf/sbrn/WedemannCD06");
14 + /* example.com is redirected, so we tell libcurl to follow redirection */
15 + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
16 +
17 + /* Perform the request, res will get the return code */
18 + res = curl_easy_perform(curl);
19 + /* Check for errors */
20 + if (res != CURLE_OK)
21 + fprintf(stderr, "curl_easy_perform() failed: %s\n",
22 + curl_easy_strerror(res));
23 +
24 + /* always cleanup */
25 + curl_easy_cleanup(curl);
26 + }
27 + return 0;
28 + }
29 +
7 QApplication app(argc, argv); 30 QApplication app(argc, argv);
8 31
9 MainWindow m; 32 MainWindow m;
......