当前位置: 首页>>代码示例>>C++>>正文


C++ FtpSendCmd函数代码示例

本文整理汇总了C++中FtpSendCmd函数的典型用法代码示例。如果您正苦于以下问题:C++ FtpSendCmd函数的具体用法?C++ FtpSendCmd怎么用?C++ FtpSendCmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了FtpSendCmd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FtpOpenPort

static int FtpOpenPort(struct stream_priv_s* p) {
  int resp,fd;
  char rsp_txt[256];
  char* par,str[128];
  int num[6];

  resp = FtpSendCmd("PASV",p,rsp_txt);
  if(resp != 2) {
    mp_msg(MSGT_OPEN,MSGL_WARN, "[ftp] command 'PASV' failed: %s\n",rsp_txt);
    return 0;
  }
  
  par = strchr(rsp_txt,'(');
  
  if(!par || !par[0] || !par[1]) {
    mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] invalid server response: %s ??\n",rsp_txt);
    return 0;
  }

  sscanf(par+1,"%u,%u,%u,%u,%u,%u",&num[0],&num[1],&num[2],
	 &num[3],&num[4],&num[5]);
  snprintf(str,127,"%d.%d.%d.%d",num[0],num[1],num[2],num[3]);
  fd = connect2Server(str,(num[4]<<8)+num[5],0);

  if(fd < 0)
    mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] failed to create data connection\n");

  return fd;
}
开发者ID:batman52,项目名称:dingux-code,代码行数:29,代码来源:stream_ftp.c

示例2: FtpLogin

/*
 * FtpLogin - log in to remote server
 *
 * return 1 if logged in, 0 otherwise
 */
GLOBALDEF int FtpLogin(const char *user, const char *pass, netbuf *nControl)
{
	char tempbuf[64];

	if (((strlen(user) + 7) > sizeof(tempbuf)) ||
			((strlen(pass) + 7) > sizeof(tempbuf)))
		return 0;
	sprintf(tempbuf,"USER %s",user);
	if (!FtpSendCmd(tempbuf,'3',nControl))
	{
		if (nControl->response[0] == '2')
			return 1;
		return 0;
	}
	sprintf(tempbuf,"PASS %s",pass);
	return FtpSendCmd(tempbuf,'2',nControl);
}
开发者ID:vmiklos,项目名称:vmexam,代码行数:22,代码来源:ftplib.c

示例3: FtpQuit

/*
 * FtpQuit - disconnect from remote
 *
 * return 1 if successful, 0 otherwise
 */
GLOBALDEF void FtpQuit (netbuf *nControl) {
    if (nControl->dir != FTPLIB_CONTROL)
        return;
    FtpSendCmd("QUIT", '2', nControl);
    net_close(nControl->handle);
    free(nControl->buf);
    free(nControl);
}
开发者ID:MikhailTatsky,项目名称:SilkJS,代码行数:13,代码来源:ftplib.cpp

示例4: FtpRmdir

/*
 * FtpRmdir - remove directory at remote
 *
 * return 1 if successful, 0 otherwise
 */
GLOBALDEF int FtpRmdir (const char *path, netbuf *nControl) {
    char buf[256];

    if ((strlen(path) + 6) > sizeof (buf))
        return 0;
    sprintf(buf, "RMD %s", path);
    if (!FtpSendCmd(buf, '2', nControl))
        return 0;
    return 1;
}
开发者ID:MikhailTatsky,项目名称:SilkJS,代码行数:15,代码来源:ftplib.cpp

示例5: FtpDelete

/*
 * FtpDelete - delete a file at remote
 *
 * return 1 if successful, 0 otherwise
 */
GLOBALDEF int FtpDelete (const char *fnm, netbuf *nControl) {
    char cmd[256];

    if ((strlen(fnm) + 7) > sizeof (cmd))
        return 0;
    sprintf(cmd, "DELE %s", fnm);
    if (!FtpSendCmd(cmd, '2', nControl))
        return 0;
    return 1;
}
开发者ID:MikhailTatsky,项目名称:SilkJS,代码行数:15,代码来源:ftplib.cpp

示例6: FtpRestart

/*
 * FtpRestart - issue a REST command
 *
 * return 1 if successful, 0 otherwise
 */
GLOBALDEF int FtpRestart(int offset, netbuf *nControl)
{
	char cmd[256];
	int rv=1;

	sprintf(cmd,"REST %d",offset);
	if (!FtpSendCmd(cmd,'3',nControl))
		rv = 0;
	return rv;
}
开发者ID:vmiklos,项目名称:vmexam,代码行数:15,代码来源:ftplib.c

示例7: FtpSite

/*
 * FtpSite - send a SITE command
 *
 * return 1 if command successful, 0 otherwise
 */
