⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ftplib.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/ftpLib.html - generated by refgen from ftpLib.c --> <title> ftpLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.html"><i>VxWorks Reference Manual :  Libraries</i></a></p></blockquote><h1>ftpLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>ftpLib</strong> - File Transfer Protocol (FTP) library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><i><a href="./ftpLib.html#ftpCommand">ftpCommand</a></i>(&nbsp;)</b>  -  send an FTP command and get the reply<br><b><i><a href="./ftpLib.html#ftpXfer">ftpXfer</a></i>(&nbsp;)</b>  -  initiate a transfer via FTP<br><b><i><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a></i>(&nbsp;)</b>  -  get an FTP command reply<br><b><i><a href="./ftpLib.html#ftpHookup">ftpHookup</a></i>(&nbsp;)</b>  -  get a control connection to the FTP server on a specified host<br><b><i><a href="./ftpLib.html#ftpLogin">ftpLogin</a></i>(&nbsp;)</b>  -  log in to a remote FTP server<br><b><i><a href="./ftpLib.html#ftpDataConnInit">ftpDataConnInit</a></i>(&nbsp;)</b>  -  initialize an FTP data connection<br><b><i><a href="./ftpLib.html#ftpDataConnGet">ftpDataConnGet</a></i>(&nbsp;)</b>  -  get a completed FTP data connection<br><b><i><a href="./ftpLib.html#ftpLs">ftpLs</a></i>(&nbsp;)</b>  -  list directory contents via FTP<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides facilities for transferring files to and from a hostvia File Transfer Protocol (FTP).  This library implements only the"client" side of the FTP facilities.<p></blockquote><h4>FTP IN VXWORKS</h4><blockquote><p>VxWorks provides an I/O driver, <b><a href="./netDrv.html#top">netDrv</a></b>, that allows transparent access toremote files via standard I/O system calls.  The FTP facilities of <b><a href="./ftpLib.html#top">ftpLib</a></b>are primarily used by <b><a href="./netDrv.html#top">netDrv</a></b> to access remote files.  Thus for mostpurposes, it is not necessary to be familiar with ftpLib.<p></blockquote><h4>HIGH-LEVEL INTERFACE</h4><blockquote><p>The routines <b><i><a href="./ftpLib.html#ftpXfer">ftpXfer</a></i>(&nbsp;)</b> and <b><i><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a></i>(&nbsp;)</b> provide the highest level ofdirect interface to FTP.  The routine <b><i><a href="./ftpLib.html#ftpXfer">ftpXfer</a></i>(&nbsp;)</b> connects to a specifiedremote FTP server, logs in under a specified user name, and initiates aspecified data transfer command.  The routine <b><i><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a></i>(&nbsp;)</b> receivescontrol reply messages sent by the remote FTP server in response to thecommands sent.<p></blockquote><h4>LOW-LEVEL INTERFACE</h4><blockquote><p>The routines <b><i><a href="./ftpLib.html#ftpHookup">ftpHookup</a></i>(&nbsp;)</b>, <b><i><a href="./ftpLib.html#ftpLogin">ftpLogin</a></i>(&nbsp;)</b>, <b><i><a href="./ftpLib.html#ftpDataConnInit">ftpDataConnInit</a></i>(&nbsp;)</b>, <b><i><a href="./ftpLib.html#ftpDataConnGet">ftpDataConnGet</a></i>(&nbsp;)</b>,and <b><i><a href="./ftpLib.html#ftpCommand">ftpCommand</a></i>(&nbsp;)</b> provide the primitives necessary to create and usecontrol and data connections to remote FTP servers.  The following exampleshows how to use these low-level routines.  It implements roughly the samefunction as <b><i><a href="./ftpLib.html#ftpXfer">ftpXfer</a></i>(&nbsp;)</b>.<p><pre>char *host, *user, *passwd, *acct, *dirname, *filename;int ctrlSock = ERROR;int dataSock = ERROR;if (((ctrlSock = ftpHookup (host)) == ERROR)                                  ||    (ftpLogin (ctrlSock, user, passwd, acct) == ERROR)                        ||    (ftpCommand (ctrlSock, "TYPE I", 0, 0, 0, 0, 0, 0) != FTP_COMPLETE)       ||    (ftpCommand (ctrlSock, "CWD %s", dirname, 0, 0, 0, 0, 0) != FTP_COMPLETE) ||    ((dataSock = ftpDataConnInit (ctrlSock)) == ERROR)                        ||    (ftpCommand (ctrlSock, "RETR %s", filename, 0, 0, 0, 0, 0) != FTP_PRELIM) ||    ((dataSock = ftpDataConnGet (dataSock)) == ERROR))    {    /* an error occurred; close any open sockets and return */    if (ctrlSock != ERROR)        close (ctrlSock);    if (dataSock != ERROR)        close (dataSock);    return (ERROR);    }</pre></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>ftpLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ftpLib.html#top">ftpLib</a></b>, <b><a href="./netDrv.html#top">netDrv</a></b><hr><a name="ftpCommand"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>ftpCommand</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>ftpCommand</i>(&nbsp;)</strong> - send an FTP command and get the reply</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int ftpCommand    (    int    ctrlSock, /* fd of control connection socket */    char * fmt,      /* format string of command to send */    int    arg1,     /* first of six args to format string */    int    arg2,    int    arg3,    int    arg4,    int    arg5,    int    arg6    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine sends the specified command on the specified socket, whichshould be a control connection to a remote FTP server.The command is specified as a string in <b><i><a href="./fioLib.html#printf">printf</a></i>(&nbsp;)</b> format with upto six arguments.<p>After the command is sent, <b><i><a href="./ftpLib.html#ftpCommand">ftpCommand</a></i>(&nbsp;)</b> waits for the reply from theremote server.  The FTP reply code is returned in the same way as in<b><i><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a></i>(&nbsp;)</b>.<p></blockquote><h4>EXAMPLE</h4><blockquote><p><pre>ftpCommand (ctrlSock, "TYPE I", 0, 0, 0, 0, 0, 0);     /* image-type xfer */ftpCommand (ctrlSock, "STOR %s", file, 0, 0, 0, 0, 0); /* init file write */</pre></blockquote><h4>RETURNS</h4><blockquote><p><p>&nbsp;1&nbsp;=&nbsp;<b>FTP_PRELIM</b>&nbsp;(positive&nbsp;preliminary)<br>&nbsp;2&nbsp;=&nbsp;<b>FTP_COMPLETE</b>&nbsp;(positive&nbsp;completion)<br>&nbsp;3&nbsp;=&nbsp;<b>FTP_CONTINUE</b>&nbsp;(positive&nbsp;intermediate)<br>&nbsp;4&nbsp;=&nbsp;<b>FTP_TRANSIENT</b>&nbsp;(transient&nbsp;negative&nbsp;completion)<br>&nbsp;5&nbsp;=&nbsp;<b>FTP_ERROR</b>&nbsp;(permanent&nbsp;negative&nbsp;completion)<p>ERROR if there is a read/write error or an unexpected EOF.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ftpLib.html#top">ftpLib</a></b>, <b><i><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a></i>(&nbsp;)</b><p>VARARGS2<hr><a name="ftpXfer"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>ftpXfer</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>ftpXfer</i>(&nbsp;)</strong> - initiate a transfer via FTP</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS ftpXfer    (    char * host,      /* name of server host */    char * user,      /* user name for host login */    char * passwd,    /* password for host login */    char * acct,      /* account for host login */    char * cmd,       /* command to send to host */    char * dirname,   /* directory to <b>cd</b> to before sending command */    char * filename,  /* filename to send with command */    int *  pCtrlSock, /* where to return control socket fd */    int *  pDataSock  /* where to return data socket fd, (NULL == don't open */                      /* connection) */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine initiates a transfer via a remote FTP serverin the following order:<dl><dt>(1)<dd>Establishes a connection to the FTP server on the specified host.<p><dt>(2)<dd>Logs in with the specified user name, password, and account,as necessary for the particular host.<p><dt>(3)<dd>Sets the transfer type to image by sending the command "TYPE I".<p><dt>(4)<dd>Changes to the specified directory by sendingthe command "CWD <i>dirname</i>".<p><dt>(5)<dd> Sends the specified transfer commandwith the specified filename as an argument, and establishes a data connection.Typical transfer commands are "STOR %s", to write to a remote file,or "RETR %s", to read a remote file. </dl><p>The resulting control and data connection file descriptors are returnedvia <i>pCtrlSock</i> and <i>pDataSock</i>, respectively.<p>After calling this routine, the data can be read or written to the remoteserver by reading or writing on the file descriptor returned in<i>pDataSock</i>.  When all incoming data has been read (as indicated by an EOF when reading the data socket) and/or all outgoing data has beenwritten, the data socket fd should be closed.  The routine <b><i><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a></i>(&nbsp;)</b>should then be called to receive the final reply on the control socket,after which the control socket should be closed.<p>If the FTP command does not involve data transfer, <i>pDataSock</i> should be NULL, in which case no data connection will be established. The only FTP commands supported for this case are DELE, RMD, and MKD.<p></blockquote><h4>EXAMPLE</h4><blockquote><p>The following code fragment reads the file "/usr/fred/myfile" from thehost "server", logged in as user "fred", with password "magic"and no account name.<p><pre>    #include "vxWorks.h"    #include "ftpLib.h"    int       ctrlSock;    int       dataSock;    char      buf [512];    int       nBytes;    STATUS    status;    if (ftpXfer ("server", "fred", "magic", "",                 "RETR %s", "/usr/fred", "myfile",                 &amp;ctrlSock, &amp;dataSock) == ERROR)        return (ERROR);    while ((nBytes = read (dataSock, buf, sizeof (buf))) &gt; 0)        {        ...        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -