Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > c9cfbd1355daacaf3b34517a6d7b18cc > files > 1182

libdap-doc-3.11.0-2.fc15.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>libdap++: getdap.cc Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.3 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">libdap++&#160;<span id="projectnumber">Updated for version 3.8.2</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;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 id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('getdap_8cc.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<h1>getdap.cc</h1>  </div>
</div>
<div class="contents">
<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&#39;; 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 &quot;<a class="code" href="config_8h.html">config.h</a>&quot;</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#a05e109ec893d0b12023d5b0cf4f718c4">not_used</a> =
<a name="l00039"></a>00039     { <span class="stringliteral">&quot;$Id: getdap.cc 21695 2009-11-04 17:45:04Z jimg $&quot;</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 &quot;GetOpt.h&quot;</span>
<a name="l00052"></a>00052 
<a name="l00053"></a>00053 <span class="preprocessor">#include &quot;<a class="code" href="Sequence_8h.html">Sequence.h</a>&quot;</span>
<a name="l00054"></a>00054 <span class="preprocessor">#include &quot;<a class="code" href="Connect_8h.html">Connect.h</a>&quot;</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include &quot;<a class="code" href="Response_8h.html">Response.h</a>&quot;</span>
<a name="l00056"></a>00056 <span class="preprocessor">#include &quot;<a class="code" href="StdinResponse_8h.html">StdinResponse.h</a>&quot;</span>
<a name="l00057"></a>00057 
<a name="l00058"></a>00058 <span class="keyword">using</span> std::cerr;
<a name="l00059"></a>00059 <span class="keyword">using</span> std::endl;
<a name="l00060"></a>00060 <span class="keyword">using</span> std::flush;
<a name="l00061"></a>00061 
<a name="l00062"></a>00062 <span class="keyword">using namespace </span>libdap ;
<a name="l00063"></a>00063 
<a name="l00064"></a><a class="code" href="getdap_8cc.html#aa31f487a99743d24af9076a3e11e5425">00064</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="getdap_8cc.html#aa31f487a99743d24af9076a3e11e5425">version</a> = <a class="code" href="config_8h.html#a3a86ed8fb42f5192508897934b5f977e">CVER</a> <span class="stringliteral">&quot; (&quot;</span> <a class="code" href="config_8h.html#ab2eef76504098908aacbd5ec3433d93c">DVR</a> <span class="stringliteral">&quot; DAP/&quot;</span> <a class="code" href="config_8h.html#a9757f0cc77df1fd0759b1b91a9f63ff0">DAP_PROTOCOL_VERSION</a> <span class="stringliteral">&quot;)&quot;</span>;
<a name="l00065"></a>00065 
<a name="l00066"></a>00066 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="namespacelibdap.html#aeafd230ca250e819c46862dc43deb4fa">libdap::dods_keep_temps</a>;     <span class="comment">// defined in HTTPResponse.h</span>
<a name="l00067"></a>00067 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="namespacelibdap.html#aab2a595ed5ba24c6f549093fdf645c67">libdap::www_trace</a>;
<a name="l00068"></a>00068 
<a name="l00069"></a><a class="code" href="getdap_8cc.html#a9391ac68c9115711e45eb80120891130">00069</a> <span class="keywordtype">void</span> <a class="code" href="namespacelibdap.html#a6f36b78e0590ec9e3a0583f0ecfead64">usage</a>(<span class="keywordtype">string</span> name)
<a name="l00070"></a>00070 {
<a name="l00071"></a>00071     cerr &lt;&lt; <span class="stringliteral">&quot;Usage: &quot;</span> &lt;&lt; name &lt;&lt; endl;
<a name="l00072"></a>00072     cerr &lt;&lt;
<a name="l00073"></a>00073     <span class="stringliteral">&quot; [idDaxAVvks] [-B &lt;db&gt;][-c &lt;expr&gt;][-m &lt;num&gt;] &lt;url&gt; [&lt;url&gt; ...]&quot;</span> &lt;&lt;
<a name="l00074"></a>00074     endl;
<a name="l00075"></a>00075     cerr &lt;&lt; <span class="stringliteral">&quot; [VvksM] &lt;file&gt; [&lt;file&gt; ...]&quot;</span> &lt;&lt; endl;
<a name="l00076"></a>00076     cerr &lt;&lt; endl;
<a name="l00077"></a>00077     cerr &lt;&lt; <span class="stringliteral">&quot;In the first form of the command, dereference the URL and&quot;</span>
<a name="l00078"></a>00078     &lt;&lt; endl;
<a name="l00079"></a>00079     cerr &lt;&lt; <span class="stringliteral">&quot;perform the requested operations. This includes routing&quot;</span> &lt;&lt;
<a name="l00080"></a>00080     endl;
<a name="l00081"></a>00081     cerr &lt;&lt; <span class="stringliteral">&quot;the returned information through the DAP processing&quot;</span> &lt;&lt; endl;
<a name="l00082"></a>00082     cerr &lt;&lt; <span class="stringliteral">&quot;library (parsing the returned objects, et c.). If none&quot;</span> &lt;&lt;
<a name="l00083"></a>00083     endl;
<a name="l00084"></a>00084     cerr &lt;&lt; <span class="stringliteral">&quot;of a, d, or D are used with a URL, then the DAP library&quot;</span> &lt;&lt;
<a name="l00085"></a>00085     endl;
<a name="l00086"></a>00086     cerr &lt;&lt; <span class="stringliteral">&quot;routines are NOT used and the URLs contents are dumped&quot;</span> &lt;&lt;
<a name="l00087"></a>00087     endl;
<a name="l00088"></a>00088     cerr &lt;&lt; <span class="stringliteral">&quot;to standard output.&quot;</span> &lt;&lt; endl;
<a name="l00089"></a>00089     cerr &lt;&lt; endl;
<a name="l00090"></a>00090     cerr &lt;&lt; <span class="stringliteral">&quot;In the second form of the command, assume the files are&quot;</span> &lt;&lt;
<a name="l00091"></a>00091     endl;
<a name="l00092"></a>00092     cerr &lt;&lt; <span class="stringliteral">&quot;DataDDS objects (stored in files or read from pipes)&quot;</span> &lt;&lt; endl;
<a name="l00093"></a>00093     cerr &lt;&lt; <span class="stringliteral">&quot;and process them as if -D were given. In this case the&quot;</span> &lt;&lt;
<a name="l00094"></a>00094     endl;
<a name="l00095"></a>00095     cerr &lt;&lt; <span class="stringliteral">&quot;information *must* contain valid MIME header in order&quot;</span> &lt;&lt;
<a name="l00096"></a>00096     endl;
<a name="l00097"></a>00097     cerr &lt;&lt; <span class="stringliteral">&quot;to be processed.&quot;</span> &lt;&lt; endl;
<a name="l00098"></a>00098     cerr &lt;&lt; endl;
<a name="l00099"></a>00099     cerr &lt;&lt; <span class="stringliteral">&quot;Options:&quot;</span> &lt;&lt; endl;
<a name="l00100"></a>00100     cerr &lt;&lt; <span class="stringliteral">&quot;        i: For each URL, get the server version.&quot;</span> &lt;&lt; endl;
<a name="l00101"></a>00101     cerr &lt;&lt; <span class="stringliteral">&quot;        d: For each URL, get the the DDS.&quot;</span> &lt;&lt; endl;
<a name="l00102"></a>00102     cerr &lt;&lt; <span class="stringliteral">&quot;        a: For each URL, get the the DAS.&quot;</span> &lt;&lt; endl;
<a name="l00103"></a>00103     cerr &lt;&lt; <span class="stringliteral">&quot;        D: For each URL, get the the DataDDS.&quot;</span> &lt;&lt; endl;
<a name="l00104"></a>00104     cerr &lt;&lt;
<a name="l00105"></a>00105     <span class="stringliteral">&quot;        x: For each URL, get the DDX object. Does not get data.&quot;</span>
<a name="l00106"></a>00106     &lt;&lt; endl;
<a name="l00107"></a>00107     cerr &lt;&lt; <span class="stringliteral">&quot;        X: Request a DataDDX from the server (the DAP4 data response&quot;</span> &lt;&lt; endl;
<a name="l00108"></a>00108     cerr &lt;&lt; <span class="stringliteral">&quot;        B: Build a DDX in getdap using the DDS and DAS.&quot;</span> &lt;&lt; endl;
<a name="l00109"></a>00109     cerr &lt;&lt; <span class="stringliteral">&quot;        v: Verbose output.&quot;</span> &lt;&lt; endl;
<a name="l00110"></a>00110     cerr &lt;&lt; <span class="stringliteral">&quot;        V: Version of this client; see &#39;i&#39; for server version.&quot;</span> &lt;&lt; endl;
<a name="l00111"></a>00111     cerr &lt;&lt; <span class="stringliteral">&quot;        c: &lt;expr&gt; is a constraint expression. Used with -D/X.&quot;</span> &lt;&lt;
<a name="l00112"></a>00112     endl;
<a name="l00113"></a>00113     cerr &lt;&lt; <span class="stringliteral">&quot;           NB: You can use a `?&#39; for the CE also.&quot;</span> &lt;&lt; endl;
<a name="l00114"></a>00114     cerr &lt;&lt; <span class="stringliteral">&quot;        k: Keep temporary files created by libdap.&quot;</span> &lt;&lt; endl;
<a name="l00115"></a>00115     cerr &lt;&lt; <span class="stringliteral">&quot;        m: Request the same URL &lt;num&gt; times.&quot;</span> &lt;&lt; endl;
<a name="l00116"></a>00116     cerr &lt;&lt; <span class="stringliteral">&quot;        z: Ask the server to compress data.&quot;</span> &lt;&lt; endl;
<a name="l00117"></a>00117     cerr &lt;&lt; <span class="stringliteral">&quot;        s: Print Sequences using numbered rows.&quot;</span> &lt;&lt; endl;
<a name="l00118"></a>00118     cerr &lt;&lt; <span class="stringliteral">&quot;        M: Assume data read from a file has no MIME headers&quot;</span> &lt;&lt; endl;
<a name="l00119"></a>00119     cerr &lt;&lt; <span class="stringliteral">&quot;           (the default is to assume the headers are present).&quot;</span> &lt;&lt; endl;
<a name="l00120"></a>00120     cerr &lt;&lt; <span class="stringliteral">&quot;        p: Set DAP protocol to x.y&quot;</span> &lt;&lt; endl;
<a name="l00121"></a>00121 }
<a name="l00122"></a>00122 
<a name="l00123"></a><a class="code" href="getdap_8cc.html#ae894a8fa14082e1c9fe5146b6dba5c92">00123</a> <span class="keywordtype">bool</span> <a class="code" href="getdap_8cc.html#ae894a8fa14082e1c9fe5146b6dba5c92">read_data</a>(FILE * fp)
<a name="l00124"></a>00124 {
<a name="l00125"></a>00125     <span class="keywordflow">if</span> (!fp) {
<a name="l00126"></a>00126         fprintf(stderr, <span class="stringliteral">&quot;getdap: Whoa!!! Null stream pointer.\n&quot;</span>);
<a name="l00127"></a>00127         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00128"></a>00128     }
<a name="l00129"></a>00129     <span class="comment">// Changed from a loop that used getc() to one that uses fread(). getc()</span>
<a name="l00130"></a>00130     <span class="comment">// worked fine for transfers of text information, but *not* for binary</span>
<a name="l00131"></a>00131     <span class="comment">// transfers. fread() will handle both.</span>
<a name="l00132"></a>00132     <span class="keywordtype">char</span> c;
<a name="l00133"></a>00133     <span class="keywordflow">while</span> (fp &amp;&amp; !feof(fp) &amp;&amp; fread(&amp;c, 1, 1, fp))
<a name="l00134"></a>00134         printf(<span class="stringliteral">&quot;%c&quot;</span>, c);        <span class="comment">// stick with stdio</span>
<a name="l00135"></a>00135 
<a name="l00136"></a>00136     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00137"></a>00137 }
<a name="l00138"></a>00138 
<a name="l00139"></a>00139 <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="l00140"></a>00140 {
<a name="l00141"></a>00141     cout &lt;&lt; <span class="stringliteral">&quot;The data:&quot;</span> &lt;&lt; endl;
<a name="l00142"></a>00142 
<a name="l00143"></a>00143     <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1DDS.html#a5140f67d8f7eecf0a260d8a5d9fc39c5">DDS::Vars_iter</a> i = dds.<a class="code" href="classlibdap_1_1DDS.html#aac98f248cd5730a8769f9d71af9788d3" title="Return an iterator to the first variable.">var_begin</a>(); i != dds.<a class="code" href="classlibdap_1_1DDS.html#ad204bbd6eed8d440fb996f41bc986058" title="Return an iterator.">var_end</a>(); i++) {
<a name="l00144"></a>00144         <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> *v = *i;
<a name="l00145"></a>00145         <span class="keywordflow">if</span> (print_rows &amp;&amp; (*i)-&gt;type() == <a class="code" href="namespacelibdap.html#a05ca706d4539ae7b750c3bc7066ab6e6a0b03707324b30e4a7c88876bbf8c7e3b">dods_sequence_c</a>)
<a name="l00146"></a>00146             dynamic_cast &lt; Sequence * &gt;(*i)-&gt;print_val_by_rows(cout);
<a name="l00147"></a>00147         <span class="keywordflow">else</span>
<a name="l00148"></a>00148             v-&gt;<a class="code" href="classlibdap_1_1BaseType.html#a94edd5b610afb1432144158740710488" title="Prints the value of the variable.">print_val</a>(cout);
<a name="l00149"></a>00149     }
<a name="l00150"></a>00150 
<a name="l00151"></a>00151     cout &lt;&lt; endl &lt;&lt; flush;
<a name="l00152"></a>00152 }
<a name="l00153"></a>00153 
<a name="l00154"></a><a class="code" href="getdap_8cc.html#a0ddf1224851353fc92bfbff6f499fa97">00154</a> <span class="keywordtype">int</span> <a class="code" href="getdap_8cc.html#a0ddf1224851353fc92bfbff6f499fa97">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
<a name="l00155"></a>00155 {
<a name="l00156"></a>00156     GetOpt getopt(argc, argv, <span class="stringliteral">&quot;idaDxXBVvkc:m:zshM?Hp:t&quot;</span>);
<a name="l00157"></a>00157     <span class="keywordtype">int</span> option_char;
<a name="l00158"></a>00158 
<a name="l00159"></a>00159     <span class="keywordtype">bool</span> get_das = <span class="keyword">false</span>;
<a name="l00160"></a>00160     <span class="keywordtype">bool</span> get_dds = <span class="keyword">false</span>;
<a name="l00161"></a>00161     <span class="keywordtype">bool</span> get_data = <span class="keyword">false</span>;
<a name="l00162"></a>00162     <span class="keywordtype">bool</span> get_ddx = <span class="keyword">false</span>;
<a name="l00163"></a>00163     <span class="keywordtype">bool</span> get_data_ddx = <span class="keyword">false</span>;
<a name="l00164"></a>00164     <span class="keywordtype">bool</span> build_ddx = <span class="keyword">false</span>;
<a name="l00165"></a>00165     <span class="keywordtype">bool</span> get_version = <span class="keyword">false</span>;
<a name="l00166"></a>00166     <span class="keywordtype">bool</span> cexpr = <span class="keyword">false</span>;
<a name="l00167"></a>00167     <span class="keywordtype">bool</span> verbose = <span class="keyword">false</span>;
<a name="l00168"></a>00168     <span class="keywordtype">bool</span> multi = <span class="keyword">false</span>;
<a name="l00169"></a>00169     <span class="keywordtype">bool</span> accept_deflate = <span class="keyword">false</span>;
<a name="l00170"></a>00170     <span class="keywordtype">bool</span> print_rows = <span class="keyword">false</span>;
<a name="l00171"></a>00171     <span class="keywordtype">bool</span> mime_headers = <span class="keyword">true</span>;
<a name="l00172"></a>00172     <span class="keywordtype">int</span> times = 1;
<a name="l00173"></a>00173     <span class="keywordtype">int</span> dap_client_major = 2;
<a name="l00174"></a>00174     <span class="keywordtype">int</span> dap_client_minor = 0;
<a name="l00175"></a>00175     <span class="keywordtype">string</span> expr = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00176"></a>00176 
<a name="l00177"></a>00177 <span class="preprocessor">#ifdef WIN32</span>
<a name="l00178"></a>00178 <span class="preprocessor"></span>    _setmode(_fileno(stdout), _O_BINARY);
<a name="l00179"></a>00179 <span class="preprocessor">#endif</span>
<a name="l00180"></a>00180 <span class="preprocessor"></span>
<a name="l00181"></a>00181     <span class="keywordflow">while</span> ((option_char = getopt()) != EOF)
<a name="l00182"></a>00182         <span class="keywordflow">switch</span> (option_char) {
<a name="l00183"></a>00183         <span class="keywordflow">case</span> <span class="charliteral">&#39;d&#39;</span>:
<a name="l00184"></a>00184             get_dds = <span class="keyword">true</span>;
<a name="l00185"></a>00185             <span class="keywordflow">break</span>;
<a name="l00186"></a>00186         <span class="keywordflow">case</span> <span class="charliteral">&#39;a&#39;</span>:
<a name="l00187"></a>00187             get_das = <span class="keyword">true</span>;
<a name="l00188"></a>00188             <span class="keywordflow">break</span>;
<a name="l00189"></a>00189         <span class="keywordflow">case</span> <span class="charliteral">&#39;D&#39;</span>:
<a name="l00190"></a>00190             get_data = <span class="keyword">true</span>;
<a name="l00191"></a>00191             <span class="keywordflow">break</span>;
<a name="l00192"></a>00192         <span class="keywordflow">case</span> <span class="charliteral">&#39;x&#39;</span>:
<a name="l00193"></a>00193             get_ddx = <span class="keyword">true</span>;
<a name="l00194"></a>00194             <span class="keywordflow">break</span>;
<a name="l00195"></a>00195         <span class="keywordflow">case</span> <span class="charliteral">&#39;X&#39;</span>:
<a name="l00196"></a>00196             get_data_ddx = <span class="keyword">true</span>;
<a name="l00197"></a>00197             <span class="keywordflow">break</span>;
<a name="l00198"></a>00198         <span class="keywordflow">case</span> <span class="charliteral">&#39;V&#39;</span>:
<a name="l00199"></a>00199             fprintf(stderr, <span class="stringliteral">&quot;getdap version: %s\n&quot;</span>, <a class="code" href="getdap_8cc.html#aa31f487a99743d24af9076a3e11e5425">version</a>);
<a name="l00200"></a>00200             exit(0);
<a name="l00201"></a>00201         <span class="keywordflow">case</span> <span class="charliteral">&#39;i&#39;</span>:
<a name="l00202"></a>00202             get_version = <span class="keyword">true</span>;
<a name="l00203"></a>00203             <span class="keywordflow">break</span>;
<a name="l00204"></a>00204         <span class="keywordflow">case</span> <span class="charliteral">&#39;v&#39;</span>:
<a name="l00205"></a>00205             verbose = <span class="keyword">true</span>;
<a name="l00206"></a>00206             <span class="keywordflow">break</span>;
<a name="l00207"></a>00207         <span class="keywordflow">case</span> <span class="charliteral">&#39;k&#39;</span>:
<a name="l00208"></a>00208             <a class="code" href="namespacelibdap.html#aeafd230ca250e819c46862dc43deb4fa">dods_keep_temps</a> = 1;
<a name="l00209"></a>00209             <span class="keywordflow">break</span>;              <span class="comment">// keep_temp is in Connect.cc</span>
<a name="l00210"></a>00210         <span class="keywordflow">case</span> <span class="charliteral">&#39;c&#39;</span>:
<a name="l00211"></a>00211             cexpr = <span class="keyword">true</span>;
<a name="l00212"></a>00212             expr = getopt.optarg;
<a name="l00213"></a>00213             <span class="keywordflow">break</span>;
<a name="l00214"></a>00214         <span class="keywordflow">case</span> <span class="charliteral">&#39;m&#39;</span>:
<a name="l00215"></a>00215             multi = <span class="keyword">true</span>;
<a name="l00216"></a>00216             times = atoi(getopt.optarg);
<a name="l00217"></a>00217             <span class="keywordflow">break</span>;
<a name="l00218"></a>00218         <span class="keywordflow">case</span> <span class="charliteral">&#39;B&#39;</span>:
<a name="l00219"></a>00219             build_ddx = <span class="keyword">true</span>;
<a name="l00220"></a>00220             <span class="keywordflow">break</span>;
<a name="l00221"></a>00221         <span class="keywordflow">case</span> <span class="charliteral">&#39;z&#39;</span>:
<a name="l00222"></a>00222             accept_deflate = <span class="keyword">true</span>;
<a name="l00223"></a>00223             <span class="keywordflow">break</span>;
<a name="l00224"></a>00224         <span class="keywordflow">case</span> <span class="charliteral">&#39;s&#39;</span>:
<a name="l00225"></a>00225             print_rows = <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">&#39;M&#39;</span>:
<a name="l00228"></a>00228             mime_headers = <span class="keyword">false</span>;
<a name="l00229"></a>00229             <span class="keywordflow">break</span>;
<a name="l00230"></a>00230         <span class="keywordflow">case</span> <span class="charliteral">&#39;p&#39;</span>: {
<a name="l00231"></a>00231             istringstream iss(getopt.optarg);
<a name="l00232"></a>00232             <span class="keywordtype">char</span> dot;
<a name="l00233"></a>00233             iss &gt;&gt; dap_client_major;
<a name="l00234"></a>00234             iss &gt;&gt; dot;
<a name="l00235"></a>00235             iss &gt;&gt; dap_client_minor;
<a name="l00236"></a>00236             <span class="keywordflow">break</span>;
<a name="l00237"></a>00237         }
<a name="l00238"></a>00238         <span class="keywordflow">case</span> <span class="charliteral">&#39;t&#39;</span>:
<a name="l00239"></a>00239             <a class="code" href="namespacelibdap.html#aab2a595ed5ba24c6f549093fdf645c67">www_trace</a> = 1;
<a name="l00240"></a>00240             <span class="keywordflow">break</span>;
<a name="l00241"></a>00241         <span class="keywordflow">case</span> <span class="charliteral">&#39;h&#39;</span>:
<a name="l00242"></a>00242         <span class="keywordflow">case</span> <span class="charliteral">&#39;?&#39;</span>:
<a name="l00243"></a>00243         <span class="keywordflow">default</span>:
<a name="l00244"></a>00244             <a class="code" href="namespacelibdap.html#a6f36b78e0590ec9e3a0583f0ecfead64">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">&quot;Fetching: %s\n&quot;</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 
<a name="l00259"></a>00259             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="l00260"></a>00260 
<a name="l00261"></a>00261             <span class="comment">// This overrides the value set in the .dodsrc file.</span>
<a name="l00262"></a>00262             <span class="keywordflow">if</span> (accept_deflate)
<a name="l00263"></a>00263                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a186f76bfea3b61dc3587bcff5760ed8b">set_accept_deflate</a>(accept_deflate);
<a name="l00264"></a>00264 
<a name="l00265"></a>00265             <span class="keywordflow">if</span> (dap_client_major &gt; 2)
<a name="l00266"></a>00266                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a4af759a2313d9ecbc1db1c811f549379">set_xdap_protocol</a>(dap_client_major, dap_client_minor);
<a name="l00267"></a>00267 
<a name="l00268"></a>00268             <span class="keywordflow">if</span> (url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a3901ce9383c3df11d1a1c28d4a09bb54">is_local</a>()) {
<a name="l00269"></a>00269                 <span class="keywordflow">if</span> (verbose) {
<a name="l00270"></a>00270                     fprintf(stderr,
<a name="l00271"></a>00271                             <span class="stringliteral">&quot;Assuming that the argument %s is a file that contains a DAP2 data object; decoding.\n&quot;</span>, argv[i]);
<a name="l00272"></a>00272                 }
<a name="l00273"></a>00273 
<a name="l00274"></a>00274                 <a class="code" href="classlibdap_1_1Response.html">Response</a> *r = 0;
<a name="l00275"></a>00275                 <a class="code" href="classlibdap_1_1BaseTypeFactory.html">BaseTypeFactory</a> factory;
<a name="l00276"></a>00276                 <a class="code" href="classlibdap_1_1DataDDS.html" title="Holds a DAP2 DDS.">DataDDS</a> dds(&amp;factory);
<a name="l00277"></a>00277 
<a name="l00278"></a>00278                 <span class="keywordflow">try</span> {
<a name="l00279"></a>00279                     <span class="keywordflow">if</span> (strcmp(argv[i], <span class="stringliteral">&quot;-&quot;</span>) == 0) {
<a name="l00280"></a>00280                         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="l00281"></a>00281 
<a name="l00282"></a>00282                         <span class="keywordflow">if</span> (!r-&gt;<a class="code" href="classlibdap_1_1Response.html#a5b4903bb627c5e6ccd4cd50712e1f0a1">get_stream</a>())
<a name="l00283"></a>00283                             <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a>(<span class="stringliteral">&quot;Could not open standard input.&quot;</span>);
<a name="l00284"></a>00284 
<a name="l00285"></a>00285                         <span class="keywordflow">if</span> (mime_headers)
<a name="l00286"></a>00286                             url-&gt;<a class="code" href="classlibdap_1_1Connect.html#ae50d98d353023b9786c9bd5b0833a7de" title="Read data which is preceded by MIME headers. This method works for both data dds and data ddx respons...">read_data</a>(dds, r); <span class="comment">// The default case</span>
<a name="l00287"></a>00287                         <span class="keywordflow">else</span>
<a name="l00288"></a>00288                             url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a486b095a58614dfc2be0321035784306" title="Read data from a file which does not have response MIME headers. This method is a companion to read_d...">read_data_no_mime</a>(dds, r);
<a name="l00289"></a>00289                     }
<a name="l00290"></a>00290                     <span class="keywordflow">else</span> {
<a name="l00291"></a>00291                         r = <span class="keyword">new</span> <a class="code" href="classlibdap_1_1Response.html">Response</a>(fopen(argv[i], <span class="stringliteral">&quot;r&quot;</span>), 0);
<a name="l00292"></a>00292 
<a name="l00293"></a>00293                         <span class="keywordflow">if</span> (!r-&gt;<a class="code" href="classlibdap_1_1Response.html#a5b4903bb627c5e6ccd4cd50712e1f0a1">get_stream</a>())
<a name="l00294"></a>00294                             <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">&quot;The input source: &quot;</span>)
<a name="l00295"></a>00295                                         + string(argv[i])
<a name="l00296"></a>00296                                         + string(<span class="stringliteral">&quot; could not be opened&quot;</span>));
<a name="l00297"></a>00297 
<a name="l00298"></a>00298                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a486b095a58614dfc2be0321035784306" title="Read data from a file which does not have response MIME headers. This method is a companion to read_d...">read_data_no_mime</a>(dds, r);
<a name="l00299"></a>00299                     }
<a name="l00300"></a>00300                 }
<a name="l00301"></a>00301                 <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="l00302"></a>00302                     cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#a917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00303"></a>00303                     <span class="keyword">delete</span> r;
<a name="l00304"></a>00304                     r = 0;
<a name="l00305"></a>00305                     <span class="keyword">delete</span> url;
<a name="l00306"></a>00306                     url = 0;
<a name="l00307"></a>00307                     <span class="keywordflow">break</span>;
<a name="l00308"></a>00308                 }
<a name="l00309"></a>00309 
<a name="l00310"></a>00310                 <span class="keywordflow">if</span> (verbose)
<a name="l00311"></a>00311                     fprintf(stderr, <span class="stringliteral">&quot;DAP version: %s, Server version: %s\n&quot;</span>,
<a name="l00312"></a>00312                             url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a4223a898b3da719509d173dd990c45f1">get_protocol</a>().c_str(),
<a name="l00313"></a>00313                             url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00314"></a>00314 
<a name="l00315"></a>00315                 print_data(dds, print_rows);
<a name="l00316"></a>00316 
<a name="l00317"></a>00317             }
<a name="l00318"></a>00318 
<a name="l00319"></a>00319             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (get_version) {
<a name="l00320"></a>00320                 fprintf(stderr, <span class="stringliteral">&quot;DAP version: %s, Server version: %s\n&quot;</span>,
<a name="l00321"></a>00321                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#aaa1ab562899da9a4630de01f943d1aa9">request_protocol</a>().c_str(),
<a name="l00322"></a>00322                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00323"></a>00323             }
<a name="l00324"></a>00324 
<a name="l00325"></a>00325             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (get_das) {
<a name="l00326"></a>00326                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; times; ++j) {
<a name="l00327"></a>00327                     <a class="code" href="classlibdap_1_1DAS.html" title="Hold attribute data for a DAP2 dataset.">DAS</a> das;
<a name="l00328"></a>00328                     <span class="keywordflow">try</span> {
<a name="l00329"></a>00329                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a816ef3bb8e729712ffeb6523f2cc4f0e" title="Get the DAS from a server.">request_das</a>(das);
<a name="l00330"></a>00330                     }
<a name="l00331"></a>00331                     <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="l00332"></a>00332                         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#a917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00333"></a>00333                         <span class="keyword">delete</span> url;
<a name="l00334"></a>00334                         url = 0;
<a name="l00335"></a>00335                         <span class="keywordflow">continue</span>;
<a name="l00336"></a>00336                     }
<a name="l00337"></a>00337 
<a name="l00338"></a>00338                     <span class="keywordflow">if</span> (verbose) {
<a name="l00339"></a>00339                         fprintf(stderr, <span class="stringliteral">&quot;DAP version: %s, Server version: %s\n&quot;</span>,
<a name="l00340"></a>00340                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a4223a898b3da719509d173dd990c45f1">get_protocol</a>().c_str(),
<a name="l00341"></a>00341                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00342"></a>00342 
<a name="l00343"></a>00343                         fprintf(stderr, <span class="stringliteral">&quot;DAS:\n&quot;</span>);
<a name="l00344"></a>00344                     }
<a name="l00345"></a>00345 
<a name="l00346"></a>00346                     das.<a class="code" href="classlibdap_1_1DAS.html#a8983b961e6fba3a6fd33ffcfd944eaf2">print</a>(stdout);
<a name="l00347"></a>00347                 }
<a name="l00348"></a>00348             }
<a name="l00349"></a>00349 
<a name="l00350"></a>00350             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (get_dds) {
<a name="l00351"></a>00351                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; times; ++j) {
<a name="l00352"></a>00352                     <a class="code" href="classlibdap_1_1BaseTypeFactory.html">BaseTypeFactory</a> factory;
<a name="l00353"></a>00353                     <a class="code" href="classlibdap_1_1DDS.html">DDS</a> dds(&amp;factory);
<a name="l00354"></a>00354                     <span class="keywordflow">try</span> {
<a name="l00355"></a>00355                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#aad5ef370110577e9ca2a0161928f9efa" title="Get the DDS from a server.">request_dds</a>(dds, expr);
<a name="l00356"></a>00356                     }
<a name="l00357"></a>00357                     <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="l00358"></a>00358                         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#a917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00359"></a>00359                         <span class="keyword">delete</span> url;
<a name="l00360"></a>00360                         url = 0;
<a name="l00361"></a>00361                         <span class="keywordflow">continue</span>;       <span class="comment">// Goto the next URL or exit the loop.</span>
<a name="l00362"></a>00362                     }
<a name="l00363"></a>00363 
<a name="l00364"></a>00364                     <span class="keywordflow">if</span> (verbose) {
<a name="l00365"></a>00365                         fprintf(stderr, <span class="stringliteral">&quot;DAP version: %s, Server version: %s\n&quot;</span>,
<a name="l00366"></a>00366                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a4223a898b3da719509d173dd990c45f1">get_protocol</a>().c_str(),
<a name="l00367"></a>00367                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00368"></a>00368 
<a name="l00369"></a>00369                         fprintf(stderr, <span class="stringliteral">&quot;DDS:\n&quot;</span>);
<a name="l00370"></a>00370                     }
<a name="l00371"></a>00371 
<a name="l00372"></a>00372                     dds.<a class="code" href="classlibdap_1_1DDS.html#a535b5900c31f0038061f4aef5fa1c6c1" title="Print the entire DDS to the specified ostream.">print</a>(cout);
<a name="l00373"></a>00373                 }
<a name="l00374"></a>00374             }
<a name="l00375"></a>00375 
<a name="l00376"></a>00376             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (get_ddx) {
<a name="l00377"></a>00377                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; times; ++j) {
<a name="l00378"></a>00378                     <a class="code" href="classlibdap_1_1BaseTypeFactory.html">BaseTypeFactory</a> factory;
<a name="l00379"></a>00379                     <a class="code" href="classlibdap_1_1DDS.html">DDS</a> dds(&amp;factory);
<a name="l00380"></a>00380                     <span class="keywordflow">try</span> {
<a name="l00381"></a>00381                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a4395cc18cf5ec1a5167795a5a5491958" title="Get the DDX from a server.">request_ddx</a>(dds, expr);
<a name="l00382"></a>00382                     }
<a name="l00383"></a>00383                     <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="l00384"></a>00384                         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#a917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00385"></a>00385                         <span class="keywordflow">continue</span>;       <span class="comment">// Goto the next URL or exit the loop.</span>
<a name="l00386"></a>00386                     }
<a name="l00387"></a>00387 
<a name="l00388"></a>00388                     <span class="keywordflow">if</span> (verbose) {
<a name="l00389"></a>00389                         fprintf(stderr, <span class="stringliteral">&quot;DAP version: %s, Server version: %s\n&quot;</span>,
<a name="l00390"></a>00390                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a4223a898b3da719509d173dd990c45f1">get_protocol</a>().c_str(),
<a name="l00391"></a>00391                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00392"></a>00392 
<a name="l00393"></a>00393                         fprintf(stderr, <span class="stringliteral">&quot;DDX:\n&quot;</span>);
<a name="l00394"></a>00394                     }
<a name="l00395"></a>00395 
<a name="l00396"></a>00396                     dds.<a class="code" href="classlibdap_1_1DDS.html#af319354a044d02ea89732160131004dc">print_xml</a>(cout, <span class="keyword">false</span>);
<a name="l00397"></a>00397                 }
<a name="l00398"></a>00398             }
<a name="l00399"></a>00399 
<a name="l00400"></a>00400             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (build_ddx) {
<a name="l00401"></a>00401                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; times; ++j) {
<a name="l00402"></a>00402                     <a class="code" href="classlibdap_1_1BaseTypeFactory.html">BaseTypeFactory</a> factory;
<a name="l00403"></a>00403                     <a class="code" href="classlibdap_1_1DDS.html">DDS</a> dds(&amp;factory);
<a name="l00404"></a>00404                     <span class="keywordflow">try</span> {
<a name="l00405"></a>00405                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#aad5ef370110577e9ca2a0161928f9efa" title="Get the DDS from a server.">request_dds</a>(dds, expr);
<a name="l00406"></a>00406                         <a class="code" href="classlibdap_1_1DAS.html" title="Hold attribute data for a DAP2 dataset.">DAS</a> das;
<a name="l00407"></a>00407                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a816ef3bb8e729712ffeb6523f2cc4f0e" title="Get the DAS from a server.">request_das</a>(das);
<a name="l00408"></a>00408                         dds.<a class="code" href="classlibdap_1_1DDS.html#a2810a944fbdc7d21b08f2d8c19022b52">transfer_attributes</a>(&amp;das);
<a name="l00409"></a>00409                     }
<a name="l00410"></a>00410                     <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="l00411"></a>00411                         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#a917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00412"></a>00412                         <span class="keywordflow">continue</span>;       <span class="comment">// Goto the next URL or exit the loop.</span>
<a name="l00413"></a>00413                     }
<a name="l00414"></a>00414 
<a name="l00415"></a>00415                     <span class="keywordflow">if</span> (verbose) {
<a name="l00416"></a>00416                         fprintf(stderr, <span class="stringliteral">&quot;DAP version: %s, Server version: %s\n&quot;</span>,
<a name="l00417"></a>00417                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a4223a898b3da719509d173dd990c45f1">get_protocol</a>().c_str(),
<a name="l00418"></a>00418                                 url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00419"></a>00419 
<a name="l00420"></a>00420                         fprintf(stderr, <span class="stringliteral">&quot;Client-built DDX:\n&quot;</span>);
<a name="l00421"></a>00421                     }
<a name="l00422"></a>00422 
<a name="l00423"></a>00423                     dds.<a class="code" href="classlibdap_1_1DDS.html#af319354a044d02ea89732160131004dc">print_xml</a>(cout, <span class="keyword">false</span>);
<a name="l00424"></a>00424                 }
<a name="l00425"></a>00425             }
<a name="l00426"></a>00426 
<a name="l00427"></a>00427             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (get_data) {
<a name="l00428"></a>00428                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; times; ++j) {
<a name="l00429"></a>00429                     <a class="code" href="classlibdap_1_1BaseTypeFactory.html">BaseTypeFactory</a> factory;
<a name="l00430"></a>00430                     <a class="code" href="classlibdap_1_1DataDDS.html" title="Holds a DAP2 DDS.">DataDDS</a> dds(&amp;factory);
<a name="l00431"></a>00431                     <span class="keywordflow">try</span> {
<a name="l00432"></a>00432                         <a class="code" href="debug_8h.html#a32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr &lt;&lt; <span class="stringliteral">&quot;URL: &quot;</span> &lt;&lt; url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a523bf24520185e3d71f36ac0203b98e6" title="Get the object&amp;#39;s URL.">URL</a>(<span class="keyword">false</span>) &lt;&lt; endl);
<a name="l00433"></a>00433                         <a class="code" href="debug_8h.html#a32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr &lt;&lt; <span class="stringliteral">&quot;CE: &quot;</span> &lt;&lt; expr &lt;&lt; endl);
<a name="l00434"></a>00434                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a814e98ac5e99927ccc79bb0feb32d241" title="Get the DAS from a server.">request_data</a>(dds, expr);
<a name="l00435"></a>00435 
<a name="l00436"></a>00436                         <span class="keywordflow">if</span> (verbose)
<a name="l00437"></a>00437                             fprintf(stderr, <span class="stringliteral">&quot;DAP version: %s, Server version: %s\n&quot;</span>,
<a name="l00438"></a>00438                                     url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a4223a898b3da719509d173dd990c45f1">get_protocol</a>().c_str(),
<a name="l00439"></a>00439                                     url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00440"></a>00440 
<a name="l00441"></a>00441                         print_data(dds, print_rows);
<a name="l00442"></a>00442                     }
<a name="l00443"></a>00443                     <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="l00444"></a>00444                         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#a917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00445"></a>00445                         <span class="keyword">delete</span> url;
<a name="l00446"></a>00446                         url = 0;
<a name="l00447"></a>00447                         <span class="keywordflow">continue</span>;
<a name="l00448"></a>00448                     }
<a name="l00449"></a>00449                 }
<a name="l00450"></a>00450             }
<a name="l00451"></a>00451 
<a name="l00452"></a>00452             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (get_data_ddx) {
<a name="l00453"></a>00453                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; times; ++j) {
<a name="l00454"></a>00454                     <a class="code" href="classlibdap_1_1BaseTypeFactory.html">BaseTypeFactory</a> factory;
<a name="l00455"></a>00455                     <a class="code" href="classlibdap_1_1DataDDS.html" title="Holds a DAP2 DDS.">DataDDS</a> dds(&amp;factory);
<a name="l00456"></a>00456                     <span class="keywordflow">try</span> {
<a name="l00457"></a>00457                         <a class="code" href="debug_8h.html#a32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr &lt;&lt; <span class="stringliteral">&quot;URL: &quot;</span> &lt;&lt; url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a523bf24520185e3d71f36ac0203b98e6" title="Get the object&amp;#39;s URL.">URL</a>(<span class="keyword">false</span>) &lt;&lt; endl);
<a name="l00458"></a>00458                         <a class="code" href="debug_8h.html#a32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr &lt;&lt; <span class="stringliteral">&quot;CE: &quot;</span> &lt;&lt; expr &lt;&lt; endl);
<a name="l00459"></a>00459                         url-&gt;<a class="code" href="classlibdap_1_1Connect.html#ab3bc39b8320ae5a79af7bf168f930b07">request_data_ddx</a>(dds, expr);
<a name="l00460"></a>00460 
<a name="l00461"></a>00461                         <span class="keywordflow">if</span> (verbose)
<a name="l00462"></a>00462                             fprintf(stderr, <span class="stringliteral">&quot;DAP version: %s, Server version: %s\n&quot;</span>,
<a name="l00463"></a>00463                                     url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a4223a898b3da719509d173dd990c45f1">get_protocol</a>().c_str(),
<a name="l00464"></a>00464                                     url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a30fe6746add5a210d59b5dc9d678355f">get_version</a>().c_str());
<a name="l00465"></a>00465 
<a name="l00466"></a>00466                         print_data(dds, print_rows);
<a name="l00467"></a>00467                     }
<a name="l00468"></a>00468                     <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="l00469"></a>00469                         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#a917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00470"></a>00470                         <span class="keyword">delete</span> url;
<a name="l00471"></a>00471                         url = 0;
<a name="l00472"></a>00472                         <span class="keywordflow">continue</span>;
<a name="l00473"></a>00473                     }
<a name="l00474"></a>00474                 }
<a name="l00475"></a>00475             }
<a name="l00476"></a>00476 
<a name="l00477"></a>00477             <span class="keywordflow">else</span> {
<a name="l00478"></a>00478                 <span class="comment">// if (!get_das &amp;&amp; !get_dds &amp;&amp; !get_data) This code uses</span>
<a name="l00479"></a>00479                 <span class="comment">// HTTPConnect::fetch_url which cannot be accessed using an</span>
<a name="l00480"></a>00480                 <span class="comment">// instance of Connect. So some of the options supported by</span>
<a name="l00481"></a>00481                 <span class="comment">// other URLs won&#39;t work here (e.g., the verbose option</span>
<a name="l00482"></a>00482                 <span class="comment">// doesn&#39;t show the server version number).</span>
<a name="l00483"></a>00483                 <a class="code" href="classlibdap_1_1HTTPConnect.html">HTTPConnect</a> http(<a class="code" href="classlibdap_1_1RCReader.html#a8272ec2f2eae73a038d21bfcd0c23fd3">RCReader::instance</a>());
<a name="l00484"></a>00484 
<a name="l00485"></a>00485                 <span class="comment">// This overrides the value set in the .dodsrc file.</span>
<a name="l00486"></a>00486                 <span class="keywordflow">if</span> (accept_deflate)
<a name="l00487"></a>00487                     http.<a class="code" href="classlibdap_1_1HTTPConnect.html#a01d67a5afa18a84ef744b8f222094260">set_accept_deflate</a>(accept_deflate);
<a name="l00488"></a>00488 
<a name="l00489"></a>00489                 <span class="keywordflow">if</span> (dap_client_major &gt; 2)
<a name="l00490"></a>00490                     url-&gt;<a class="code" href="classlibdap_1_1Connect.html#a4af759a2313d9ecbc1db1c811f549379">set_xdap_protocol</a>(dap_client_major, dap_client_minor);
<a name="l00491"></a>00491 
<a name="l00492"></a>00492                 <span class="keywordtype">string</span> url_string = argv[i];
<a name="l00493"></a>00493                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; times; ++j) {
<a name="l00494"></a>00494                     <span class="keywordflow">try</span> {
<a name="l00495"></a>00495                         <a class="code" href="classlibdap_1_1Response.html">Response</a> *r = http.<a class="code" href="classlibdap_1_1HTTPConnect.html#a5e3558838e245a96c9392b33ef4ba298">fetch_url</a>(url_string);
<a name="l00496"></a>00496                         <span class="keywordflow">if</span> (!<a class="code" href="getdap_8cc.html#ae894a8fa14082e1c9fe5146b6dba5c92">read_data</a>(r-&gt;<a class="code" href="classlibdap_1_1Response.html#a5b4903bb627c5e6ccd4cd50712e1f0a1">get_stream</a>())) {
<a name="l00497"></a>00497                             <span class="keywordflow">continue</span>;
<a name="l00498"></a>00498                         }
<a name="l00499"></a>00499                         <span class="keyword">delete</span> r;
<a name="l00500"></a>00500                         r = 0;
<a name="l00501"></a>00501                     }
<a name="l00502"></a>00502                     <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="l00503"></a>00503                         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#a917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00504"></a>00504                         <span class="keywordflow">continue</span>;
<a name="l00505"></a>00505                     }
<a name="l00506"></a>00506                 }
<a name="l00507"></a>00507             }
<a name="l00508"></a>00508 
<a name="l00509"></a>00509             <span class="keyword">delete</span> url;
<a name="l00510"></a>00510             url = 0;
<a name="l00511"></a>00511         }
<a name="l00512"></a>00512     }
<a name="l00513"></a>00513     <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="l00514"></a>00514         cerr &lt;&lt; e.<a class="code" href="classlibdap_1_1Error.html#a917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>() &lt;&lt; endl;
<a name="l00515"></a>00515         <span class="keywordflow">return</span> 1;
<a name="l00516"></a>00516     }
<a name="l00517"></a>00517     <span class="keywordflow">catch</span> (exception &amp;e) {
<a name="l00518"></a>00518         cerr &lt;&lt; <span class="stringliteral">&quot;C++ library exception: &quot;</span> &lt;&lt; e.what() &lt;&lt; endl;
<a name="l00519"></a>00519         <span class="keywordflow">return</span> 1;
<a name="l00520"></a>00520     }
<a name="l00521"></a>00521 
<a name="l00522"></a>00522     <span class="keywordflow">return</span> 0;
<a name="l00523"></a>00523 }
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="getdap_8cc.html">getdap.cc</a>      </li>
      <li class="footer">Generated on Tue Feb 8 2011 for libdap++ by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li>
    </ul>
  </div>

</body>
</html>