00001
00002
00003 #ifndef COMMAND_
00004 #define COMMAND_
00005 #include <string>
00006
00007 using namespace std;
00008
00010
00020
00021
00023 #define register_file 1
00025 #define unregister_file 2
00027 #define start_file_transfer 3
00029 #define end_file_transfer 4
00031 #define reg_notification 5
00033 #define notify 6
00035 #define get_file 7
00036
00037
00038
00040 #define OK 11
00042 #define ERR_FILE_NOT_REGISTERED 12
00044 #define ERR_TOO_MANY_CLIENTS 13
00046 #define ERR_FILE_NOT_EXISTS 14
00048 #define ERR_NO_TRANSFER 15
00050 #define ERR_NO_NOTIFICATION 16
00052 #define ERR_UNKNOWN 17
00053
00055 #define INT_AS_STRING_BYTES 11
00056
00058
00072 class command {
00073 public:
00075
00084 int id;
00085
00087
00090 string file_name;
00091
00093
00095 int max_clients;
00096
00098
00100 int port;
00101
00103
00104 command();
00105
00107
00110 command(int id, const char* file_name, int max_clients = 0, int port = 0);
00111
00113
00124 char* to_string();
00125
00127
00137 int fill_from_string(const char* s);
00138
00140
00144 friend int send_command(int sock, command com, int* rep_data_size, char** rep_data);
00145
00147
00151 friend int receive_command(int sock, command* com);
00152 };
00153
00155
00184 int send_command(int sock, command com, int* rep_data_size, char** rep_data);
00185
00187
00197 int receive_command(int sock, command* com);
00198
00200
00227 int reply_command(int sock, int status, int add_bytes, const char* add_data);
00228
00230
00251 int receive_sft_reply(int sock, int* rep_data_size, char** rep_data);
00252
00253 #endif