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