diff options
Diffstat (limited to 'mdk-stage1')
-rw-r--r-- | mdk-stage1/url.c | 6292 |
1 files changed, 560 insertions, 5732 deletions
diff --git a/mdk-stage1/url.c b/mdk-stage1/url.c index b9af3c689..3d2846649 100644 --- a/mdk-stage1/url.c +++ b/mdk-stage1/url.c @@ -1,5732 +1,560 @@ - - - - - - - - - - - -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" -"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<!-- ViewVC :: http://www.viewvc.org/ --> -<head> -<title>[soft] Contents of /drakx/trunk/mdk-stage1/url.c</title> -<meta name="generator" content="ViewVC 1.1.15" /> -<link rel="shortcut icon" href="/viewvc/images/favicon.ico" /> -<link rel="stylesheet" href="/viewvc/styles.css" type="text/css" /> - -</head> -<body> -<div class="vc_navheader"> -<table><tr> -<td><strong><a href="/"><span class="pathdiv">/</span></a><a href="/soft/?pathrev=6430">[soft]</a><span class="pathdiv">/</span><a href="/soft/drakx/?pathrev=6430">drakx</a><span class="pathdiv">/</span><a href="/soft/drakx/trunk/?pathrev=6430">trunk</a><span class="pathdiv">/</span><a href="/soft/drakx/trunk/mdk-stage1/?pathrev=6430">mdk-stage1</a><span class="pathdiv">/</span><a href="/soft/drakx/trunk/mdk-stage1/url.c?view=log&pathrev=6430">url.c</a></strong></td> -<td style="text-align: right;"></td> -</tr></table> -</div> -<div style="float: right; padding: 5px;"><a href="http://www.viewvc.org/" title="ViewVC Home"><img src="/viewvc/images/viewvc-logo.png" alt="ViewVC logotype" width="240" height="70" /></a></div> -<h1>Contents of /drakx/trunk/mdk-stage1/url.c</h1> - -<p style="margin:0;"> - -<a href="/soft/drakx/trunk/mdk-stage1/?pathrev=6430"><img src="/viewvc/images/back_small.png" class="vc_icon" alt="Parent Directory" /> Parent Directory</a> - -| <a href="/soft/drakx/trunk/mdk-stage1/url.c?view=log&pathrev=6430"><img src="/viewvc/images/log.png" class="vc_icon" alt="Revision Log" /> Revision Log</a> - - - - -</p> - -<hr /> -<div class="vc_summary"> -Revision <a href="/soft?view=revision&revision=2834"><strong>2834</strong></a> - -(<a href="/soft/drakx/trunk/mdk-stage1/url.c?annotate=2834&pathrev=6430"><strong>show annotations</strong></a>) -(<a href="/soft/drakx/trunk/mdk-stage1/url.c?revision=2834&view=co&pathrev=6430"><strong>download</strong></a>) -(<a href="/soft/drakx/trunk/mdk-stage1/url.c?view=co&revision=2834&content-type=text%2Fplain&pathrev=6430"><strong>as text</strong></a>) - -<br /><em>Fri Jan 27 07:14:12 2012 UTC</em> -(9 months, 2 weeks ago) -by <em>tv</em> - - - - - - -<br />File MIME type: text/x-c - - -<br />File size: 12365 byte(s) - - - - - - -<pre class="vc_log">kill dead emails -</pre> - -</div> - - - - - - -<div id="vc_file"> -<table cellspacing="0" cellpadding="0"> - - - - - - - - -<tr class="vc_row_odd" id="l1"> -<td class="vc_file_line_number">1</td> - -<td class="vc_file_line_text"><span class="pygments-cm">/*</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l2"> -<td class="vc_file_line_number">2</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> * Guillaume Cottenceau (gc)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l3"> -<td class="vc_file_line_number">3</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> *</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l4"> -<td class="vc_file_line_number">4</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> * Copyright 2000 Mandriva</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l5"> -<td class="vc_file_line_number">5</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> *</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l6"> -<td class="vc_file_line_number">6</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> * This software may be freely redistributed under the terms of the GNU</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l7"> -<td class="vc_file_line_number">7</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> * public license.</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l8"> -<td class="vc_file_line_number">8</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> *</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l9"> -<td class="vc_file_line_number">9</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> * You should have received a copy of the GNU General Public License</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l10"> -<td class="vc_file_line_number">10</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> * along with this program; if not, write to the Free Software</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l11"> -<td class="vc_file_line_number">11</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l12"> -<td class="vc_file_line_number">12</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> *</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l13"> -<td class="vc_file_line_number">13</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> */</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l14"> -<td class="vc_file_line_number">14</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l15"> -<td class="vc_file_line_number">15</td> - -<td class="vc_file_line_text"><span class="pygments-cm">/*</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l16"> -<td class="vc_file_line_number">16</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> * Portions from Erik Troan <ewt@redhat.com> and Matt Wilson <msw@redhat.com></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l17"> -<td class="vc_file_line_number">17</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> *</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l18"> -<td class="vc_file_line_number">18</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> * Copyright 1999 Red Hat, Inc.</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l19"> -<td class="vc_file_line_number">19</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> *</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l20"> -<td class="vc_file_line_number">20</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> */</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l21"> -<td class="vc_file_line_number">21</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l22"> -<td class="vc_file_line_number">22</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <alloca.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l23"> -<td class="vc_file_line_number">23</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <sys/socket.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l24"> -<td class="vc_file_line_number">24</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <sys/types.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l25"> -<td class="vc_file_line_number">25</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <netinet/in_systm.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l26"> -<td class="vc_file_line_number">26</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l27"> -<td class="vc_file_line_number">27</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <ctype.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l28"> -<td class="vc_file_line_number">28</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <errno.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l29"> -<td class="vc_file_line_number">29</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <fcntl.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l30"> -<td class="vc_file_line_number">30</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <netdb.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l31"> -<td class="vc_file_line_number">31</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <stdarg.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l32"> -<td class="vc_file_line_number">32</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <stdio.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l33"> -<td class="vc_file_line_number">33</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <stdlib.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l34"> -<td class="vc_file_line_number">34</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <string.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l35"> -<td class="vc_file_line_number">35</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <strings.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l36"> -<td class="vc_file_line_number">36</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <sys/socket.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l37"> -<td class="vc_file_line_number">37</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <sys/time.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l38"> -<td class="vc_file_line_number">38</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <sys/types.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l39"> -<td class="vc_file_line_number">39</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <unistd.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l40"> -<td class="vc_file_line_number">40</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <sys/poll.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l41"> -<td class="vc_file_line_number">41</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l42"> -<td class="vc_file_line_number">42</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <netinet/in.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l43"> -<td class="vc_file_line_number">43</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <netinet/ip.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l44"> -<td class="vc_file_line_number">44</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include <arpa/inet.h></span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l45"> -<td class="vc_file_line_number">45</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l46"> -<td class="vc_file_line_number">46</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include "dns.h"</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l47"> -<td class="vc_file_line_number">47</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include "log.h"</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l48"> -<td class="vc_file_line_number">48</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include "tools.h"</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l49"> -<td class="vc_file_line_number">49</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include "utils.h"</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l50"> -<td class="vc_file_line_number">50</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l51"> -<td class="vc_file_line_number">51</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#include "url.h"</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l52"> -<td class="vc_file_line_number">52</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l53"> -<td class="vc_file_line_number">53</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l54"> -<td class="vc_file_line_number">54</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#define TIMEOUT_SECS 60</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l55"> -<td class="vc_file_line_number">55</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#define BUFFER_SIZE 4096</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l56"> -<td class="vc_file_line_number">56</td> - -<td class="vc_file_line_text"><span class="pygments-cp">#define HTTP_MAX_RECURSION 5</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l57"> -<td class="vc_file_line_number">57</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l58"> -<td class="vc_file_line_number">58</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l59"> -<td class="vc_file_line_number">59</td> - -<td class="vc_file_line_text"><span class="pygments-k">static</span> <span class="pygments-kt">int</span> <span class="pygments-nf">ftp_check_response</span><span class="pygments-p">(</span><span class="pygments-kt">int</span> <span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">**</span> <span class="pygments-n">str</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l60"> -<td class="vc_file_line_number">60</td> - -<td class="vc_file_line_text"><span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l61"> -<td class="vc_file_line_number">61</td> - -<td class="vc_file_line_text"> <span class="pygments-k">static</span> <span class="pygments-kt">char</span> <span class="pygments-n">buf</span><span class="pygments-p">[</span><span class="pygments-n">BUFFER_SIZE</span> <span class="pygments-o">+</span> <span class="pygments-mi">1</span><span class="pygments-p">];</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l62"> -<td class="vc_file_line_number">62</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">bufLength</span> <span class="pygments-o">=</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l63"> -<td class="vc_file_line_number">63</td> - -<td class="vc_file_line_text"> <span class="pygments-k">struct</span> <span class="pygments-n">pollfd</span> <span class="pygments-n">polls</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l64"> -<td class="vc_file_line_number">64</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">chptr</span><span class="pygments-p">,</span> <span class="pygments-o">*</span> <span class="pygments-n">start</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l65"> -<td class="vc_file_line_number">65</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">bytesRead</span><span class="pygments-p">,</span> <span class="pygments-n">rc</span> <span class="pygments-o">=</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l66"> -<td class="vc_file_line_number">66</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">doesContinue</span> <span class="pygments-o">=</span> <span class="pygments-mi">1</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l67"> -<td class="vc_file_line_number">67</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-n">errorCode</span><span class="pygments-p">[</span><span class="pygments-mi">4</span><span class="pygments-p">];</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l68"> -<td class="vc_file_line_number">68</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l69"> -<td class="vc_file_line_number">69</td> - -<td class="vc_file_line_text"> <span class="pygments-n">errorCode</span><span class="pygments-p">[</span><span class="pygments-mi">0</span><span class="pygments-p">]</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l70"> -<td class="vc_file_line_number">70</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l71"> -<td class="vc_file_line_number">71</td> - -<td class="vc_file_line_text"> <span class="pygments-k">do</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l72"> -<td class="vc_file_line_number">72</td> - -<td class="vc_file_line_text"> <span class="pygments-n">polls</span><span class="pygments-p">.</span><span class="pygments-n">fd</span> <span class="pygments-o">=</span> <span class="pygments-n">sock</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l73"> -<td class="vc_file_line_number">73</td> - -<td class="vc_file_line_text"> <span class="pygments-n">polls</span><span class="pygments-p">.</span><span class="pygments-n">events</span> <span class="pygments-o">=</span> <span class="pygments-n">POLLIN</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l74"> -<td class="vc_file_line_number">74</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">poll</span><span class="pygments-p">(</span><span class="pygments-o">&</span><span class="pygments-n">polls</span><span class="pygments-p">,</span> <span class="pygments-mi">1</span><span class="pygments-p">,</span> <span class="pygments-n">TIMEOUT_SECS</span><span class="pygments-o">*</span><span class="pygments-mi">1000</span><span class="pygments-p">)</span> <span class="pygments-o">!=</span> <span class="pygments-mi">1</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l75"> -<td class="vc_file_line_number">75</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_BAD_SERVER_RESPONSE</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l76"> -<td class="vc_file_line_number">76</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l77"> -<td class="vc_file_line_number">77</td> - -<td class="vc_file_line_text"> <span class="pygments-n">bytesRead</span> <span class="pygments-o">=</span> <span class="pygments-n">read</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-n">buf</span> <span class="pygments-o">+</span> <span class="pygments-n">bufLength</span><span class="pygments-p">,</span> <span class="pygments-k">sizeof</span><span class="pygments-p">(</span><span class="pygments-n">buf</span><span class="pygments-p">)</span> <span class="pygments-o">-</span> <span class="pygments-n">bufLength</span> <span class="pygments-o">-</span> <span class="pygments-mi">1</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l78"> -<td class="vc_file_line_number">78</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l79"> -<td class="vc_file_line_number">79</td> - -<td class="vc_file_line_text"> <span class="pygments-n">bufLength</span> <span class="pygments-o">+=</span> <span class="pygments-n">bytesRead</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l80"> -<td class="vc_file_line_number">80</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l81"> -<td class="vc_file_line_number">81</td> - -<td class="vc_file_line_text"> <span class="pygments-n">buf</span><span class="pygments-p">[</span><span class="pygments-n">bufLength</span><span class="pygments-p">]</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l82"> -<td class="vc_file_line_number">82</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l83"> -<td class="vc_file_line_number">83</td> - -<td class="vc_file_line_text"> <span class="pygments-cm">/* divide the response into lines, checking each one to see if </span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l84"> -<td class="vc_file_line_number">84</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> we are finished or need to continue */</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l85"> -<td class="vc_file_line_number">85</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l86"> -<td class="vc_file_line_number">86</td> - -<td class="vc_file_line_text"> <span class="pygments-n">start</span> <span class="pygments-o">=</span> <span class="pygments-n">chptr</span> <span class="pygments-o">=</span> <span class="pygments-n">buf</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l87"> -<td class="vc_file_line_number">87</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l88"> -<td class="vc_file_line_number">88</td> - -<td class="vc_file_line_text"> <span class="pygments-k">do</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l89"> -<td class="vc_file_line_number">89</td> - -<td class="vc_file_line_text"> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">!=</span> <span class="pygments-sc">'\n'</span> <span class="pygments-o">&&</span> <span class="pygments-o">*</span><span class="pygments-n">chptr</span><span class="pygments-p">)</span> <span class="pygments-n">chptr</span><span class="pygments-o">++</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l90"> -<td class="vc_file_line_number">90</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l91"> -<td class="vc_file_line_number">91</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">==</span> <span class="pygments-sc">'\n'</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l92"> -<td class="vc_file_line_number">92</td> - -<td class="vc_file_line_text"> <span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l93"> -<td class="vc_file_line_number">93</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-p">(</span><span class="pygments-n">chptr</span> <span class="pygments-o">-</span> <span class="pygments-mi">1</span><span class="pygments-p">)</span> <span class="pygments-o">==</span> <span class="pygments-sc">'\r'</span><span class="pygments-p">)</span> <span class="pygments-o">*</span><span class="pygments-p">(</span><span class="pygments-n">chptr</span> <span class="pygments-o">-</span> <span class="pygments-mi">1</span><span class="pygments-p">)</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l94"> -<td class="vc_file_line_number">94</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">str</span><span class="pygments-p">)</span> <span class="pygments-o">*</span><span class="pygments-n">str</span> <span class="pygments-o">=</span> <span class="pygments-n">start</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l95"> -<td class="vc_file_line_number">95</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l96"> -<td class="vc_file_line_number">96</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">errorCode</span><span class="pygments-p">[</span><span class="pygments-mi">0</span><span class="pygments-p">])</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l97"> -<td class="vc_file_line_number">97</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">!</span><span class="pygments-n">strncmp</span><span class="pygments-p">(</span><span class="pygments-n">start</span><span class="pygments-p">,</span> <span class="pygments-n">errorCode</span><span class="pygments-p">,</span> <span class="pygments-mi">3</span><span class="pygments-p">)</span> <span class="pygments-o">&&</span> <span class="pygments-n">start</span><span class="pygments-p">[</span><span class="pygments-mi">3</span><span class="pygments-p">]</span> <span class="pygments-o">==</span> <span class="pygments-sc">' '</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l98"> -<td class="vc_file_line_number">98</td> - -<td class="vc_file_line_text"> <span class="pygments-n">doesContinue</span> <span class="pygments-o">=</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l99"> -<td class="vc_file_line_number">99</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> <span class="pygments-k">else</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l100"> -<td class="vc_file_line_number">100</td> - -<td class="vc_file_line_text"> <span class="pygments-n">strncpy</span><span class="pygments-p">(</span><span class="pygments-n">errorCode</span><span class="pygments-p">,</span> <span class="pygments-n">start</span><span class="pygments-p">,</span> <span class="pygments-mi">3</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l101"> -<td class="vc_file_line_number">101</td> - -<td class="vc_file_line_text"> <span class="pygments-n">errorCode</span><span class="pygments-p">[</span><span class="pygments-mi">3</span><span class="pygments-p">]</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l102"> -<td class="vc_file_line_number">102</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">start</span><span class="pygments-p">[</span><span class="pygments-mi">3</span><span class="pygments-p">]</span> <span class="pygments-o">!=</span> <span class="pygments-sc">'-'</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l103"> -<td class="vc_file_line_number">103</td> - -<td class="vc_file_line_text"> <span class="pygments-n">doesContinue</span> <span class="pygments-o">=</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l104"> -<td class="vc_file_line_number">104</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l105"> -<td class="vc_file_line_number">105</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l106"> -<td class="vc_file_line_number">106</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l107"> -<td class="vc_file_line_number">107</td> - -<td class="vc_file_line_text"> <span class="pygments-n">start</span> <span class="pygments-o">=</span> <span class="pygments-n">chptr</span> <span class="pygments-o">+</span> <span class="pygments-mi">1</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l108"> -<td class="vc_file_line_number">108</td> - -<td class="vc_file_line_text"> <span class="pygments-n">chptr</span><span class="pygments-o">++</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l109"> -<td class="vc_file_line_number">109</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> <span class="pygments-k">else</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l110"> -<td class="vc_file_line_number">110</td> - -<td class="vc_file_line_text"> <span class="pygments-n">chptr</span><span class="pygments-o">++</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l111"> -<td class="vc_file_line_number">111</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l112"> -<td class="vc_file_line_number">112</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">chptr</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l113"> -<td class="vc_file_line_number">113</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l114"> -<td class="vc_file_line_number">114</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">doesContinue</span> <span class="pygments-o">&&</span> <span class="pygments-n">chptr</span> <span class="pygments-o">></span> <span class="pygments-n">start</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l115"> -<td class="vc_file_line_number">115</td> - -<td class="vc_file_line_text"> <span class="pygments-n">memcpy</span><span class="pygments-p">(</span><span class="pygments-n">buf</span><span class="pygments-p">,</span> <span class="pygments-n">start</span><span class="pygments-p">,</span> <span class="pygments-n">chptr</span> <span class="pygments-o">-</span> <span class="pygments-n">start</span> <span class="pygments-o">-</span> <span class="pygments-mi">1</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l116"> -<td class="vc_file_line_number">116</td> - -<td class="vc_file_line_text"> <span class="pygments-n">bufLength</span> <span class="pygments-o">=</span> <span class="pygments-n">chptr</span> <span class="pygments-o">-</span> <span class="pygments-n">start</span> <span class="pygments-o">-</span> <span class="pygments-mi">1</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l117"> -<td class="vc_file_line_number">117</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> <span class="pygments-k">else</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l118"> -<td class="vc_file_line_number">118</td> - -<td class="vc_file_line_text"> <span class="pygments-n">bufLength</span> <span class="pygments-o">=</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l119"> -<td class="vc_file_line_number">119</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l120"> -<td class="vc_file_line_number">120</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-n">doesContinue</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l121"> -<td class="vc_file_line_number">121</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l122"> -<td class="vc_file_line_number">122</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">errorCode</span> <span class="pygments-o">==</span> <span class="pygments-sc">'4'</span> <span class="pygments-o">||</span> <span class="pygments-o">*</span><span class="pygments-n">errorCode</span> <span class="pygments-o">==</span> <span class="pygments-sc">'5'</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l123"> -<td class="vc_file_line_number">123</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">!</span><span class="pygments-n">strncmp</span><span class="pygments-p">(</span><span class="pygments-n">errorCode</span><span class="pygments-p">,</span> <span class="pygments-s">"550"</span><span class="pygments-p">,</span> <span class="pygments-mi">3</span><span class="pygments-p">))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l124"> -<td class="vc_file_line_number">124</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_FILE_NOT_FOUND</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l125"> -<td class="vc_file_line_number">125</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l126"> -<td class="vc_file_line_number">126</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l127"> -<td class="vc_file_line_number">127</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_BAD_SERVER_RESPONSE</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l128"> -<td class="vc_file_line_number">128</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l129"> -<td class="vc_file_line_number">129</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l130"> -<td class="vc_file_line_number">130</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">rc</span><span class="pygments-p">)</span> <span class="pygments-k">return</span> <span class="pygments-n">rc</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l131"> -<td class="vc_file_line_number">131</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l132"> -<td class="vc_file_line_number">132</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l133"> -<td class="vc_file_line_number">133</td> - -<td class="vc_file_line_text"><span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l134"> -<td class="vc_file_line_number">134</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l135"> -<td class="vc_file_line_number">135</td> - -<td class="vc_file_line_text"><span class="pygments-k">static</span> <span class="pygments-kt">int</span> <span class="pygments-nf">ftp_command</span><span class="pygments-p">(</span><span class="pygments-kt">int</span> <span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">command</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">param</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l136"> -<td class="vc_file_line_number">136</td> - -<td class="vc_file_line_text"><span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l137"> -<td class="vc_file_line_number">137</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-n">buf</span><span class="pygments-p">[</span><span class="pygments-mi">500</span><span class="pygments-p">];</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l138"> -<td class="vc_file_line_number">138</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">rc</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l139"> -<td class="vc_file_line_number">139</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l140"> -<td class="vc_file_line_number">140</td> - -<td class="vc_file_line_text"> <span class="pygments-n">snprintf</span><span class="pygments-p">(</span><span class="pygments-n">buf</span><span class="pygments-p">,</span> <span class="pygments-k">sizeof</span><span class="pygments-p">(</span><span class="pygments-n">buf</span><span class="pygments-p">),</span> <span class="pygments-s">"%s%s%s</span><span class="pygments-se">\r\n</span><span class="pygments-s">"</span><span class="pygments-p">,</span> <span class="pygments-n">command</span><span class="pygments-p">,</span> <span class="pygments-n">param</span> <span class="pygments-o">?</span> <span class="pygments-s">" "</span> <span class="pygments-o">:</span> <span class="pygments-s">""</span><span class="pygments-p">,</span> <span class="pygments-n">param</span> <span class="pygments-o">?</span> <span class="pygments-n">param</span> <span class="pygments-o">:</span> <span class="pygments-s">""</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l141"> -<td class="vc_file_line_number">141</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l142"> -<td class="vc_file_line_number">142</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">write</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-n">buf</span><span class="pygments-p">,</span> <span class="pygments-n">strlen</span><span class="pygments-p">(</span><span class="pygments-n">buf</span><span class="pygments-p">))</span> <span class="pygments-o">!=</span> <span class="pygments-p">(</span><span class="pygments-kt">ssize_t</span><span class="pygments-p">)</span><span class="pygments-n">strlen</span><span class="pygments-p">(</span><span class="pygments-n">buf</span><span class="pygments-p">))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l143"> -<td class="vc_file_line_number">143</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_SERVER_IO_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l144"> -<td class="vc_file_line_number">144</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l145"> -<td class="vc_file_line_number">145</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l146"> -<td class="vc_file_line_number">146</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">rc</span> <span class="pygments-o">=</span> <span class="pygments-n">ftp_check_response</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-nb">NULL</span><span class="pygments-p">)))</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l147"> -<td class="vc_file_line_number">147</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">rc</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l148"> -<td class="vc_file_line_number">148</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l149"> -<td class="vc_file_line_number">149</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l150"> -<td class="vc_file_line_number">150</td> - -<td class="vc_file_line_text"><span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l151"> -<td class="vc_file_line_number">151</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l152"> -<td class="vc_file_line_number">152</td> - -<td class="vc_file_line_text"><span class="pygments-k">static</span> <span class="pygments-kt">int</span> <span class="pygments-nf">get_host_address</span><span class="pygments-p">(</span><span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">host</span><span class="pygments-p">,</span> <span class="pygments-k">struct</span> <span class="pygments-n">in_addr</span> <span class="pygments-o">*</span> <span class="pygments-n">address</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l153"> -<td class="vc_file_line_number">153</td> - -<td class="vc_file_line_text"><span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l154"> -<td class="vc_file_line_number">154</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">isdigit</span><span class="pygments-p">(</span><span class="pygments-n">host</span><span class="pygments-p">[</span><span class="pygments-mi">0</span><span class="pygments-p">]))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l155"> -<td class="vc_file_line_number">155</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">!</span><span class="pygments-n">inet_aton</span><span class="pygments-p">(</span><span class="pygments-n">host</span><span class="pygments-p">,</span> <span class="pygments-n">address</span><span class="pygments-p">))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l156"> -<td class="vc_file_line_number">156</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_BAD_HOST_ADDR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l157"> -<td class="vc_file_line_number">157</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l158"> -<td class="vc_file_line_number">158</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> <span class="pygments-k">else</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l159"> -<td class="vc_file_line_number">159</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">mygethostbyname</span><span class="pygments-p">(</span><span class="pygments-n">host</span><span class="pygments-p">,</span> <span class="pygments-n">address</span><span class="pygments-p">))</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l160"> -<td class="vc_file_line_number">160</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_BAD_HOSTNAME</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l161"> -<td class="vc_file_line_number">161</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l162"> -<td class="vc_file_line_number">162</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l163"> -<td class="vc_file_line_number">163</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l164"> -<td class="vc_file_line_number">164</td> - -<td class="vc_file_line_text"><span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l165"> -<td class="vc_file_line_number">165</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l166"> -<td class="vc_file_line_number">166</td> - -<td class="vc_file_line_text"><span class="pygments-kt">int</span> <span class="pygments-nf">ftp_open_connection</span><span class="pygments-p">(</span><span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">host</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">name</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">password</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">proxy</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l167"> -<td class="vc_file_line_number">167</td> - -<td class="vc_file_line_text"><span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l168"> -<td class="vc_file_line_number">168</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">sock</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l169"> -<td class="vc_file_line_number">169</td> - -<td class="vc_file_line_text"> <span class="pygments-k">struct</span> <span class="pygments-n">in_addr</span> <span class="pygments-n">serverAddress</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l170"> -<td class="vc_file_line_number">170</td> - -<td class="vc_file_line_text"> <span class="pygments-k">struct</span> <span class="pygments-n">sockaddr_in</span> <span class="pygments-n">destPort</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l171"> -<td class="vc_file_line_number">171</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">rc</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l172"> -<td class="vc_file_line_number">172</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">port</span> <span class="pygments-o">=</span> <span class="pygments-mi">21</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l173"> -<td class="vc_file_line_number">173</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l174"> -<td class="vc_file_line_number">174</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">!</span><span class="pygments-n">strcmp</span><span class="pygments-p">(</span><span class="pygments-n">name</span><span class="pygments-p">,</span> <span class="pygments-s">""</span><span class="pygments-p">))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l175"> -<td class="vc_file_line_number">175</td> - -<td class="vc_file_line_text"> <span class="pygments-n">name</span> <span class="pygments-o">=</span> <span class="pygments-s">"anonymous"</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l176"> -<td class="vc_file_line_number">176</td> - -<td class="vc_file_line_text"> <span class="pygments-n">password</span> <span class="pygments-o">=</span> <span class="pygments-s">"-drakx@"</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l177"> -<td class="vc_file_line_number">177</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l178"> -<td class="vc_file_line_number">178</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l179"> -<td class="vc_file_line_number">179</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">strcmp</span><span class="pygments-p">(</span><span class="pygments-n">proxy</span><span class="pygments-p">,</span> <span class="pygments-s">""</span><span class="pygments-p">))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l180"> -<td class="vc_file_line_number">180</td> - -<td class="vc_file_line_text"> <span class="pygments-n">name</span> <span class="pygments-o">=</span> <span class="pygments-n">asprintf_</span><span class="pygments-p">(</span><span class="pygments-s">"%s@%s"</span><span class="pygments-p">,</span> <span class="pygments-n">name</span><span class="pygments-p">,</span> <span class="pygments-n">host</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l181"> -<td class="vc_file_line_number">181</td> - -<td class="vc_file_line_text"> <span class="pygments-n">host</span> <span class="pygments-o">=</span> <span class="pygments-n">proxy</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l182"> -<td class="vc_file_line_number">182</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l183"> -<td class="vc_file_line_number">183</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l184"> -<td class="vc_file_line_number">184</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">rc</span> <span class="pygments-o">=</span> <span class="pygments-n">get_host_address</span><span class="pygments-p">(</span><span class="pygments-n">host</span><span class="pygments-p">,</span> <span class="pygments-o">&</span><span class="pygments-n">serverAddress</span><span class="pygments-p">)))</span> <span class="pygments-k">return</span> <span class="pygments-n">rc</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l185"> -<td class="vc_file_line_number">185</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l186"> -<td class="vc_file_line_number">186</td> - -<td class="vc_file_line_text"> <span class="pygments-n">sock</span> <span class="pygments-o">=</span> <span class="pygments-n">socket</span><span class="pygments-p">(</span><span class="pygments-n">AF_INET</span><span class="pygments-p">,</span> <span class="pygments-n">SOCK_STREAM</span><span class="pygments-p">,</span> <span class="pygments-n">IPPROTO_IP</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l187"> -<td class="vc_file_line_number">187</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">sock</span> <span class="pygments-o"><</span> <span class="pygments-mi">0</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l188"> -<td class="vc_file_line_number">188</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_FAILED_CONNECT</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l189"> -<td class="vc_file_line_number">189</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l190"> -<td class="vc_file_line_number">190</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l191"> -<td class="vc_file_line_number">191</td> - -<td class="vc_file_line_text"> <span class="pygments-n">destPort</span><span class="pygments-p">.</span><span class="pygments-n">sin_family</span> <span class="pygments-o">=</span> <span class="pygments-n">AF_INET</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l192"> -<td class="vc_file_line_number">192</td> - -<td class="vc_file_line_text"> <span class="pygments-n">destPort</span><span class="pygments-p">.</span><span class="pygments-n">sin_port</span> <span class="pygments-o">=</span> <span class="pygments-n">htons</span><span class="pygments-p">(</span><span class="pygments-n">port</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l193"> -<td class="vc_file_line_number">193</td> - -<td class="vc_file_line_text"> <span class="pygments-n">destPort</span><span class="pygments-p">.</span><span class="pygments-n">sin_addr</span> <span class="pygments-o">=</span> <span class="pygments-n">serverAddress</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l194"> -<td class="vc_file_line_number">194</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l195"> -<td class="vc_file_line_number">195</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">connect</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-p">(</span><span class="pygments-k">struct</span> <span class="pygments-n">sockaddr</span> <span class="pygments-o">*</span><span class="pygments-p">)</span> <span class="pygments-o">&</span><span class="pygments-n">destPort</span><span class="pygments-p">,</span> <span class="pygments-k">sizeof</span><span class="pygments-p">(</span><span class="pygments-n">destPort</span><span class="pygments-p">)))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l196"> -<td class="vc_file_line_number">196</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l197"> -<td class="vc_file_line_number">197</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_FAILED_CONNECT</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l198"> -<td class="vc_file_line_number">198</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l199"> -<td class="vc_file_line_number">199</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l200"> -<td class="vc_file_line_number">200</td> - -<td class="vc_file_line_text"> <span class="pygments-cm">/* ftpCheckResponse() assumes the socket is nonblocking */</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l201"> -<td class="vc_file_line_number">201</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">fcntl</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-n">F_SETFL</span><span class="pygments-p">,</span> <span class="pygments-n">O_NONBLOCK</span><span class="pygments-p">))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l202"> -<td class="vc_file_line_number">202</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l203"> -<td class="vc_file_line_number">203</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_FAILED_CONNECT</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l204"> -<td class="vc_file_line_number">204</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l205"> -<td class="vc_file_line_number">205</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l206"> -<td class="vc_file_line_number">206</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">rc</span> <span class="pygments-o">=</span> <span class="pygments-n">ftp_check_response</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-nb">NULL</span><span class="pygments-p">)))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l207"> -<td class="vc_file_line_number">207</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">rc</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l208"> -<td class="vc_file_line_number">208</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l209"> -<td class="vc_file_line_number">209</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l210"> -<td class="vc_file_line_number">210</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">rc</span> <span class="pygments-o">=</span> <span class="pygments-n">ftp_command</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-s">"USER"</span><span class="pygments-p">,</span> <span class="pygments-n">name</span><span class="pygments-p">)))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l211"> -<td class="vc_file_line_number">211</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l212"> -<td class="vc_file_line_number">212</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">rc</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l213"> -<td class="vc_file_line_number">213</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l214"> -<td class="vc_file_line_number">214</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l215"> -<td class="vc_file_line_number">215</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">rc</span> <span class="pygments-o">=</span> <span class="pygments-n">ftp_command</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-s">"PASS"</span><span class="pygments-p">,</span> <span class="pygments-n">password</span><span class="pygments-p">)))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l216"> -<td class="vc_file_line_number">216</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l217"> -<td class="vc_file_line_number">217</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">rc</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l218"> -<td class="vc_file_line_number">218</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l219"> -<td class="vc_file_line_number">219</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l220"> -<td class="vc_file_line_number">220</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">rc</span> <span class="pygments-o">=</span> <span class="pygments-n">ftp_command</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-s">"TYPE"</span><span class="pygments-p">,</span> <span class="pygments-s">"I"</span><span class="pygments-p">)))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l221"> -<td class="vc_file_line_number">221</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l222"> -<td class="vc_file_line_number">222</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">rc</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l223"> -<td class="vc_file_line_number">223</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l224"> -<td class="vc_file_line_number">224</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l225"> -<td class="vc_file_line_number">225</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">sock</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l226"> -<td class="vc_file_line_number">226</td> - -<td class="vc_file_line_text"><span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l227"> -<td class="vc_file_line_number">227</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l228"> -<td class="vc_file_line_number">228</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l229"> -<td class="vc_file_line_number">229</td> - -<td class="vc_file_line_text"><span class="pygments-kt">int</span> <span class="pygments-nf">ftp_data_command</span><span class="pygments-p">(</span><span class="pygments-kt">int</span> <span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">command</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">param</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l230"> -<td class="vc_file_line_number">230</td> - -<td class="vc_file_line_text"><span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l231"> -<td class="vc_file_line_number">231</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">dataSocket</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l232"> -<td class="vc_file_line_number">232</td> - -<td class="vc_file_line_text"> <span class="pygments-k">struct</span> <span class="pygments-n">sockaddr_in</span> <span class="pygments-n">dataAddress</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l233"> -<td class="vc_file_line_number">233</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">i</span><span class="pygments-p">,</span> <span class="pygments-n">j</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l234"> -<td class="vc_file_line_number">234</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">passReply</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l235"> -<td class="vc_file_line_number">235</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">chptr</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l236"> -<td class="vc_file_line_number">236</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-n">retrCommand</span><span class="pygments-p">[</span><span class="pygments-mi">500</span><span class="pygments-p">];</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l237"> -<td class="vc_file_line_number">237</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">rc</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l238"> -<td class="vc_file_line_number">238</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l239"> -<td class="vc_file_line_number">239</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">write</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-s">"PASV</span><span class="pygments-se">\r\n</span><span class="pygments-s">"</span><span class="pygments-p">,</span> <span class="pygments-mi">6</span><span class="pygments-p">)</span> <span class="pygments-o">!=</span> <span class="pygments-mi">6</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l240"> -<td class="vc_file_line_number">240</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_SERVER_IO_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l241"> -<td class="vc_file_line_number">241</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l242"> -<td class="vc_file_line_number">242</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">rc</span> <span class="pygments-o">=</span> <span class="pygments-n">ftp_check_response</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-o">&</span><span class="pygments-n">passReply</span><span class="pygments-p">)))</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l243"> -<td class="vc_file_line_number">243</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_PASSIVE_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l244"> -<td class="vc_file_line_number">244</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l245"> -<td class="vc_file_line_number">245</td> - -<td class="vc_file_line_text"> <span class="pygments-n">chptr</span> <span class="pygments-o">=</span> <span class="pygments-n">passReply</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l246"> -<td class="vc_file_line_number">246</td> - -<td class="vc_file_line_text"> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">&&</span> <span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">!=</span> <span class="pygments-sc">'('</span><span class="pygments-p">)</span> <span class="pygments-n">chptr</span><span class="pygments-o">++</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l247"> -<td class="vc_file_line_number">247</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">!=</span> <span class="pygments-sc">'('</span><span class="pygments-p">)</span> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_PASSIVE_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l248"> -<td class="vc_file_line_number">248</td> - -<td class="vc_file_line_text"> <span class="pygments-n">chptr</span><span class="pygments-o">++</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l249"> -<td class="vc_file_line_number">249</td> - -<td class="vc_file_line_text"> <span class="pygments-n">passReply</span> <span class="pygments-o">=</span> <span class="pygments-n">chptr</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l250"> -<td class="vc_file_line_number">250</td> - -<td class="vc_file_line_text"> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">&&</span> <span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">!=</span> <span class="pygments-sc">')'</span><span class="pygments-p">)</span> <span class="pygments-n">chptr</span><span class="pygments-o">++</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l251"> -<td class="vc_file_line_number">251</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">!=</span> <span class="pygments-sc">')'</span><span class="pygments-p">)</span> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_PASSIVE_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l252"> -<td class="vc_file_line_number">252</td> - -<td class="vc_file_line_text"> <span class="pygments-o">*</span><span class="pygments-n">chptr</span><span class="pygments-o">--</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l253"> -<td class="vc_file_line_number">253</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l254"> -<td class="vc_file_line_number">254</td> - -<td class="vc_file_line_text"> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">&&</span> <span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">!=</span> <span class="pygments-sc">','</span><span class="pygments-p">)</span> <span class="pygments-n">chptr</span><span class="pygments-o">--</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l255"> -<td class="vc_file_line_number">255</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">!=</span> <span class="pygments-sc">','</span><span class="pygments-p">)</span> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_PASSIVE_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l256"> -<td class="vc_file_line_number">256</td> - -<td class="vc_file_line_text"> <span class="pygments-n">chptr</span><span class="pygments-o">--</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l257"> -<td class="vc_file_line_number">257</td> - -<td class="vc_file_line_text"> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">&&</span> <span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">!=</span> <span class="pygments-sc">','</span><span class="pygments-p">)</span> <span class="pygments-n">chptr</span><span class="pygments-o">--</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l258"> -<td class="vc_file_line_number">258</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">!=</span> <span class="pygments-sc">','</span><span class="pygments-p">)</span> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_PASSIVE_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l259"> -<td class="vc_file_line_number">259</td> - -<td class="vc_file_line_text"> <span class="pygments-o">*</span><span class="pygments-n">chptr</span><span class="pygments-o">++</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l260"> -<td class="vc_file_line_number">260</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l261"> -<td class="vc_file_line_number">261</td> - -<td class="vc_file_line_text"> <span class="pygments-cm">/* now passReply points to the IP portion, and chptr points to the</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l262"> -<td class="vc_file_line_number">262</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> port number portion */</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l263"> -<td class="vc_file_line_number">263</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l264"> -<td class="vc_file_line_number">264</td> - -<td class="vc_file_line_text"> <span class="pygments-n">dataAddress</span><span class="pygments-p">.</span><span class="pygments-n">sin_family</span> <span class="pygments-o">=</span> <span class="pygments-n">AF_INET</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l265"> -<td class="vc_file_line_number">265</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">sscanf</span><span class="pygments-p">(</span><span class="pygments-n">chptr</span><span class="pygments-p">,</span> <span class="pygments-s">"%d,%d"</span><span class="pygments-p">,</span> <span class="pygments-o">&</span><span class="pygments-n">i</span><span class="pygments-p">,</span> <span class="pygments-o">&</span><span class="pygments-n">j</span><span class="pygments-p">)</span> <span class="pygments-o">!=</span> <span class="pygments-mi">2</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l266"> -<td class="vc_file_line_number">266</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_PASSIVE_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l267"> -<td class="vc_file_line_number">267</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l268"> -<td class="vc_file_line_number">268</td> - -<td class="vc_file_line_text"> <span class="pygments-n">dataAddress</span><span class="pygments-p">.</span><span class="pygments-n">sin_port</span> <span class="pygments-o">=</span> <span class="pygments-n">htons</span><span class="pygments-p">((</span><span class="pygments-n">i</span> <span class="pygments-o"><<</span> <span class="pygments-mi">8</span><span class="pygments-p">)</span> <span class="pygments-o">+</span> <span class="pygments-n">j</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l269"> -<td class="vc_file_line_number">269</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l270"> -<td class="vc_file_line_number">270</td> - -<td class="vc_file_line_text"> <span class="pygments-n">chptr</span> <span class="pygments-o">=</span> <span class="pygments-n">passReply</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l271"> -<td class="vc_file_line_number">271</td> - -<td class="vc_file_line_text"> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">chptr</span><span class="pygments-o">++</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l272"> -<td class="vc_file_line_number">272</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">==</span> <span class="pygments-sc">','</span><span class="pygments-p">)</span> <span class="pygments-o">*</span><span class="pygments-n">chptr</span> <span class="pygments-o">=</span> <span class="pygments-sc">'.'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l273"> -<td class="vc_file_line_number">273</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l274"> -<td class="vc_file_line_number">274</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l275"> -<td class="vc_file_line_number">275</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">!</span><span class="pygments-n">inet_aton</span><span class="pygments-p">(</span><span class="pygments-n">passReply</span><span class="pygments-p">,</span> <span class="pygments-o">&</span><span class="pygments-n">dataAddress</span><span class="pygments-p">.</span><span class="pygments-n">sin_addr</span><span class="pygments-p">))</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l276"> -<td class="vc_file_line_number">276</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_PASSIVE_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l277"> -<td class="vc_file_line_number">277</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l278"> -<td class="vc_file_line_number">278</td> - -<td class="vc_file_line_text"> <span class="pygments-n">dataSocket</span> <span class="pygments-o">=</span> <span class="pygments-n">socket</span><span class="pygments-p">(</span><span class="pygments-n">AF_INET</span><span class="pygments-p">,</span> <span class="pygments-n">SOCK_STREAM</span><span class="pygments-p">,</span> <span class="pygments-n">IPPROTO_IP</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l279"> -<td class="vc_file_line_number">279</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">dataSocket</span> <span class="pygments-o"><</span> <span class="pygments-mi">0</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l280"> -<td class="vc_file_line_number">280</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_FAILED_CONNECT</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l281"> -<td class="vc_file_line_number">281</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l282"> -<td class="vc_file_line_number">282</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l283"> -<td class="vc_file_line_number">283</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">!</span><span class="pygments-n">param</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l284"> -<td class="vc_file_line_number">284</td> - -<td class="vc_file_line_text"> <span class="pygments-n">sprintf</span><span class="pygments-p">(</span><span class="pygments-n">retrCommand</span><span class="pygments-p">,</span> <span class="pygments-s">"%s</span><span class="pygments-se">\r\n</span><span class="pygments-s">"</span><span class="pygments-p">,</span> <span class="pygments-n">command</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l285"> -<td class="vc_file_line_number">285</td> - -<td class="vc_file_line_text"> <span class="pygments-k">else</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l286"> -<td class="vc_file_line_number">286</td> - -<td class="vc_file_line_text"> <span class="pygments-n">sprintf</span><span class="pygments-p">(</span><span class="pygments-n">retrCommand</span><span class="pygments-p">,</span> <span class="pygments-s">"%s %s</span><span class="pygments-se">\r\n</span><span class="pygments-s">"</span><span class="pygments-p">,</span> <span class="pygments-n">command</span><span class="pygments-p">,</span> <span class="pygments-n">param</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l287"> -<td class="vc_file_line_number">287</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l288"> -<td class="vc_file_line_number">288</td> - -<td class="vc_file_line_text"> <span class="pygments-n">i</span> <span class="pygments-o">=</span> <span class="pygments-n">strlen</span><span class="pygments-p">(</span><span class="pygments-n">retrCommand</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l289"> -<td class="vc_file_line_number">289</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l290"> -<td class="vc_file_line_number">290</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">write</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-n">retrCommand</span><span class="pygments-p">,</span> <span class="pygments-n">i</span><span class="pygments-p">)</span> <span class="pygments-o">!=</span> <span class="pygments-n">i</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l291"> -<td class="vc_file_line_number">291</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_SERVER_IO_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l292"> -<td class="vc_file_line_number">292</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l293"> -<td class="vc_file_line_number">293</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l294"> -<td class="vc_file_line_number">294</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">connect</span><span class="pygments-p">(</span><span class="pygments-n">dataSocket</span><span class="pygments-p">,</span> <span class="pygments-p">(</span><span class="pygments-k">struct</span> <span class="pygments-n">sockaddr</span> <span class="pygments-o">*</span><span class="pygments-p">)</span> <span class="pygments-o">&</span><span class="pygments-n">dataAddress</span><span class="pygments-p">,</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l295"> -<td class="vc_file_line_number">295</td> - -<td class="vc_file_line_text"> <span class="pygments-k">sizeof</span><span class="pygments-p">(</span><span class="pygments-n">dataAddress</span><span class="pygments-p">)))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l296"> -<td class="vc_file_line_number">296</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">dataSocket</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l297"> -<td class="vc_file_line_number">297</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_FAILED_DATA_CONNECT</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l298"> -<td class="vc_file_line_number">298</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l299"> -<td class="vc_file_line_number">299</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l300"> -<td class="vc_file_line_number">300</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">rc</span> <span class="pygments-o">=</span> <span class="pygments-n">ftp_check_response</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-nb">NULL</span><span class="pygments-p">)))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l301"> -<td class="vc_file_line_number">301</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">dataSocket</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l302"> -<td class="vc_file_line_number">302</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">rc</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l303"> -<td class="vc_file_line_number">303</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l304"> -<td class="vc_file_line_number">304</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l305"> -<td class="vc_file_line_number">305</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">dataSocket</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l306"> -<td class="vc_file_line_number">306</td> - -<td class="vc_file_line_text"><span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l307"> -<td class="vc_file_line_number">307</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l308"> -<td class="vc_file_line_number">308</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l309"> -<td class="vc_file_line_number">309</td> - -<td class="vc_file_line_text"><span class="pygments-kt">int</span> <span class="pygments-nf">ftp_get_filesize</span><span class="pygments-p">(</span><span class="pygments-kt">int</span> <span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">remotename</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l310"> -<td class="vc_file_line_number">310</td> - -<td class="vc_file_line_text"><span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l311"> -<td class="vc_file_line_number">311</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">size</span> <span class="pygments-o">=</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l312"> -<td class="vc_file_line_number">312</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-n">buf</span><span class="pygments-p">[</span><span class="pygments-mi">2000</span><span class="pygments-p">];</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l313"> -<td class="vc_file_line_number">313</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-n">file</span><span class="pygments-p">[</span><span class="pygments-mi">500</span><span class="pygments-p">];</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l314"> -<td class="vc_file_line_number">314</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">ptr</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l315"> -<td class="vc_file_line_number">315</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">fd</span><span class="pygments-p">,</span> <span class="pygments-n">rc</span><span class="pygments-p">,</span> <span class="pygments-n">tot</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l316"> -<td class="vc_file_line_number">316</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">i</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l317"> -<td class="vc_file_line_number">317</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l318"> -<td class="vc_file_line_number">318</td> - -<td class="vc_file_line_text"> <span class="pygments-n">strcpy</span><span class="pygments-p">(</span><span class="pygments-n">buf</span><span class="pygments-p">,</span> <span class="pygments-n">remotename</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l319"> -<td class="vc_file_line_number">319</td> - -<td class="vc_file_line_text"> <span class="pygments-n">ptr</span> <span class="pygments-o">=</span> <span class="pygments-n">strrchr</span><span class="pygments-p">(</span><span class="pygments-n">buf</span><span class="pygments-p">,</span> <span class="pygments-sc">'/'</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l320"> -<td class="vc_file_line_number">320</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">!*</span><span class="pygments-n">ptr</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l321"> -<td class="vc_file_line_number">321</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-o">-</span><span class="pygments-mi">1</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l322"> -<td class="vc_file_line_number">322</td> - -<td class="vc_file_line_text"> <span class="pygments-o">*</span><span class="pygments-n">ptr</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l323"> -<td class="vc_file_line_number">323</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l324"> -<td class="vc_file_line_number">324</td> - -<td class="vc_file_line_text"> <span class="pygments-n">strcpy</span><span class="pygments-p">(</span><span class="pygments-n">file</span><span class="pygments-p">,</span> <span class="pygments-n">ptr</span><span class="pygments-o">+</span><span class="pygments-mi">1</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l325"> -<td class="vc_file_line_number">325</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l326"> -<td class="vc_file_line_number">326</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">rc</span> <span class="pygments-o">=</span> <span class="pygments-n">ftp_command</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-s">"CWD"</span><span class="pygments-p">,</span> <span class="pygments-n">buf</span><span class="pygments-p">)))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l327"> -<td class="vc_file_line_number">327</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-o">-</span><span class="pygments-mi">1</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l328"> -<td class="vc_file_line_number">328</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l329"> -<td class="vc_file_line_number">329</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l330"> -<td class="vc_file_line_number">330</td> - -<td class="vc_file_line_text"> <span class="pygments-n">fd</span> <span class="pygments-o">=</span> <span class="pygments-n">ftp_data_command</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-s">"LIST"</span><span class="pygments-p">,</span> <span class="pygments-n">file</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l331"> -<td class="vc_file_line_number">331</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">fd</span> <span class="pygments-o"><=</span> <span class="pygments-mi">0</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l332"> -<td class="vc_file_line_number">332</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l333"> -<td class="vc_file_line_number">333</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-o">-</span><span class="pygments-mi">1</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l334"> -<td class="vc_file_line_number">334</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l335"> -<td class="vc_file_line_number">335</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l336"> -<td class="vc_file_line_number">336</td> - -<td class="vc_file_line_text"> <span class="pygments-n">ptr</span> <span class="pygments-o">=</span> <span class="pygments-n">buf</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l337"> -<td class="vc_file_line_number">337</td> - -<td class="vc_file_line_text"> <span class="pygments-k">while</span> <span class="pygments-p">((</span><span class="pygments-n">tot</span> <span class="pygments-o">=</span> <span class="pygments-n">read</span><span class="pygments-p">(</span><span class="pygments-n">fd</span><span class="pygments-p">,</span> <span class="pygments-n">ptr</span><span class="pygments-p">,</span> <span class="pygments-k">sizeof</span><span class="pygments-p">(</span><span class="pygments-n">buf</span><span class="pygments-p">)</span> <span class="pygments-o">-</span> <span class="pygments-p">(</span><span class="pygments-n">ptr</span> <span class="pygments-o">-</span> <span class="pygments-n">buf</span><span class="pygments-p">)</span> <span class="pygments-o">-</span> <span class="pygments-mi">1</span><span class="pygments-p">))</span> <span class="pygments-o">!=</span> <span class="pygments-mi">0</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l338"> -<td class="vc_file_line_number">338</td> - -<td class="vc_file_line_text"> <span class="pygments-n">ptr</span> <span class="pygments-o">+=</span> <span class="pygments-n">tot</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l339"> -<td class="vc_file_line_number">339</td> - -<td class="vc_file_line_text"> <span class="pygments-o">*</span><span class="pygments-n">ptr</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l340"> -<td class="vc_file_line_number">340</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">fd</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l341"> -<td class="vc_file_line_number">341</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l342"> -<td class="vc_file_line_number">342</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">!</span><span class="pygments-p">(</span><span class="pygments-n">ptr</span> <span class="pygments-o">=</span> <span class="pygments-n">strstr</span><span class="pygments-p">(</span><span class="pygments-n">buf</span><span class="pygments-p">,</span> <span class="pygments-n">file</span><span class="pygments-p">)))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l343"> -<td class="vc_file_line_number">343</td> - -<td class="vc_file_line_text"> <span class="pygments-n">log_message</span><span class="pygments-p">(</span><span class="pygments-s">"FTP/get_filesize: Bad mood, directory does not contain searched file (%s)"</span><span class="pygments-p">,</span> <span class="pygments-n">file</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l344"> -<td class="vc_file_line_number">344</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">ftp_end_data_command</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">))</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l345"> -<td class="vc_file_line_number">345</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l346"> -<td class="vc_file_line_number">346</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-o">-</span><span class="pygments-mi">1</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l347"> -<td class="vc_file_line_number">347</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l348"> -<td class="vc_file_line_number">348</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l349"> -<td class="vc_file_line_number">349</td> - -<td class="vc_file_line_text"> <span class="pygments-k">for</span> <span class="pygments-p">(</span><span class="pygments-n">i</span><span class="pygments-o">=</span><span class="pygments-mi">0</span><span class="pygments-p">;</span> <span class="pygments-n">i</span><span class="pygments-o"><</span><span class="pygments-mi">4</span><span class="pygments-p">;</span> <span class="pygments-n">i</span><span class="pygments-o">++</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l350"> -<td class="vc_file_line_number">350</td> - -<td class="vc_file_line_text"> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">ptr</span> <span class="pygments-o">&&</span> <span class="pygments-o">*</span><span class="pygments-n">ptr</span> <span class="pygments-o">!=</span> <span class="pygments-sc">' '</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l351"> -<td class="vc_file_line_number">351</td> - -<td class="vc_file_line_text"> <span class="pygments-n">ptr</span><span class="pygments-o">--</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l352"> -<td class="vc_file_line_number">352</td> - -<td class="vc_file_line_text"> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">ptr</span> <span class="pygments-o">&&</span> <span class="pygments-o">*</span><span class="pygments-n">ptr</span> <span class="pygments-o">==</span> <span class="pygments-sc">' '</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l353"> -<td class="vc_file_line_number">353</td> - -<td class="vc_file_line_text"> <span class="pygments-n">ptr</span><span class="pygments-o">--</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l354"> -<td class="vc_file_line_number">354</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l355"> -<td class="vc_file_line_number">355</td> - -<td class="vc_file_line_text"> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">ptr</span> <span class="pygments-o">&&</span> <span class="pygments-o">*</span><span class="pygments-n">ptr</span> <span class="pygments-o">!=</span> <span class="pygments-sc">' '</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l356"> -<td class="vc_file_line_number">356</td> - -<td class="vc_file_line_text"> <span class="pygments-n">ptr</span><span class="pygments-o">--</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l357"> -<td class="vc_file_line_number">357</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l358"> -<td class="vc_file_line_number">358</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">ptr</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l359"> -<td class="vc_file_line_number">359</td> - -<td class="vc_file_line_text"> <span class="pygments-n">size</span> <span class="pygments-o">=</span> <span class="pygments-n">charstar_to_int</span><span class="pygments-p">(</span><span class="pygments-n">ptr</span><span class="pygments-o">+</span><span class="pygments-mi">1</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l360"> -<td class="vc_file_line_number">360</td> - -<td class="vc_file_line_text"> <span class="pygments-k">else</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l361"> -<td class="vc_file_line_number">361</td> - -<td class="vc_file_line_text"> <span class="pygments-n">size</span> <span class="pygments-o">=</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l362"> -<td class="vc_file_line_number">362</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l363"> -<td class="vc_file_line_number">363</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">ftp_end_data_command</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l364"> -<td class="vc_file_line_number">364</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l365"> -<td class="vc_file_line_number">365</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-o">-</span><span class="pygments-mi">1</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l366"> -<td class="vc_file_line_number">366</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l367"> -<td class="vc_file_line_number">367</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l368"> -<td class="vc_file_line_number">368</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">size</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l369"> -<td class="vc_file_line_number">369</td> - -<td class="vc_file_line_text"><span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l370"> -<td class="vc_file_line_number">370</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l371"> -<td class="vc_file_line_number">371</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l372"> -<td class="vc_file_line_number">372</td> - -<td class="vc_file_line_text"><span class="pygments-kt">int</span> <span class="pygments-nf">ftp_start_download</span><span class="pygments-p">(</span><span class="pygments-kt">int</span> <span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">remotename</span><span class="pygments-p">,</span> <span class="pygments-kt">int</span> <span class="pygments-o">*</span> <span class="pygments-n">size</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l373"> -<td class="vc_file_line_number">373</td> - -<td class="vc_file_line_text"><span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l374"> -<td class="vc_file_line_number">374</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-o">*</span><span class="pygments-n">size</span> <span class="pygments-o">=</span> <span class="pygments-n">ftp_get_filesize</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-n">remotename</span><span class="pygments-p">))</span> <span class="pygments-o">==</span> <span class="pygments-o">-</span><span class="pygments-mi">1</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l375"> -<td class="vc_file_line_number">375</td> - -<td class="vc_file_line_text"> <span class="pygments-n">log_message</span><span class="pygments-p">(</span><span class="pygments-s">"FTP: could not get filesize (trying to continue)"</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l376"> -<td class="vc_file_line_number">376</td> - -<td class="vc_file_line_text"> <span class="pygments-o">*</span><span class="pygments-n">size</span> <span class="pygments-o">=</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l377"> -<td class="vc_file_line_number">377</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l378"> -<td class="vc_file_line_number">378</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">ftp_data_command</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-s">"RETR"</span><span class="pygments-p">,</span> <span class="pygments-n">remotename</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l379"> -<td class="vc_file_line_number">379</td> - -<td class="vc_file_line_text"><span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l380"> -<td class="vc_file_line_number">380</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l381"> -<td class="vc_file_line_number">381</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l382"> -<td class="vc_file_line_number">382</td> - -<td class="vc_file_line_text"><span class="pygments-kt">int</span> <span class="pygments-nf">ftp_end_data_command</span><span class="pygments-p">(</span><span class="pygments-kt">int</span> <span class="pygments-n">sock</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l383"> -<td class="vc_file_line_number">383</td> - -<td class="vc_file_line_text"><span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l384"> -<td class="vc_file_line_number">384</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">ftp_check_response</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-nb">NULL</span><span class="pygments-p">))</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l385"> -<td class="vc_file_line_number">385</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_BAD_SERVER_RESPONSE</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l386"> -<td class="vc_file_line_number">386</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l387"> -<td class="vc_file_line_number">387</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l388"> -<td class="vc_file_line_number">388</td> - -<td class="vc_file_line_text"><span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l389"> -<td class="vc_file_line_number">389</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l390"> -<td class="vc_file_line_number">390</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l391"> -<td class="vc_file_line_number">391</td> - -<td class="vc_file_line_text"><span class="pygments-kt">char</span> <span class="pygments-o">*</span><span class="pygments-nf">str_ftp_error</span><span class="pygments-p">(</span><span class="pygments-kt">int</span> <span class="pygments-n">error</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l392"> -<td class="vc_file_line_number">392</td> - -<td class="vc_file_line_text"><span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l393"> -<td class="vc_file_line_number">393</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">error</span> <span class="pygments-o">==</span> <span class="pygments-n">FTPERR_PASSIVE_ERROR</span> <span class="pygments-o">?</span> <span class="pygments-s">"error with passive connection"</span> <span class="pygments-o">:</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l394"> -<td class="vc_file_line_number">394</td> - -<td class="vc_file_line_text"> <span class="pygments-n">error</span> <span class="pygments-o">==</span> <span class="pygments-n">FTPERR_FAILED_CONNECT</span> <span class="pygments-o">?</span> <span class="pygments-s">"couldn't connect to server"</span> <span class="pygments-o">:</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l395"> -<td class="vc_file_line_number">395</td> - -<td class="vc_file_line_text"> <span class="pygments-n">error</span> <span class="pygments-o">==</span> <span class="pygments-n">FTPERR_FILE_NOT_FOUND</span> <span class="pygments-o">?</span> <span class="pygments-s">"file not found"</span> <span class="pygments-o">:</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l396"> -<td class="vc_file_line_number">396</td> - -<td class="vc_file_line_text"> <span class="pygments-n">error</span> <span class="pygments-o">==</span> <span class="pygments-n">FTPERR_BAD_SERVER_RESPONSE</span> <span class="pygments-o">?</span> <span class="pygments-s">"bad server response (server too busy?)"</span> <span class="pygments-o">:</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l397"> -<td class="vc_file_line_number">397</td> - -<td class="vc_file_line_text"> <span class="pygments-nb">NULL</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l398"> -<td class="vc_file_line_number">398</td> - -<td class="vc_file_line_text"><span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l399"> -<td class="vc_file_line_number">399</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l400"> -<td class="vc_file_line_number">400</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l401"> -<td class="vc_file_line_number">401</td> - -<td class="vc_file_line_text"><span class="pygments-k">static</span> <span class="pygments-kt">int</span> <span class="pygments-nf">_http_download_file</span><span class="pygments-p">(</span><span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">hostname</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">remotename</span><span class="pygments-p">,</span> <span class="pygments-kt">int</span> <span class="pygments-o">*</span> <span class="pygments-n">size</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">proxyprotocol</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">proxyname</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">proxyport</span><span class="pygments-p">,</span> <span class="pygments-kt">int</span> <span class="pygments-n">recursion</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l402"> -<td class="vc_file_line_number">402</td> - -<td class="vc_file_line_text"><span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l403"> -<td class="vc_file_line_number">403</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">buf</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l404"> -<td class="vc_file_line_number">404</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-n">headers</span><span class="pygments-p">[</span><span class="pygments-mi">4096</span><span class="pygments-p">];</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l405"> -<td class="vc_file_line_number">405</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">nextChar</span> <span class="pygments-o">=</span> <span class="pygments-n">headers</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l406"> -<td class="vc_file_line_number">406</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">statusCode</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l407"> -<td class="vc_file_line_number">407</td> - -<td class="vc_file_line_text"> <span class="pygments-k">struct</span> <span class="pygments-n">in_addr</span> <span class="pygments-n">serverAddress</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l408"> -<td class="vc_file_line_number">408</td> - -<td class="vc_file_line_text"> <span class="pygments-k">struct</span> <span class="pygments-n">pollfd</span> <span class="pygments-n">polls</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l409"> -<td class="vc_file_line_number">409</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">sock</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l410"> -<td class="vc_file_line_number">410</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">rc</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l411"> -<td class="vc_file_line_number">411</td> - -<td class="vc_file_line_text"> <span class="pygments-k">struct</span> <span class="pygments-n">sockaddr_in</span> <span class="pygments-n">destPort</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l412"> -<td class="vc_file_line_number">412</td> - -<td class="vc_file_line_text"> <span class="pygments-k">const</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">header_content_length</span> <span class="pygments-o">=</span> <span class="pygments-s">"Content-Length: "</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l413"> -<td class="vc_file_line_number">413</td> - -<td class="vc_file_line_text"> <span class="pygments-k">const</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">header_location</span> <span class="pygments-o">=</span> <span class="pygments-s">"Location: http://"</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l414"> -<td class="vc_file_line_number">414</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">http_server_name</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l415"> -<td class="vc_file_line_number">415</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">int</span> <span class="pygments-n">http_server_port</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l416"> -<td class="vc_file_line_number">416</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l417"> -<td class="vc_file_line_number">417</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">proxyprotocol</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l418"> -<td class="vc_file_line_number">418</td> - -<td class="vc_file_line_text"> <span class="pygments-n">http_server_name</span> <span class="pygments-o">=</span> <span class="pygments-n">proxyname</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l419"> -<td class="vc_file_line_number">419</td> - -<td class="vc_file_line_text"> <span class="pygments-n">http_server_port</span> <span class="pygments-o">=</span> <span class="pygments-n">atoi</span><span class="pygments-p">(</span><span class="pygments-n">proxyport</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l420"> -<td class="vc_file_line_number">420</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> <span class="pygments-k">else</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l421"> -<td class="vc_file_line_number">421</td> - -<td class="vc_file_line_text"> <span class="pygments-n">http_server_name</span> <span class="pygments-o">=</span> <span class="pygments-n">hostname</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l422"> -<td class="vc_file_line_number">422</td> - -<td class="vc_file_line_text"> <span class="pygments-n">http_server_port</span> <span class="pygments-o">=</span> <span class="pygments-mi">80</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l423"> -<td class="vc_file_line_number">423</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l424"> -<td class="vc_file_line_number">424</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l425"> -<td class="vc_file_line_number">425</td> - -<td class="vc_file_line_text"> <span class="pygments-n">log_message</span><span class="pygments-p">(</span><span class="pygments-s">"HTTP: connecting to server %s:%i (%s)"</span><span class="pygments-p">,</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l426"> -<td class="vc_file_line_number">426</td> - -<td class="vc_file_line_text"> <span class="pygments-n">http_server_name</span><span class="pygments-p">,</span> <span class="pygments-n">http_server_port</span><span class="pygments-p">,</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l427"> -<td class="vc_file_line_number">427</td> - -<td class="vc_file_line_text"> <span class="pygments-n">proxyprotocol</span> <span class="pygments-o">?</span> <span class="pygments-s">"proxy"</span> <span class="pygments-o">:</span> <span class="pygments-s">"no proxy"</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l428"> -<td class="vc_file_line_number">428</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l429"> -<td class="vc_file_line_number">429</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">rc</span> <span class="pygments-o">=</span> <span class="pygments-n">get_host_address</span><span class="pygments-p">(</span><span class="pygments-n">http_server_name</span><span class="pygments-p">,</span> <span class="pygments-o">&</span><span class="pygments-n">serverAddress</span><span class="pygments-p">)))</span> <span class="pygments-k">return</span> <span class="pygments-n">rc</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l430"> -<td class="vc_file_line_number">430</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l431"> -<td class="vc_file_line_number">431</td> - -<td class="vc_file_line_text"> <span class="pygments-n">sock</span> <span class="pygments-o">=</span> <span class="pygments-n">socket</span><span class="pygments-p">(</span><span class="pygments-n">AF_INET</span><span class="pygments-p">,</span> <span class="pygments-n">SOCK_STREAM</span><span class="pygments-p">,</span> <span class="pygments-n">IPPROTO_IP</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l432"> -<td class="vc_file_line_number">432</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">sock</span> <span class="pygments-o"><</span> <span class="pygments-mi">0</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l433"> -<td class="vc_file_line_number">433</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_FAILED_CONNECT</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l434"> -<td class="vc_file_line_number">434</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l435"> -<td class="vc_file_line_number">435</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l436"> -<td class="vc_file_line_number">436</td> - -<td class="vc_file_line_text"> <span class="pygments-n">destPort</span><span class="pygments-p">.</span><span class="pygments-n">sin_family</span> <span class="pygments-o">=</span> <span class="pygments-n">AF_INET</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l437"> -<td class="vc_file_line_number">437</td> - -<td class="vc_file_line_text"> <span class="pygments-n">destPort</span><span class="pygments-p">.</span><span class="pygments-n">sin_port</span> <span class="pygments-o">=</span> <span class="pygments-n">htons</span><span class="pygments-p">(</span><span class="pygments-n">http_server_port</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l438"> -<td class="vc_file_line_number">438</td> - -<td class="vc_file_line_text"> <span class="pygments-n">destPort</span><span class="pygments-p">.</span><span class="pygments-n">sin_addr</span> <span class="pygments-o">=</span> <span class="pygments-n">serverAddress</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l439"> -<td class="vc_file_line_number">439</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l440"> -<td class="vc_file_line_number">440</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">connect</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-p">(</span><span class="pygments-k">struct</span> <span class="pygments-n">sockaddr</span> <span class="pygments-o">*</span><span class="pygments-p">)</span> <span class="pygments-o">&</span><span class="pygments-n">destPort</span><span class="pygments-p">,</span> <span class="pygments-k">sizeof</span><span class="pygments-p">(</span><span class="pygments-n">destPort</span><span class="pygments-p">)))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l441"> -<td class="vc_file_line_number">441</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l442"> -<td class="vc_file_line_number">442</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_FAILED_CONNECT</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l443"> -<td class="vc_file_line_number">443</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l444"> -<td class="vc_file_line_number">444</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l445"> -<td class="vc_file_line_number">445</td> - -<td class="vc_file_line_text"> <span class="pygments-n">buf</span> <span class="pygments-o">=</span> <span class="pygments-n">proxyprotocol</span> <span class="pygments-o">?</span> <span class="pygments-n">asprintf_</span><span class="pygments-p">(</span><span class="pygments-s">"GET %s://%s%s HTTP/1.0</span><span class="pygments-se">\r\n</span><span class="pygments-s">Host: %s</span><span class="pygments-se">\r\n\r\n</span><span class="pygments-s">"</span><span class="pygments-p">,</span> <span class="pygments-n">proxyprotocol</span><span class="pygments-p">,</span> <span class="pygments-n">hostname</span><span class="pygments-p">,</span> <span class="pygments-n">remotename</span><span class="pygments-p">,</span> <span class="pygments-n">hostname</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l446"> -<td class="vc_file_line_number">446</td> - -<td class="vc_file_line_text"> <span class="pygments-o">:</span> <span class="pygments-n">asprintf_</span><span class="pygments-p">(</span><span class="pygments-s">"GET %s HTTP/1.0</span><span class="pygments-se">\r\n</span><span class="pygments-s">Host: %s</span><span class="pygments-se">\r\n\r\n</span><span class="pygments-s">"</span><span class="pygments-p">,</span> <span class="pygments-n">remotename</span><span class="pygments-p">,</span> <span class="pygments-n">hostname</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l447"> -<td class="vc_file_line_number">447</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l448"> -<td class="vc_file_line_number">448</td> - -<td class="vc_file_line_text"> <span class="pygments-n">write</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-n">buf</span><span class="pygments-p">,</span> <span class="pygments-n">strlen</span><span class="pygments-p">(</span><span class="pygments-n">buf</span><span class="pygments-p">));</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l449"> -<td class="vc_file_line_number">449</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l450"> -<td class="vc_file_line_number">450</td> - -<td class="vc_file_line_text"> <span class="pygments-cm">/* This is fun; read the response a character at a time until we:</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l451"> -<td class="vc_file_line_number">451</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l452"> -<td class="vc_file_line_number">452</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> 1) Get our first \r\n; which lets us check the return code</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l453"> -<td class="vc_file_line_number">453</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> 2) Get a \r\n\r\n, which means we're done */</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l454"> -<td class="vc_file_line_number">454</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l455"> -<td class="vc_file_line_number">455</td> - -<td class="vc_file_line_text"> <span class="pygments-o">*</span><span class="pygments-n">nextChar</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l456"> -<td class="vc_file_line_number">456</td> - -<td class="vc_file_line_text"> <span class="pygments-n">statusCode</span> <span class="pygments-o">=</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l457"> -<td class="vc_file_line_number">457</td> - -<td class="vc_file_line_text"> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-o">!</span><span class="pygments-n">strstr</span><span class="pygments-p">(</span><span class="pygments-n">headers</span><span class="pygments-p">,</span> <span class="pygments-s">"</span><span class="pygments-se">\r\n\r\n</span><span class="pygments-s">"</span><span class="pygments-p">))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l458"> -<td class="vc_file_line_number">458</td> - -<td class="vc_file_line_text"> <span class="pygments-n">polls</span><span class="pygments-p">.</span><span class="pygments-n">fd</span> <span class="pygments-o">=</span> <span class="pygments-n">sock</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l459"> -<td class="vc_file_line_number">459</td> - -<td class="vc_file_line_text"> <span class="pygments-n">polls</span><span class="pygments-p">.</span><span class="pygments-n">events</span> <span class="pygments-o">=</span> <span class="pygments-n">POLLIN</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l460"> -<td class="vc_file_line_number">460</td> - -<td class="vc_file_line_text"> <span class="pygments-n">rc</span> <span class="pygments-o">=</span> <span class="pygments-n">poll</span><span class="pygments-p">(</span><span class="pygments-o">&</span><span class="pygments-n">polls</span><span class="pygments-p">,</span> <span class="pygments-mi">1</span><span class="pygments-p">,</span> <span class="pygments-n">TIMEOUT_SECS</span><span class="pygments-o">*</span><span class="pygments-mi">1000</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l461"> -<td class="vc_file_line_number">461</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l462"> -<td class="vc_file_line_number">462</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">rc</span> <span class="pygments-o">==</span> <span class="pygments-mi">0</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l463"> -<td class="vc_file_line_number">463</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l464"> -<td class="vc_file_line_number">464</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_SERVER_TIMEOUT</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l465"> -<td class="vc_file_line_number">465</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> <span class="pygments-k">else</span> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">rc</span> <span class="pygments-o"><</span> <span class="pygments-mi">0</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l466"> -<td class="vc_file_line_number">466</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l467"> -<td class="vc_file_line_number">467</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_SERVER_IO_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l468"> -<td class="vc_file_line_number">468</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l469"> -<td class="vc_file_line_number">469</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l470"> -<td class="vc_file_line_number">470</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">read</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">,</span> <span class="pygments-n">nextChar</span><span class="pygments-p">,</span> <span class="pygments-mi">1</span><span class="pygments-p">)</span> <span class="pygments-o">!=</span> <span class="pygments-mi">1</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l471"> -<td class="vc_file_line_number">471</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l472"> -<td class="vc_file_line_number">472</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_SERVER_IO_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l473"> -<td class="vc_file_line_number">473</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l474"> -<td class="vc_file_line_number">474</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l475"> -<td class="vc_file_line_number">475</td> - -<td class="vc_file_line_text"> <span class="pygments-n">nextChar</span><span class="pygments-o">++</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l476"> -<td class="vc_file_line_number">476</td> - -<td class="vc_file_line_text"> <span class="pygments-o">*</span><span class="pygments-n">nextChar</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l477"> -<td class="vc_file_line_number">477</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l478"> -<td class="vc_file_line_number">478</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">nextChar</span> <span class="pygments-o">-</span> <span class="pygments-n">headers</span> <span class="pygments-o">==</span> <span class="pygments-k">sizeof</span><span class="pygments-p">(</span><span class="pygments-n">headers</span><span class="pygments-p">))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l479"> -<td class="vc_file_line_number">479</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l480"> -<td class="vc_file_line_number">480</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_SERVER_IO_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l481"> -<td class="vc_file_line_number">481</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l482"> -<td class="vc_file_line_number">482</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l483"> -<td class="vc_file_line_number">483</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">!</span><span class="pygments-n">statusCode</span> <span class="pygments-o">&&</span> <span class="pygments-n">strstr</span><span class="pygments-p">(</span><span class="pygments-n">headers</span><span class="pygments-p">,</span> <span class="pygments-s">"</span><span class="pygments-se">\r\n</span><span class="pygments-s">"</span><span class="pygments-p">))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l484"> -<td class="vc_file_line_number">484</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">start</span><span class="pygments-p">,</span> <span class="pygments-o">*</span> <span class="pygments-n">end</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l485"> -<td class="vc_file_line_number">485</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l486"> -<td class="vc_file_line_number">486</td> - -<td class="vc_file_line_text"> <span class="pygments-n">start</span> <span class="pygments-o">=</span> <span class="pygments-n">headers</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l487"> -<td class="vc_file_line_number">487</td> - -<td class="vc_file_line_text"> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-o">!</span><span class="pygments-n">isspace</span><span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">start</span><span class="pygments-p">)</span> <span class="pygments-o">&&</span> <span class="pygments-o">*</span><span class="pygments-n">start</span><span class="pygments-p">)</span> <span class="pygments-n">start</span><span class="pygments-o">++</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l488"> -<td class="vc_file_line_number">488</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">!*</span><span class="pygments-n">start</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l489"> -<td class="vc_file_line_number">489</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l490"> -<td class="vc_file_line_number">490</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_SERVER_IO_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l491"> -<td class="vc_file_line_number">491</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l492"> -<td class="vc_file_line_number">492</td> - -<td class="vc_file_line_text"> <span class="pygments-n">start</span><span class="pygments-o">++</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l493"> -<td class="vc_file_line_number">493</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l494"> -<td class="vc_file_line_number">494</td> - -<td class="vc_file_line_text"> <span class="pygments-n">end</span> <span class="pygments-o">=</span> <span class="pygments-n">start</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l495"> -<td class="vc_file_line_number">495</td> - -<td class="vc_file_line_text"> <span class="pygments-k">while</span> <span class="pygments-p">(</span><span class="pygments-o">!</span><span class="pygments-n">isspace</span><span class="pygments-p">(</span><span class="pygments-o">*</span><span class="pygments-n">end</span><span class="pygments-p">)</span> <span class="pygments-o">&&</span> <span class="pygments-o">*</span><span class="pygments-n">end</span><span class="pygments-p">)</span> <span class="pygments-n">end</span><span class="pygments-o">++</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l496"> -<td class="vc_file_line_number">496</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-o">!*</span><span class="pygments-n">end</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l497"> -<td class="vc_file_line_number">497</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l498"> -<td class="vc_file_line_number">498</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_SERVER_IO_ERROR</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l499"> -<td class="vc_file_line_number">499</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l500"> -<td class="vc_file_line_number">500</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l501"> -<td class="vc_file_line_number">501</td> - -<td class="vc_file_line_text"> <span class="pygments-o">*</span><span class="pygments-n">end</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l502"> -<td class="vc_file_line_number">502</td> - -<td class="vc_file_line_text"> <span class="pygments-n">log_message</span><span class="pygments-p">(</span><span class="pygments-s">"HTTP: server response '%s'"</span><span class="pygments-p">,</span> <span class="pygments-n">start</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l503"> -<td class="vc_file_line_number">503</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">streq</span><span class="pygments-p">(</span><span class="pygments-n">start</span><span class="pygments-p">,</span> <span class="pygments-s">"404"</span><span class="pygments-p">))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l504"> -<td class="vc_file_line_number">504</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l505"> -<td class="vc_file_line_number">505</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_FILE_NOT_FOUND</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l506"> -<td class="vc_file_line_number">506</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> <span class="pygments-k">else</span> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">streq</span><span class="pygments-p">(</span><span class="pygments-n">start</span><span class="pygments-p">,</span> <span class="pygments-s">"302"</span><span class="pygments-p">))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l507"> -<td class="vc_file_line_number">507</td> - -<td class="vc_file_line_text"> <span class="pygments-n">log_message</span><span class="pygments-p">(</span><span class="pygments-s">"HTTP: found, but document has moved"</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l508"> -<td class="vc_file_line_number">508</td> - -<td class="vc_file_line_text"> <span class="pygments-n">statusCode</span> <span class="pygments-o">=</span> <span class="pygments-mi">302</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l509"> -<td class="vc_file_line_number">509</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> <span class="pygments-k">else</span> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">streq</span><span class="pygments-p">(</span><span class="pygments-n">start</span><span class="pygments-p">,</span> <span class="pygments-s">"200"</span><span class="pygments-p">))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l510"> -<td class="vc_file_line_number">510</td> - -<td class="vc_file_line_text"> <span class="pygments-n">statusCode</span> <span class="pygments-o">=</span> <span class="pygments-mi">200</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l511"> -<td class="vc_file_line_number">511</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> <span class="pygments-k">else</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l512"> -<td class="vc_file_line_number">512</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l513"> -<td class="vc_file_line_number">513</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_BAD_SERVER_RESPONSE</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l514"> -<td class="vc_file_line_number">514</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l515"> -<td class="vc_file_line_number">515</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l516"> -<td class="vc_file_line_number">516</td> - -<td class="vc_file_line_text"> <span class="pygments-o">*</span><span class="pygments-n">end</span> <span class="pygments-o">=</span> <span class="pygments-sc">' '</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l517"> -<td class="vc_file_line_number">517</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l518"> -<td class="vc_file_line_number">518</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l519"> -<td class="vc_file_line_number">519</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l520"> -<td class="vc_file_line_number">520</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">statusCode</span> <span class="pygments-o">==</span> <span class="pygments-mi">302</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l521"> -<td class="vc_file_line_number">521</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">(</span><span class="pygments-n">recursion</span> <span class="pygments-o">>=</span> <span class="pygments-n">HTTP_MAX_RECURSION</span><span class="pygments-p">)</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l522"> -<td class="vc_file_line_number">522</td> - -<td class="vc_file_line_text"> <span class="pygments-n">log_message</span><span class="pygments-p">(</span><span class="pygments-s">"HTTP: too many levels of recursion, aborting"</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l523"> -<td class="vc_file_line_number">523</td> - -<td class="vc_file_line_text"> <span class="pygments-n">close</span><span class="pygments-p">(</span><span class="pygments-n">sock</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l524"> -<td class="vc_file_line_number">524</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">FTPERR_UNKNOWN</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l525"> -<td class="vc_file_line_number">525</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l526"> -<td class="vc_file_line_number">526</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">buf</span> <span class="pygments-o">=</span> <span class="pygments-n">strstr</span><span class="pygments-p">(</span><span class="pygments-n">headers</span><span class="pygments-p">,</span> <span class="pygments-n">header_location</span><span class="pygments-p">)))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l527"> -<td class="vc_file_line_number">527</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">found_host</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l528"> -<td class="vc_file_line_number">528</td> - -<td class="vc_file_line_text"> <span class="pygments-kt">char</span> <span class="pygments-o">*</span><span class="pygments-n">found_file</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l529"> -<td class="vc_file_line_number">529</td> - -<td class="vc_file_line_text"> <span class="pygments-n">found_host</span> <span class="pygments-o">=</span> <span class="pygments-n">buf</span> <span class="pygments-o">+</span> <span class="pygments-n">strlen</span><span class="pygments-p">(</span><span class="pygments-n">header_location</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l530"> -<td class="vc_file_line_number">530</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">found_file</span> <span class="pygments-o">=</span> <span class="pygments-n">index</span><span class="pygments-p">(</span><span class="pygments-n">found_host</span><span class="pygments-p">,</span> <span class="pygments-sc">'/'</span><span class="pygments-p">)))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l531"> -<td class="vc_file_line_number">531</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">buf</span> <span class="pygments-o">=</span> <span class="pygments-n">index</span><span class="pygments-p">(</span><span class="pygments-n">found_file</span><span class="pygments-p">,</span> <span class="pygments-sc">'\r'</span><span class="pygments-p">)))</span> <span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l532"> -<td class="vc_file_line_number">532</td> - -<td class="vc_file_line_text"> <span class="pygments-n">buf</span><span class="pygments-p">[</span><span class="pygments-mi">0</span><span class="pygments-p">]</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l533"> -<td class="vc_file_line_number">533</td> - -<td class="vc_file_line_text"> <span class="pygments-n">remotename</span> <span class="pygments-o">=</span> <span class="pygments-n">strdup</span><span class="pygments-p">(</span><span class="pygments-n">found_file</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l534"> -<td class="vc_file_line_number">534</td> - -<td class="vc_file_line_text"> <span class="pygments-n">found_file</span><span class="pygments-p">[</span><span class="pygments-mi">0</span><span class="pygments-p">]</span> <span class="pygments-o">=</span> <span class="pygments-sc">'\0'</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l535"> -<td class="vc_file_line_number">535</td> - -<td class="vc_file_line_text"> <span class="pygments-n">hostname</span> <span class="pygments-o">=</span> <span class="pygments-n">strdup</span><span class="pygments-p">(</span><span class="pygments-n">found_host</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l536"> -<td class="vc_file_line_number">536</td> - -<td class="vc_file_line_text"> <span class="pygments-n">log_message</span><span class="pygments-p">(</span><span class="pygments-s">"HTTP: redirected to new host </span><span class="pygments-se">\"</span><span class="pygments-s">%s</span><span class="pygments-se">\"</span><span class="pygments-s"> and file </span><span class="pygments-se">\"</span><span class="pygments-s">%s</span><span class="pygments-se">\"</span><span class="pygments-s">"</span><span class="pygments-p">,</span> <span class="pygments-n">hostname</span><span class="pygments-p">,</span> <span class="pygments-n">remotename</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l537"> -<td class="vc_file_line_number">537</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l538"> -<td class="vc_file_line_number">538</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l539"> -<td class="vc_file_line_number">539</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l540"> -<td class="vc_file_line_number">540</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l541"> -<td class="vc_file_line_number">541</td> - -<td class="vc_file_line_text"> <span class="pygments-cm">/*</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l542"> -<td class="vc_file_line_number">542</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> * don't fail if new URL can't be parsed,</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l543"> -<td class="vc_file_line_number">543</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> * asking the same URL may work if the DNS server are doing round-robin</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l544"> -<td class="vc_file_line_number">544</td> - -<td class="vc_file_line_text"><span class="pygments-cm"> */</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l545"> -<td class="vc_file_line_number">545</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">_http_download_file</span><span class="pygments-p">(</span><span class="pygments-n">hostname</span><span class="pygments-p">,</span> <span class="pygments-n">remotename</span><span class="pygments-p">,</span> <span class="pygments-n">size</span><span class="pygments-p">,</span> <span class="pygments-n">proxyprotocol</span><span class="pygments-p">,</span> <span class="pygments-n">proxyname</span><span class="pygments-p">,</span> <span class="pygments-n">proxyport</span><span class="pygments-p">,</span> <span class="pygments-n">recursion</span> <span class="pygments-o">+</span> <span class="pygments-mi">1</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l546"> -<td class="vc_file_line_number">546</td> - -<td class="vc_file_line_text"> <span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l547"> -<td class="vc_file_line_number">547</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l548"> -<td class="vc_file_line_number">548</td> - -<td class="vc_file_line_text"> <span class="pygments-k">if</span> <span class="pygments-p">((</span><span class="pygments-n">buf</span> <span class="pygments-o">=</span> <span class="pygments-n">strstr</span><span class="pygments-p">(</span><span class="pygments-n">headers</span><span class="pygments-p">,</span> <span class="pygments-n">header_content_length</span><span class="pygments-p">)))</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l549"> -<td class="vc_file_line_number">549</td> - -<td class="vc_file_line_text"> <span class="pygments-o">*</span><span class="pygments-n">size</span> <span class="pygments-o">=</span> <span class="pygments-n">charstar_to_int</span><span class="pygments-p">(</span><span class="pygments-n">buf</span> <span class="pygments-o">+</span> <span class="pygments-n">strlen</span><span class="pygments-p">(</span><span class="pygments-n">header_content_length</span><span class="pygments-p">));</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l550"> -<td class="vc_file_line_number">550</td> - -<td class="vc_file_line_text"> <span class="pygments-k">else</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l551"> -<td class="vc_file_line_number">551</td> - -<td class="vc_file_line_text"> <span class="pygments-o">*</span><span class="pygments-n">size</span> <span class="pygments-o">=</span> <span class="pygments-mi">0</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l552"> -<td class="vc_file_line_number">552</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l553"> -<td class="vc_file_line_number">553</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">sock</span><span class="pygments-p">;</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l554"> -<td class="vc_file_line_number">554</td> - -<td class="vc_file_line_text"><span class="pygments-p">}</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l555"> -<td class="vc_file_line_number">555</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l556"> -<td class="vc_file_line_number">556</td> - -<td class="vc_file_line_text"> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l557"> -<td class="vc_file_line_number">557</td> - -<td class="vc_file_line_text"><span class="pygments-kt">int</span> <span class="pygments-nf">http_download_file</span><span class="pygments-p">(</span><span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">hostname</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">remotename</span><span class="pygments-p">,</span> <span class="pygments-kt">int</span> <span class="pygments-o">*</span> <span class="pygments-n">size</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">proxyprotocol</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">proxyname</span><span class="pygments-p">,</span> <span class="pygments-kt">char</span> <span class="pygments-o">*</span> <span class="pygments-n">proxyport</span><span class="pygments-p">)</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l558"> -<td class="vc_file_line_number">558</td> - -<td class="vc_file_line_text"><span class="pygments-p">{</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l559"> -<td class="vc_file_line_number">559</td> - -<td class="vc_file_line_text"> <span class="pygments-k">return</span> <span class="pygments-n">_http_download_file</span><span class="pygments-p">(</span><span class="pygments-n">hostname</span><span class="pygments-p">,</span> <span class="pygments-n">remotename</span><span class="pygments-p">,</span> <span class="pygments-n">size</span><span class="pygments-p">,</span> <span class="pygments-n">proxyprotocol</span><span class="pygments-p">,</span> <span class="pygments-n">proxyname</span><span class="pygments-p">,</span> <span class="pygments-n">proxyport</span><span class="pygments-p">,</span> <span class="pygments-mi">0</span><span class="pygments-p">);</span> -</td> -</tr> - - - - -<tr class="vc_row_odd" id="l560"> -<td class="vc_file_line_number">560</td> - -<td class="vc_file_line_text"><span class="pygments-p">}</span> -</td> -</tr> - - -</table> -</div> - - - -<hr/> -<div class="vc_properties"> -<h2>Properties</h2> -<table cellspacing="1" cellpadding="2" class="auto"> -<thead> -<tr> -<th class="vc_header_sort">Name</th> -<th class="vc_header">Value</th> -</tr> -</thead> -<tbody> - -<tr class="vc_row_even"> -<td><strong>svn:eol-style</strong></td> - -<td style="white-space: pre;">native -</td> - -</tr> - -</tbody> -</table> -</div> - - - -<hr /> -<table> -<tr> -<td> </td> -<td style="text-align: right;"><strong><a href="/viewvc/help_rootview.html">ViewVC Help</a></strong></td> -</tr> -<tr> -<td>Powered by <a href="http://viewvc.tigris.org/">ViewVC 1.1.15</a></td> -<td style="text-align: right;"> </td> -</tr> -</table> -</body> -</html> - +/* + * Guillaume Cottenceau (gc) + * + * Copyright 2000 Mandriva + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +/* + * Portions from Erik Troan <ewt@redhat.com> and Matt Wilson <msw@redhat.com> + * + * Copyright 1999 Red Hat, Inc. + * + */ + +#include <alloca.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <netinet/in_systm.h> + +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <netdb.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include <sys/socket.h> +#include <sys/time.h> +#include <sys/types.h> +#include <unistd.h> +#include <sys/poll.h> + +#include <netinet/in.h> +#include <netinet/ip.h> +#include <arpa/inet.h> + +#include "dns.h" +#include "log.h" +#include "tools.h" +#include "utils.h" + +#include "url.h" + + +#define TIMEOUT_SECS 60 +#define BUFFER_SIZE 4096 +#define HTTP_MAX_RECURSION 5 + + +static int ftp_check_response(int sock, char ** str) +{ + static char buf[BUFFER_SIZE + 1]; + int bufLength = 0; + struct pollfd polls; + char * chptr, * start; + int bytesRead, rc = 0; + int doesContinue = 1; + char errorCode[4]; + + errorCode[0] = '\0'; + + do { + polls.fd = sock; + polls.events = POLLIN; + if (poll(&polls, 1, TIMEOUT_SECS*1000) != 1) + return FTPERR_BAD_SERVER_RESPONSE; + + bytesRead = read(sock, buf + bufLength, sizeof(buf) - bufLength - 1); + + bufLength += bytesRead; + + buf[bufLength] = '\0'; + + /* divide the response into lines, checking each one to see if + we are finished or need to continue */ + + start = chptr = buf; + + do { + while (*chptr != '\n' && *chptr) chptr++; + + if (*chptr == '\n') { + *chptr = '\0'; + if (*(chptr - 1) == '\r') *(chptr - 1) = '\0'; + if (str) *str = start; + + if (errorCode[0]) { + if (!strncmp(start, errorCode, 3) && start[3] == ' ') + doesContinue = 0; + } else { + strncpy(errorCode, start, 3); + errorCode[3] = '\0'; + if (start[3] != '-') { + doesContinue = 0; + } + } + + start = chptr + 1; + chptr++; + } else { + chptr++; + } + } while (*chptr); + + if (doesContinue && chptr > start) { + memcpy(buf, start, chptr - start - 1); + bufLength = chptr - start - 1; + } else { + bufLength = 0; + } + } while (doesContinue); + + if (*errorCode == '4' || *errorCode == '5') { + if (!strncmp(errorCode, "550", 3)) { + return FTPERR_FILE_NOT_FOUND; + } + + return FTPERR_BAD_SERVER_RESPONSE; + } + + if (rc) return rc; + + return 0; +} + +static int ftp_command(int sock, char * command, char * param) +{ + char buf[500]; + int rc; + + snprintf(buf, sizeof(buf), "%s%s%s\r\n", command, param ? " " : "", param ? param : ""); + + if (write(sock, buf, strlen(buf)) != (ssize_t)strlen(buf)) { + return FTPERR_SERVER_IO_ERROR; + } + + if ((rc = ftp_check_response(sock, NULL))) + return rc; + + return 0; +} + +static int get_host_address(char * host, struct in_addr * address) +{ + if (isdigit(host[0])) { + if (!inet_aton(host, address)) { + return FTPERR_BAD_HOST_ADDR; + } + } else { + if (mygethostbyname(host, address)) + return FTPERR_BAD_HOSTNAME; + } + + return 0; +} + +int ftp_open_connection(char * host, char * name, char * password, char * proxy) +{ + int sock; + struct in_addr serverAddress; + struct sockaddr_in destPort; + int rc; + int port = 21; + + if (!strcmp(name, "")) { + name = "anonymous"; + password = "-drakx@"; + } + + if (strcmp(proxy, "")) { + name = asprintf_("%s@%s", name, host); + host = proxy; + } + + if ((rc = get_host_address(host, &serverAddress))) return rc; + + sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); + if (sock < 0) { + return FTPERR_FAILED_CONNECT; + } + + destPort.sin_family = AF_INET; + destPort.sin_port = htons(port); + destPort.sin_addr = serverAddress; + + if (connect(sock, (struct sockaddr *) &destPort, sizeof(destPort))) { + close(sock); + return FTPERR_FAILED_CONNECT; + } + + /* ftpCheckResponse() assumes the socket is nonblocking */ + if (fcntl(sock, F_SETFL, O_NONBLOCK)) { + close(sock); + return FTPERR_FAILED_CONNECT; + } + + if ((rc = ftp_check_response(sock, NULL))) { + return rc; + } + + if ((rc = ftp_command(sock, "USER", name))) { + close(sock); + return rc; + } + + if ((rc = ftp_command(sock, "PASS", password))) { + close(sock); + return rc; + } + + if ((rc = ftp_command(sock, "TYPE", "I"))) { + close(sock); + return rc; + } + + return sock; +} + + +int ftp_data_command(int sock, char * command, char * param) +{ + int dataSocket; + struct sockaddr_in dataAddress; + int i, j; + char * passReply; + char * chptr; + char retrCommand[500]; + int rc; + + if (write(sock, "PASV\r\n", 6) != 6) { + return FTPERR_SERVER_IO_ERROR; + } + if ((rc = ftp_check_response(sock, &passReply))) + return FTPERR_PASSIVE_ERROR; + + chptr = passReply; + while (*chptr && *chptr != '(') chptr++; + if (*chptr != '(') return FTPERR_PASSIVE_ERROR; + chptr++; + passReply = chptr; + while (*chptr && *chptr != ')') chptr++; + if (*chptr != ')') return FTPERR_PASSIVE_ERROR; + *chptr-- = '\0'; + + while (*chptr && *chptr != ',') chptr--; + if (*chptr != ',') return FTPERR_PASSIVE_ERROR; + chptr--; + while (*chptr && *chptr != ',') chptr--; + if (*chptr != ',') return FTPERR_PASSIVE_ERROR; + *chptr++ = '\0'; + + /* now passReply points to the IP portion, and chptr points to the + port number portion */ + + dataAddress.sin_family = AF_INET; + if (sscanf(chptr, "%d,%d", &i, &j) != 2) { + return FTPERR_PASSIVE_ERROR; + } + dataAddress.sin_port = htons((i << 8) + j); + + chptr = passReply; + while (*chptr++) { + if (*chptr == ',') *chptr = '.'; + } + + if (!inet_aton(passReply, &dataAddress.sin_addr)) + return FTPERR_PASSIVE_ERROR; + + dataSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); + if (dataSocket < 0) { + return FTPERR_FAILED_CONNECT; + } + + if (!param) + sprintf(retrCommand, "%s\r\n", command); + else + sprintf(retrCommand, "%s %s\r\n", command, param); + + i = strlen(retrCommand); + + if (write(sock, retrCommand, i) != i) { + return FTPERR_SERVER_IO_ERROR; + } + + if (connect(dataSocket, (struct sockaddr *) &dataAddress, + sizeof(dataAddress))) { + close(dataSocket); + return FTPERR_FAILED_DATA_CONNECT; + } + + if ((rc = ftp_check_response(sock, NULL))) { + close(dataSocket); + return rc; + } + + return dataSocket; +} + + +int ftp_get_filesize(int sock, char * remotename) +{ + int size = 0; + char buf[2000]; + char file[500]; + char * ptr; + int fd, rc, tot; + int i; + + strcpy(buf, remotename); + ptr = strrchr(buf, '/'); + if (!*ptr) + return -1; + *ptr = '\0'; + + strcpy(file, ptr+1); + + if ((rc = ftp_command(sock, "CWD", buf))) { + return -1; + } + + fd = ftp_data_command(sock, "LIST", file); + if (fd <= 0) { + close(sock); + return -1; + } + + ptr = buf; + while ((tot = read(fd, ptr, sizeof(buf) - (ptr - buf) - 1)) != 0) + ptr += tot; + *ptr = '\0'; + close(fd); + + if (!(ptr = strstr(buf, file))) { + log_message("FTP/get_filesize: Bad mood, directory does not contain searched file (%s)", file); + if (ftp_end_data_command(sock)) + close(sock); + return -1; + } + + for (i=0; i<4; i++) { + while (*ptr && *ptr != ' ') + ptr--; + while (*ptr && *ptr == ' ') + ptr--; + } + while (*ptr && *ptr != ' ') + ptr--; + + if (ptr) + size = charstar_to_int(ptr+1); + else + size = 0; + + if (ftp_end_data_command(sock)) { + close(sock); + return -1; + } + + return size; +} + + +int ftp_start_download(int sock, char * remotename, int * size) +{ + if ((*size = ftp_get_filesize(sock, remotename)) == -1) { + log_message("FTP: could not get filesize (trying to continue)"); + *size = 0; + } + return ftp_data_command(sock, "RETR", remotename); +} + + +int ftp_end_data_command(int sock) +{ + if (ftp_check_response(sock, NULL)) + return FTPERR_BAD_SERVER_RESPONSE; + + return 0; +} + + +char *str_ftp_error(int error) +{ + return error == FTPERR_PASSIVE_ERROR ? "error with passive connection" : + error == FTPERR_FAILED_CONNECT ? "couldn't connect to server" : + error == FTPERR_FILE_NOT_FOUND ? "file not found" : + error == FTPERR_BAD_SERVER_RESPONSE ? "bad server response (server too busy?)" : + NULL; +} + + +static int _http_download_file(char * hostname, char * remotename, int * size, char * proxyprotocol, char * proxyname, char * proxyport, int recursion) +{ + char * buf; + char headers[4096]; + char * nextChar = headers; + int statusCode; + struct in_addr serverAddress; + struct pollfd polls; + int sock; + int rc; + struct sockaddr_in destPort; + const char * header_content_length = "Content-Length: "; + const char * header_location = "Location: http://"; + char * http_server_name; + int http_server_port; + + if (proxyprotocol) { + http_server_name = proxyname; + http_server_port = atoi(proxyport); + } else { + http_server_name = hostname; + http_server_port = 80; + } + + log_message("HTTP: connecting to server %s:%i (%s)", + http_server_name, http_server_port, + proxyprotocol ? "proxy" : "no proxy"); + + if ((rc = get_host_address(http_server_name, &serverAddress))) return rc; + + sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); + if (sock < 0) { + return FTPERR_FAILED_CONNECT; + } + + destPort.sin_family = AF_INET; + destPort.sin_port = htons(http_server_port); + destPort.sin_addr = serverAddress; + + if (connect(sock, (struct sockaddr *) &destPort, sizeof(destPort))) { + close(sock); + return FTPERR_FAILED_CONNECT; + } + + buf = proxyprotocol ? asprintf_("GET %s://%s%s HTTP/1.0\r\nHost: %s\r\n\r\n", proxyprotocol, hostname, remotename, hostname) + : asprintf_("GET %s HTTP/1.0\r\nHost: %s\r\n\r\n", remotename, hostname); + + write(sock, buf, strlen(buf)); + + /* This is fun; read the response a character at a time until we: + + 1) Get our first \r\n; which lets us check the return code + 2) Get a \r\n\r\n, which means we're done */ + + *nextChar = '\0'; + statusCode = 0; + while (!strstr(headers, "\r\n\r\n")) { + polls.fd = sock; + polls.events = POLLIN; + rc = poll(&polls, 1, TIMEOUT_SECS*1000); + + if (rc == 0) { + close(sock); + return FTPERR_SERVER_TIMEOUT; + } else if (rc < 0) { + close(sock); + return FTPERR_SERVER_IO_ERROR; + } + + if (read(sock, nextChar, 1) != 1) { + close(sock); + return FTPERR_SERVER_IO_ERROR; + } + + nextChar++; + *nextChar = '\0'; + + if (nextChar - headers == sizeof(headers)) { + close(sock); + return FTPERR_SERVER_IO_ERROR; + } + + if (!statusCode && strstr(headers, "\r\n")) { + char * start, * end; + + start = headers; + while (!isspace(*start) && *start) start++; + if (!*start) { + close(sock); + return FTPERR_SERVER_IO_ERROR; + } + start++; + + end = start; + while (!isspace(*end) && *end) end++; + if (!*end) { + close(sock); + return FTPERR_SERVER_IO_ERROR; + } + + *end = '\0'; + log_message("HTTP: server response '%s'", start); + if (streq(start, "404")) { + close(sock); + return FTPERR_FILE_NOT_FOUND; + } else if (streq(start, "302")) { + log_message("HTTP: found, but document has moved"); + statusCode = 302; + } else if (streq(start, "200")) { + statusCode = 200; + } else { + close(sock); + return FTPERR_BAD_SERVER_RESPONSE; + } + + *end = ' '; + } + } + + if (statusCode == 302) { + if (recursion >= HTTP_MAX_RECURSION) { + log_message("HTTP: too many levels of recursion, aborting"); + close(sock); + return FTPERR_UNKNOWN; + } + if ((buf = strstr(headers, header_location))) { + char * found_host; + char *found_file; + found_host = buf + strlen(header_location); + if ((found_file = index(found_host, '/'))) { + if ((buf = index(found_file, '\r'))) { + buf[0] = '\0'; + remotename = strdup(found_file); + found_file[0] = '\0'; + hostname = strdup(found_host); + log_message("HTTP: redirected to new host \"%s\" and file \"%s\"", hostname, remotename); + } + } + + } + /* + * don't fail if new URL can't be parsed, + * asking the same URL may work if the DNS server are doing round-robin + */ + return _http_download_file(hostname, remotename, size, proxyprotocol, proxyname, proxyport, recursion + 1); + } + + if ((buf = strstr(headers, header_content_length))) + *size = charstar_to_int(buf + strlen(header_content_length)); + else + *size = 0; + + return sock; +} + + +int http_download_file(char * hostname, char * remotename, int * size, char * proxyprotocol, char * proxyname, char * proxyport) +{ + return _http_download_file(hostname, remotename, size, proxyprotocol, proxyname, proxyport, 0); +} |