GLOBALDEF int FtpSite (const char *cmd, netbuf *nControl) {
    char buf[256];

    if ((strlen(cmd) + 7) > sizeof (buf))
        return 0;
    sprintf(buf, "SITE %s", cmd);
    if (!FtpSendCmd(buf, '2', nControl))
        return 0;
    return 1;
}
开发者ID:MikhailTatsky,项目名称:SilkJS,代码行数:15,代码来源:ftplib.cpp

示例8: FtpSize

/*
 * FtpSize - determine the size of a remote file
 *
 * return 1 if successful, 0 otherwise
 */
GLOBALDEF int FtpSize (const char *path, int *size, char mode, netbuf *nControl) {
    char cmd[256];
    int resp, sz, rv = 1;

    if ((strlen(path) + 7) > sizeof (cmd))
        return 0;
    sprintf(cmd, "TYPE %c", mode);
    if (!FtpSendCmd(cmd, '2', nControl))
        return 0;
    sprintf(cmd, "SIZE %s", path);
    if (!FtpSendCmd(cmd, '2', nControl))
        rv = 0;
    else {
        if (sscanf(nControl->response, "%d %d", &resp, &sz) == 2)
            *size = sz;
        else
            rv = 0;
    }
    return rv;
}
开发者ID:MikhailTatsky,项目名称:SilkJS,代码行数:25,代码来源:ftplib.cpp

示例9: seek

static int seek(stream_t *s,off_t newpos) {
  struct stream_priv_s* p = s->priv;
  int resp;
  char rsp_txt[256];

  if(s->pos > s->end_pos) {
    s->eof=1;
    return 0;
  }

  // Check to see if the server did not already terminate the transfer
  if(fd_can_read(p->handle, 0)) {
    if(readresp(p,rsp_txt) != 2)
      mp_msg(MSGT_OPEN,MSGL_WARN, "[ftp] Warning the server didn't finished the transfer correctly: %s\n",rsp_txt);
    closesocket(s->fd);
    s->fd = -1;
  }

  // Close current download
  if(s->fd >= 0) {
    static const char pre_cmd[]={TELNET_IAC,TELNET_IP,TELNET_IAC,TELNET_SYNCH};
    //int fl;
    
    // First close the fd
    closesocket(s->fd);
    s->fd = 0;
    
    // Send send the telnet sequence needed to make the server react
    
    // Dunno if this is really needed, lftp have it. I let
    // it here in case it turn out to be needed on some other OS
    //fl=fcntl(p->handle,F_GETFL);
    //fcntl(p->handle,F_SETFL,fl&~O_NONBLOCK);

    // send only first byte as OOB due to OOB braindamage in many unices
    send(p->handle,pre_cmd,1,MSG_OOB);
    send(p->handle,pre_cmd+1,sizeof(pre_cmd)-1,0);
    
    //fcntl(p->handle,F_SETFL,fl);

    // Get the 426 Transfer aborted
    // Or the 226 Transfer complete
    resp = readresp(p,rsp_txt);
    if(resp != 4 && resp != 2) {
      mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] Server didn't abort correctly: %s\n",rsp_txt);
      s->eof = 1;
      return 0;
    }
    // Send the ABOR command
    // Ignore the return code as sometimes it fail with "nothing to abort"
    FtpSendCmd("ABOR",p,rsp_txt);
  }
  return FtpOpenData(s,newpos);
}
开发者ID:batman52,项目名称:dingux-code,代码行数:54,代码来源:stream_ftp.c

示例10: FtpSysType

/*
 * FtpSysType - send a SYST command
 *
 * Fills in the user buffer with the remote system type.  If more
 * information from the response is required, the user can parse
 * it out of the response buffer returned by FtpLastResponse().
 *
 * return 1 if command successful, 0 otherwise
 */
GLOBALDEF int FtpSysType (char *buf, int max, netbuf *nControl) {
    int l = max;
    char *b = buf;
    char *s;
    if (!FtpSendCmd("SYST", '2', nControl))
        return 0;
    s = &nControl->response[4];
    while ((--l) && (*s != ' '))
        *b++ = *s++;
    *b++ = '\0';
    return 1;
}
开发者ID:MikhailTatsky,项目名称:SilkJS,代码行数:21,代码来源:ftplib.cpp

示例11: FtpModDate

/*
 * FtpModDate - determine the modification date of a remote file
 *
 * return 1 if successful, 0 otherwise
 */
GLOBALDEF int FtpModDate (const char *path, char *dt, int max, netbuf *nControl) {
    char buf[256];
    int rv = 1;

    if ((strlen(path) + 7) > sizeof (buf))
        return 0;
    sprintf(buf, "MDTM %s", path);
    if (!FtpSendCmd(buf, '2', nControl))
        rv = 0;
    else
        strncpy(dt, &nControl->response[4], max);
    return rv;
}
开发者ID:MikhailTatsky,项目名称:SilkJS,代码行数:18,代码来源:ftplib.cpp

