> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of HU Chengzhe
> Sent: Thursday, August 19, 2010 2:51 PM
> To: [email protected]
> Subject: About some FTP client functions by using libcurl
> 
> 
> Hello, 
> 
>       I'm planing to implement a ftp client using libcurl. 
> But when I try to implement some basic functions of ftp 
> client, I encounter some problems.
> 
>    
>    1) getRootPath(), this function should return ftp server 
> root path by absolute path format. my code as follow: 
> int main(void){ 
>        CURL *curl; 
>       CURLcode res; 

  FILE *fHeader = NULL;

  if ((fHeader = fopen("./headerFile", "w")) == NULL)
  {
        printf("can't open header file");
        return -1;
  }

>       curl_global_init(CURL_GLOBAL_DEFAULT); 
> 
>        curl = curl_easy_init(); 
>        if(curl) { 
>            curl_easy_setopt(curl, CURLOPT_URL, 
>                      "ftp://135.252.234.82 <ftp://135.252.234.82> "); 
>              //set username for transfer 
>                curl_easy_setopt(curl, CURLOPT_USERNAME, "hello"); 
> 
>                //set password for transfer 
>               curl_easy_setopt(curl, CURLOPT_PASSWORD, "hello"); 
> 
>               struct curl_slist *headerlist = NULL; 
>               const char s[] = "PWD"; 
>                headerlist = curl_slist_append(headerlist, s);    
>               curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist); 

curl_easy_setopt(curl, CURLOPT_WRITEHEADER, fHeader);

>               res = curl_easy_perform(curl); 
> 
>                /* always cleanup */ 
>               curl_easy_cleanup(curl); 
>               if(CURLE_OK != res) { 
>                    fprintf(stderr, "curl told us %d\n", res); 
>                } 
>          }
>   curl_global_cleanup();
> } 
> 
> expected result: print ftp server root path actual result: 
> list all flie and directory information which are under  ftp 
> server root path, just like this: 
> -r--r--r--   1 oamops   oamgroup    9539 Jul  9  2008 .alias_oam 
> -rw-------   1 oamops   oamgroup    1612 Aug  4 18:50 .bash_history 
> -r--r--r--   1 oamops   oamgroup    7815 Feb  3  2010 .cshrc 
> -r--r--r--   1 oamops   oamgroup    3268 Nov 19  2009 .cshrc.oamops 
> -rw-r-----   1 oamops   oamgroup    2309 Aug 18 14:33 .history 
> -rw-r--r--   1 oamops   oamgroup     157 Jul 19 15:43 .login 
> -rw-------   1 oamops   oamgroup   30860 Jul 26 10:59 .lsof_zsups382 
> -rw-r--r--   1 oamops   oamgroup     253 Jul 19 17:26 .profile 
> ......... 
> 
> so is there anyone can tell me why the result is like this? 
> If this way can't work, please tell me how to implement the 
> function of getRootPath().
> 
> 2)getNodeType(), this function should return a node type, it 
> may be file or directory. But until now, I have no idea about 
> implementing it.
> 
> Is there any API can be called? or other convenient way? The 
> worsest way seems need a complicated string parse function to 
> parse a string like this:
> 
> -rw-r--r--   1 oamops   oamgroup     253 Jul 19 17:26 .profile 
> 
> 3)getPermission(), this function should return the access 
> permission of a file or directory. 
> The difficulty is same as problem 2). Is there convenient way 
> to implement it? 
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to