|
1 /* |
|
2 * ftp.x: FTP Protocol specification for remote file fetching |
|
3 */ |
|
4 |
|
5 const MAXLEN = 1024; |
|
6 |
|
7 /* |
|
8 * Type for storing path |
|
9 */ |
|
10 typedef string filename<MAXLEN>; |
|
11 |
|
12 /* |
|
13 * Structure for sending request. Expects the path of the file |
|
14 * and the byte number at which to start reading the file from |
|
15 */ |
|
16 struct request { |
|
17 filename name; |
|
18 int start; |
|
19 }; |
|
20 |
|
21 /* |
|
22 * Type that represents the structute for request |
|
23 */ |
|
24 typedef struct request request; |
|
25 |
|
26 /* |
|
27 * Type for storing a chunk of the file that is being |
|
28 * sent from the server to the client in the current |
|
29 * remote procedure call |
|
30 */ |
|
31 typedef int filechunk<MAXLEN>; |
|
32 |
|
33 /* |
|
34 * Response sent by the server to the client as a response |
|
35 * to remote procedure call, containing the filechunk for |
|
36 * the current call and number of bytes actually read |
|
37 */ |
|
38 struct chunkreceive { |
|
39 filechunk data; |
|
40 int bytes; |
|
41 }; |
|
42 |
|
43 /* |
|
44 * Type that represents the structure for file's chunks |
|
45 * to be received from the server |
|
46 */ |
|
47 typedef struct chunkreceive chunkreceive; |
|
48 |
|
49 /* |
|
50 * File data sent by the server from client to store |
|
51 * it on the server along with the filename and the |
|
52 * number of bytes in the data |
|
53 */ |
|
54 struct chunksend { |
|
55 filename name; |
|
56 filechunk data; |
|
57 int bytes; |
|
58 }; |
|
59 |
|
60 /* |
|
61 * Type that represents the structure for file's chunks |
|
62 * to be sent to the server |
|
63 */ |
|
64 typedef struct chunksend chunksend; |
|
65 |
|
66 /* |
|
67 * union for returning from remote procedure call, returns |
|
68 * the proper chunkdata response if everything worked fine |
|
69 * or will return the error number if an error occured |
|
70 */ |
|
71 union readfile_res switch (int errno) { |
|
72 case 0: |
|
73 chunkreceive chunk; |
|
74 default: |
|
75 void; |
|
76 }; |
|
77 |
|
78 /* |
|
79 * Remote procedure defined in the Interface Definition Language |
|
80 * of SUN RPC, contains PROGRAM and VERSION name definitions and |
|
81 * the remote procedure signature |
|
82 */ |
|
83 program FTPPROG { |
|
84 version FTPVER { |
|
85 readfile_res retrieve_file(request *) = 1; |
|
86 int send_file(chunksend *) = 2; |
|
87 } = 1; |
|
88 } = 0x20000011; |
|
89 |