示例12: FtpPwd

/*
 * FtpPwd - get working directory at remote
 *
 * return 1 if successful, 0 otherwise
 */
GLOBALDEF int FtpPwd (char *path, int max, netbuf *nControl) {
    int l = max;
    char *b = path;
    char *s;
    if (!FtpSendCmd("PWD", '2', nControl))
        return 0;
    s = strchr(nControl->response, '"');
    if (s == NULL)
        return 0;
    s++;
    while ((--l) && (*s) && (*s != '"'))
        *b++ = *s++;
    *b++ = '\0';
    return 1;
}
开发者ID:MikhailTatsky,项目名称:SilkJS,代码行数:20,代码来源:ftplib.cpp

示例13: close_f

static void close_f(stream_t *s) {
  struct stream_priv_s* p = s->priv;

  if(!p) return;

  if(s->fd > 0) {
    closesocket(s->fd);
    s->fd = 0;
  }

  FtpSendCmd("QUIT",p,NULL);

  if(p->handle) closesocket(p->handle);
  if(p->buf) free(p->buf);

  m_struct_free(&stream_opts,p);
}
开发者ID:batman52,项目名称:dingux-code,代码行数:17,代码来源:stream_ftp.c

示例14: FtpSendCmd

static int FtpSendCmd(const char *cmd, struct stream_priv_s *nControl,char* rsp)
{
  int l = strlen(cmd);
  int hascrlf = cmd[l - 2] == '\r' && cmd[l - 1] == '\n';

  if(hascrlf && l == 2) mp_msg(MSGT_STREAM,MSGL_V, "\n");
  else mp_msg(MSGT_STREAM,MSGL_V, "[ftp] > %s",cmd);
  while(l > 0) {
    int s = send(nControl->handle,cmd,l,0);

    if(s <= 0) {
      mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] write error: %s\n",strerror(errno));
      return 0;
    }
    
    cmd += s;
    l -= s;
  }
    
  if (hascrlf)  
    return readresp(nControl,rsp);
  else
    return FtpSendCmd("\r\n", nControl, rsp);
}
开发者ID:batman52,项目名称:dingux-code,代码行数:24,代码来源:stream_ftp.c

示例15: FtpAccess

/*
 * FtpAccess - return a handle for a data stream
 *
 * return 1 if successful, 0 otherwise
 */
GLOBALDEF int FtpAccess(const char *path, int typ, int mode, netbuf *nControl,
		netbuf **nData)
{
	char buf[256];
	int dir;
	if ((path == NULL) &&
			((typ == FTPLIB_FILE_WRITE) || (typ == FTPLIB_FILE_READ)))
	{
		sprintf(nControl->response,
				"Missing path argument for file transfer\n");
		return 0;
	}
	sprintf(buf, "TYPE %c", mode);
	if (!FtpSendCmd(buf, '2', nControl))
		return 0;
	switch (typ)
	{
		case FTPLIB_DIR:
			strcpy(buf,"NLST");
			dir = FTPLIB_READ;
			break;
		case FTPLIB_DIR_VERBOSE:
			strcpy(buf,"LIST");
			dir = FTPLIB_READ;
			break;
		case FTPLIB_FILE_READ:
			strcpy(buf,"RETR");
			dir = FTPLIB_READ;
			break;
		case FTPLIB_FILE_WRITE:
			strcpy(buf,"STOR");
			dir = FTPLIB_WRITE;
			break;
		default:
			sprintf(nControl->response, "Invalid open type %d\n", typ);
			return 0;
	}
	if (path != NULL)
	{
		int i = strlen(buf);
		buf[i++] = ' ';
		if ((strlen(path) + i) >= sizeof(buf))
			return 0;
		strcpy(&buf[i],path);
	}
	if (FtpOpenPort(nControl, nData, mode, dir) == -1)
		return 0;
	if (!FtpSendCmd(buf, '1', nControl))
	{
		FtpClose(*nData);
		*nData = NULL;
		return 0;
	}
	(*nData)->ctrl = nControl;
	nControl->data = *nData;
	if (nControl->cmode == FTPLIB_PORT)
	{
		if (!FtpAcceptConnection(*nData,nControl))
		{
			FtpClose(*nData);
			*nData = NULL;
			nControl->data = NULL;
			return 0;
		}
	}
	return 1;
}
开发者ID:vmiklos,项目名称:vmexam,代码行数:72,代码来源:ftplib.c


注:本文中的FtpSendCmd函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。