src_CL/CL.cpp File Reference

#include "../include/CL.h"
#include "../include/command.h"
#include "../include/utility.h"
#include "../include/cond_comp.h"
#include <netdb.h>
#include <fcntl.h>
#include <arpa/inet.h>
#include <cstdlib>
#include <cstring>

Include dependency graph for CL.cpp:

Go to the source code of this file.

Functions

int send_end_command (int sock, string file_name, string CL_address)
 function to notify the end of transfer to the DFR
FS_info_structget_FS_info (const char *mes)
 response data parser
int transfer_file (int FS_sd, string file_name, string new_file_name, string CL_address)
 function to transfer a file from a FS
int main (int argc, char *argv[])


Function Documentation

FS_info_struct* get_FS_info ( const char *  mes  ) 

response data parser

when a clients asks for a file or asks for a notification, the DFR may allocate to the client the file it was looking for... in this case, in the response message, some info about how to reach the FS may be included in the response, and are transferred as a single string <FS_ip_address:FS_port> this function fills a FS_info_struct using the mes string passed as a parameter

Parameters:
mes | char array to parse
Returns:
the new FS_info_struct containing FS parameters (allocated dynamically) or NULL if some error was detected

Definition at line 37 of file CL.cpp.

References FS_info_struct::ip_address, and FS_info_struct::port.

Referenced by mode_1(), and mode_2().

int main ( int  argc,
char *  argv[] 
)

Definition at line 116 of file CL.cpp.

References DEB, init_sd_cli(), LOG, mode_1(), and mode_2().

int send_end_command ( int  sock,
string  file_name,
string  CL_address 
)

function to notify the end of transfer to the DFR

it is used to send the end_file_transfer command to the DFR after transfer completion.

Parameters:
sock | socket connected to the DFR
file_name | file to release
CL_address | address and port string identifying the caller
Returns:
0 on success, 1 on minor error, -1 on bad on error

Definition at line 13 of file CL.cpp.

References end_file_transfer, ERR_NO_TRANSFER, LOG, OK, and send_command().

Referenced by mode_1(), and mode_2().

int transfer_file ( int  FS_sd,
string  file_name,
string  new_file_name,
string  CL_address 
)

function to transfer a file from a FS

it is used to send a command to a FS to obtain a file it holds

Parameters:
FS_sd | working socket descriptor connected to the listening FS
file_name | name of the file on the FS that the caller wants to transfer
new_file_name | name of the new file created on the caller side after transfer
CL_address | address and port string identifying the caller
Returns:
0 on success, 1 on minor error, -1 on bad on error

Definition at line 62 of file CL.cpp.

References ERR_FILE_NOT_EXISTS, ERR_TOO_MANY_CLIENTS, get_file, LOG, OK, and send_command().

Referenced by mode_1(), and mode_2().


Generated on Sat Jun 13 21:06:30 2009 for DistributedFileRepository by  doxygen 1.5.8