Mercurial > octave-nkf
annotate libinterp/corefcn/urlwrite.cc @ 17861:870f3e12e163
maint: Use phrase "FIXME:" for problem areas in code.
* libinterp/corefcn/betainc.cc, libinterp/corefcn/bitfcns.cc,
libinterp/corefcn/display.cc, libinterp/corefcn/gammainc.cc,
libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/graphics.cc,
libinterp/corefcn/load-save.cc, libinterp/corefcn/ls-hdf5.cc,
libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/ls-oct-binary.cc,
libinterp/corefcn/luinc.cc, libinterp/corefcn/mex.cc,
libinterp/corefcn/regexp.cc, libinterp/corefcn/sighandlers.cc,
libinterp/corefcn/sparse-xpow.cc, libinterp/corefcn/urlwrite.cc,
libinterp/corefcn/variables.cc, libinterp/dldfcn/__init_fltk__.cc,
libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/chol.cc,
libinterp/octave-value/ov-bool-sparse.cc,
libinterp/octave-value/ov-fcn-inline.cc,
libinterp/octave-value/ov-flt-re-mat.cc, libinterp/octave-value/ov-re-mat.cc,
libinterp/octave-value/ov-str-mat.cc, libinterp/parse-tree/lex.ll,
liboctave/numeric/SparseCmplxQR.cc, liboctave/numeric/SparseQR.cc,
liboctave/numeric/sparse-dmsolve.cc, liboctave/util/lo-utils.cc,
liboctave/util/sparse-util.cc, liboctave/util/url-transfer.cc:
maint: Use phrase "FIXME:" for problem areas in code.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 06 Nov 2013 11:42:35 -0800 |
parents | 175b392e91fe |
children | 9a43d8d6e29e |
rev | line source |
---|---|
6043 | 1 // urlwrite and urlread, a curl front-end for octave |
2 /* | |
3 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17596
diff
changeset
|
4 Copyright (C) 2006-2013 Alexander Barth |
9880 | 5 Copyright (C) 2009 David Bateman |
6043 | 6 |
7 This file is part of Octave. | |
8 | |
9 Octave is free software; you can redistribute it and/or modify it | |
10 under the terms of the GNU General Public License as published by the | |
7016 | 11 Free Software Foundation; either version 3 of the License, or (at your |
12 option) any later version. | |
6043 | 13 |
14 Octave is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
7016 | 20 along with Octave; see the file COPYING. If not, see |
21 <http://www.gnu.org/licenses/>. | |
6043 | 22 |
23 */ | |
24 | |
25 // Author: Alexander Barth <abarth@marine.usf.edu> | |
26 // Adapted-By: jwe | |
27 | |
28 #ifdef HAVE_CONFIG_H | |
29 #include <config.h> | |
30 #endif | |
31 | |
32 #include <string> | |
33 #include <fstream> | |
34 #include <iomanip> | |
9880 | 35 #include <iostream> |
6043 | 36 |
9880 | 37 #include "dir-ops.h" |
8151
3725f819b5b3
urlwrite.cc (Furlwrite): delete files we create if download fails
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
38 #include "file-ops.h" |
3725f819b5b3
urlwrite.cc (Furlwrite): delete files we create if download fails
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
39 #include "file-stat.h" |
6043 | 40 #include "oct-env.h" |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
41 #include "oct-handle.h" |
9880 | 42 #include "glob-match.h" |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
43 #include "singleton-cleanup.h" |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
44 #include "url-transfer.h" |
6043 | 45 |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
46 #include "defun.h" |
6043 | 47 #include "error.h" |
48 #include "oct-obj.h" | |
49 #include "ov-cell.h" | |
50 #include "pager.h" | |
9880 | 51 #include "oct-map.h" |
13985
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13978
diff
changeset
|
52 #include "oct-refcount.h" |
8151
3725f819b5b3
urlwrite.cc (Furlwrite): delete files we create if download fails
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
53 #include "unwind-prot.h" |
17550
77127a3badaa
move curl_object actions to rep class
John W. Eaton <jwe@octave.org>
parents:
17549
diff
changeset
|
54 |
77127a3badaa
move curl_object actions to rep class
John W. Eaton <jwe@octave.org>
parents:
17549
diff
changeset
|
55 static void |
77127a3badaa
move curl_object actions to rep class
John W. Eaton <jwe@octave.org>
parents:
17549
diff
changeset
|
56 delete_file (const std::string& file) |
77127a3badaa
move curl_object actions to rep class
John W. Eaton <jwe@octave.org>
parents:
17549
diff
changeset
|
57 { |
77127a3badaa
move curl_object actions to rep class
John W. Eaton <jwe@octave.org>
parents:
17549
diff
changeset
|
58 octave_unlink (file); |
77127a3badaa
move curl_object actions to rep class
John W. Eaton <jwe@octave.org>
parents:
17549
diff
changeset
|
59 } |
6043 | 60 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
61 typedef octave_handle curl_handle; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
62 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
63 class OCTINTERP_API ch_manager |
9880 | 64 { |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
65 protected: |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
66 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
67 ch_manager (void) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
68 : handle_map (), handle_free_list (), |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
69 next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0)) { } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
70 |
9880 | 71 public: |
72 | |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
73 static void create_instance (void); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
74 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
75 static bool instance_ok (void) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
76 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
77 bool retval = true; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
78 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
79 if (! instance) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
80 create_instance (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
81 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
82 if (! instance) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
83 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
84 ::error ("unable to create ch_manager!"); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
85 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
86 retval = false; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
87 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
88 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
89 return retval; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
90 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
91 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
92 static void cleanup_instance (void) { delete instance; instance = 0; } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
93 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
94 static curl_handle get_handle (void) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
95 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
96 return instance_ok () ? instance->do_get_handle () : curl_handle (); |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
97 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
98 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
99 static void free (const curl_handle& h) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
100 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
101 if (instance_ok ()) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
102 instance->do_free (h); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
103 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
104 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
105 static curl_handle lookup (double val) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
106 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
107 return instance_ok () ? instance->do_lookup (val) : curl_handle (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
108 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
109 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
110 static curl_handle lookup (const octave_value& val) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
111 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
112 return val.is_real_scalar () ? lookup (val.double_value ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
113 : curl_handle (); |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
114 } |
6043 | 115 |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
116 static url_transfer get_object (double val) |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
117 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
118 return get_object (lookup (val)); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
119 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
120 |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
121 static url_transfer get_object (const octave_value& val) |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
122 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
123 return get_object (lookup (val)); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
124 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
125 |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
126 static url_transfer get_object (const curl_handle& h) |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
127 { |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
128 return instance_ok () ? instance->do_get_object (h) : url_transfer (); |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
129 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
130 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
131 static curl_handle make_curl_handle (const std::string& host, |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
132 const std::string& user, |
17556
9e8a9f043944
fix error in previous commit
John W. Eaton <jwe@octave.org>
parents:
17555
diff
changeset
|
133 const std::string& passwd, |
9e8a9f043944
fix error in previous commit
John W. Eaton <jwe@octave.org>
parents:
17555
diff
changeset
|
134 std::ostream& os) |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
135 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
136 return instance_ok () |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
137 ? instance->do_make_curl_handle (host, user, passwd, os) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
138 : curl_handle (); |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
139 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
140 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
141 static Matrix handle_list (void) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
142 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
143 return instance_ok () ? instance->do_handle_list () : Matrix (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
144 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
145 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
146 private: |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
147 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
148 static ch_manager *instance; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
149 |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
150 typedef std::map<curl_handle, url_transfer>::iterator iterator; |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
151 typedef std::map<curl_handle, url_transfer>::const_iterator const_iterator; |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
152 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
153 typedef std::set<curl_handle>::iterator free_list_iterator; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
154 typedef std::set<curl_handle>::const_iterator const_free_list_iterator; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
155 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
156 // A map of handles to curl objects. |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
157 std::map<curl_handle, url_transfer> handle_map; |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
158 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
159 // The available curl handles. |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
160 std::set<curl_handle> handle_free_list; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
161 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
162 // The next handle available if handle_free_list is empty. |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
163 double next_handle; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
164 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
165 curl_handle do_get_handle (void); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
166 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
167 void do_free (const curl_handle& h); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
168 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
169 curl_handle do_lookup (double val) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
170 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
171 iterator p = (xisnan (val) ? handle_map.end () : handle_map.find (val)); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
172 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
173 return (p != handle_map.end ()) ? p->first : curl_handle (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
174 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
175 |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
176 url_transfer do_get_object (const curl_handle& h) |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
177 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
178 iterator p = (h.ok () ? handle_map.find (h) : handle_map.end ()); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
179 |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
180 return (p != handle_map.end ()) ? p->second : url_transfer (); |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
181 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
182 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
183 curl_handle do_make_curl_handle (const std::string& host, |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
184 const std::string& user, |
17556
9e8a9f043944
fix error in previous commit
John W. Eaton <jwe@octave.org>
parents:
17555
diff
changeset
|
185 const std::string& passwd, |
9e8a9f043944
fix error in previous commit
John W. Eaton <jwe@octave.org>
parents:
17555
diff
changeset
|
186 std::ostream& os) |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
187 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
188 curl_handle h = get_handle (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
189 |
17556
9e8a9f043944
fix error in previous commit
John W. Eaton <jwe@octave.org>
parents:
17555
diff
changeset
|
190 url_transfer obj (host, user, passwd, os); |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
191 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
192 if (! error_state) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
193 handle_map[h] = obj; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
194 else |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
195 h = curl_handle (); |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
196 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
197 return h; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
198 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
199 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
200 Matrix do_handle_list (void) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
201 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
202 Matrix retval (1, handle_map.size ()); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
203 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
204 octave_idx_type i = 0; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
205 for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
206 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
207 curl_handle h = p->first; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
208 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
209 retval(i++) = h.value (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
210 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
211 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
212 return retval; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
213 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
214 }; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
215 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
216 void |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
217 ch_manager::create_instance (void) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
218 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
219 instance = new ch_manager (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
220 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
221 if (instance) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
222 singleton_cleanup_list::add (cleanup_instance); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
223 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
224 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
225 static double |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
226 make_handle_fraction (void) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
227 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
228 static double maxrand = RAND_MAX + 2.0; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
229 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
230 return (rand () + 1.0) / maxrand; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
231 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
232 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
233 curl_handle |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
234 ch_manager::do_get_handle (void) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
235 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
236 curl_handle retval; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
237 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
238 // Curl handles are negative integers plus some random fractional |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
239 // part. To avoid running out of integers, we recycle the integer |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
240 // part but tack on a new random part each time. |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
241 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
242 free_list_iterator p = handle_free_list.begin (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
243 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
244 if (p != handle_free_list.end ()) |
9880 | 245 { |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
246 retval = *p; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
247 handle_free_list.erase (p); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
248 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
249 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
250 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
251 retval = curl_handle (next_handle); |
6992 | 252 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
253 next_handle = std::ceil (next_handle) - 1.0 - make_handle_fraction (); |
9880 | 254 } |
255 | |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
256 return retval; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
257 } |
9880 | 258 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
259 void |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
260 ch_manager::do_free (const curl_handle& h) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
261 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
262 if (h.ok ()) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
263 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
264 iterator p = handle_map.find (h); |
9880 | 265 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
266 if (p != handle_map.end ()) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
267 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
268 // Curl handles are negative integers plus some random |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
269 // fractional part. To avoid running out of integers, we |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
270 // recycle the integer part but tack on a new random part |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
271 // each time. |
9880 | 272 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
273 handle_map.erase (p); |
9880 | 274 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
275 if (h.value () < 0) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
276 handle_free_list.insert |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
277 (std::ceil (h.value ()) - make_handle_fraction ()); |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
278 } |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
279 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
280 error ("ch_manager::free: invalid object %g", h.value ()); |
9880 | 281 } |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
282 } |
9880 | 283 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
284 ch_manager *ch_manager::instance = 0; |
9880 | 285 |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
286 DEFUN (urlwrite, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
287 "-*- texinfo -*-\n\ |
10840 | 288 @deftypefn {Loadable Function} {} urlwrite (@var{url}, @var{localfile})\n\ |
6043 | 289 @deftypefnx {Loadable Function} {@var{f} =} urlwrite (@var{url}, @var{localfile})\n\ |
290 @deftypefnx {Loadable Function} {[@var{f}, @var{success}] =} urlwrite (@var{url}, @var{localfile})\n\ | |
291 @deftypefnx {Loadable Function} {[@var{f}, @var{success}, @var{message}] =} urlwrite (@var{url}, @var{localfile})\n\ | |
9880 | 292 Download a remote file specified by its @var{url} and save it as\n\ |
10840 | 293 @var{localfile}. For example:\n\ |
6043 | 294 \n\ |
295 @example\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
296 @group\n\ |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
297 urlwrite (\"ftp://ftp.octave.org/pub/octave/README\",\n\ |
7031 | 298 \"README.txt\");\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
299 @end group\n\ |
6043 | 300 @end example\n\ |
301 \n\ | |
302 The full path of the downloaded file is returned in @var{f}. The\n\ | |
303 variable @var{success} is 1 if the download was successful,\n\ | |
304 otherwise it is 0 in which case @var{message} contains an error\n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
305 message. If no output argument is specified and an error occurs,\n\ |
6588 | 306 then the error is signaled through Octave's error handling mechanism.\n\ |
6043 | 307 \n\ |
308 This function uses libcurl. Curl supports, among others, the HTTP,\n\ | |
309 FTP and FILE protocols. Username and password may be specified in\n\ | |
310 the URL, for example:\n\ | |
311 \n\ | |
312 @example\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
313 @group\n\ |
6588 | 314 urlwrite (\"http://username:password@@example.com/file.txt\",\n\ |
315 \"file.txt\");\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
316 @end group\n\ |
6043 | 317 @end example\n\ |
318 \n\ | |
319 GET and POST requests can be specified by @var{method} and @var{param}.\n\ | |
6589 | 320 The parameter @var{method} is either @samp{get} or @samp{post}\n\ |
6588 | 321 and @var{param} is a cell array of parameter and value pairs.\n\ |
322 For example:\n\ | |
6043 | 323 \n\ |
324 @example\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
325 @group\n\ |
6588 | 326 urlwrite (\"http://www.google.com/search\", \"search.html\",\n\ |
327 \"get\", @{\"query\", \"octave\"@});\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
328 @end group\n\ |
6043 | 329 @end example\n\ |
330 @seealso{urlread}\n\ | |
331 @end deftypefn") | |
332 { | |
333 octave_value_list retval; | |
334 | |
335 int nargin = args.length (); | |
336 | |
337 // verify arguments | |
338 if (nargin != 2 && nargin != 4) | |
339 { | |
340 print_usage (); | |
341 return retval; | |
342 } | |
343 | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14424
diff
changeset
|
344 std::string url = args(0).string_value (); |
6043 | 345 |
346 if (error_state) | |
347 { | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
348 error ("urlwrite: URL must be a character string"); |
6043 | 349 return retval; |
350 } | |
351 | |
352 // name to store the file if download is succesful | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14424
diff
changeset
|
353 std::string filename = args(1).string_value (); |
6043 | 354 |
355 if (error_state) | |
356 { | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
357 error ("urlwrite: LOCALFILE must be a character string"); |
6043 | 358 return retval; |
359 } | |
360 | |
361 std::string method; | |
17554
f0d21e7d4653
avoid Cell arrays in usr_transfer classes
John W. Eaton <jwe@octave.org>
parents:
17553
diff
changeset
|
362 Array<std::string> param; |
6043 | 363 |
364 if (nargin == 4) | |
365 { | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14424
diff
changeset
|
366 method = args(2).string_value (); |
6043 | 367 |
368 if (error_state) | |
369 { | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
370 error ("urlwrite: METHOD must be \"get\" or \"post\""); |
6043 | 371 return retval; |
372 } | |
373 | |
374 if (method != "get" && method != "post") | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
375 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
376 error ("urlwrite: METHOD must be \"get\" or \"post\""); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
377 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
378 } |
6043 | 379 |
17554
f0d21e7d4653
avoid Cell arrays in usr_transfer classes
John W. Eaton <jwe@octave.org>
parents:
17553
diff
changeset
|
380 param = args(3).cellstr_value (); |
6043 | 381 |
382 if (error_state) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
383 { |
17554
f0d21e7d4653
avoid Cell arrays in usr_transfer classes
John W. Eaton <jwe@octave.org>
parents:
17553
diff
changeset
|
384 error ("urlwrite: parameters (PARAM) for get and post requests must be given as a cell array of character strings"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
385 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
386 } |
6043 | 387 |
388 | |
389 if (param.numel () % 2 == 1 ) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
390 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
391 error ("urlwrite: number of elements in PARAM must be even"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
392 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
393 } |
6043 | 394 } |
395 | |
8151
3725f819b5b3
urlwrite.cc (Furlwrite): delete files we create if download fails
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
396 // The file should only be deleted if it doesn't initially exist, we |
3725f819b5b3
urlwrite.cc (Furlwrite): delete files we create if download fails
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
397 // create it, and the download fails. We use unwind_protect to do |
3725f819b5b3
urlwrite.cc (Furlwrite): delete files we create if download fails
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
398 // it so that the deletion happens no matter how we exit the function. |
3725f819b5b3
urlwrite.cc (Furlwrite): delete files we create if download fails
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
399 |
3725f819b5b3
urlwrite.cc (Furlwrite): delete files we create if download fails
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
400 file_stat fs (filename); |
3725f819b5b3
urlwrite.cc (Furlwrite): delete files we create if download fails
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
401 |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14424
diff
changeset
|
402 std::ofstream ofile (filename.c_str (), std::ios::out | std::ios::binary); |
6043 | 403 |
6986 | 404 if (! ofile.is_open ()) |
6043 | 405 { |
406 error ("urlwrite: unable to open file"); | |
407 return retval; | |
408 } | |
409 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9918
diff
changeset
|
410 unwind_protect_safe frame; |
8151
3725f819b5b3
urlwrite.cc (Furlwrite): delete files we create if download fails
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
411 |
17549
a646665cd574
eliminate unecessary static function in urlwrite.cc
John W. Eaton <jwe@octave.org>
parents:
17548
diff
changeset
|
412 frame.add_fcn (delete_file, filename); |
9880 | 413 |
17596
43b9181340fb
separate object creation from http actions in url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17556
diff
changeset
|
414 url_transfer curl = url_transfer (url, ofile); |
43b9181340fb
separate object creation from http actions in url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17556
diff
changeset
|
415 |
43b9181340fb
separate object creation from http actions in url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17556
diff
changeset
|
416 curl.http_action (param, method); |
6043 | 417 |
6986 | 418 ofile.close (); |
6043 | 419 |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
420 if (curl.good ()) |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
421 frame.discard (); |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
422 |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
423 if (nargout > 0) |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
424 { |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
425 if (curl.good ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
426 { |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
427 retval(2) = std::string (); |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
428 retval(1) = true; |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
429 retval(0) = octave_env::make_absolute (filename); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
430 } |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
431 else |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
432 { |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
433 retval(2) = curl.lasterror (); |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
434 retval(1) = false; |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
435 retval(0) = std::string (); |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
436 } |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
437 } |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
438 |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
439 if (nargout < 2 && ! curl.good ()) |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
440 error ("urlwrite: %s", curl.lasterror ().c_str ()); |
6043 | 441 |
442 return retval; | |
443 } | |
444 | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
445 DEFUN (urlread, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
446 "-*- texinfo -*-\n\ |
10840 | 447 @deftypefn {Loadable Function} {@var{s} =} urlread (@var{url})\n\ |
6043 | 448 @deftypefnx {Loadable Function} {[@var{s}, @var{success}] =} urlread (@var{url})\n\ |
6549 | 449 @deftypefnx {Loadable Function} {[@var{s}, @var{success}, @var{message}] =} urlread (@var{url})\n\ |
6547 | 450 @deftypefnx {Loadable Function} {[@dots{}] =} urlread (@var{url}, @var{method}, @var{param})\n\ |
9880 | 451 Download a remote file specified by its @var{url} and return its content\n\ |
10840 | 452 in string @var{s}. For example:\n\ |
6043 | 453 \n\ |
454 @example\n\ | |
6588 | 455 s = urlread (\"ftp://ftp.octave.org/pub/octave/README\");\n\ |
6043 | 456 @end example\n\ |
457 \n\ | |
458 The variable @var{success} is 1 if the download was successful,\n\ | |
459 otherwise it is 0 in which case @var{message} contains an error\n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
460 message. If no output argument is specified and an error occurs,\n\ |
6588 | 461 then the error is signaled through Octave's error handling mechanism.\n\ |
6043 | 462 \n\ |
463 This function uses libcurl. Curl supports, among others, the HTTP,\n\ | |
464 FTP and FILE protocols. Username and password may be specified in the\n\ | |
10840 | 465 URL@. For example:\n\ |
6043 | 466 \n\ |
467 @example\n\ | |
7031 | 468 s = urlread (\"http://user:password@@example.com/file.txt\");\n\ |
6043 | 469 @end example\n\ |
470 \n\ | |
471 GET and POST requests can be specified by @var{method} and @var{param}.\n\ | |
6588 | 472 The parameter @var{method} is either @samp{get} or @samp{post}\n\ |
473 and @var{param} is a cell array of parameter and value pairs.\n\ | |
10840 | 474 For example:\n\ |
6043 | 475 \n\ |
476 @example\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
477 @group\n\ |
6588 | 478 s = urlread (\"http://www.google.com/search\", \"get\",\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
479 @{\"query\", \"octave\"@});\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
480 @end group\n\ |
6043 | 481 @end example\n\ |
482 @seealso{urlwrite}\n\ | |
483 @end deftypefn") | |
484 { | |
6588 | 485 // Octave's return value |
6043 | 486 octave_value_list retval; |
487 | |
488 int nargin = args.length (); | |
489 | |
490 // verify arguments | |
491 if (nargin != 1 && nargin != 3) | |
492 { | |
493 print_usage (); | |
494 return retval; | |
495 } | |
496 | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14424
diff
changeset
|
497 std::string url = args(0).string_value (); |
6043 | 498 |
499 if (error_state) | |
500 { | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
501 error ("urlread: URL must be a character string"); |
6043 | 502 return retval; |
503 } | |
504 | |
505 std::string method; | |
17554
f0d21e7d4653
avoid Cell arrays in usr_transfer classes
John W. Eaton <jwe@octave.org>
parents:
17553
diff
changeset
|
506 Array<std::string> param; |
6043 | 507 |
508 if (nargin == 3) | |
509 { | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14424
diff
changeset
|
510 method = args(1).string_value (); |
6043 | 511 |
512 if (error_state) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
513 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
514 error ("urlread: METHOD must be \"get\" or \"post\""); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
515 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
516 } |
6043 | 517 |
518 if (method != "get" && method != "post") | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
519 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
520 error ("urlread: METHOD must be \"get\" or \"post\""); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
521 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
522 } |
6043 | 523 |
17554
f0d21e7d4653
avoid Cell arrays in usr_transfer classes
John W. Eaton <jwe@octave.org>
parents:
17553
diff
changeset
|
524 param = args(2).cellstr_value (); |
6043 | 525 |
526 if (error_state) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
527 { |
17554
f0d21e7d4653
avoid Cell arrays in usr_transfer classes
John W. Eaton <jwe@octave.org>
parents:
17553
diff
changeset
|
528 error ("urlread: parameters (PARAM) for get and post requests must be given as a cell array of character strings"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
529 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
530 } |
6043 | 531 |
532 if (param.numel () % 2 == 1 ) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
533 { |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
534 error ("urlread: number of elements in PARAM must be even"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
535 return retval; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
536 } |
6043 | 537 } |
538 | |
6986 | 539 std::ostringstream buf; |
6043 | 540 |
17596
43b9181340fb
separate object creation from http actions in url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17556
diff
changeset
|
541 url_transfer curl = url_transfer (url, buf); |
43b9181340fb
separate object creation from http actions in url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17556
diff
changeset
|
542 |
43b9181340fb
separate object creation from http actions in url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17556
diff
changeset
|
543 curl.http_action (param, method); |
6043 | 544 |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
545 if (curl.good ()) |
6043 | 546 { |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
547 if (nargout > 0) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
548 { |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
549 // Return empty string if no error occured. |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
550 retval(2) = curl.good () ? "" : curl.lasterror (); |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
551 retval(1) = curl.good (); |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
552 retval(0) = buf.str (); |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
553 } |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
554 } |
6043 | 555 |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
556 if (nargout < 2 && ! curl.good ()) |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
557 error ("urlread: %s", curl.lasterror().c_str()); |
6043 | 558 |
559 return retval; | |
560 } | |
9880 | 561 |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
562 DEFUN (__ftp__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
563 "-*- texinfo -*-\n\ |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
564 @deftypefn {Loadable Function} {@var{handle} =} __ftp__ (@var{host})\n\ |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
565 @deftypefnx {Loadable Function} {@var{handle} =} __ftp__ (@var{host}, @var{username}, @var{password})\n\ |
9880 | 566 Undocumented internal function\n\ |
567 @end deftypefn") | |
568 { | |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
569 octave_value retval; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
570 |
9880 | 571 int nargin = args.length (); |
572 std::string host; | |
573 std::string user = "anonymous"; | |
574 std::string passwd = ""; | |
575 | |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
576 if (nargin < 1 || nargin > 3) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
577 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
578 print_usage (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
579 return retval; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
580 } |
9880 | 581 else |
582 { | |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
583 host = args(0).string_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
584 |
9880 | 585 if (nargin > 1) |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
586 user = args(1).string_value (); |
9880 | 587 |
588 if (nargin > 2) | |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
589 passwd = args(2).string_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
590 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
591 if (! error_state) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
592 { |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
593 curl_handle ch |
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
594 = ch_manager::make_curl_handle (host, user, passwd, octave_stdout); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
595 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
596 if (! error_state) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
597 retval = ch.value (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
598 } |
9880 | 599 } |
600 | |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
601 return retval; |
9880 | 602 } |
603 | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
604 DEFUN (__ftp_pwd__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
605 "-*- texinfo -*-\n\ |
9880 | 606 @deftypefn {Loadable Function} {} __ftp_pwd__ (@var{handle})\n\ |
607 Undocumented internal function\n\ | |
608 @end deftypefn") | |
609 { | |
610 octave_value retval; | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
611 |
9880 | 612 int nargin = args.length (); |
613 | |
614 if (nargin != 1) | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
615 error ("__ftp_pwd__: incorrect number of arguments"); |
9880 | 616 else |
617 { | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
618 url_transfer curl = ch_manager::get_object (args(0)); |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
619 |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
620 if (error_state) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
621 return retval; |
9880 | 622 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
623 if (curl.is_valid ()) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
624 retval = curl.pwd (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
625 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
626 error ("__ftp_pwd__: invalid ftp handle"); |
9880 | 627 } |
628 | |
629 return retval; | |
630 } | |
631 | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
632 DEFUN (__ftp_cwd__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
633 "-*- texinfo -*-\n\ |
9880 | 634 @deftypefn {Loadable Function} {} __ftp_cwd__ (@var{handle}, @var{path})\n\ |
635 Undocumented internal function\n\ | |
636 @end deftypefn") | |
637 { | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
638 octave_value retval; |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
639 |
9880 | 640 int nargin = args.length (); |
641 | |
642 if (nargin != 1 && nargin != 2) | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
643 error ("__ftp_cwd__: incorrect number of arguments"); |
9880 | 644 else |
645 { | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
646 url_transfer curl = ch_manager::get_object (args(0)); |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
647 |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
648 if (error_state) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
649 return retval; |
9880 | 650 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
651 if (curl.is_valid ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
652 { |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
653 std::string path = ""; |
9880 | 654 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
655 if (nargin > 1) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
656 path = args(1).string_value (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
657 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
658 if (! error_state) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
659 curl.cwd (path); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
660 else |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
661 error ("__ftp_cwd__: expecting path as second argument"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
662 } |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
663 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
664 error ("__ftp_cwd__: invalid ftp handle"); |
9880 | 665 } |
666 | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
667 return retval; |
9880 | 668 } |
669 | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
670 DEFUN (__ftp_dir__, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
671 "-*- texinfo -*-\n\ |
9880 | 672 @deftypefn {Loadable Function} {} __ftp_dir__ (@var{handle})\n\ |
673 Undocumented internal function\n\ | |
674 @end deftypefn") | |
675 { | |
676 octave_value retval; | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
677 |
9880 | 678 int nargin = args.length (); |
679 | |
680 if (nargin != 1) | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
681 error ("__ftp_dir__: incorrect number of arguments"); |
9880 | 682 else |
683 { | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
684 url_transfer curl = ch_manager::get_object (args(0)); |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
685 |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
686 if (error_state) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
687 return retval; |
9880 | 688 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
689 if (curl.is_valid ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
690 { |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
691 if (nargout == 0) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
692 curl.dir (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
693 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
694 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
695 string_vector sv = curl.list (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
696 octave_idx_type n = sv.length (); |
9880 | 697 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
698 if (n == 0) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
699 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
700 string_vector flds (5); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
701 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
702 flds(0) = "name"; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
703 flds(1) = "date"; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
704 flds(2) = "bytes"; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
705 flds(3) = "isdir"; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
706 flds(4) = "datenum"; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
707 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
708 retval = octave_map (flds); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
709 } |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
710 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
711 { |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
712 octave_map st; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
713 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
714 Cell filectime (dim_vector (n, 1)); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
715 Cell filesize (dim_vector (n, 1)); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
716 Cell fileisdir (dim_vector (n, 1)); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
717 Cell filedatenum (dim_vector (n, 1)); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
718 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
719 st.assign ("name", Cell (sv)); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
720 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
721 for (octave_idx_type i = 0; i < n; i++) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
722 { |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
723 time_t ftime; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
724 bool fisdir; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
725 double fsize; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
726 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
727 curl.get_fileinfo (sv(i), fsize, ftime, fisdir); |
9880 | 728 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
729 fileisdir (i) = fisdir; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
730 filectime (i) = ctime (&ftime); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
731 filesize (i) = fsize; |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
732 filedatenum (i) = double (ftime); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
733 } |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
734 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
735 st.assign ("date", filectime); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
736 st.assign ("bytes", filesize); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
737 st.assign ("isdir", fileisdir); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
738 st.assign ("datenum", filedatenum); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
739 |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
740 retval = st; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
741 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
742 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
743 } |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
744 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
745 error ("__ftp_dir__: invalid ftp handle"); |
9880 | 746 } |
747 | |
748 return retval; | |
749 } | |
750 | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
751 DEFUN (__ftp_ascii__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
752 "-*- texinfo -*-\n\ |
9880 | 753 @deftypefn {Loadable Function} {} __ftp_ascii__ (@var{handle})\n\ |
754 Undocumented internal function\n\ | |
755 @end deftypefn") | |
756 { | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
757 octave_value retval; |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
758 |
9880 | 759 int nargin = args.length (); |
760 | |
761 if (nargin != 1) | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
762 error ("__ftp_ascii__: incorrect number of arguments"); |
9880 | 763 else |
764 { | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
765 url_transfer curl = ch_manager::get_object (args(0)); |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
766 |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
767 if (error_state) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
768 return retval; |
9880 | 769 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
770 if (curl.is_valid ()) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
771 curl.ascii (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
772 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
773 error ("__ftp_ascii__: invalid ftp handle"); |
9880 | 774 } |
775 | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
776 return retval; |
9880 | 777 } |
778 | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
779 DEFUN (__ftp_binary__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
780 "-*- texinfo -*-\n\ |
9880 | 781 @deftypefn {Loadable Function} {} __ftp_binary__ (@var{handle})\n\ |
782 Undocumented internal function\n\ | |
783 @end deftypefn") | |
784 { | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
785 octave_value retval; |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
786 |
9880 | 787 int nargin = args.length (); |
788 | |
789 if (nargin != 1) | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
790 error ("__ftp_binary__: incorrect number of arguments"); |
9880 | 791 else |
792 { | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
793 url_transfer curl = ch_manager::get_object (args(0)); |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
794 |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
795 if (error_state) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
796 return retval; |
9880 | 797 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
798 if (curl.is_valid ()) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
799 curl.binary (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
800 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
801 error ("__ftp_binary__: invalid ftp handle"); |
9880 | 802 } |
803 | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
804 return retval; |
9880 | 805 } |
806 | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
807 DEFUN (__ftp_close__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
808 "-*- texinfo -*-\n\ |
9880 | 809 @deftypefn {Loadable Function} {} __ftp_close__ (@var{handle})\n\ |
17318
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
810 Undocumented internal function\n\ |
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
811 @end deftypefn") |
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
812 { |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
813 octave_value retval; |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
814 |
17318
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
815 int nargin = args.length (); |
9880 | 816 |
17318
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
817 if (nargin != 1) |
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
818 error ("__ftp_close__: incorrect number of arguments"); |
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
819 else |
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
820 { |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
821 curl_handle h = ch_manager::lookup (args(0)); |
9880 | 822 |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
823 if (error_state) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
824 return retval; |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
825 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
826 if (h.ok ()) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
827 ch_manager::free (h); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
828 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
829 error ("__ftp_close__: invalid ftp handle"); |
17318
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
830 } |
9880 | 831 |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
832 return retval; |
17318
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
833 } |
9880 | 834 |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
835 DEFUN (__ftp_mode__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
836 "-*- texinfo -*-\n\ |
9880 | 837 @deftypefn {Loadable Function} {} __ftp_mode__ (@var{handle})\n\ |
17318
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
838 Undocumented internal function\n\ |
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
839 @end deftypefn") |
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
840 { |
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
841 octave_value retval; |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
842 |
17318
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
843 int nargin = args.length (); |
9880 | 844 |
17318
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
845 if (nargin != 1) |
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
846 error ("__ftp_mode__: incorrect number of arguments"); |
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
847 else |
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
848 { |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
849 url_transfer curl = ch_manager::get_object (args(0)); |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
850 |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
851 if (error_state) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
852 return retval; |
9880 | 853 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
854 if (curl.is_valid ()) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
855 retval = (curl.is_ascii () ? "ascii" : "binary"); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
856 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
857 error ("__ftp_binary__: invalid ftp handle"); |
17318
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
858 } |
9880 | 859 |
17318
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
860 return retval; |
accafe1aee7c
Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents:
15326
diff
changeset
|
861 } |
9880 | 862 |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
863 DEFUN (__ftp_delete__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
864 "-*- texinfo -*-\n\ |
9880 | 865 @deftypefn {Loadable Function} {} __ftp_delete__ (@var{handle}, @var{path})\n\ |
866 Undocumented internal function\n\ | |
867 @end deftypefn") | |
868 { | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
869 octave_value retval; |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
870 |
9880 | 871 int nargin = args.length (); |
872 | |
873 if (nargin != 2) | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
874 error ("__ftp_delete__: incorrect number of arguments"); |
9880 | 875 else |
876 { | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
877 url_transfer curl = ch_manager::get_object (args(0)); |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
878 |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
879 if (error_state) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
880 return retval; |
9880 | 881 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
882 if (curl.is_valid ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
883 { |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
884 std::string file = args(1).string_value (); |
9880 | 885 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
886 if (! error_state) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
887 curl.del (file); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
888 else |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
889 error ("__ftp_delete__: expecting file name as second argument"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
890 } |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
891 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
892 error ("__ftp_delete__: invalid ftp handle"); |
9880 | 893 } |
894 | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
895 return retval; |
9880 | 896 } |
897 | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
898 DEFUN (__ftp_rmdir__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
899 "-*- texinfo -*-\n\ |
9880 | 900 @deftypefn {Loadable Function} {} __ftp_rmdir__ (@var{handle}, @var{path})\n\ |
901 Undocumented internal function\n\ | |
902 @end deftypefn") | |
903 { | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
904 octave_value retval; |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
905 |
9880 | 906 int nargin = args.length (); |
907 | |
908 if (nargin != 2) | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
909 error ("__ftp_rmdir__: incorrect number of arguments"); |
9880 | 910 else |
911 { | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
912 url_transfer curl = ch_manager::get_object (args(0)); |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
913 |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
914 if (error_state) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
915 return retval; |
9880 | 916 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
917 if (curl.is_valid ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
918 { |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
919 std::string dir = args(1).string_value (); |
9880 | 920 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
921 if (! error_state) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
922 curl.rmdir (dir); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
923 else |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
924 error ("__ftp_rmdir__: expecting directory name as second argument"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
925 } |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
926 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
927 error ("__ftp_rmdir__: invalid ftp handle"); |
9880 | 928 } |
929 | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
930 return retval; |
9880 | 931 } |
932 | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
933 DEFUN (__ftp_mkdir__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
934 "-*- texinfo -*-\n\ |
9880 | 935 @deftypefn {Loadable Function} {} __ftp_mkdir__ (@var{handle}, @var{path})\n\ |
936 Undocumented internal function\n\ | |
937 @end deftypefn") | |
938 { | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
939 octave_value retval; |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
940 |
9880 | 941 int nargin = args.length (); |
942 | |
943 if (nargin != 2) | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
944 error ("__ftp_mkdir__: incorrect number of arguments"); |
9880 | 945 else |
946 { | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
947 url_transfer curl = ch_manager::get_object (args(0)); |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
948 |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
949 if (error_state) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
950 return retval; |
9880 | 951 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
952 if (curl.is_valid ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
953 { |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
954 std::string dir = args(1).string_value (); |
9880 | 955 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
956 if (! error_state) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
957 curl.mkdir (dir); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
958 else |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
959 error ("__ftp_mkdir__: expecting directory name as second argument"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
960 } |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
961 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
962 error ("__ftp_mkdir__: invalid ftp handle"); |
9880 | 963 } |
964 | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
965 return retval; |
9880 | 966 } |
967 | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
968 DEFUN (__ftp_rename__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
969 "-*- texinfo -*-\n\ |
9880 | 970 @deftypefn {Loadable Function} {} __ftp_rename__ (@var{handle}, @var{path})\n\ |
971 Undocumented internal function\n\ | |
972 @end deftypefn") | |
973 { | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
974 octave_value retval; |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
975 |
9880 | 976 int nargin = args.length (); |
977 | |
978 if (nargin != 3) | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
979 error ("__ftp_rename__: incorrect number of arguments"); |
9880 | 980 else |
981 { | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
982 url_transfer curl = ch_manager::get_object (args(0)); |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
983 |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
984 if (error_state) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
985 return retval; |
9880 | 986 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
987 if (curl.is_valid ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
988 { |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
989 std::string oldname = args(1).string_value (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
990 std::string newname = args(2).string_value (); |
9880 | 991 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
992 if (! error_state) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
993 curl.rename (oldname, newname); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
994 else |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
995 error ("__ftp_rename__: expecting file names for second and third arguments"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
996 } |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
997 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
998 error ("__ftp_rename__: invalid ftp handle"); |
9880 | 999 } |
1000 | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1001 return retval; |
9880 | 1002 } |
1003 | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
1004 DEFUN (__ftp_mput__, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1005 "-*- texinfo -*-\n\ |
9880 | 1006 @deftypefn {Loadable Function} {} __ftp_mput__ (@var{handle}, @var{files})\n\ |
1007 Undocumented internal function\n\ | |
1008 @end deftypefn") | |
1009 { | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1010 octave_value retval; |
9880 | 1011 |
1012 int nargin = args.length (); | |
1013 | |
1014 if (nargin != 2) | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
1015 error ("__ftp_mput__: incorrect number of arguments"); |
9880 | 1016 else |
1017 { | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
1018 url_transfer curl = ch_manager::get_object (args(0)); |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1019 |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1020 if (error_state) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1021 return retval; |
9880 | 1022 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1023 if (curl.is_valid ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1024 { |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1025 std::string pat = args(1).string_value (); |
9880 | 1026 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1027 if (! error_state) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1028 { |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1029 string_vector file_list; |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1030 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1031 glob_match pattern (file_ops::tilde_expand (pat)); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1032 string_vector files = pattern.glob (); |
9880 | 1033 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1034 for (octave_idx_type i = 0; i < files.length (); i++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1035 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1036 std::string file = files (i); |
9880 | 1037 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1038 file_stat fs (file); |
9880 | 1039 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1040 if (! fs.exists ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1041 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1042 error ("__ftp__mput: file does not exist"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1043 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1044 } |
9880 | 1045 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1046 if (fs.is_dir ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1047 { |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1048 file_list.append (curl.mput_directory ("", file)); |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1049 |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1050 if (! curl.good ()) |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1051 { |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1052 error ("__ftp_mput__: %s", curl.lasterror().c_str()); |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1053 break; |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1054 } |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1055 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1056 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1057 { |
17861
870f3e12e163
maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
1058 // FIXME: Does ascii mode need to be flagged here? |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14424
diff
changeset
|
1059 std::ifstream ifile (file.c_str (), std::ios::in | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1060 std::ios::binary); |
9880 | 1061 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1062 if (! ifile.is_open ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1063 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1064 error ("__ftp_mput__: unable to open file"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1065 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1066 } |
9880 | 1067 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1068 curl.put (file, ifile); |
9880 | 1069 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1070 ifile.close (); |
9880 | 1071 |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1072 if (! curl.good ()) |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1073 { |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1074 error ("__ftp_mput__: %s", curl.lasterror().c_str()); |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1075 break; |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1076 } |
9880 | 1077 |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1078 file_list.append (file); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1079 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1080 } |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1081 |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1082 if (nargout > 0) |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1083 retval = file_list; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1084 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1085 else |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1086 error ("__ftp_mput__: expecting file name patter as second argument"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1087 } |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1088 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1089 error ("__ftp_mput__: invalid ftp handle"); |
9880 | 1090 } |
1091 | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1092 return retval; |
9880 | 1093 } |
1094 | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
1095 DEFUN (__ftp_mget__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1096 "-*- texinfo -*-\n\ |
9880 | 1097 @deftypefn {Loadable Function} {} __ftp_mget__ (@var{handle}, @var{files})\n\ |
1098 Undocumented internal function\n\ | |
1099 @end deftypefn") | |
1100 { | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1101 octave_value retval; |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1102 |
9880 | 1103 int nargin = args.length (); |
1104 | |
1105 if (nargin != 2 && nargin != 3) | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11548
diff
changeset
|
1106 error ("__ftp_mget__: incorrect number of arguments"); |
9880 | 1107 else |
1108 { | |
17555
0946b0e06544
move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents:
17554
diff
changeset
|
1109 url_transfer curl = ch_manager::get_object (args(0)); |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1110 |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1111 if (error_state) |
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1112 return retval; |
9880 | 1113 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1114 if (curl.is_valid ()) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1115 { |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1116 std::string file = args(1).string_value (); |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1117 std::string target; |
9880 | 1118 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1119 if (nargin == 3) |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1120 target = args(2).string_value () + file_ops::dir_sep_str (); |
9880 | 1121 |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1122 if (! error_state) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1123 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1124 string_vector sv = curl.list (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1125 octave_idx_type n = 0; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1126 glob_match pattern (file); |
9880 | 1127 |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1128 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1129 for (octave_idx_type i = 0; i < sv.length (); i++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1130 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1131 if (pattern.match (sv(i))) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1132 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1133 n++; |
9880 | 1134 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1135 time_t ftime; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1136 bool fisdir; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1137 double fsize; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1138 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1139 curl.get_fileinfo (sv(i), fsize, ftime, fisdir); |
9880 | 1140 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1141 if (fisdir) |
17550
77127a3badaa
move curl_object actions to rep class
John W. Eaton <jwe@octave.org>
parents:
17549
diff
changeset
|
1142 curl.mget_directory (sv(i), target); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1143 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1144 { |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14424
diff
changeset
|
1145 std::ofstream ofile ((target + sv(i)).c_str (), |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
1146 std::ios::out | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1147 std::ios::binary); |
9880 | 1148 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1149 if (! ofile.is_open ()) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1150 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1151 error ("__ftp_mget__: unable to open file"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1152 break; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1153 } |
9880 | 1154 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9918
diff
changeset
|
1155 unwind_protect_safe frame; |
9880 | 1156 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1157 frame.add_fcn (delete_file, target + sv(i)); |
9880 | 1158 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1159 curl.get (sv(i), ofile); |
9880 | 1160 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1161 ofile.close (); |
9880 | 1162 |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1163 if (curl.good ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1164 frame.discard (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1165 } |
9880 | 1166 |
17553
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1167 if (! curl.good ()) |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1168 { |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1169 error ("__ftp_mget__: %s", curl.lasterror().c_str()); |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1170 break; |
2d01e20abd85
rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents:
17551
diff
changeset
|
1171 } |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1172 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1173 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1174 if (n == 0) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1175 error ("__ftp_mget__: file not found"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1176 } |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1177 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1178 error ("__ftp_mget__: expecting file name and target as second and third arguments"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10084
diff
changeset
|
1179 } |
17548
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1180 else |
92541ff4cc3c
improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents:
17546
diff
changeset
|
1181 error ("__ftp_mget__: invalid ftp handle"); |
9880 | 1182 } |
1183 | |
17551
8fca0bbdd4c1
reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents:
17550
diff
changeset
|
1184 return retval; |
9880 | 1185 } |