33 #define MULTI_XFER_VERBOSE // keep this defined for verbose debug output
35 #define MULTI_XFER_INVALID_HANDLE(handle) ( (handle < 0) || (handle > (MAX_XFER_ENTRIES-1)) || !(Multi_xfer_entry[handle].flags & MULTI_XFER_FLAG_USED) || (strlen(Multi_xfer_entry[handle].filename) <= 0) )
38 #define MULTI_XFER_CODE_ACK 0 // simple response to the last request
39 #define MULTI_XFER_CODE_NAK 1 // simple response to the last request
40 #define MULTI_XFER_CODE_HEADER 2 // file xfer header information follows, requires a HEADER_RESPONSE
41 #define MULTI_XFER_CODE_DATA 3 // data block follows, requires an ack
42 #define MULTI_XFER_CODE_FINAL 4 // indication from sender that xfer is complete, requires an ack
45 #define MULTI_XFER_FLAG_USED (1<<0) // this entry is in use
46 #define MULTI_XFER_FLAG_SEND (1<<1) // this entry is sending a file
47 #define MULTI_XFER_FLAG_RECV (1<<2) // this entry is receiving a file
48 #define MULTI_XFER_FLAG_PENDING (1<<3) // this entry is ready to send a header and start the process
49 #define MULTI_XFER_FLAG_WAIT_ACK (1<<4) // waiting for an ack/nak
50 #define MULTI_XFER_FLAG_WAIT_DATA (1<<5) // waiting for another block of data
51 #define MULTI_XFER_FLAG_UNKNOWN (1<<6) // xfer final has been sent, and we are waiting for a response
52 #define MULTI_XFER_FLAG_SUCCESS (1<<7) // finished xfer
53 #define MULTI_XFER_FLAG_FAIL (1<<8) // xfer failed
54 #define MULTI_XFER_FLAG_TIMEOUT (1<<9) // xfer has timed-out
55 #define MULTI_XFER_FLAG_QUEUE_CURRENT (1<<10) // for a set of XFER_FLAG_QUEUE'd files, this is the current one sending
58 #define MULTI_XFER_MAX_DATA_SIZE 490 // this will keep us within the MULTI_XFER_MAX_SIZE_LIMIT
61 #define MULTI_XFER_TIMEOUT 10000
66 #define MULTI_XFER_FNAME_PREFIX "_fsx_"
71 #define MAX_XFER_ENTRIES 60 // the max allowed file xfer entries
197 memset(Multi_xfer_entry,0,
sizeof(
xfer_entry) * MAX_XFER_ENTRIES);
224 temp_entry.
file = NULL;
226 if(temp_entry.
file == NULL){
227 #ifdef MULTI_XFER_VERBOSE
228 nprintf((
"Network",
"MULTI XFER : Could not open file %s on xfer send!\n",filename));
238 #ifdef MULTI_XFER_VERBOSE
239 nprintf((
"Network",
"MULTI XFER : Could not get file length for file %s on xfer send\n",filename));
247 #ifdef MULTI_XFER_VERBOSE
248 nprintf((
"Network",
"MULTI XFER : Could not get file checksum for file %s on xfer send\n",filename));
252 #ifdef MULTI_XFER_VERBOSE
269 memset(&Multi_xfer_entry[handle],0,
sizeof(
xfer_entry));
270 memcpy(&Multi_xfer_entry[handle],&temp_entry,
sizeof(
xfer_entry));
318 xe = &Multi_xfer_entry[handle];
321 if(xe->
file != NULL){
349 xe = &Multi_xfer_entry[handle];
352 if(xe->
file != NULL){
378 return Multi_xfer_entry[handle].
filename;
409 Multi_xfer_entry[handle].
force_dir = cf_type;
434 return Multi_xfer_entry[handle].
flags;
443 if((filename == NULL) || (strlen(filename) <= 0)){
468 if(Multi_xfer_entry[handle].file_size == 0){
473 return (
float)Multi_xfer_entry[handle].
file_ptr / (
float)Multi_xfer_entry[handle].file_size;
495 return Multi_xfer_entry[handle].
force_dir;
522 xe_c = &Multi_xfer_entry[
idx];
538 #ifdef MULTI_XFER_VERBOSE
539 nprintf((
"Network",
"MULTI_XFER : Starting xfer send for queued entry %s\n", xe->
filename));
592 if((Multi_xfer_entry[idx].file_socket == who) && (Multi_xfer_entry[idx].sig == sig)){
593 return &Multi_xfer_entry[
idx];
608 if(xe->
file != NULL){
661 ubyte xfer_data[600];
672 memcpy(xfer_data, data + offset, data_size);
709 #ifdef MULTI_XFER_VERBOSE
710 nprintf((
"Network",
"MULTI XFER : Could not find xfer entry for incoming data!\n"));
715 ml_string(
"MULTI XFER : Could not find xfer entry for incoming data :");
778 #ifdef MULTI_XFER_VERBOSE
779 nprintf((
"Network",
"MULTI XFER : Successfully sent file %s\n", xe->
filename));
810 if(xe->
file != NULL){
822 #ifdef MULTI_XFER_VERBOSE
832 #ifdef MULTI_XFER_VERBOSE
847 nprintf((
"Network",
"FAILED TO TRANSFER FILE (could not rename temp file %s)\n", xe->
ex_filename));
909 xe = &Multi_xfer_entry[handle];
934 #ifdef MULTI_XFER_VERBOSE
961 if(xe->
file == NULL){
975 #ifdef MULTI_XFER_VERBOSE
1031 if(
cfread(data+packet_size,1,(
int)data_size,xe->
file) == 0){
1041 packet_size += (
int)data_size;
1152 strcpy(ex_filename, temp);
#define MULTI_XFER_CODE_NAK
int timestamp(int delta_ms)
int multi_xfer_process_packet(unsigned char *data, PSNET_SOCKET_RELIABLE who)
#define MULTI_XFER_FLAG_UNKNOWN
int cf_delete(const char *filename, int path_type)
Delete the specified file.
int cfread(void *buf, int elsize, int nelem, CFILE *fp)
#define MULTI_XFER_CODE_DATA
char * multi_xfer_get_filename(int handle)
void multi_xfer_process_header(ubyte *data, PSNET_SOCKET_RELIABLE who, ushort sig, char *filename, int file_size, ushort file_checksum)
uint PSNET_SOCKET_RELIABLE
#define MULTI_XFER_FLAG_QUEUE
void(* Multi_xfer_recv_notify)(int handle)
void multi_xfer_process_ack(xfer_entry *xe)
void multi_xfer_process_nak(xfer_entry *xe)
void ml_string(const char *string, int add_time)
ushort multi_xfer_get_sig()
int multi_xfer_lookup(char *filename)
char ex_filename[MAX_FILENAME_LEN+10]
int psnet_rel_send(PSNET_SOCKET_RELIABLE socketid, ubyte *data, int length, int np_index)
float multi_xfer_pct_complete(int handle)
#define MULTI_XFER_FNAME_PREFIX
#define MULTI_XFER_FLAG_SEND
#define MULTI_XFER_FLAG_RECV
void multi_xfer_fail_entry(xfer_entry *xe)
void multi_xfer_force_dir(int cf_type)
#define CF_TYPE_MULTI_CACHE
#define MULTI_XFER_FLAG_AUTODESTROY
void multi_xfer_send_ack(PSNET_SOCKET_RELIABLE socket, ushort sig)
int multi_xfer_get_status(int handle)
void multi_xfer_conv_prefix(char *filename, char *ex_filename)
#define MULTI_XFER_FLAG_USED
#define MULTI_XFER_CODE_FINAL
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
#define MULTI_XFER_INVALID_HANDLE(handle)
void ml_printf(const char *format,...)
#define MULTI_XFER_QUEUED
void multi_xfer_eval_entry(xfer_entry *xe)
#define MULTI_XFER_MAX_DATA_SIZE
void multi_xfer_handle_force_dir(int handle, int cf_type)
#define MULTI_XFER_CODE_ACK
#define MULTI_XFER_TIMEDOUT
void multi_xfer_xor_flags(int handle, int flags)
#define MULTI_XFER_FLAG_REJECT
int multi_xfer_send_file(PSNET_SOCKET_RELIABLE who, char *filename, int cfile_flags, int flags)
int cf_rename(const char *old_name, const char *name, int dir_type)
int cfwrite(const void *buf, int elsize, int nelem, CFILE *cfile)
void multi_xfer_process_final(xfer_entry *xe)
#define MULTI_XFER_IN_PROGRESS
#define MULTI_XFER_CODE_HEADER
void multi_xfer_send_next(xfer_entry *xe)
#define MULTI_XFER_FLAG_PENDING
void multi_xfer_init(void(*multi_xfer_recv_callback)(int handle))
void multi_xfer_release_handle(int handle)
char filename[MAX_FILENAME_LEN+1]
int cf_chksum_short(const char *filename, ushort *chksum, int max_size, int cf_type)
typedef void(APIENTRY *PFNGLARRAYELEMENTEXTPROC)(GLint i)
void multi_xfer_send_nak(PSNET_SOCKET_RELIABLE socket, ushort sig)
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
void multi_xfer_process_data(xfer_entry *xe, ubyte *data, int data_size)
#define MULTI_XFER_TIMEOUT
#define MULTI_XFER_FLAG_TIMEOUT
#define MULTI_XFER_FLAG_QUEUE_CURRENT
#define MULTI_XFER_FLAG_SUCCESS
struct xfer_entry xfer_entry
int multi_xfer_get_force_dir(int handle)
PSNET_SOCKET_RELIABLE file_socket
int multi_xfer_get_flags(int handle)
GLenum GLsizei GLenum GLenum const GLvoid * data
#define timestamp_elapsed(stamp)
uint multi_xfer_get_sock(int handle)
#define MULTI_XFER_FLAG_WAIT_ACK
int find_player_socket(PSNET_SOCKET_RELIABLE sock)
int multi_xfer_get_free_handle()
void multi_xfer_send_final(xfer_entry *xe)
xfer_entry * multi_xfer_find_entry(PSNET_SOCKET_RELIABLE who, ushort sig, int sender_side)
int cfclose(CFILE *cfile)
#define MULTI_XFER_FLAG_WAIT_DATA
net_player Net_players[MAX_PLAYERS]
xfer_entry Multi_xfer_entry[MAX_XFER_ENTRIES]
void multi_xfer_send_header(xfer_entry *xe)
#define MULTI_XFER_FLAG_FAIL
#define MULTI_XFER_SUCCESS
int cfilelength(CFILE *cfile)
#define CF_RENAME_SUCCESS
int cfseek(CFILE *fp, int offset, int where)
void multi_xfer_abort(int handle)