comparison libinterp/dldfcn/urlwrite.cc @ 17318:accafe1aee7c

Make use of gripe_disabled_feature() instead of custom error message. * urlwrite.cc: make use of the standard gripe_disabled_feature() function to error, instead of custom error messages. (__ftp_mode__, __ftp__close): fix weird 3 space indentation.
author Carnë Draug <carandraug@octave.org>
date Fri, 23 Aug 2013 14:43:06 +0100
parents 81fe6665ed3c
children 53ae37d37b16
comparison
equal deleted inserted replaced
17317:56fe31b248de 17318:accafe1aee7c
46 #include "ov-cell.h" 46 #include "ov-cell.h"
47 #include "pager.h" 47 #include "pager.h"
48 #include "oct-map.h" 48 #include "oct-map.h"
49 #include "oct-refcount.h" 49 #include "oct-refcount.h"
50 #include "unwind-prot.h" 50 #include "unwind-prot.h"
51 #include "gripes.h"
51 52
52 #ifdef HAVE_CURL 53 #ifdef HAVE_CURL
53 54
54 #include <curl/curl.h> 55 #include <curl/curl.h>
55 #include <curl/curlver.h> 56 #include <curl/curlver.h>
841 842
842 if (nargout < 2 && ! ok) 843 if (nargout < 2 && ! ok)
843 error ("urlwrite: curl: %s", curl.lasterror ().c_str ()); 844 error ("urlwrite: curl: %s", curl.lasterror ().c_str ());
844 845
845 #else 846 #else
846 error ("urlwrite: not available in this version of Octave"); 847 gripe_disabled_feature ("urlwrite", "urlwrite");
847 #endif 848 #endif
848 849
849 return retval; 850 return retval;
850 } 851 }
851 852
960 961
961 if (nargout < 2 && ! ok) 962 if (nargout < 2 && ! ok)
962 error ("urlread: curl: %s", curl.lasterror().c_str()); 963 error ("urlread: curl: %s", curl.lasterror().c_str());
963 964
964 #else 965 #else
965 error ("urlread: not available in this version of Octave"); 966 gripe_disabled_feature ("urlread", "urlread");
966 #endif 967 #endif
967 968
968 return retval; 969 return retval;
969 } 970 }
970 971
1002 if (error_state) 1003 if (error_state)
1003 handles.del (handle); 1004 handles.del (handle);
1004 } 1005 }
1005 } 1006 }
1006 #else 1007 #else
1007 error ("__ftp__: not available in this version of Octave"); 1008 gripe_disabled_feature ("__ftp__", "FTP");
1008 #endif 1009 #endif
1009 1010
1010 return octave_value (); 1011 return octave_value ();
1011 } 1012 }
1012 1013
1035 else 1036 else
1036 error ("__ftp_pwd__: invalid ftp handle"); 1037 error ("__ftp_pwd__: invalid ftp handle");
1037 } 1038 }
1038 } 1039 }
1039 #else 1040 #else
1040 error ("__ftp_pwd__: not available in this version of Octave"); 1041 gripe_disabled_feature ("__ftp_pwd__", "FTP");
1041 #endif 1042 #endif
1042 1043
1043 return retval; 1044 return retval;
1044 } 1045 }
1045 1046
1071 else 1072 else
1072 error ("__ftp_cwd__: invalid ftp handle"); 1073 error ("__ftp_cwd__: invalid ftp handle");
1073 } 1074 }
1074 } 1075 }
1075 #else 1076 #else
1076 error ("__ftp_cwd__: not available in this version of Octave"); 1077 gripe_disabled_feature ("__ftp_cwd__", "FTP");
1077 #endif 1078 #endif
1078 1079
1079 return octave_value (); 1080 return octave_value ();
1080 } 1081 }
1081 1082
1151 else 1152 else
1152 error ("__ftp_dir__: invalid ftp handle"); 1153 error ("__ftp_dir__: invalid ftp handle");
1153 } 1154 }
1154 } 1155 }
1155 #else 1156 #else
1156 error ("__ftp_dir__: not available in this version of Octave"); 1157 gripe_disabled_feature ("__ftp_dir__", "FTP");
1157 #endif 1158 #endif
1158 1159
1159 return retval; 1160 return retval;
1160 } 1161 }
1161 1162
1183 else 1184 else
1184 error ("__ftp_ascii__: invalid ftp handle"); 1185 error ("__ftp_ascii__: invalid ftp handle");
1185 } 1186 }
1186 } 1187 }
1187 #else 1188 #else
1188 error ("__ftp_ascii__: not available in this version of Octave"); 1189 gripe_disabled_feature ("__ftp_ascii__", "FTP");
1189 #endif 1190 #endif
1190 1191
1191 return octave_value (); 1192 return octave_value ();
1192 } 1193 }
1193 1194
1215 else 1216 else
1216 error ("__ftp_binary__: invalid ftp handle"); 1217 error ("__ftp_binary__: invalid ftp handle");
1217 } 1218 }
1218 } 1219 }
1219 #else 1220 #else
1220 error ("__ftp_binary__: not available in this version of Octave"); 1221 gripe_disabled_feature ("__ftp_binary__", "FTP");
1221 #endif 1222 #endif
1222 1223
1223 return octave_value (); 1224 return octave_value ();
1224 } 1225 }
1225 1226
1226 DEFUN_DLD (__ftp_close__, args, , 1227 DEFUN_DLD (__ftp_close__, args, ,
1227 "-*- texinfo -*-\n\ 1228 "-*- texinfo -*-\n\
1228 @deftypefn {Loadable Function} {} __ftp_close__ (@var{handle})\n\ 1229 @deftypefn {Loadable Function} {} __ftp_close__ (@var{handle})\n\
1229 Undocumented internal function\n\ 1230 Undocumented internal function\n\
1230 @end deftypefn") 1231 @end deftypefn")
1231 { 1232 {
1232 #ifdef HAVE_CURL 1233 #ifdef HAVE_CURL
1233 int nargin = args.length (); 1234 int nargin = args.length ();
1234 1235
1235 if (nargin != 1) 1236 if (nargin != 1)
1236 error ("__ftp_close__: incorrect number of arguments"); 1237 error ("__ftp_close__: incorrect number of arguments");
1237 else 1238 else
1238 { 1239 {
1239 std::string handle = args(0).string_value (); 1240 std::string handle = args(0).string_value ();
1240 1241
1241 if (!error_state) 1242 if (! error_state)
1242 handles.del (handle); 1243 handles.del (handle);
1243 } 1244 }
1244 #else 1245 #else
1245 error ("__ftp_close__: not available in this version of Octave"); 1246 gripe_disabled_feature ("__ftp_close__", "FTP");
1246 #endif 1247 #endif
1247 1248
1248 return octave_value (); 1249 return octave_value ();
1249 } 1250 }
1250 1251
1251 DEFUN_DLD (__ftp_mode__, args, , 1252 DEFUN_DLD (__ftp_mode__, args, ,
1252 "-*- texinfo -*-\n\ 1253 "-*- texinfo -*-\n\
1253 @deftypefn {Loadable Function} {} __ftp_mode__ (@var{handle})\n\ 1254 @deftypefn {Loadable Function} {} __ftp_mode__ (@var{handle})\n\
1254 Undocumented internal function\n\ 1255 Undocumented internal function\n\
1255 @end deftypefn") 1256 @end deftypefn")
1256 { 1257 {
1257 octave_value retval; 1258 octave_value retval;
1258 #ifdef HAVE_CURL 1259 #ifdef HAVE_CURL
1259 int nargin = args.length (); 1260 int nargin = args.length ();
1260 1261
1261 if (nargin != 1) 1262 if (nargin != 1)
1262 error ("__ftp_mode__: incorrect number of arguments"); 1263 error ("__ftp_mode__: incorrect number of arguments");
1263 else 1264 else
1264 { 1265 {
1265 std::string handle = args(0).string_value (); 1266 std::string handle = args(0).string_value ();
1266 1267
1267 1268
1268 if (!error_state) 1269 if (! error_state)
1269 { 1270 {
1270 const curl_handle curl = handles.contents (handle); 1271 const curl_handle curl = handles.contents (handle);
1271 1272
1272 if (curl.is_valid ()) 1273 if (curl.is_valid ())
1273 retval = (curl.is_ascii () ? "ascii" : "binary"); 1274 retval = (curl.is_ascii () ? "ascii" : "binary");
1274 else 1275 else
1275 error ("__ftp_binary__: invalid ftp handle"); 1276 error ("__ftp_binary__: invalid ftp handle");
1276 } 1277 }
1277 } 1278 }
1278 #else 1279 #else
1279 error ("__ftp_mode__: not available in this version of Octave"); 1280 gripe_disabled_feature ("__ftp_mode__", "FTP");
1280 #endif 1281 #endif
1281 1282
1282 return retval; 1283 return retval;
1283 } 1284 }
1284 1285
1285 DEFUN_DLD (__ftp_delete__, args, , 1286 DEFUN_DLD (__ftp_delete__, args, ,
1286 "-*- texinfo -*-\n\ 1287 "-*- texinfo -*-\n\
1287 @deftypefn {Loadable Function} {} __ftp_delete__ (@var{handle}, @var{path})\n\ 1288 @deftypefn {Loadable Function} {} __ftp_delete__ (@var{handle}, @var{path})\n\
1288 Undocumented internal function\n\ 1289 Undocumented internal function\n\
1307 else 1308 else
1308 error ("__ftp_delete__: invalid ftp handle"); 1309 error ("__ftp_delete__: invalid ftp handle");
1309 } 1310 }
1310 } 1311 }
1311 #else 1312 #else
1312 error ("__ftp_delete__: not available in this version of Octave"); 1313 gripe_disabled_feature ("__ftp_delete__", "FTP");
1313 #endif 1314 #endif
1314 1315
1315 return octave_value (); 1316 return octave_value ();
1316 } 1317 }
1317 1318
1340 else 1341 else
1341 error ("__ftp_rmdir__: invalid ftp handle"); 1342 error ("__ftp_rmdir__: invalid ftp handle");
1342 } 1343 }
1343 } 1344 }
1344 #else 1345 #else
1345 error ("__ftp_rmdir__: not available in this version of Octave"); 1346 gripe_disabled_feature ("__ftp_rmdir__", "FTP");
1346 #endif 1347 #endif
1347 1348
1348 return octave_value (); 1349 return octave_value ();
1349 } 1350 }
1350 1351
1373 else 1374 else
1374 error ("__ftp_mkdir__: invalid ftp handle"); 1375 error ("__ftp_mkdir__: invalid ftp handle");
1375 } 1376 }
1376 } 1377 }
1377 #else 1378 #else
1378 error ("__ftp_mkdir__: not available in this version of Octave"); 1379 gripe_disabled_feature ("__ftp_mkdir__", "FTP");
1379 #endif 1380 #endif
1380 1381
1381 return octave_value (); 1382 return octave_value ();
1382 } 1383 }
1383 1384
1407 else 1408 else
1408 error ("__ftp_rename__: invalid ftp handle"); 1409 error ("__ftp_rename__: invalid ftp handle");
1409 } 1410 }
1410 } 1411 }
1411 #else 1412 #else
1412 error ("__ftp_rename__: not available in this version of Octave"); 1413 gripe_disabled_feature ("__ftp_rename__", "FTP");
1413 #endif 1414 #endif
1414 1415
1415 return octave_value (); 1416 return octave_value ();
1416 } 1417 }
1417 1418
1572 else 1573 else
1573 error ("__ftp_mput__: invalid ftp handle"); 1574 error ("__ftp_mput__: invalid ftp handle");
1574 } 1575 }
1575 } 1576 }
1576 #else 1577 #else
1577 error ("__ftp_mput__: not available in this version of Octave"); 1578 gripe_disabled_feature ("__ftp_mput__", "FTP");
1578 #endif 1579 #endif
1579 1580
1580 return (nargout > 0 ? octave_value (retval) : octave_value ()); 1581 return (nargout > 0 ? octave_value (retval) : octave_value ());
1581 } 1582 }
1582 1583
1733 error ("__ftp_mget__: file not found"); 1734 error ("__ftp_mget__: file not found");
1734 } 1735 }
1735 } 1736 }
1736 } 1737 }
1737 #else 1738 #else
1738 error ("__ftp_mget__: not available in this version of Octave"); 1739 gripe_disabled_feature ("__ftp_mget__", "FTP");
1739 #endif 1740 #endif
1740 1741
1741 return octave_value (); 1742 return octave_value ();
1742 } 1743 }