FS2_Open
Open source remastering of the Freespace 2 engine
multi_xfer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #ifndef _FREESPACE_FILE_TRANSFER_HEADER
13 #define _FREESPACE_FILE_TRANSFER_HEADER
14 
15 // ------------------------------------------------------------------------------------------
16 // MULTI XFER DEFINES/VARS
17 //
18 #include "globalincs/pstypes.h"
19 
21 
22 // status codes for transfers
23 #define MULTI_XFER_NONE -1 // nothing is happening - this is an invalid handle
24 #define MULTI_XFER_SUCCESS 0 // the xfer has successfully transferred
25 #define MULTI_XFER_FAIL 1 // the xfer has failed for one reason or another
26 #define MULTI_XFER_UNKNOWN 2 // the xfer has finished but its unknown if it was successful - wait a while longer
27 #define MULTI_XFER_TIMEDOUT 3 // the xfer has timed-out during some stage of the process
28 #define MULTI_XFER_IN_PROGRESS 4 // the xfer is in progress
29 #define MULTI_XFER_QUEUED 5 // queued up - hasn't started yet
30 
31 #define MULTI_XFER_FLAG_AUTODESTROY (1<<15) // automatically clear and free an xfer handle that is done
32 #define MULTI_XFER_FLAG_REJECT (1<<16) // set by the receive callback function if we want to disallow xfer of this file
33 // if this flag is set, the system will only xfer one file at a time to a given destination.
34 // so, suppose you start sending 3 files to one target, all which have this flag set. Only the first file will send.
35 // Once it is complete, the second one will go. Then the third. This is extremely useful for files where you don't
36 // _really_ care if it arrives or not (eg - sending multiple pilot pics or sounds or squad logos, etc). If you _do_
37 // care about the file (eg - mission files), you probably shouldn't be using this flag
38 #define MULTI_XFER_FLAG_QUEUE (1<<17)
39 
40 // the xfer system is guaranteed never to spew data larger than this
41 #define MULTI_XFER_MAX_SIZE 500
42 
43 // ------------------------------------------------------------------------------------------
44 // MULTI XFER FUNCTIONS
45 //
46 
47 // initialize all file xfer transaction stuff, call in multi_level_init()
48 void multi_xfer_init(void (*multi_xfer_recv_callback)(int handle));
49 
50 // do frame for all file xfers, call in multi_do_frame()
51 void multi_xfer_do();
52 
53 // reset the xfer system, including shutting down/killing all active xfers
54 void multi_xfer_reset();
55 
56 // send a file to the specified player, return a handle
57 int multi_xfer_send_file(PSNET_SOCKET_RELIABLE who, char *filename, int cfile_flags, int flags = 0);
58 
59 // get the status of the current file xfer
60 int multi_xfer_get_status(int handle);
61 
62 // abort a transferring file
63 void multi_xfer_abort(int handle);
64 
65 // release an xfer handle
66 void multi_xfer_release_handle(int handle);
67 
68 // get the filename of the xfer for the given handle
69 char *multi_xfer_get_filename(int handle);
70 
71 // lock the xfer system (don't accept incoming files, don't allow outgoing files)
72 void multi_xfer_lock();
73 
74 // unlock the xfer system
75 void multi_xfer_unlock();
76 
77 // force all receives to go into the specified directory by cfile type
78 void multi_xfer_force_dir(int cf_type);
79 
80 // forces the given xfer entry to the specified directory type (only valid when called from the recv_callback function)
81 void multi_xfer_handle_force_dir(int handle,int cf_type);
82 
83 // xor the flag on a given entry
84 void multi_xfer_xor_flags(int handle,int flags);
85 
86 // get the flags for a given entry
87 int multi_xfer_get_flags(int handle);
88 
89 // if the passed filename is being xferred, return the xfer handle, otherwise return -1
90 int multi_xfer_lookup(char *filename);
91 
92 // get the % of completion of the passed file handle, return < 0 if invalid
93 float multi_xfer_pct_complete(int handle);
94 
95 // get the socket of the file xfer (useful for identifying players)
96 uint multi_xfer_get_sock(int handle);
97 
98 // get the CF_TYPE of the directory this file is going to
99 int multi_xfer_get_force_dir(int handle);
100 
101 // ------------------------------------------------------------------------------------------
102 // MULTI XFER PACKET HANDLERS
103 //
104 
105 // process an incoming file xfer data packet, return bytes processed, guaranteed to process the entire
106 // packet regardless of error conditions
107 int multi_xfer_process_packet(unsigned char *data, PSNET_SOCKET_RELIABLE who);
108 
109 #endif
uint PSNET_SOCKET_RELIABLE
Definition: multi_xfer.h:20
void multi_xfer_handle_force_dir(int handle, int cf_type)
Definition: multi_xfer.cpp:401
int multi_xfer_get_flags(int handle)
Definition: multi_xfer.cpp:426
int multi_xfer_send_file(PSNET_SOCKET_RELIABLE who, char *filename, int cfile_flags, int flags=0)
Definition: multi_xfer.cpp:201
void multi_xfer_release_handle(int handle)
Definition: multi_xfer.cpp:339
void multi_xfer_lock()
Definition: multi_xfer.cpp:382
float multi_xfer_pct_complete(int handle)
Definition: multi_xfer.cpp:460
void multi_xfer_force_dir(int cf_type)
Definition: multi_xfer.cpp:394
unsigned int uint
Definition: pstypes.h:64
char * filename
uint multi_xfer_get_sock(int handle)
Definition: multi_xfer.cpp:477
void multi_xfer_unlock()
Definition: multi_xfer.cpp:388
int multi_xfer_get_status(int handle)
Definition: multi_xfer.cpp:276
int multi_xfer_lookup(char *filename)
Definition: multi_xfer.cpp:438
GLbitfield flags
Definition: Glext.h:6722
void multi_xfer_abort(int handle)
Definition: multi_xfer.cpp:308
GLenum GLsizei GLenum GLenum const GLvoid * data
Definition: Gl.h:1509
void multi_xfer_do()
Definition: multi_xfer.cpp:170
int multi_xfer_get_force_dir(int handle)
Definition: multi_xfer.cpp:488
void multi_xfer_reset()
Definition: multi_xfer.cpp:185
int multi_xfer_process_packet(unsigned char *data, PSNET_SOCKET_RELIABLE who)
Definition: multi_xfer.cpp:652
char * multi_xfer_get_filename(int handle)
Definition: multi_xfer.cpp:370
void multi_xfer_init(void(*multi_xfer_recv_callback)(int handle))
Definition: multi_xfer.cpp:154
void multi_xfer_xor_flags(int handle, int flags)
Definition: multi_xfer.cpp:414