annotate libinterp/corefcn/urlwrite.cc @ 23742:1f0daaf81955

don't use singleton for ch_manager, rename to url_handle_manager * url-handle-manager.h, url-handle-manager.cc: New files. Move ch_manager class here from urlwrite.cc. Rewrite to not use singleton pattern. Rename curl_handle to url_handle. Move inside octave namespace. Change all uses. * libinterp/corefcn/module.mk: Update. * interpreter.h, interpreter.cc (interpreter::m_url_handle_manager): New variable. (interpreter::interpreter): Initialize it. (interpreter::get_url_handle_manager): New function.
author John W. Eaton <jwe@octave.org>
date Thu, 06 Jul 2017 17:26:10 -0400
parents 80c42f4cca13
children 90689bdbe048
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
1 /*
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
2
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 2006-2017 Alexander Barth
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
4 Copyright (C) 2009 David Bateman
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
5
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
7
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
9 under the terms of the GNU General Public License as published by
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
10 the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
11 (at your option) any later version.
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
12
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
13 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
14 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
16 GNU General Public License for more details.
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
17
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7013
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7013
diff changeset
20 <http://www.gnu.org/licenses/>.
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
21
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
22 */
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
23
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
24 // Author: Alexander Barth <abarth@marine.usf.edu>
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
25 // Adapted-By: jwe
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
26
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21547
diff changeset
27 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
28 # include "config.h"
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
29 #endif
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
30
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
31 #include <string>
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
32 #include <fstream>
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
33 #include <iomanip>
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
34 #include <iostream>
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
35
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
36 #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
37 #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
38 #include "file-stat.h"
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
39 #include "oct-env.h"
17548
92541ff4cc3c improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents: 17546
diff changeset
40 #include "oct-handle.h"
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
41 #include "glob-match.h"
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents: 17554
diff changeset
42 #include "url-transfer.h"
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
43
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents: 17554
diff changeset
44 #include "defun.h"
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
45 #include "error.h"
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
46 #include "interpreter.h"
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
47 #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
48 #include "oct-refcount.h"
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
49 #include "ov-cell.h"
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
50 #include "ovl.h"
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
51 #include "pager.h"
8151
3725f819b5b3 urlwrite.cc (Furlwrite): delete files we create if download fails
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
52 #include "unwind-prot.h"
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
53 #include "url-handle-manager.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 {
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
58 octave::sys::unlink (file);
17550
77127a3badaa move curl_object actions to rep class
John W. Eaton <jwe@octave.org>
parents: 17549
diff changeset
59 }
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
60
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents: 17554
diff changeset
61 DEFUN (urlwrite, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
62 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
63 @deftypefn {} {} urlwrite (@var{url}, @var{localfile})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
64 @deftypefnx {} {@var{f} =} urlwrite (@var{url}, @var{localfile})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
65 @deftypefnx {} {[@var{f}, @var{success}] =} urlwrite (@var{url}, @var{localfile})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
66 @deftypefnx {} {[@var{f}, @var{success}, @var{message}] =} urlwrite (@var{url}, @var{localfile})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
67 Download a remote file specified by its @var{url} and save it as
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
68 @var{localfile}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
69
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
70 For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
71
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
72 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
73 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
74 urlwrite ("ftp://ftp.octave.org/pub/README",
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
75 "README.txt");
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
76 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
77 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
78
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
79 The full path of the downloaded file is returned in @var{f}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
80
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
81 The variable @var{success} is 1 if the download was successful,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
82 otherwise it is 0 in which case @var{message} contains an error message.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
83
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
84 If no output argument is specified and an error occurs, then the error is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
85 signaled through Octave's error handling mechanism.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
86
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
87 This function uses libcurl. Curl supports, among others, the HTTP, FTP, and
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
88 FILE protocols. Username and password may be specified in the URL, for
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
89 example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
90
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
91 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
92 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
93 urlwrite ("http://username:password@@example.com/file.txt",
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
94 "file.txt");
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
95 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
96 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
97
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
98 GET and POST requests can be specified by @var{method} and @var{param}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
99 The parameter @var{method} is either @samp{get} or @samp{post} and
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
100 @var{param} is a cell array of parameter and value pairs.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
101 For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
102
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
103 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
104 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
105 urlwrite ("http://www.google.com/search", "search.html",
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
106 "get", @{"query", "octave"@});
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
107 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
108 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
109 @seealso{urlread}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
110 @end deftypefn */)
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
111 {
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
112 int nargin = args.length ();
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
113
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
114 // verify arguments
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
115 if (nargin != 2 && nargin != 4)
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
116 print_usage ();
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
117
20700
68e3a747ca02 rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents: 20681
diff changeset
118 std::string url = args(0).xstring_value ("urlwrite: URL must be a string");
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
119
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
120 // name to store the file if download is successful
20700
68e3a747ca02 rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents: 20681
diff changeset
121 std::string filename = args(1).xstring_value ("urlwrite: LOCALFILE must be a string");
19404
c2f4f6eb5907 A few more instances of stricter input validation for strings (bug #42651).
Rik <rik@octave.org>
parents: 19403
diff changeset
122
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
123 std::string method;
17554
f0d21e7d4653 avoid Cell arrays in usr_transfer classes
John W. Eaton <jwe@octave.org>
parents: 17553
diff changeset
124 Array<std::string> param;
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
125
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
126 if (nargin == 4)
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
127 {
20700
68e3a747ca02 rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents: 20681
diff changeset
128 method = args(2).xstring_value ("urlwrite: METHOD must be a string");
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
129
19404
c2f4f6eb5907 A few more instances of stricter input validation for strings (bug #42651).
Rik <rik@octave.org>
parents: 19403
diff changeset
130 if (method != "get" && method != "post")
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20819
diff changeset
131 error ("urlwrite: METHOD must be \"get\" or \"post\"");
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
132
20700
68e3a747ca02 rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents: 20681
diff changeset
133 param = args(3).xcellstr_value ("urlwrite: parameters (PARAM) for get and post requests must be given as a cell array of strings");
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
134
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18391
diff changeset
135 if (param.numel () % 2 == 1)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20819
diff changeset
136 error ("urlwrite: number of elements in PARAM must be even");
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
137 }
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
138
8151
3725f819b5b3 urlwrite.cc (Furlwrite): delete files we create if download fails
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
139 // 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
140 // 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
141 // 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
142
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
143 octave::sys::file_stat fs (filename);
8151
3725f819b5b3 urlwrite.cc (Furlwrite): delete files we create if download fails
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
144
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
145 std::ofstream ofile (filename.c_str (), std::ios::out | std::ios::binary);
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
146
6986
4ad04ff722d7 [project @ 2007-10-09 17:43:00 by jwe]
jwe
parents: 6984
diff changeset
147 if (! ofile.is_open ())
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20819
diff changeset
148 error ("urlwrite: unable to open file");
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
149
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
150 octave::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
151
17549
a646665cd574 eliminate unecessary static function in urlwrite.cc
John W. Eaton <jwe@octave.org>
parents: 17548
diff changeset
152 frame.add_fcn (delete_file, filename);
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
153
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
154 octave::url_transfer url_xfer (url, ofile);
17596
43b9181340fb separate object creation from http actions in url_transfer class
John W. Eaton <jwe@octave.org>
parents: 17556
diff changeset
155
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
156 octave_value_list retval;
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
157
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
158 if (! url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
159 error ("support for URL transfers was disabled when Octave was built");
17553
2d01e20abd85 rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 17551
diff changeset
160
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
161 url_xfer.http_action (param, method);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
162
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
163 ofile.close ();
18287
9a43d8d6e29e avoid startup crash if curl library is not available (bug #41067)
John W. Eaton <jwe@octave.org>
parents: 17861
diff changeset
164
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
165 if (url_xfer.good ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
166 frame.discard ();
18287
9a43d8d6e29e avoid startup crash if curl library is not available (bug #41067)
John W. Eaton <jwe@octave.org>
parents: 17861
diff changeset
167
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
168 if (nargout > 0)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
169 {
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
170 if (url_xfer.good ())
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
171 retval = ovl (octave::sys::env::make_absolute (filename), true, "");
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
172 else
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
173 retval = ovl ("", false, url_xfer.lasterror ());
17553
2d01e20abd85 rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 17551
diff changeset
174 }
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
175
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
176 if (nargout < 2 && ! url_xfer.good ())
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
177 error ("urlwrite: %s", url_xfer.lasterror ().c_str ());
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
178
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
179 return retval;
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
180 }
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
181
17555
0946b0e06544 move url_transfer classes to liboctave
John W. Eaton <jwe@octave.org>
parents: 17554
diff changeset
182 DEFUN (urlread, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
183 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
184 @deftypefn {} {@var{s} =} urlread (@var{url})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
185 @deftypefnx {} {[@var{s}, @var{success}] =} urlread (@var{url})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
186 @deftypefnx {} {[@var{s}, @var{success}, @var{message}] =} urlread (@var{url})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
187 @deftypefnx {} {[@dots{}] =} urlread (@var{url}, @var{method}, @var{param})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
188 Download a remote file specified by its @var{url} and return its content
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
189 in string @var{s}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
190
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
191 For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
192
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
193 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
194 s = urlread ("ftp://ftp.octave.org/pub/README");
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
195 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
196
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
197 The variable @var{success} is 1 if the download was successful,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
198 otherwise it is 0 in which case @var{message} contains an error
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
199 message.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
200
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
201 If no output argument is specified and an error occurs, then the error is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
202 signaled through Octave's error handling mechanism.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
203
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
204 This function uses libcurl. Curl supports, among others, the HTTP, FTP, and
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
205 FILE protocols. Username and password may be specified in the URL@. For
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
206 example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
207
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
208 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
209 s = urlread ("http://user:password@@example.com/file.txt");
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
210 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
211
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
212 GET and POST requests can be specified by @var{method} and @var{param}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
213 The parameter @var{method} is either @samp{get} or @samp{post} and
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
214 @var{param} is a cell array of parameter and value pairs.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
215 For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
216
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
217 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
218 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
219 s = urlread ("http://www.google.com/search", "get",
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
220 @{"query", "octave"@});
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
221 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
222 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
223 @seealso{urlwrite}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
224 @end deftypefn */)
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
225 {
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
226 int nargin = args.length ();
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
227
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
228 // verify arguments
19403
03067dab10ca Use stricter input validation when looking for a string as input (bug #42651).
Rik <rik@octave.org>
parents: 19220
diff changeset
229 if (nargin != 1 && nargin != 3)
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
230 print_usage ();
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
231
20700
68e3a747ca02 rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents: 20681
diff changeset
232 std::string url = args(0).xstring_value ("urlread: URL must be a string");
19404
c2f4f6eb5907 A few more instances of stricter input validation for strings (bug #42651).
Rik <rik@octave.org>
parents: 19403
diff changeset
233
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
234 std::string method;
17554
f0d21e7d4653 avoid Cell arrays in usr_transfer classes
John W. Eaton <jwe@octave.org>
parents: 17553
diff changeset
235 Array<std::string> param;
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
236
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
237 if (nargin == 3)
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
238 {
20700
68e3a747ca02 rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents: 20681
diff changeset
239 method = args(1).xstring_value ("urlread: METHOD must be a string");
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
240
19404
c2f4f6eb5907 A few more instances of stricter input validation for strings (bug #42651).
Rik <rik@octave.org>
parents: 19403
diff changeset
241 if (method != "get" && method != "post")
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20819
diff changeset
242 error ("urlread: METHOD must be \"get\" or \"post\"");
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
243
20700
68e3a747ca02 rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents: 20681
diff changeset
244 param = args(2).xcellstr_value ("urlread: parameters (PARAM) for get and post requests must be given as a cell array of strings");
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
245
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18391
diff changeset
246 if (param.numel () % 2 == 1)
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20819
diff changeset
247 error ("urlread: number of elements in PARAM must be even");
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
248 }
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
249
6986
4ad04ff722d7 [project @ 2007-10-09 17:43:00 by jwe]
jwe
parents: 6984
diff changeset
250 std::ostringstream buf;
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
251
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
252 octave::url_transfer url_xfer = octave::url_transfer (url, buf);
17596
43b9181340fb separate object creation from http actions in url_transfer class
John W. Eaton <jwe@octave.org>
parents: 17556
diff changeset
253
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
254 if (! url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
255 error ("support for URL transfers was disabled when Octave was built");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
256
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
257 url_xfer.http_action (param, method);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
258
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
259 octave_value_list retval;
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
260
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
261 if (nargout > 0)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
262 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
263 // Return empty string if no error occurred.
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
264 retval = ovl (buf.str (), url_xfer.good (),
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
265 url_xfer.good () ? "" : url_xfer.lasterror ());
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
266 }
18287
9a43d8d6e29e avoid startup crash if curl library is not available (bug #41067)
John W. Eaton <jwe@octave.org>
parents: 17861
diff changeset
267
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
268 if (nargout < 2 && ! url_xfer.good ())
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
269 error ("urlread: %s", url_xfer.lasterror ().c_str ());
6043
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
270
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
271 return retval;
199f15a8d1fc [project @ 2006-10-09 19:49:03 by jwe]
jwe
parents:
diff changeset
272 }
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
273
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
274 DEFMETHOD (__ftp__, interp, args, ,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
275 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
276 @deftypefn {} {@var{handle} =} __ftp__ (@var{host})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
277 @deftypefnx {} {@var{handle} =} __ftp__ (@var{host}, @var{username}, @var{password})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
278 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
279 @end deftypefn */)
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
280 {
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
281 int nargin = args.length ();
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
282
17548
92541ff4cc3c improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents: 17546
diff changeset
283 if (nargin < 1 || nargin > 3)
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
284 print_usage ();
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
285
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
286 std::string host = args(0).xstring_value ("__ftp__: HOST must be a string");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
287
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
288 std::string user = (nargin > 1)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
289 ? args(1).xstring_value ("__ftp__: USER must be a string")
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
290 : std::string ("anonymous");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
291
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
292 std::string passwd = (nargin > 2)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20726
diff changeset
293 ? args(2).xstring_value ("__ftp__: PASSWD must be a string")
21017
93748bcaec17 maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents: 21005
diff changeset
294 : "";
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
295
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
296 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
297
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
298 octave::url_handle uh = uhm.make_url_handle (host, user, passwd,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
299 octave_stdout);
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
300
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
301 return ovl (uh.value ());
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
302 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
303
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
304 DEFMETHOD (__ftp_pwd__, interp, args, ,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
305 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
306 @deftypefn {} {} __ftp_pwd__ (@var{handle})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
307 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
308 @end deftypefn */)
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
309 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
310 if (args.length () != 1)
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11548
diff changeset
311 error ("__ftp_pwd__: incorrect number of arguments");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
312
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
313 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
17551
8fca0bbdd4c1 reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents: 17550
diff changeset
314
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
315 octave::url_transfer url_xfer = uhm.get_object (args(0));
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
316
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
317 if (! url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
318 error ("__ftp_pwd__: invalid ftp handle");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
319
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
320 return ovl (url_xfer.pwd ());
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
321 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
322
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
323 DEFMETHOD (__ftp_cwd__, interp, args, ,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
324 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
325 @deftypefn {} {} __ftp_cwd__ (@var{handle}, @var{path})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
326 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
327 @end deftypefn */)
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
328 {
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
329 int nargin = args.length ();
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
330
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
331 if (nargin != 1 && nargin != 2)
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11548
diff changeset
332 error ("__ftp_cwd__: incorrect number of arguments");
17551
8fca0bbdd4c1 reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents: 17550
diff changeset
333
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
334 std::string path = "";
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
335 if (nargin > 1)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
336 path = args(1).xstring_value ("__ftp_cwd__: PATH must be a string");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
337
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
338 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
339
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
340 octave::url_transfer url_xfer = uhm.get_object (args(0));
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
341
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
342 if (! url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
343 error ("__ftp_cwd__: invalid ftp handle");
17548
92541ff4cc3c improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents: 17546
diff changeset
344
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
345 url_xfer.cwd (path);
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
346
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
347 return ovl ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
348 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
349
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
350 DEFMETHOD (__ftp_dir__, interp, args, nargout,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
351 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
352 @deftypefn {} {} __ftp_dir__ (@var{handle})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
353 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
354 @end deftypefn */)
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
355 {
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
356 if (args.length () != 1)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
357 error ("__ftp_dir__: incorrect number of arguments");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
358
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
359 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
360
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
361 octave::url_transfer url_xfer = uhm.get_object (args(0));
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
362
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
363 if (! url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
364 error ("__ftp_dir__: invalid ftp handle");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
365
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
366 octave_value retval;
17551
8fca0bbdd4c1 reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents: 17550
diff changeset
367
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
368 if (nargout == 0)
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
369 url_xfer.dir ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
370 else
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
371 {
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
372 string_vector sv = url_xfer.list ();
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
373 octave_idx_type n = sv.numel ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
374
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
375 if (n == 0)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
376 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
377 string_vector flds (5);
17548
92541ff4cc3c improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents: 17546
diff changeset
378
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
379 flds(0) = "name";
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
380 flds(1) = "date";
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
381 flds(2) = "bytes";
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
382 flds(3) = "isdir";
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
383 flds(4) = "datenum";
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
384
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
385 retval = octave_map (flds);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10084
diff changeset
386 }
17548
92541ff4cc3c improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents: 17546
diff changeset
387 else
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
388 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
389 octave_map st;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
390
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
391 Cell filectime (dim_vector (n, 1));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
392 Cell filesize (dim_vector (n, 1));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
393 Cell fileisdir (dim_vector (n, 1));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
394 Cell filedatenum (dim_vector (n, 1));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
395
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
396 st.assign ("name", Cell (sv));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
397
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
398 for (octave_idx_type i = 0; i < n; i++)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
399 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
400 time_t ftime;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
401 bool fisdir;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
402 double fsize;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
403
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
404 url_xfer.get_fileinfo (sv(i), fsize, ftime, fisdir);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
405
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
406 fileisdir (i) = fisdir;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
407 filectime (i) = ctime (&ftime);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
408 filesize (i) = fsize;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
409 filedatenum (i) = double (ftime);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
410 }
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
411
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
412 st.assign ("date", filectime);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
413 st.assign ("bytes", filesize);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
414 st.assign ("isdir", fileisdir);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
415 st.assign ("datenum", filedatenum);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
416
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
417 retval = st;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
418 }
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
419 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
420
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
421 return retval;
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
422 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
423
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
424 DEFMETHOD (__ftp_ascii__, interp, args, ,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
425 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
426 @deftypefn {} {} __ftp_ascii__ (@var{handle})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
427 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
428 @end deftypefn */)
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
429 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
430 if (args.length () != 1)
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11548
diff changeset
431 error ("__ftp_ascii__: incorrect number of arguments");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
432
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
433 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
17551
8fca0bbdd4c1 reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents: 17550
diff changeset
434
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
435 octave::url_transfer url_xfer = uhm.get_object (args(0));
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
436
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
437 if (! url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
438 error ("__ftp_ascii__: invalid ftp handle");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
439
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
440 url_xfer.ascii ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
441
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
442 return ovl ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
443 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
444
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
445 DEFMETHOD (__ftp_binary__, interp, args, ,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
446 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
447 @deftypefn {} {} __ftp_binary__ (@var{handle})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
448 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
449 @end deftypefn */)
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
450 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
451 if (args.length () != 1)
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11548
diff changeset
452 error ("__ftp_binary__: incorrect number of arguments");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
453
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
454 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
17551
8fca0bbdd4c1 reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents: 17550
diff changeset
455
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
456 octave::url_transfer url_xfer = uhm.get_object (args(0));
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
457
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
458 if (! url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
459 error ("__ftp_binary__: invalid ftp handle");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
460
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
461 url_xfer.binary ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
462
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
463 return ovl ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
464 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
465
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
466 DEFMETHOD (__ftp_close__, interp, args, ,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
467 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
468 @deftypefn {} {} __ftp_close__ (@var{handle})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
469 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
470 @end deftypefn */)
17318
accafe1aee7c Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents: 15326
diff changeset
471 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
472 if (args.length () != 1)
17318
accafe1aee7c Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents: 15326
diff changeset
473 error ("__ftp_close__: incorrect number of arguments");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
474
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
475 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
476
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
477 octave::url_handle h = uhm.lookup (args(0));
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
478
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
479 if (! h.ok ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
480 error ("__ftp_close__: invalid ftp handle");
17551
8fca0bbdd4c1 reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents: 17550
diff changeset
481
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
482 uhm.free (h);
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
483
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
484 return ovl ();
17318
accafe1aee7c Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents: 15326
diff changeset
485 }
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
486
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
487 DEFMETHOD (__ftp_mode__, interp, args, ,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
488 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
489 @deftypefn {} {} __ftp_mode__ (@var{handle})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
490 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
491 @end deftypefn */)
17318
accafe1aee7c Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents: 15326
diff changeset
492 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
493 if (args.length () != 1)
17318
accafe1aee7c Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents: 15326
diff changeset
494 error ("__ftp_mode__: incorrect number of arguments");
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
495
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
496 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
17551
8fca0bbdd4c1 reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents: 17550
diff changeset
497
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
498 octave::url_transfer url_xfer = uhm.get_object (args(0));
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
499
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
500 if (! url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
501 error ("__ftp_binary__: invalid ftp handle");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
502
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
503 return ovl (url_xfer.is_ascii () ? "ascii" : "binary");
17318
accafe1aee7c Make use of gripe_disabled_feature() instead of custom error message.
Carnë Draug <carandraug@octave.org>
parents: 15326
diff changeset
504 }
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
505
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
506 DEFMETHOD (__ftp_delete__, interp, args, ,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
507 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
508 @deftypefn {} {} __ftp_delete__ (@var{handle}, @var{path})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
509 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
510 @end deftypefn */)
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
511 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
512 if (args.length () != 2)
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11548
diff changeset
513 error ("__ftp_delete__: incorrect number of arguments");
17551
8fca0bbdd4c1 reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents: 17550
diff changeset
514
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
515 std::string file = args(1).xstring_value ("__ftp_delete__: FILE must be a string");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
516
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
517 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
518
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
519 octave::url_transfer url_xfer = uhm.get_object (args(0));
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
520
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
521 if (! url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
522 error ("__ftp_delete__: invalid ftp handle");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
523
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
524 url_xfer.del (file);
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
525
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
526 return ovl ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
527 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
528
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
529 DEFMETHOD (__ftp_rmdir__, interp, args, ,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
530 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
531 @deftypefn {} {} __ftp_rmdir__ (@var{handle}, @var{path})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
532 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
533 @end deftypefn */)
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
534 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
535 if (args.length () != 2)
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11548
diff changeset
536 error ("__ftp_rmdir__: incorrect number of arguments");
17551
8fca0bbdd4c1 reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents: 17550
diff changeset
537
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
538 std::string dir = args(1).xstring_value ("__ftp_rmdir__: DIR must be a string");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
539
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
540 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
541
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
542 octave::url_transfer url_xfer = uhm.get_object (args(0));
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
543
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
544 if (! url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
545 error ("__ftp_rmdir__: invalid ftp handle");
17551
8fca0bbdd4c1 reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents: 17550
diff changeset
546
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
547 url_xfer.rmdir (dir);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
548
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
549 return ovl ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
550 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
551
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
552 DEFMETHOD (__ftp_mkdir__, interp, args, ,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
553 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
554 @deftypefn {} {} __ftp_mkdir__ (@var{handle}, @var{path})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
555 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
556 @end deftypefn */)
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
557 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
558 if (args.length () != 2)
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11548
diff changeset
559 error ("__ftp_mkdir__: incorrect number of arguments");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
560
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
561 std::string dir = args(1).xstring_value ("__ftp_mkdir__: DIR must be a string");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
562
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
563 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
564
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
565 octave::url_transfer url_xfer = uhm.get_object (args(0));
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
566
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
567 if (! url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
568 error ("__ftp_mkdir__: invalid ftp handle");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
569
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
570 url_xfer.mkdir (dir);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
571
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
572 return ovl ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
573 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
574
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
575 DEFMETHOD (__ftp_rename__, interp, args, ,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
576 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
577 @deftypefn {} {} __ftp_rename__ (@var{handle}, @var{path})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
578 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
579 @end deftypefn */)
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
580 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
581 if (args.length () != 3)
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11548
diff changeset
582 error ("__ftp_rename__: incorrect number of arguments");
17551
8fca0bbdd4c1 reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents: 17550
diff changeset
583
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
584 std::string oldname = args(1).xstring_value ("__ftp_rename__: OLDNAME must be a string");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
585 std::string newname = args(2).xstring_value ("__ftp_rename__: NEWNAME must be a string");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
586
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
587 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
588
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
589 octave::url_transfer url_xfer = uhm.get_object (args(0));
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
590
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
591 if (url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
592 error ("__ftp_rename__: invalid ftp handle");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
593
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
594 url_xfer.rename (oldname, newname);
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
595
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
596 return ovl ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
597 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
598
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
599 DEFMETHOD (__ftp_mput__, interp, args, nargout,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
600 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
601 @deftypefn {} {} __ftp_mput__ (@var{handle}, @var{files})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
602 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
603 @end deftypefn */)
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
604 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20799
diff changeset
605 if (args.length () != 2)
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11548
diff changeset
606 error ("__ftp_mput__: incorrect number of arguments");
17551
8fca0bbdd4c1 reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents: 17550
diff changeset
607
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
608 std::string pat = args(1).xstring_value ("__ftp_mput__: PATTERN must be a string");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
609
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
610 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
611
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
612 octave::url_transfer url_xfer = uhm.get_object (args(0));
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
613
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
614 if (! url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
615 error ("__ftp_mput__: invalid ftp handle");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
616
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
617 string_vector file_list;
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
618
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
619 glob_match pattern (octave::sys::file_ops::tilde_expand (pat));
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
620 string_vector files = pattern.glob ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
621
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
622 for (octave_idx_type i = 0; i < files.numel (); i++)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
623 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
624 std::string file = files(i);
17553
2d01e20abd85 rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 17551
diff changeset
625
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
626 octave::sys::file_stat fs (file);
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
627
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
628 if (! fs.exists ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
629 error ("__ftp__mput: file does not exist");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
630
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
631 if (fs.is_dir ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
632 {
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
633 file_list.append (url_xfer.mput_directory ("", file));
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
634
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
635 if (! url_xfer.good ())
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
636 error ("__ftp_mput__: %s", url_xfer.lasterror ().c_str ());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10084
diff changeset
637 }
17548
92541ff4cc3c improve implementation of ftp object handles
John W. Eaton <jwe@octave.org>
parents: 17546
diff changeset
638 else
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
639 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
640 // FIXME: Does ascii mode need to be flagged here?
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
641 std::ifstream ifile (file.c_str (), std::ios::in | std::ios::binary);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
642
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
643 if (! ifile.is_open ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
644 error ("__ftp_mput__: unable to open file");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
645
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
646 url_xfer.put (file, ifile);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
647
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
648 ifile.close ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
649
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
650 if (! url_xfer.good ())
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
651 error ("__ftp_mput__: %s", url_xfer.lasterror ().c_str ());
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
652
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
653 file_list.append (file);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
654 }
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
655 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
656
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
657 if (nargout > 0)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
658 return ovl (file_list);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
659 else
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
660 return ovl ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
661 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
662
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
663 DEFMETHOD (__ftp_mget__, interp, args, ,
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
664 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
665 @deftypefn {} {} __ftp_mget__ (@var{handle}, @var{pattern})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
666 @deftypefnx {} {} __ftp_mget__ (@var{handle}, @var{pattern}, @var{target})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
667 Undocumented internal function
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
668 @end deftypefn */)
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
669 {
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
670 int nargin = args.length ();
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
671
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
672 if (nargin != 2 && nargin != 3)
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11548
diff changeset
673 error ("__ftp_mget__: incorrect number of arguments");
17551
8fca0bbdd4c1 reorganize curl wrapper class
John W. Eaton <jwe@octave.org>
parents: 17550
diff changeset
674
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
675 std::string file = args(1).xstring_value ("__ftp_mget__: PATTERN must be a string");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
676
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
677 std::string target;
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
678
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23461
diff changeset
679 if (nargin == 3 && ! args(2).isempty ())
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
680 target = args(2).xstring_value ("__ftp_mget__: TARGET must be a string") + octave::sys::file_ops::dir_sep_str ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
681
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
682 octave::url_handle_manager& uhm = interp.get_url_handle_manager ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
683
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
684 octave::url_transfer url_xfer = uhm.get_object (args(0));
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
685
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
686 if (! url_xfer.is_valid ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
687 error ("__ftp_mget__: invalid ftp handle");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
688
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
689 string_vector sv = url_xfer.list ();
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
690 octave_idx_type n = 0;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
691 glob_match pattern (file);
17553
2d01e20abd85 rework error handling for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 17551
diff changeset
692
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
693 for (octave_idx_type i = 0; i < sv.numel (); i++)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
694 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
695 if (pattern.match (sv(i)))
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
696 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
697 n++;
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
698
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
699 time_t ftime;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
700 bool fisdir;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
701 double fsize;
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
702
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
703 url_xfer.get_fileinfo (sv(i), fsize, ftime, fisdir);
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
704
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
705 if (fisdir)
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
706 url_xfer.mget_directory (sv(i), target);
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
707 else
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
708 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
709 std::ofstream ofile ((target + sv(i)).c_str (),
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
710 std::ios::out |
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
711 std::ios::binary);
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
712
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
713 if (! ofile.is_open ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
714 error ("__ftp_mget__: unable to open file");
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
715
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
716 octave::unwind_protect_safe frame;
20679
19d6f94c21cb eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20577
diff changeset
717
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
718 frame.add_fcn (delete_file, target + sv(i));
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
719
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
720 url_xfer.get (sv(i), ofile);
20679
19d6f94c21cb eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20577
diff changeset
721
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
722 ofile.close ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
723
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
724 if (url_xfer.good ())
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
725 frame.discard ();
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10084
diff changeset
726 }
20679
19d6f94c21cb eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20577
diff changeset
727
23742
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
728 if (! url_xfer.good ())
1f0daaf81955 don't use singleton for ch_manager, rename to url_handle_manager
John W. Eaton <jwe@octave.org>
parents: 23577
diff changeset
729 error ("__ftp_mget__: %s", url_xfer.lasterror().c_str());
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10084
diff changeset
730 }
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
731 }
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
732
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
733 if (n == 0)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
734 error ("__ftp_mget__: file not found");
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20909
diff changeset
735
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20940
diff changeset
736 return ovl ();
9880
7f77e5081e83 Add ftp objects
David Bateman <dbateman@free.fr>
parents: 9064
diff changeset
737 }