Mercurial > octave-nkf
annotate liboctave/util/url-transfer.cc @ 17595:4b65355a31f2
avoid some code duplication in url-transfer ftp methods
* url-transfer.cc (url_transfer::ftp_file_or_dir_action):
New function.
(url_transfer::cwd, url_transfer::del, url_transfer::rmdir,
url_transfer::mkdir): Call ftp_file_or_dir_action.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 07 Oct 2013 21:23:51 -0400 |
parents | d7ca186396d4 |
children | 43b9181340fb |
rev | line source |
---|---|
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3 Copyright (C) 2013 John W. Eaton |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 Copyright (C) 2006-2012 Alexander Barth |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 Copyright (C) 2009 David Bateman |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 This file is part of Octave. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 Octave is free software; you can redistribute it and/or modify it |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 under the terms of the GNU General Public License as published by the |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 Free Software Foundation; either version 3 of the License, or (at your |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 option) any later version. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 Octave is distributed in the hope that it will be useful, but WITHOUT |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 for more details. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 You should have received a copy of the GNU General Public License |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 along with Octave; see the file COPYING. If not, see |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 <http://www.gnu.org/licenses/>. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 */ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 // Author: Alexander Barth <abarth@marine.usf.edu> |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 // Author: jwe |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #ifdef HAVE_CONFIG_H |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include <config.h> |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #endif |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <fstream> |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include <iomanip> |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include <iostream> |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include "dir-ops.h" |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "file-ops.h" |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "file-stat.h" |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include "unwind-prot.h" |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #include "url-transfer.h" |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 #ifdef HAVE_CURL |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 #include <curl/curl.h> |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 #include <curl/curlver.h> |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 #include <curl/easy.h> |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 #endif |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 |
17557
58039875767d
move function definition out of header file
John W. Eaton <jwe@octave.org>
parents:
17555
diff
changeset
|
48 void base_url_transfer::delete_file (const std::string& file) |
58039875767d
move function definition out of header file
John W. Eaton <jwe@octave.org>
parents:
17555
diff
changeset
|
49 { |
58039875767d
move function definition out of header file
John W. Eaton <jwe@octave.org>
parents:
17555
diff
changeset
|
50 octave_unlink (file); |
58039875767d
move function definition out of header file
John W. Eaton <jwe@octave.org>
parents:
17555
diff
changeset
|
51 } |
58039875767d
move function definition out of header file
John W. Eaton <jwe@octave.org>
parents:
17555
diff
changeset
|
52 |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 void |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 base_url_transfer::mget_directory (const std::string& directory, |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 const std::string& target) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 std::string sep = file_ops::dir_sep_str (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 file_stat fs (directory); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 if (!fs || !fs.is_dir ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 std::string msg; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 int status = octave_mkdir (directory, 0777, msg); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 if (status < 0) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 ok = false; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 errmsg = "__ftp_mget__: can not create directory '" |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 + target + sep + directory + "': " + msg; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 return; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 cwd (directory); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 if (good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 unwind_protect_safe frame; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 frame.add_fcn (reset_path, this); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 string_vector sv = list (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 for (octave_idx_type i = 0; i < sv.length (); i++) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 time_t ftime; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 bool fisdir; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 double fsize; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 get_fileinfo (sv(i), fsize, ftime, fisdir); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 if (fisdir) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 mget_directory (sv(i), target + directory + sep); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 else |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 std::string realfile = target + directory + sep + sv(i); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 std::ofstream ofile (realfile.c_str (), |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 std::ios::out | std::ios::binary); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 if (! ofile.is_open ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 ok = false; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 errmsg = "__ftp_mget__: unable to open file"; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 break; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 unwind_protect_safe frame2; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 frame2.add_fcn (delete_file, realfile); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
112 get (sv(i), ofile); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
114 ofile.close (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 if (good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 frame2.discard (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 if (! good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 break; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
124 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 string_vector |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 base_url_transfer::mput_directory (const std::string& base, |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 const std::string& directory) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 string_vector file_list; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 std::string realdir |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 = (base.length () == 0 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 ? directory : base + file_ops::dir_sep_str () + directory); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 mkdir (directory); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 if (! good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 return file_list; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 cwd (directory); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
142 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 if (good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
144 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
145 unwind_protect_safe frame; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 frame.add_fcn (reset_path, this); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
148 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 dir_entry dirlist (realdir); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 if (dirlist) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
153 string_vector files = dirlist.read (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 for (octave_idx_type i = 0; i < files.length (); i++) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 std::string file = files (i); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 if (file == "." || file == "..") |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
160 continue; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 std::string realfile = realdir + file_ops::dir_sep_str () + file; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
163 file_stat fs (realfile); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 if (! fs.exists ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 ok = false; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 errmsg = "__ftp__mput: file '" + realfile |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 + "' does not exist"; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
170 break; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 if (fs.is_dir ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
174 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 file_list.append (mput_directory (realdir, file)); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
176 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 if (! good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 break; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 else |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
181 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 // FIXME Does ascii mode need to be flagged here? |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 std::ifstream ifile (realfile.c_str (), std::ios::in | |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
184 std::ios::binary); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
185 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
186 if (! ifile.is_open ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
187 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 ok = false; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 errmsg = "__ftp_mput__: unable to open file '" |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 + realfile + "'"; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
191 break; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 put (file, ifile); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
195 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 ifile.close (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 if (! good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 break; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
200 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 file_list.append (realfile); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
204 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 else |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 ok = false; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 errmsg = "__ftp_mput__: can not read the directory '" |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 + realdir + "'"; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
210 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
214 #if defined (HAVE_CURL) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 static int |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 write_data (void *buffer, size_t size, size_t nmemb, void *streamp) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 std::ostream& stream = *(static_cast<std::ostream*> (streamp)); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 stream.write (static_cast<const char*> (buffer), size*nmemb); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
221 return (stream.fail () ? 0 : size * nmemb); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
224 static int |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 read_data (void *buffer, size_t size, size_t nmemb, void *streamp) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
226 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
227 std::istream& stream = *(static_cast<std::istream*> (streamp)); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
228 stream.read (static_cast<char*> (buffer), size*nmemb); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
229 if (stream.eof ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 return stream.gcount (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
231 else |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 return (stream.fail () ? 0 : size * nmemb); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
233 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
235 static size_t |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
236 throw_away (void *, size_t size, size_t nmemb, void *) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
238 return static_cast<size_t>(size * nmemb); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
239 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 // I'd love to rewrite this as a private method of the url_transfer |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 // class, but you can't pass the va_list from the wrapper SETOPT to |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 // the curl_easy_setopt function. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 #define SETOPT(option, parameter) \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 do \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 { \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 CURLcode res = curl_easy_setopt (curl, option, parameter); \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 if (res != CURLE_OK) \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
249 { \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 ok = false; \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
251 errmsg = curl_easy_strerror (res); \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 return; \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 } \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 } \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 while (0) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
257 // Same as above but with a return value. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
258 #define SETOPTR(option, parameter) \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 do \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 { \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 CURLcode res = curl_easy_setopt (curl, option, parameter); \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 if (res != CURLE_OK) \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
263 { \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
264 ok = false; \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
265 errmsg = curl_easy_strerror (res); \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
266 return retval; \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
267 } \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
268 } \ |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
269 while (0) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
270 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
271 class curl_transfer : public base_url_transfer |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
272 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
273 public: |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
274 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
275 curl_transfer (void) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
276 : base_url_transfer (), curl (curl_easy_init ()), errnum () |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
277 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
278 if (curl) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
279 valid = true; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
280 else |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 errmsg = "can not create curl object"; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
283 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
284 curl_transfer (const std::string& host_arg, const std::string& user_arg, |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
285 const std::string& passwd, std::ostream& os) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
286 : base_url_transfer (host_arg, user_arg, passwd, os), |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 curl (curl_easy_init ()), errnum () |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
288 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
289 if (curl) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
290 valid = true; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
291 else |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
292 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
293 errmsg = "can not create curl object"; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
294 return; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
295 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
296 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
297 init (user_arg, passwd, std::cin, os); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
298 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
299 std::string url ("ftp://" + host_arg); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
300 SETOPT (CURLOPT_URL, url.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
301 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
302 // Setup the link, with no transfer. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
303 perform (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
305 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
306 curl_transfer (const std::string& url, const std::string& method, |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
307 const Array<std::string>& param, std::ostream& os) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
308 : base_url_transfer (url, method, param, os), |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
309 curl (curl_easy_init ()), errnum () |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
310 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
311 if (curl) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
312 valid = true; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
313 else |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
314 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
315 errmsg = "can not create curl object"; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
316 return; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
317 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
318 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
319 init ("", "", std::cin, os); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
320 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
321 SETOPT (CURLOPT_NOBODY, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
322 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
323 // Restore the default HTTP request method to GET after setting |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
324 // NOBODY to true and back to false. This is needed for backward |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
325 // compatibility with versions of libcurl < 7.18.2. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
326 SETOPT (CURLOPT_HTTPGET, 1); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
328 // Don't need to store the parameters here as we can't change |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
329 // the URL after the object is created |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
330 std::string query_string = form_query_string (param); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
331 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
332 if (method == "get") |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
333 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
334 query_string = url + "?" + query_string; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
335 SETOPT (CURLOPT_URL, query_string.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
336 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 else if (method == "post") |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
338 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
339 SETOPT (CURLOPT_URL, url.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
340 SETOPT (CURLOPT_POSTFIELDS, query_string.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
341 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
342 else |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
343 SETOPT (CURLOPT_URL, url.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
344 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
345 perform (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
346 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
347 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
348 ~curl_transfer (void) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
349 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
350 if (curl) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
351 curl_easy_cleanup (curl); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
352 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
353 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
354 void perform (void) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
355 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
356 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
357 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
358 errnum = curl_easy_perform (curl); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
359 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
360 if (errnum != CURLE_OK) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
361 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
362 ok = false; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
363 errmsg = curl_easy_strerror (errnum); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
364 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
365 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
366 END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
367 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
368 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
369 std::string lasterror (void) const |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
370 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
371 return std::string (curl_easy_strerror (errnum)); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
372 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
373 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
374 std::ostream& set_ostream (std::ostream& os) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
375 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
376 std::ostream& retval = *curr_ostream; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
377 curr_ostream = &os; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
378 SETOPTR (CURLOPT_WRITEDATA, static_cast<void*> (curr_ostream)); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
379 return retval; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
380 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
381 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
382 std::istream& set_istream (std::istream& is) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
383 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
384 std::istream& retval = *curr_istream; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
385 curr_istream = &is; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
386 SETOPTR (CURLOPT_READDATA, static_cast<void*> (curr_istream)); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
387 return retval; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
388 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
389 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
390 void ascii (void) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
391 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
392 ascii_mode = true; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
393 SETOPT (CURLOPT_TRANSFERTEXT, 1); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
394 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
395 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
396 void binary (void) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
397 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
398 ascii_mode = false; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
399 SETOPT (CURLOPT_TRANSFERTEXT, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
400 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
401 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
402 void cwd (const std::string& path) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
403 { |
17595
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
404 ftp_file_or_dir_action (path, "cwd"); |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
405 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
406 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
407 void del (const std::string& file) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
408 { |
17595
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
409 ftp_file_or_dir_action (file, "dele"); |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
410 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
411 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
412 void rmdir (const std::string& path) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
413 { |
17595
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
414 ftp_file_or_dir_action (path, "rmd"); |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
415 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
416 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
417 void mkdir (const std::string& path) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
418 { |
17595
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
419 ftp_file_or_dir_action (path, "mkd"); |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
420 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
421 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 void rename (const std::string& oldname, const std::string& newname) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
423 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
424 struct curl_slist *slist = 0; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
425 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
426 unwind_protect frame; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
427 frame.add_fcn (curl_slist_free_all, slist); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
428 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
429 std::string cmd = "rnfr " + oldname; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
430 slist = curl_slist_append (slist, cmd.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
431 cmd = "rnto " + newname; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
432 slist = curl_slist_append (slist, cmd.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
433 SETOPT (CURLOPT_POSTQUOTE, slist); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
434 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
435 perform (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
436 if (! good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
437 return; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
438 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
439 SETOPT (CURLOPT_POSTQUOTE, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
440 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
441 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
442 void put (const std::string& file, std::istream& is) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
443 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
444 std::string url = "ftp://" + host + "/" + file; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
445 SETOPT (CURLOPT_URL, url.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
446 SETOPT (CURLOPT_UPLOAD, 1); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
447 SETOPT (CURLOPT_NOBODY, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
448 std::istream& old_is = set_istream (is); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
449 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
450 perform (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
451 if (! good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
452 return; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
453 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
454 set_istream (old_is); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
455 SETOPT (CURLOPT_NOBODY, 1); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
456 SETOPT (CURLOPT_UPLOAD, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
457 url = "ftp://" + host; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
458 SETOPT (CURLOPT_URL, url.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
459 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
460 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
461 void get (const std::string& file, std::ostream& os) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
462 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
463 std::string url = "ftp://" + host + "/" + file; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
464 SETOPT (CURLOPT_URL, url.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
465 SETOPT (CURLOPT_NOBODY, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
466 std::ostream& old_os = set_ostream (os); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
467 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
468 perform (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
469 if (! good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
470 return; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
471 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
472 set_ostream (old_os); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
473 SETOPT (CURLOPT_NOBODY, 1); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
474 url = "ftp://" + host; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
475 SETOPT (CURLOPT_URL, url.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
476 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
477 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
478 void dir (void) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
479 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
480 std::string url = "ftp://" + host + "/"; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
481 SETOPT (CURLOPT_URL, url.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
482 SETOPT (CURLOPT_NOBODY, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
483 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
484 perform (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
485 if (! good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
486 return; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
487 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
488 SETOPT (CURLOPT_NOBODY, 1); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
489 url = "ftp://" + host; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
490 SETOPT (CURLOPT_URL, url.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
491 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
492 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
493 string_vector list (void) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
494 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
495 string_vector retval; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
496 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
497 std::ostringstream buf; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
498 std::string url = "ftp://" + host + "/"; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
499 SETOPTR (CURLOPT_WRITEDATA, static_cast<void*> (&buf)); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
500 SETOPTR (CURLOPT_URL, url.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
501 SETOPTR (CURLOPT_DIRLISTONLY, 1); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
502 SETOPTR (CURLOPT_NOBODY, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
503 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
504 perform (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
505 if (! good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
506 return retval; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
507 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
508 SETOPTR (CURLOPT_NOBODY, 1); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
509 url = "ftp://" + host; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
510 SETOPTR (CURLOPT_WRITEDATA, static_cast<void*> (curr_ostream)); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
511 SETOPTR (CURLOPT_DIRLISTONLY, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
512 SETOPTR (CURLOPT_URL, url.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
513 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
514 // Count number of directory entries |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
515 std::string str = buf.str (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
516 octave_idx_type n = 0; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
517 size_t pos = 0; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
518 while (true) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
519 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
520 pos = str.find_first_of ('\n', pos); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
521 if (pos == std::string::npos) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
522 break; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
523 pos++; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
524 n++; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
525 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
526 retval.resize (n); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
527 pos = 0; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
528 for (octave_idx_type i = 0; i < n; i++) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
529 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
530 size_t newpos = str.find_first_of ('\n', pos); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
531 if (newpos == std::string::npos) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
532 break; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
533 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
534 retval(i) = str.substr(pos, newpos - pos); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
535 pos = newpos + 1; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
536 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
537 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
538 return retval; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
540 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
541 void get_fileinfo (const std::string& filename, double& filesize, |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
542 time_t& filetime, bool& fileisdir) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
543 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
544 std::string path = pwd (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
545 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
546 std::string url = "ftp://" + host + "/" + path + "/" + filename; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
547 SETOPT (CURLOPT_URL, url.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
548 SETOPT (CURLOPT_FILETIME, 1); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
549 SETOPT (CURLOPT_HEADERFUNCTION, throw_away); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
550 SETOPT (CURLOPT_WRITEFUNCTION, throw_away); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
551 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
552 // FIXME |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
553 // The MDTM command fails for a directory on the servers I tested |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
554 // so this is a means of testing for directories. It also means |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
555 // I can't get the date of directories! |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
556 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
557 perform (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
558 if (! good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
559 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
560 fileisdir = true; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
561 filetime = -1; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
562 filesize = 0; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
563 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
564 return; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
565 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
566 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
567 fileisdir = false; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
568 time_t ft; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
569 curl_easy_getinfo (curl, CURLINFO_FILETIME, &ft); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
570 filetime = ft; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
571 double fs; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
572 curl_easy_getinfo (curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &fs); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
573 filesize = fs; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
574 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
575 SETOPT (CURLOPT_WRITEFUNCTION, write_data); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
576 SETOPT (CURLOPT_HEADERFUNCTION, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
577 SETOPT (CURLOPT_FILETIME, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
578 url = "ftp://" + host; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
579 SETOPT (CURLOPT_URL, url.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
580 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
581 // The MDTM command seems to reset the path to the root with the |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
582 // servers I tested with, so cd again into the correct path. Make |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
583 // the path absolute so that this will work even with servers that |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
584 // don't end up in the root after an MDTM command. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
585 cwd ("/" + path); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
586 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
587 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
588 std::string pwd (void) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
589 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
590 std::string retval; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
591 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
592 struct curl_slist *slist = 0; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
593 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
594 unwind_protect frame; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
595 frame.add_fcn (curl_slist_free_all, slist); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
596 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
597 slist = curl_slist_append (slist, "pwd"); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
598 SETOPTR (CURLOPT_POSTQUOTE, slist); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
599 SETOPTR (CURLOPT_HEADERFUNCTION, write_data); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
600 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
601 std::ostringstream buf; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
602 SETOPTR (CURLOPT_WRITEHEADER, static_cast<void *>(&buf)); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
603 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
604 perform (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
605 if (! good ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
606 return retval; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
607 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
608 retval = buf.str (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
609 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
610 // Can I assume that the path is alway in "" on the last line |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
611 size_t pos2 = retval.rfind ('"'); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
612 size_t pos1 = retval.rfind ('"', pos2 - 1); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
613 retval = retval.substr (pos1 + 1, pos2 - pos1 - 1); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
614 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
615 SETOPTR (CURLOPT_HEADERFUNCTION, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
616 SETOPTR (CURLOPT_WRITEHEADER, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
617 SETOPTR (CURLOPT_POSTQUOTE, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
618 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
619 return retval; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
620 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
621 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
622 private: |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
623 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
624 CURL *curl; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
625 CURLcode errnum; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
626 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
627 // No copying! |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
628 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
629 curl_transfer (const curl_transfer&); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
630 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
631 curl_transfer& operator = (const curl_transfer&); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
632 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
633 void init (const std::string& user, const std::string& passwd, |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
634 std::istream& is, std::ostream& os) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
635 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
636 // No data transfer by default |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
637 SETOPT (CURLOPT_NOBODY, 1); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
638 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
639 // Set the username and password |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
640 userpwd = user; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
641 if (! passwd.empty ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
642 userpwd += ":" + passwd; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
643 if (! userpwd.empty ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
644 SETOPT (CURLOPT_USERPWD, userpwd.c_str ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
645 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
646 // Define our callback to get called when there's data to be written. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
647 SETOPT (CURLOPT_WRITEFUNCTION, write_data); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
648 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
649 // Set a pointer to our struct to pass to the callback. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
650 SETOPT (CURLOPT_WRITEDATA, static_cast<void*> (&os)); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
651 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
652 // Define our callback to get called when there's data to be read |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
653 SETOPT (CURLOPT_READFUNCTION, read_data); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
654 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
655 // Set a pointer to our struct to pass to the callback. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
656 SETOPT (CURLOPT_READDATA, static_cast<void*> (&is)); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
657 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
658 // Follow redirects. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
659 SETOPT (CURLOPT_FOLLOWLOCATION, true); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
660 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
661 // Don't use EPSV since connecting to sites that don't support it |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
662 // will hang for some time (3 minutes?) before moving on to try PASV |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
663 // instead. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
664 SETOPT (CURLOPT_FTP_USE_EPSV, false); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
665 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
666 SETOPT (CURLOPT_NOPROGRESS, true); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
667 SETOPT (CURLOPT_FAILONERROR, true); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
668 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
669 SETOPT (CURLOPT_POSTQUOTE, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
670 SETOPT (CURLOPT_QUOTE, 0); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
671 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
672 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
673 std::string form_query_string (const Array<std::string>& param) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
674 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
675 std::ostringstream query; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
676 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
677 for (int i = 0; i < param.numel (); i += 2) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
678 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
679 std::string name = param(i); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
680 std::string text = param(i+1); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
681 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
682 // Encode strings. |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
683 char *enc_name = curl_easy_escape (curl, name.c_str (), |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
684 name.length ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
685 char *enc_text = curl_easy_escape (curl, text.c_str (), |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
686 text.length ()); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
687 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
688 query << enc_name << "=" << enc_text; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
689 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
690 curl_free (enc_name); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
691 curl_free (enc_text); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
692 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
693 if (i < param.numel ()-1) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
694 query << "&"; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
695 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
696 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
697 query.flush (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
698 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
699 return query.str (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
700 } |
17595
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
701 |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
702 void ftp_file_or_dir_action (const std::string& file_or_dir, |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
703 const std::string& action) |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
704 { |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
705 struct curl_slist *slist = 0; |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
706 |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
707 unwind_protect frame; |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
708 |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
709 frame.add_fcn (curl_slist_free_all, slist); |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
710 |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
711 std::string cmd = action + " " + file_or_dir; |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
712 |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
713 slist = curl_slist_append (slist, cmd.c_str ()); |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
714 |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
715 SETOPT (CURLOPT_POSTQUOTE, slist); |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
716 |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
717 perform (); |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
718 |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
719 if (! good ()) |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
720 return; |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
721 |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
722 SETOPT (CURLOPT_POSTQUOTE, 0); |
4b65355a31f2
avoid some code duplication in url-transfer ftp methods
John W. Eaton <jwe@octave.org>
parents:
17563
diff
changeset
|
723 } |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
724 }; |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
725 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
726 #undef SETOPT |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
727 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
728 #else |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
729 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
730 static void |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
731 disabled_error (void) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
732 { |
17563
d7ca186396d4
Fix compilation error when building without curl
Mike Miller <mtmiller@ieee.org>
parents:
17557
diff
changeset
|
733 (*current_liboctave_error_handler) |
d7ca186396d4
Fix compilation error when building without curl
Mike Miller <mtmiller@ieee.org>
parents:
17557
diff
changeset
|
734 ("support for url transfers was disabled when Octave was built"); |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
735 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
736 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
737 #endif |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
738 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
739 #if defined (HAVE_CURL) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
740 # define REP_CLASS curl_transfer |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
741 #else |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
742 # define REP_CLASS base_url_transfer |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
743 #endif |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
744 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
745 url_transfer::url_transfer (void) : rep (new REP_CLASS ()) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
746 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
747 #if !defined (HAVE_CURL) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
748 disabled_error (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
749 #endif |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
750 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
751 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
752 url_transfer::url_transfer (const std::string& host, const std::string& user, |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
753 const std::string& passwd, std::ostream& os) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
754 : rep (new REP_CLASS (host, user, passwd, os)) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
755 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
756 #if !defined (HAVE_CURL) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
757 disabled_error (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
758 #endif |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
759 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
760 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
761 url_transfer::url_transfer (const std::string& url, const std::string& method, |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
762 const Array<std::string>& param, std::ostream& os) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
763 : rep (new REP_CLASS (url, method, param, os)) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
764 { |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
765 #if !defined (HAVE_CURL) |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
766 disabled_error (); |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
767 #endif |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
768 } |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
769 |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
770 #undef REP_CLASS |