Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > f149f58f4a75af135bdb24f5dfe94165 > files > 1232

libdap-doc-3.9.3-3mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>libdap++: getdap.cc Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>getdap.cc</h1><a href="getdap_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="comment">// -*- mode: c++; c-basic-offset:4 -*-</span>
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 <span class="comment">// This file is part of libdap, A C++ implementation of the OPeNDAP Data</span>
<a name="l00005"></a>00005 <span class="comment">// Access Protocol.</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="comment">// Copyright (c) 2002,2003 OPeNDAP, Inc.</span>
<a name="l00008"></a>00008 <span class="comment">// Author: James Gallagher &lt;jgallagher@opendap.org&gt;</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// This library is free software; you can redistribute it and/or</span>
<a name="l00011"></a>00011 <span class="comment">// modify it under the terms of the GNU Lesser General Public</span>
<a name="l00012"></a>00012 <span class="comment">// License as published by the Free Software Foundation; either</span>
<a name="l00013"></a>00013 <span class="comment">// version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// This library is distributed in the hope that it will be useful,</span>
<a name="l00016"></a>00016 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00017"></a>00017 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<a name="l00018"></a>00018 <span class="comment">// Lesser General Public License for more details.</span>
<a name="l00019"></a>00019 <span class="comment">//</span>
<a name="l00020"></a>00020 <span class="comment">// You should have received a copy of the GNU Lesser General Public</span>
<a name="l00021"></a>00021 <span class="comment">// License along with this library; if not, write to the Free Software</span>
<a name="l00022"></a>00022 <span class="comment">// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</span>
<a name="l00023"></a>00023 <span class="comment">//</span>
<a name="l00024"></a>00024 <span class="comment">// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="comment">// (c) COPYRIGHT URI/MIT 1997-1999</span>
<a name="l00027"></a>00027 <span class="comment">// Please read the full copyright statement in the file COPYRIGHT_URI.</span>
<a name="l00028"></a>00028 <span class="comment">//</span>
<a name="l00029"></a>00029 <span class="comment">// Authors:</span>
<a name="l00030"></a>00030 <span class="comment">//      jhrg,jimg       James Gallagher &lt;jgallagher@gso.uri.edu&gt;</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="comment">// This is the source to `getdap'; a simple tool to exercise the Connect</span>
<a name="l00033"></a>00033 <span class="comment">// class. It can be used to get naked URLs as well as the DAP2 DAS and DDS</span>
<a name="l00034"></a>00034 <span class="comment">// objects.  jhrg.</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="preprocessor">#include "<a class="code" href="config_8h.html">config.h</a>"</span>
<a name="l00037"></a>00037 
<a name="l00038"></a>00038 <span class="keyword">static</span> <span class="keywordtype">char</span> rcsid[] <a class="code" href="config_8h.html#05e109ec893d0b12023d5b0cf4f718c4">not_used</a> =
<a name="l00039"></a>00039     { <span class="stringliteral">"$Id: getdap.cc 19917 2008-11-25 23:47:56Z jimg $"</span>
<a name="l00040"></a>00040     };
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 <span class="preprocessor">#ifdef WIN32</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#include &lt;io.h&gt;</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include &lt;fcntl.h&gt;</span>
<a name="l00045"></a>00045 <span class="preprocessor">#endif</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span>
<a name="l00047"></a>00047 <span class="preprocessor">#include &lt;cstring&gt;</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include &lt;sstream&gt;</span>
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 <span class="preprocessor">#include "GetOpt.h"</span>
<a name="l00052"></a>00052 
<a name="l00053"></a>00053 <span class="preprocessor">#include "<a class="code" href="AISConnect_8h.html">AISConnect.h</a>"</span>
<a name="l00054"></a>00054 <span class="preprocessor">#include "<a class="code" href="Response_8h.html">Response.h</a>"</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include "<a class="code" href="StdinResponse_8h.html">StdinResponse.h</a>"</span>
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 <span class="keyword">using</span> std::cerr;
<a name="l00058"></a>00058 <span class="keyword">using</span> std::endl;
<a name="l00059"></a>00059 <span class="keyword">using</span> std::flush;
<a name="l00060"></a>00060 
<a name="l00061"></a>00061 <span class="keyword">using namespace </span>libdap ;
<a name="l00062"></a>00062 
<a name="l00063"></a><a class="code" href="getdap_8cc.html#a31f487a99743d24af9076a3e11e5425">00063</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="getdap_8cc.html#a31f487a99743d24af9076a3e11e5425">version</a> = <a class="code" href="config_8h.html#3a86ed8fb42f5192508897934b5f977e">CVER</a> <span class="stringliteral">" ("</span> <a class="code" href="config_8h.html#b2eef76504098908aacbd5ec3433d93c">DVR</a> <span class="stringliteral">" DAP/"</span> <a class="code" href="config_8h.html#9757f0cc77df1fd0759b1b91a9f63ff0">DAP_PROTOCOL_VERSION</a> <span class="stringliteral">")"</span>;
<a name="l00064"></a>00064 
<a name="l00065"></a>00065 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="namespacelibdap.html#eafd230ca250e819c46862dc43deb4fa">libdap::dods_keep_temps</a>;     <span class="comment">// defined in HTTPResponse.h</span>
<a name="l00066"></a>00066 
<a name="l00067"></a><a class="code" href="getdap_8cc.html#9391ac68c9115711e45eb80120891130">00067</a> <span class="keywordtype">void</span> <a class="code" href="getdap_8cc.html#9391ac68c9115711e45eb80120891130">usage</a>(<span class="keywordtype">string</span> name)
<a name="l00068"></a>00068 {
<a name="l00069"></a>00069     cerr &lt;&lt; <span class="stringliteral">"Usage: "</span> &lt;&lt; name &lt;&lt; endl;
<a name="l00070"></a>00070     cerr &lt;&lt;
<a name="l00071"></a>00071     <span class="stringliteral">" [idDaxAVvks] [-B &lt;db&gt;][-c &lt;expr&gt;][-m &lt;num&gt;] &lt;url&gt; [&lt;url&gt; ...]"</span> &lt;&lt;
<a name="l00072"></a>00072     endl;
<a name="l00073"></a>00073     cerr &lt;&lt; <span class="stringliteral">" [VvksM] &lt;file&gt; [&lt;file&gt; ...]"</span> &lt;&lt; endl;
<a name="l00074"></a>00074     cerr &lt;&lt; endl;
<a name="l00075"></a>00075     cerr &lt;&lt; <span class="stringliteral">"In the first form of the command, dereference the URL and"</span>
<a name="l00076"></a>00076     &lt;&lt; endl;
<a name="l00077"></a>00077     cerr &lt;&lt; <span class="stringliteral">"perform the requested operations. This includes routing"</span> &lt;&lt;
<a name="l00078"></a>00078     endl;
<a name="l00079"></a>00079     cerr &lt;&lt; <span class="stringliteral">"the returned information through the DAP processing"</span> &lt;&lt; endl;
<a name="l00080"></a>00080     cerr &lt;&lt; <span class="stringliteral">"library (parsing the returned objects, et c.). If none"</span> &lt;&lt;
<a name="l00081"></a>00081     endl;
<a name="l00082"></a>00082     cerr &lt;&lt; <span class="stringliteral">"of a, d, or D are used with a URL, then the DAP library"</span> &lt;&lt;
<a name="l00083"></a>00083     endl;
<a name="l00084"></a>00084     cerr &lt;&lt; <span class="stringliteral">"routines are NOT used and the URLs contents are dumped"</span> &lt;&lt;
<a name="l00085"></a>00085     endl;
<a name="l00086"></a>00086     cerr &lt;&lt; <span class="stringliteral">"to standard output."</span> &lt;&lt; endl;
<a name="l00087"></a>00087     cerr &lt;&lt; endl;
<a name="l00088"></a>00088     cerr &lt;&lt; <span class="stringliteral">"In the second form of the command, assume the files are"</span> &lt;&lt;
<a name="l00089"></a>00089     endl;
<a name="l00090"></a>00090     cerr &lt;&lt; <span class="stringliteral">"DataDDS objects (stored in files or read from pipes)"</span> &lt;&lt; endl;
<a name="l00091"></a>00091     cerr &lt;&lt; <span class="stringliteral">"and process them as if -D were given. In this case the"</span> &lt;&lt;
<a name="l00092"></a>00092     endl;
<a name="l00093"></a>00093     cerr &lt;&lt; <span class="stringliteral">"information *must* contain valid MIME header in order"</span> &lt;&lt;
<a name="l00094"></a>00094     endl;
<a name="l00095"></a>00095     cerr &lt;&lt; <span class="stringliteral">"to be processed."</span> &lt;&lt; endl;
<a name="l00096"></a>00096     cerr &lt;&lt; endl;
<a name="l00097"></a>00097     cerr &lt;&lt; <span class="stringliteral">"Options:"</span> &lt;&lt; endl;
<a name="l00098"></a>00098     cerr &lt;&lt; <span class="stringliteral">"        i: For each URL, get the server version."</span> &lt;&lt; endl;
<a name="l00099"></a>00099     cerr &lt;&lt; <span class="stringliteral">"        d: For each URL, get the the DDS."</span> &lt;&lt; endl;
<a name="l00100"></a>00100     cerr &lt;&lt; <span class="stringliteral">"        a: For each URL, get the the DAS."</span> &lt;&lt; endl;
<a name="l00101"></a>00101     cerr &lt;&lt; <span class="stringliteral">"        A: Use the AIS for DAS objects."</span> &lt;&lt; endl;
<a name="l00102"></a>00102     cerr &lt;&lt; <span class="stringliteral">"        D: For each URL, get the the DataDDS."</span> &lt;&lt; endl;
<a name="l00103"></a>00103     cerr &lt;&lt;
<a name="l00104"></a>00104     <span class="stringliteral">"        x: For each URL, get the DDX object. Does not get data."</span>
<a name="l00105"></a>00105     &lt;&lt; endl;
<a name="l00106"></a>00106     cerr &lt;&lt; <span class="stringliteral">"        X: Build a DDX in getdap using the DDS and DAS."</span> &lt;&lt; endl;
<a name="l00107"></a>00107     cerr &lt;&lt; <span class="stringliteral">"        B: &lt;AIS xml dataBase&gt;. Overrides .dodsrc."</span> &lt;&lt; endl;
<a name="l00108"></a>00108     cerr &lt;&lt; <span class="stringliteral">"        v: Verbose."</span> &lt;&lt; endl;
<a name="l00109"></a>00109     cerr &lt;&lt; <span class="stringliteral">"        V: Version."</span> &lt;&lt; endl;
<a name="l00110"></a>00110     cerr &lt;&lt; <span class="stringliteral">"        c: &lt;expr&gt; is a constraint expression. Used with -D."</span> &lt;&lt;
<a name="l00111"></a>00111     endl;
<a name="l00112"></a>00112     cerr &lt;&lt; <span class="stringliteral">"           NB: You can use a `?' for the CE also."</span> &lt;&lt; endl;
<a name="l00113"></a>00113     cerr &lt;&lt; <span class="stringliteral">"        k: Keep temporary files created by libdap core"</span> &lt;&lt; endl;
<a name="l00114"></a>00114     cerr &lt;&lt; <span class="stringliteral">"        m: Request the same URL &lt;num&gt; times."</span> &lt;&lt; endl;
<a name="l00115"></a>00115     cerr &lt;&lt; <span class="stringliteral">"        z: Ask the server to compress data."</span> &lt;&lt; endl;
<a name="l00116"></a>00116     cerr &lt;&lt; <span class="stringliteral">"        s: Print Sequences using numbered rows."</span> &lt;&lt; endl;
<a name="l00117"></a>00117     cerr &lt;&lt; <span class="stringliteral">"        M: Assume data read from a file has no MIME headers"</span> &lt;&lt; endl;
<a name="l00118"></a>00118     cerr &lt;&lt; <span class="stringliteral">"           (the default is to assume the headers are present)."</span> &lt;&lt; endl;
<a name="l00119"></a>00119 }
<a name="l00120"></a>00120 
<a name="l00121"></a><a class="code" href="getdap_8cc.html#e894a8fa14082e1c9fe5146b6dba5c92">00121</a> <span class="keywordtype">bool</span> <a class="code" href="getdap_8cc.html#e894a8fa14082e1c9fe5146b6dba5c92">read_data</a>(FILE * fp)
<a name="l00122"></a>00122 {
<a name="l00123"></a>00123     <span class="keywordflow">if</span> (!fp) {
<a name="l00124"></a>00124         fprintf(stderr, <span class="stringliteral">"getdap: Whoa!!! Null stream pointer.\n"</span>);
<a name="l00125"></a>00125         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00126"></a>00126     }
<a name="l00127"></a>00127     <span class="comment">// Changed from a loop that used getc() to one that uses fread(). getc()</span>
<a name="l00128"></a>00128     <span class="comment">// worked fine for transfers of text information, but *not* for binary</span>
<a name="l00129"></a>00129     <span class="comment">// transfers. fread() will handle both.</span>
<a name="l00130"></a>00130     <span class="keywordtype">char</span> c;
<a name="l00131"></a>00131     <span class="keywordflow">while</span> (fp &amp;&amp; !feof(fp) &amp;&amp; fread(&amp;c, 1, 1, fp))
<a name="l00132"></a>00132         printf(<span class="stringliteral">"%c"</span>, c);        <span class="comment">// stick with stdio</span>
<a name="l00133"></a>00133 
<a name="l00134"></a>00134     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00135"></a>00135 }
<a name="l00136"></a>00136 
<a name="l00137"></a>00137 <span class="keyword">static</span> <span class="keywordtype">void</span> print_data(<a class="code" href="classlibdap_1_1DDS.html">DDS</a> &amp; dds, <span class="keywordtype">bool</span> print_rows = <span class="keyword">false</span>)
<a name="l00138"></a>00138 {
<a name="l00139"></a>00139     cout &lt;&lt; <span class="stringliteral">"The data:"</span> &lt;&lt; endl;
<a name="l00140"></a>00140 
<a name="l00141"></a>00141     <span class="keywordflow">for</span> (DDS::Vars_iter i = dds.<a class="code" href="classlibdap_1_1DDS.html#ac98f248cd5730a8769f9d71af9788d3" title="Return an iterator to the first variable.">var_begin</a>(); i != dds.<a class="code" href="classlibdap_1_1DDS.html#d204bbd6eed8d440fb996f41bc986058" title="Return an iterator.">var_end</a>(); i++) {
<a name="l00142"></a>00142         <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> *v = *i;
<a name="l00143"></a>00143         <span class="keywordflow">if</span> (print_rows &amp;&amp; (*i)-&gt;type() == <a class="code" href="namespacelibdap.html#05ca706d4539ae7b750c3bc7066ab6e60b03707324b30e4a7c88876bbf8c7e3b">dods_sequence_c</a>)
<a name="l00144"></a>00144             dynamic_cast &lt; Sequence * &gt;(*i)-&gt;print_val_by_rows(cout);
<a name="l00145"></a>00145         <span class="keywordflow">else</span>
<a name="l00146"></a>00146             v-&gt;<a class="code" href="classlibdap_1_1BaseType.html#16f82585af6b66f434f2132f05c4960c" title="Prints the value of the variable.">print_val</a>(cout);
<a name="l00147"></a>00147     }
<a name="l00148"></a>00148 
<a name="l00149"></a>00149     cout &lt;&lt; endl &lt;&lt; flush;
<a name="l00150"></a>00150 }
<a name="l00151"></a>00151 
<a name="l00152"></a><a class="code" href="getdap_8cc.html#0ddf1224851353fc92bfbff6f499fa97">00152</a> <span class="keywordtype">int</span> <a class="code" href="getdap_8cc.html#0ddf1224851353fc92bfbff6f499fa97">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
<a name="l00153"></a>00153 {
<a name="l00154"></a>00154     GetOpt getopt(argc, argv, <span class="stringliteral">"idaDxXAVvkB:c:m:zshM?Hp:"</span>);
<a name="l00155"></a>00155     <span class="keywordtype">int</span> option_char;
<a name="l00156"></a>00156 
<a name="l00157"></a>00157     <span class="keywordtype">bool</span> get_das = <span class="keyword">false</span>;
<a name="l00158"></a>00158     <span class="keywordtype">bool</span> get_dds = <span class="keyword">false</span>;
<a name="l00159"></a>00159     <span class="keywordtype">bool</span> get_data = <span class="keyword">false</span>;
<a name="l00160"></a>00160     <span class="keywordtype">bool</span> get_ddx = <span class="keyword">false</span>;
<a name="l00161"></a>00161     <span class="keywordtype">bool</span> build_ddx = <span class="keyword">false</span>;
<a name="l00162"></a>00162     <span class="keywordtype">bool</span> get_version = <span class="keyword">false</span>;
<a name="l00163"></a>00163     <span class="keywordtype">bool</span> cexpr = <span class="keyword">false</span>;
<a name="l00164"></a>00164     <span class="keywordtype">bool</span> verbose = <span class="keyword">false</span>;
<a name="l00165"></a>00165     <span class="keywordtype">bool</span> multi = <span class="keyword">false</span>;
<a name="l00166"></a>00166     <span class="keywordtype">bool</span> accept_deflate = <span class="keyword">false</span>;
<a name="l00167"></a>00167     <span class="keywordtype">bool</span> print_rows = <span class="keyword">false</span>;
<a name="l00168"></a>00168     <span class="keywordtype">bool</span> use_ais = <span class="keyword">false</span>;
<a name="l00169"></a>00169     <span class="keywordtype">bool</span> mime_headers = <span class="keyword">true</span>;
<a name="l00170"></a>00170     <span class="keywordtype">int</span> times = 1;
<a name="l00171"></a>00171     <span class="keywordtype">int</span> dap_client_major = 2;
<a name="l00172"></a>00172     <span class="keywordtype">int</span> dap_client_minor = 0;
<a name="l00173"></a>00173     <span class="keywordtype">string</span> expr = <span class="stringliteral">""</span>;
<a name="l00174"></a>00174     <span class="keywordtype">string</span> ais_db = <span class="stringliteral">""</span>;
<a name="l00175"></a>00175 
<a name="l00176"></a>00176 <span class="preprocessor">#ifdef WIN32</span>
<a name="l00177"></a>00177 <span class="preprocessor"></span>    _setmode(_fileno(stdout), _O_BINARY);
<a name="l00178"></a>00178 <span class="preprocessor">#endif</span>
<a name="l00179"></a>00179 <span class="preprocessor"></span>
<a name="l00180"></a>00180     <span class="keywordflow">while</span> ((option_char = getopt()) != EOF)
<a name="l00181"></a>00181         <span class="keywordflow">switch</span> (option_char) {
<a name="l00182"></a>00182         <span class="keywordflow">case</span> <span class="charliteral">'d'</span>:
<a name="l00183"></a>00183             get_dds = <span class="keyword">true</span>;
<a name="l00184"></a>00184             <span class="keywordflow">break</span>;
<a name="l00185"></a>00185         <span class="keywordflow">case</span> <span class="charliteral">'a'</span>:
<a name="l00186"></a>00186             get_das = <span class="keyword">true</span>;
<a name="l00187"></a>00187             <span class="keywordflow">break</span>;
<a name="l00188"></a>00188         <span class="keywordflow">case</span> <span class="charliteral">'D'</span>:
<a name="l00189"></a>00189             get_data = <span class="keyword">true</span>;
<a name="l00190"></a>00190             <span class="keywordflow">break</span>;
<a name="l00191"></a>00191         <span class="keywordflow">case</span> <span class="charliteral">'x'</span>:
<a name="l00192"></a>00192             get_ddx = <span class="keyword">true</span>;
<a name="l00193"></a>00193             <span class="keywordflow">break</span>;
<a name="l00194"></a>00194         <span class="keywordflow">case</span> <span class="charliteral">'X'</span>:
<a name="l00195"></a>00195             build_ddx = <span class="keyword">true</span>;
<a name="l00196"></a>00196             <span class="keywordflow">break</span>;
<a name="l00197"></a>00197         <span class="keywordflow">case</span> <span class="charliteral">'A'</span>:
<a name="l00198"></a>00198             use_ais = <span class="keyword">true</span>;
<a name="l00199"></a>00199             <span class="keywordflow">break</span>;
<a name="l00200"></a>00200         <span class="keywordflow">case</span> <span class="charliteral">'V'</span>:
<a name="l00201"></a>00201             fprintf(stderr, <span class="stringliteral">"getdap version: %s\n"</span>, <a class="code" href="getdap_8cc.html#a31f487a99743d24af9076a3e11e5425">version</a>);
<a name="l00202"></a>00202             exit(0);
<a name="l00203"></a>00203         <span class="keywordflow">case</span> <span class="charliteral">'i'</span>:
<a name="l00204"></a>00204             get_version = <span class="keyword">true</span>;
<a name="l00205"></a>00205             <span class="keywordflow">break</span>;
<a name="l00206"></a>00206         <span class="keywordflow">case</span> <span class="charliteral">'v'</span>:
<a name="l00207"></a>00207             verbose = <span class="keyword">true</span>;
<a name="l00208"></a>00208             <span class="keywordflow">break</span>;
<a name="l00209"></a>00209         <span class="keywordflow">case</span> <span class="charliteral">'k'</span>:
<a name="l00210"></a>00210             <a class="code" href="namespacelibdap.html#eafd230ca250e819c46862dc43deb4fa">dods_keep_temps</a> = 1;
<a name="l00211"></a>00211             <span class="keywordflow">break</span>;              <span class="comment">// keep_temp is in Connect.cc</span>
<a name="l00212"></a>00212         <span class="keywordflow">case</span> <span class="charliteral">'c'</span>:
<a name="l00213"></a>00213             cexpr = <span class="keyword">true</span>;
<a name="l00214"></a>00214             expr = getopt.optarg;
<a name="l00215"></a>00215             <span class="keywordflow">break</span>;
<a name="l00216"></a>00216         <span class="keywordflow">case</span> <span class="charliteral">'m'</span>:
<a name="l00217"></a>00217             multi = <span class="keyword">true</span>;
<a name="l00218"></a>00218             times = atoi(getopt.optarg);
<a name="l00219"></a>00219             <span class="keywordflow">break</span>;
<a name="l00220"></a>00220         <span class="keywordflow">case</span> <span class="charliteral">'B'</span>:
<a name="l00221"></a>00221             use_ais = <span class="keyword">true</span>;
<a name="l00222"></a>00222             ais_db = getopt.optarg;
<a name="l00223"></a>00223             <span class="keywordflow">break</span>;
<a name="l00224"></a>00224         <span class="keywordflow">case</span> <span class="charliteral">'z'</span>:
<a name="l00225"></a>00225             accept_deflate = <span class="keyword">true</span>;
<a name="l00226"></a>00226             <span class="keywordflow">break</span>;
<a name="l00227"></a>00227         <span class="keywordflow">case</span> <span class="charliteral">'s'</span>:
<a name="l00228"></a>00228             print_rows = <span class="keyword">true</span>;
<a name="l00229"></a>00229             <span class="keywordflow">break</span>;
<a name="l00230"></a>00230         <span class="keywordflow">case</span> <span class="charliteral">'M'</span>:
<a name="l00231"></a>00231             mime_headers = <span class="keyword">false</span>;
<a name="l00232"></a>00232             <span class="keywordflow">break</span>;
<a name="l00233"></a>00233         <span class="keywordflow">case</span> <span class="charliteral">'p'</span>: {
<a name="l00234"></a>00234             istringstream iss(getopt.optarg);
<a name="l00235"></a>00235             <span class="keywordtype">char</span> dot;
<a name="l00236"></a>00236             iss &gt;&gt; dap_client_major;
<a name="l00237"></a>00237             iss &gt;&gt; dot;
<a name="l00238"></a>00238             iss &gt;&gt; dap_client_minor;
<a name="l00239"></a>00239             <span class="keywordflow">break</span>;
<a name="l00240"></a>00240         }
<a name="l00241"></a>00241         <span class="keywordflow">case</span> <span class="charliteral">'h'</span>:
<a name="l00242"></a>00242         <span class="keywordflow">case</span> <span class="charliteral">'?'</span>:
<a name="l00243"></a>00243         <span class="keywordflow">default</span>:
<a name="l00244"></a>00244             <a class="code" href="getdap_8cc.html#9391ac68c9115711e45eb80120891130">usage</a>(argv[0]);
<a name="l00245"></a>00245             exit(1);
<a name="l00246"></a>00246             <span class="keywordflow">break</span>;
<a name="l00247"></a>00247         }
<a name="l00248"></a>00248 
<a name="l00249"></a>00249     <span class="keywordflow">try</span> {
<a name="l00250"></a>00250         <span class="comment">// If after processing all the command line options there is nothing</span>
<a name="l00251"></a>00251         <span class="comment">// left (no URL or file) assume that we should read from stdin.</span>
<a name="l00252"></a>00252         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = getopt.optind; i &lt; argc; ++i) {
<a name="l00253"></a>00253             <span class="keywordflow">if</span> (verbose)
<a name="l00254"></a>00254                 fprintf(stderr, <span class="stringliteral">"Fetching: %s\n"</span>, argv[i]);
<a name="l00255"></a>00255 
<a name="l00256"></a>00256             <span class="keywordtype">string</span> name = argv[i];
<a name="l00257"></a>00257             <a class="code" href="classlibdap_1_1Connect.html" title="Holds information about the link from a DAP2 client to a dataset.">Connect</a> *url = 0;
<a name="l00258"></a>00258             <span class="keywordflow">if</span> (use_ais) {
<a name="l00259"></a>00259                 <span class="keywordflow">if</span> (!ais_db.empty())
<a name="l00260"></a>00260                     url = <span class="keyword">new</span> <a class="code" href="classlibdap_1_1AISConnect.html">AISConnect</a>(name, ais_db);
<a name="l00261"></a>00261                 <span class="keywordflow">else</span>
<a name="l00262"></a>00262                     url = <span class="keyword">new</span> <a class="code" href="classlibdap_1_1AISConnect.html">AISConnect</a>(name);
<a name="l00263"></a>00263             }
<a name="l00264"></a>00264             <span class="keywordflow">else</span> {
<a name="l00265"></a>00265                 url = <span class="keyword">new</span> <a class="code" href="classlibdap_1_1Connect.html" title="Holds information about the link from a DAP2 client to a dataset.">Connect</a>(name);
<a name="l00266"></a>00266             }
<a name="l00267"></a>00267 
<a name="l00268"></a>00268             <span class="comment">// This overrides the value set in the .dodsrc file.</span>
<a name="l00269"></a>00269             <span class="keywordflow">if</span> (accept_deflate)
<a name="l00270"></a>00270                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#186f76bfea3b61dc3587bcff5760ed8b">set_accept_deflate</a>(accept_deflate);
<a name="l00271"></a>00271 
<a name="l00272"></a>00272             <span class="keywordflow">if</span> (dap_client_major &gt; 2)
<a name="l00273"></a>00273                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#4af759a2313d9ecbc1db1c811f549379">set_xdap_protocol</a>(dap_client_major, dap_client_minor);
<a name="l00274"></a>00274 
<a name="l00275"></a>00275             <span class="keywordflow">if</span> (url-&gt;<a class="code" href="classlibdap_1_1Connect.html#3901ce9383c3df11d1a1c28d4a09bb54">is_local</a>()) {
<a name="l00276"></a>00276                 <span class="keywordflow">if</span> (verbose) {
<a name="l00277"></a>00277                     fprintf(stderr,
<a name="l00278"></a>00278                             <span class="stringliteral">"Assuming that the argument %s is a file that contains a DAP2 data object; decoding.\n"</span>, argv[i]);
<a name="l00279"></a>00279                 }
<a name="l00280"></a>00280 
<a name="l00281"></a>00281                 <a class="code" href="classlibdap_1_1Response.html">Response</a> *r = 0;
<a name="l00282"></a>00282                 <a class="code" href="classlibdap_1_1BaseTypeFactory.html">BaseTypeFactory</a> factory;
<a name="l00283"></a>00283                 <a class="code" href="classlibdap_1_1DataDDS.html" title="Holds a DAP2 DDS.">DataDDS</a> dds(&amp;factory);
<a name="l00284"></a>00284 
<a name="l00285"></a>00285                 <span class="keywordflow">try</span> {
<a name="l00286"></a>00286                     <span class="keywordflow">if</span> (strcmp(argv[i], <span class="stringliteral">"-"</span>) == 0) {
<a name="l00287"></a>00287                         r = <span class="keyword">new</span> <a class="code" href="classlibdap_1_1StdinResponse.html" title="Encapsulate a response read from stdin.">StdinResponse</a>(stdin);
<a name="l00288"></a>00288 
<a name="l00289"></a>00289                         <span class="keywordflow">if</span> (!r-&gt;<a class="code" href="classlibdap_1_1Response.html#5b4903bb627c5e6ccd4cd50712e1f0a1">get_stream</a>())
<a name="l00290"></a>00290                             <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a>(<span class="stringliteral">"Could not open standard input."</span>);
<a name="l00291"></a>00291 
<a name="l00292"></a>00292                         <span class="keywordflow">if</span> (mime_headers)
<a name="l00293"></a>00293                             url-&gt;<a class="code" href="classlibdap_1_1Connect.html#e50d98d353023b9786c9bd5b0833a7de" title="Read data which is preceded by MIME headers.">read_data</a>(dds, r); <span class="comment">// The default case</span>
<a name="l00294"></a>00294                         <span class="keywordflow">else</span>
<a name="l00295"></a>00295                             url-&gt;<a class="code" href="classlibdap_1_1Connect.html#486b095a58614dfc2be0321035784306" title="Read data from a file which does not have response MIME headers. This method is a...">read_data_no_mime</a>(dds, r);
<a name="l00296"></a>00296                     }
<a name="l00297"></a>00297                     <span class="keywordflow">else</span> {
<a name="l00298"></a>00298                         r = <span class="keyword">new</span> <a class="code" href="classlibdap_1_1Response.html">Response</a>(fopen(argv[i], <span class="stringliteral">"r"</span>), 0);
<a name="l00299"></a>00299 
<a name="l00300"></a>00300                         <span class="keywordflow">if</span> (!r-&gt;<a class="code" href="classlibdap_1_1Response.html#5b4903bb627c5e6ccd4cd50712e1f0a1">get_stream</a>())
<a name="l00301"></a>00301                             <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a>(<span class="keywordtype">string</span>(<span class="stringliteral">"The input source: "</span>)
<a name="l00302"></a>00302                                         + string(argv[i])
<a name="l00303"></a>00303                                         + string(<span class="stringliteral">" could not be opened"</span>));
<a name="l00304"></a>00304 
<a name="l00305"></a>00305                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#486b095a58614dfc2be0321035784306" title="Read data from a file which does not have response MIME headers. This method is a...">read_data_no_mime</a>(dds, r);
<a name="l00306"></a>00306                     }
<a name="l00307"></a>00307                 }
<a name="l00308"></a>00308                 <span class="keywordflow">catch</span> (<a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a> &amp; e) {
<a name="l00309"></a>00309                     cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00310"></a>00310                     <span class="keyword">delete</span> r;
<a name="l00311"></a>00311                     r = 0;
<a name="l00312"></a>00312                     <span class="keyword">delete</span> url;
<a name="l00313"></a>00313                     url = 0;
<a name="l00314"></a>00314                     <span class="keywordflow">break</span>;
<a name="l00315"></a>00315                 }
<a name="l00316"></a>00316 
<a name="l00317"></a>00317                 <span class="keywordflow">if</span> (verbose)
<a name="l00318"></a>00318                     fprintf(stderr, <span class="stringliteral">"DAP version: %s, Server version: %s\n"</span>,
<a name="l00319"></a>00319                             url-&gt;<a class="code" href="classlibdap_1_1Connect.html#4223a898b3da719509d173dd990c45f1">get_protocol</a>().c_str(),
<a name="l00320"></a>00320                             url-&gt;<a class="code" href="classlibdap_1_1Connect.html#30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00321"></a>00321 
<a name="l00322"></a>00322                 print_data(dds, print_rows);
<a name="l00323"></a>00323 
<a name="l00324"></a>00324             }
<a name="l00325"></a>00325 
<a name="l00326"></a>00326             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (get_version) {
<a name="l00327"></a>00327                 fprintf(stderr, <span class="stringliteral">"DAP version: %s, Server version: %s\n"</span>,
<a name="l00328"></a>00328                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#aa1ab562899da9a4630de01f943d1aa9">request_protocol</a>().c_str(),
<a name="l00329"></a>00329                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00330"></a>00330             }
<a name="l00331"></a>00331 
<a name="l00332"></a>00332             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (get_das) {
<a name="l00333"></a>00333                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; times; ++j) {
<a name="l00334"></a>00334                     <a class="code" href="classlibdap_1_1DAS.html" title="Hold attribute data for a DAP2 dataset.">DAS</a> das;
<a name="l00335"></a>00335                     <span class="keywordflow">try</span> {
<a name="l00336"></a>00336                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#816ef3bb8e729712ffeb6523f2cc4f0e" title="Get the DAS from a server.">request_das</a>(das);
<a name="l00337"></a>00337                     }
<a name="l00338"></a>00338                     <span class="keywordflow">catch</span> (<a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a> &amp; e) {
<a name="l00339"></a>00339                         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00340"></a>00340                         <span class="keyword">delete</span> url;
<a name="l00341"></a>00341                         url = 0;
<a name="l00342"></a>00342                         <span class="keywordflow">continue</span>;
<a name="l00343"></a>00343                     }
<a name="l00344"></a>00344 
<a name="l00345"></a>00345                     <span class="keywordflow">if</span> (verbose) {
<a name="l00346"></a>00346                         fprintf(stderr, <span class="stringliteral">"DAP version: %s, Server version: %s\n"</span>,
<a name="l00347"></a>00347                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#4223a898b3da719509d173dd990c45f1">get_protocol</a>().c_str(),
<a name="l00348"></a>00348                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00349"></a>00349 
<a name="l00350"></a>00350                         fprintf(stderr, <span class="stringliteral">"DAS:\n"</span>);
<a name="l00351"></a>00351                     }
<a name="l00352"></a>00352 
<a name="l00353"></a>00353                     das.<a class="code" href="classlibdap_1_1DAS.html#8983b961e6fba3a6fd33ffcfd944eaf2">print</a>(stdout);
<a name="l00354"></a>00354                 }
<a name="l00355"></a>00355             }
<a name="l00356"></a>00356 
<a name="l00357"></a>00357             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (get_dds) {
<a name="l00358"></a>00358                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; times; ++j) {
<a name="l00359"></a>00359                     <a class="code" href="classlibdap_1_1BaseTypeFactory.html">BaseTypeFactory</a> factory;
<a name="l00360"></a>00360                     <a class="code" href="classlibdap_1_1DDS.html">DDS</a> dds(&amp;factory);
<a name="l00361"></a>00361                     <span class="keywordflow">try</span> {
<a name="l00362"></a>00362                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#ad5ef370110577e9ca2a0161928f9efa" title="Get the DDS from a server.">request_dds</a>(dds, expr);
<a name="l00363"></a>00363                     }
<a name="l00364"></a>00364                     <span class="keywordflow">catch</span> (<a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a> &amp; e) {
<a name="l00365"></a>00365                         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00366"></a>00366                         <span class="keyword">delete</span> url;
<a name="l00367"></a>00367                         url = 0;
<a name="l00368"></a>00368                         <span class="keywordflow">continue</span>;       <span class="comment">// Goto the next URL or exit the loop.</span>
<a name="l00369"></a>00369                     }
<a name="l00370"></a>00370 
<a name="l00371"></a>00371                     <span class="keywordflow">if</span> (verbose) {
<a name="l00372"></a>00372                         fprintf(stderr, <span class="stringliteral">"DAP version: %s, Server version: %s\n"</span>,
<a name="l00373"></a>00373                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#4223a898b3da719509d173dd990c45f1">get_protocol</a>().c_str(),
<a name="l00374"></a>00374                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00375"></a>00375 
<a name="l00376"></a>00376                         fprintf(stderr, <span class="stringliteral">"DDS:\n"</span>);
<a name="l00377"></a>00377                     }
<a name="l00378"></a>00378 
<a name="l00379"></a>00379                     dds.<a class="code" href="classlibdap_1_1DDS.html#471a9e61f7154518b040a7818fa5a2b5" title="Print the entire DDS to the specified file.">print</a>(cout);
<a name="l00380"></a>00380                 }
<a name="l00381"></a>00381             }
<a name="l00382"></a>00382 
<a name="l00383"></a>00383             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (get_ddx) {
<a name="l00384"></a>00384                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; times; ++j) {
<a name="l00385"></a>00385                     <a class="code" href="classlibdap_1_1BaseTypeFactory.html">BaseTypeFactory</a> factory;
<a name="l00386"></a>00386                     <a class="code" href="classlibdap_1_1DDS.html">DDS</a> dds(&amp;factory);
<a name="l00387"></a>00387                     <span class="keywordflow">try</span> {
<a name="l00388"></a>00388                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#4395cc18cf5ec1a5167795a5a5491958" title="Get the DDX from a server.">request_ddx</a>(dds, expr);
<a name="l00389"></a>00389                     }
<a name="l00390"></a>00390                     <span class="keywordflow">catch</span> (<a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a> &amp; e) {
<a name="l00391"></a>00391                         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00392"></a>00392                         <span class="keywordflow">continue</span>;       <span class="comment">// Goto the next URL or exit the loop.</span>
<a name="l00393"></a>00393                     }
<a name="l00394"></a>00394 
<a name="l00395"></a>00395                     <span class="keywordflow">if</span> (verbose) {
<a name="l00396"></a>00396                         fprintf(stderr, <span class="stringliteral">"DAP version: %s, Server version: %s\n"</span>,
<a name="l00397"></a>00397                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#4223a898b3da719509d173dd990c45f1">get_protocol</a>().c_str(),
<a name="l00398"></a>00398                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00399"></a>00399 
<a name="l00400"></a>00400                         fprintf(stderr, <span class="stringliteral">"DDX:\n"</span>);
<a name="l00401"></a>00401                     }
<a name="l00402"></a>00402 
<a name="l00403"></a>00403                     dds.<a class="code" href="classlibdap_1_1DDS.html#b36a8e3fb32b7449c32e18ca6a7f529a">print_xml</a>(cout, <span class="keyword">false</span>, <span class="stringliteral">"getdap; no blob yet"</span>);
<a name="l00404"></a>00404                 }
<a name="l00405"></a>00405             }
<a name="l00406"></a>00406 
<a name="l00407"></a>00407             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (build_ddx) {
<a name="l00408"></a>00408                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; times; ++j) {
<a name="l00409"></a>00409                     <a class="code" href="classlibdap_1_1BaseTypeFactory.html">BaseTypeFactory</a> factory;
<a name="l00410"></a>00410                     <a class="code" href="classlibdap_1_1DDS.html">DDS</a> dds(&amp;factory);
<a name="l00411"></a>00411                     <span class="keywordflow">try</span> {
<a name="l00412"></a>00412                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#ad5ef370110577e9ca2a0161928f9efa" title="Get the DDS from a server.">request_dds</a>(dds, expr);
<a name="l00413"></a>00413                         <a class="code" href="classlibdap_1_1DAS.html" title="Hold attribute data for a DAP2 dataset.">DAS</a> das;
<a name="l00414"></a>00414                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#816ef3bb8e729712ffeb6523f2cc4f0e" title="Get the DAS from a server.">request_das</a>(das);
<a name="l00415"></a>00415                         dds.<a class="code" href="classlibdap_1_1DDS.html#2810a944fbdc7d21b08f2d8c19022b52">transfer_attributes</a>(&amp;das);
<a name="l00416"></a>00416                     }
<a name="l00417"></a>00417                     <span class="keywordflow">catch</span> (<a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a> &amp; e) {
<a name="l00418"></a>00418                         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00419"></a>00419                         <span class="keywordflow">continue</span>;       <span class="comment">// Goto the next URL or exit the loop.</span>
<a name="l00420"></a>00420                     }
<a name="l00421"></a>00421 
<a name="l00422"></a>00422                     <span class="keywordflow">if</span> (verbose) {
<a name="l00423"></a>00423                         fprintf(stderr, <span class="stringliteral">"DAP version: %s, Server version: %s\n"</span>,
<a name="l00424"></a>00424                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#4223a898b3da719509d173dd990c45f1">get_protocol</a>().c_str(),
<a name="l00425"></a>00425                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00426"></a>00426 
<a name="l00427"></a>00427                         fprintf(stderr, <span class="stringliteral">"Client-built DDX:\n"</span>);
<a name="l00428"></a>00428                     }
<a name="l00429"></a>00429 
<a name="l00430"></a>00430                     dds.<a class="code" href="classlibdap_1_1DDS.html#b36a8e3fb32b7449c32e18ca6a7f529a">print_xml</a>(cout, <span class="keyword">false</span>, <span class="stringliteral">"getdap; no blob yet"</span>);
<a name="l00431"></a>00431                 }
<a name="l00432"></a>00432             }
<a name="l00433"></a>00433 
<a name="l00434"></a>00434             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (get_data) {
<a name="l00435"></a>00435                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; times; ++j) {
<a name="l00436"></a>00436                     <a class="code" href="classlibdap_1_1BaseTypeFactory.html">BaseTypeFactory</a> factory;
<a name="l00437"></a>00437                     <a class="code" href="classlibdap_1_1DataDDS.html" title="Holds a DAP2 DDS.">DataDDS</a> dds(&amp;factory);
<a name="l00438"></a>00438                     <span class="keywordflow">try</span> {
<a name="l00439"></a>00439                         <a class="code" href="debug_8h.html#32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr &lt;&lt; <span class="stringliteral">"URL: "</span> &lt;&lt; url-&gt;<a class="code" href="classlibdap_1_1Connect.html#523bf24520185e3d71f36ac0203b98e6" title="Get the object&amp;#39;s URL.">URL</a>(<span class="keyword">false</span>) &lt;&lt; endl);
<a name="l00440"></a>00440                         <a class="code" href="debug_8h.html#32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr &lt;&lt; <span class="stringliteral">"CE: "</span> &lt;&lt; expr &lt;&lt; endl);
<a name="l00441"></a>00441                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#814e98ac5e99927ccc79bb0feb32d241" title="Get the DAS from a server.">request_data</a>(dds, expr);
<a name="l00442"></a>00442 
<a name="l00443"></a>00443                         <span class="keywordflow">if</span> (verbose)
<a name="l00444"></a>00444                             fprintf(stderr, <span class="stringliteral">"DAP version: %s, Server version: %s\n"</span>,
<a name="l00445"></a>00445                                     url-&gt;<a class="code" href="classlibdap_1_1Connect.html#4223a898b3da719509d173dd990c45f1">get_protocol</a>().c_str(),
<a name="l00446"></a>00446                                     url-&gt;<a class="code" href="classlibdap_1_1Connect.html#30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00447"></a>00447 
<a name="l00448"></a>00448                         print_data(dds, print_rows);
<a name="l00449"></a>00449                     }
<a name="l00450"></a>00450                     <span class="keywordflow">catch</span> (<a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a> &amp; e) {
<a name="l00451"></a>00451                         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00452"></a>00452                         <span class="keyword">delete</span> url;
<a name="l00453"></a>00453                         url = 0;
<a name="l00454"></a>00454                         <span class="keywordflow">continue</span>;
<a name="l00455"></a>00455                     }
<a name="l00456"></a>00456                 }
<a name="l00457"></a>00457             }
<a name="l00458"></a>00458 
<a name="l00459"></a>00459             <span class="keywordflow">else</span> {
<a name="l00460"></a>00460                 <span class="comment">// if (!get_das &amp;&amp; !get_dds &amp;&amp; !get_data) This code uses</span>
<a name="l00461"></a>00461                 <span class="comment">// HTTPConnect::fetch_url which cannot be accessed using an</span>
<a name="l00462"></a>00462                 <span class="comment">// instance of Connect. So some of the options supported by</span>
<a name="l00463"></a>00463                 <span class="comment">// other URLs won't work here (e.g., the verbose option</span>
<a name="l00464"></a>00464                 <span class="comment">// doesn't show the server version number).</span>
<a name="l00465"></a>00465                 <a class="code" href="classlibdap_1_1HTTPConnect.html">HTTPConnect</a> http(RCReader::instance());
<a name="l00466"></a>00466 
<a name="l00467"></a>00467                 <span class="comment">// This overrides the value set in the .dodsrc file.</span>
<a name="l00468"></a>00468                 <span class="keywordflow">if</span> (accept_deflate)
<a name="l00469"></a>00469                     http.<a class="code" href="classlibdap_1_1HTTPConnect.html#01d67a5afa18a84ef744b8f222094260">set_accept_deflate</a>(accept_deflate);
<a name="l00470"></a>00470 
<a name="l00471"></a>00471                 <span class="keywordflow">if</span> (dap_client_major &gt; 2)
<a name="l00472"></a>00472                     url-&gt;<a class="code" href="classlibdap_1_1Connect.html#4af759a2313d9ecbc1db1c811f549379">set_xdap_protocol</a>(dap_client_major, dap_client_minor);
<a name="l00473"></a>00473 
<a name="l00474"></a>00474                 <span class="keywordtype">string</span> url_string = argv[i];
<a name="l00475"></a>00475                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; times; ++j) {
<a name="l00476"></a>00476                     <span class="keywordflow">try</span> {
<a name="l00477"></a>00477                         <a class="code" href="classlibdap_1_1Response.html">Response</a> *r = http.<a class="code" href="classlibdap_1_1HTTPConnect.html#5e3558838e245a96c9392b33ef4ba298">fetch_url</a>(url_string);
<a name="l00478"></a>00478                         <span class="keywordflow">if</span> (!<a class="code" href="getdap_8cc.html#e894a8fa14082e1c9fe5146b6dba5c92">read_data</a>(r-&gt;<a class="code" href="classlibdap_1_1Response.html#5b4903bb627c5e6ccd4cd50712e1f0a1">get_stream</a>())) {
<a name="l00479"></a>00479                             <span class="keywordflow">continue</span>;
<a name="l00480"></a>00480                         }
<a name="l00481"></a>00481                         <span class="keyword">delete</span> r;
<a name="l00482"></a>00482                         r = 0;
<a name="l00483"></a>00483                     }
<a name="l00484"></a>00484                     <span class="keywordflow">catch</span> (<a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a> &amp; e) {
<a name="l00485"></a>00485                         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00486"></a>00486                         <span class="keywordflow">continue</span>;
<a name="l00487"></a>00487                     }
<a name="l00488"></a>00488                 }
<a name="l00489"></a>00489             }
<a name="l00490"></a>00490 
<a name="l00491"></a>00491             <span class="keyword">delete</span> url;
<a name="l00492"></a>00492             url = 0;
<a name="l00493"></a>00493         }
<a name="l00494"></a>00494     }
<a name="l00495"></a>00495     <span class="keywordflow">catch</span> (<a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a> &amp;e) {
<a name="l00496"></a>00496         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00497"></a>00497         <span class="keywordflow">return</span> 1;
<a name="l00498"></a>00498     }
<a name="l00499"></a>00499     <span class="keywordflow">catch</span> (exception &amp;e) {
<a name="l00500"></a>00500         cerr &lt;&lt; <span class="stringliteral">"C++ library exception: "</span> &lt;&lt; e.what() &lt;&lt; endl;
<a name="l00501"></a>00501         <span class="keywordflow">return</span> 1;
<a name="l00502"></a>00502     }
<a name="l00503"></a>00503 
<a name="l00504"></a>00504     <span class="keywordflow">return</span> 0;
<a name="l00505"></a>00505 }
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Wed Oct 7 19:57:07 2009 for libdap++ by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>