| 1 |
ab11 |
1.1 |
#include <ftp.h> |
| 2 |
|
|
|
| 3 |
|
|
// sunos does not prototype this in stdio.h |
| 4 |
|
|
extern "C" char* getpass (char* prompt); |
| 5 |
|
|
|
| 6 |
|
|
int main (int ac, char** av) |
| 7 |
|
|
{ |
| 8 |
|
|
// this is an ftp client |
| 9 |
|
|
// It retrieves the file from the host |
| 10 |
|
|
if (ac != 4) { |
| 11 |
|
|
cerr << "USAGE: " << av [0] << " hostname user filename\n"; |
| 12 |
|
|
return 1; |
| 13 |
|
|
} |
| 14 |
|
|
|
| 15 |
|
|
ftp f (&cout); |
| 16 |
|
|
|
| 17 |
|
|
// establish connection |
| 18 |
|
|
f->connect (av [1]); |
| 19 |
|
|
f->get_response (); // get the connection response |
| 20 |
|
|
|
| 21 |
|
|
// set access |
| 22 |
|
|
f->user (av [2]); |
| 23 |
|
|
f->passwd (getpass ("passwd: ")); |
| 24 |
|
|
|
| 25 |
|
|
// get help |
| 26 |
|
|
f->help (); |
| 27 |
|
|
|
| 28 |
|
|
// set representation type to image |
| 29 |
|
|
f->rep_type (ftp::rt_image); |
| 30 |
|
|
|
| 31 |
|
|
// list the home directory |
| 32 |
|
|
f->list (); |
| 33 |
|
|
|
| 34 |
|
|
// quit |
| 35 |
|
|
f->quit (); |
| 36 |
|
|
} |
| 37 |
|
|
|