2004-08-23 01:40:25 +00:00
# ifndef IWEB_H__
# define IWEB_H__
2017-05-28 15:42:32 +00:00
qboolean SV_AllowDownload ( const char * name ) ;
# if defined(WEBSERVER) || defined(FTPSERVER)
2004-08-23 01:40:25 +00:00
# ifdef WEBSVONLY
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
//When running standalone
2004-08-23 01:40:25 +00:00
# define Con_TPrintf IWebPrintf
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
void VARGS IWebDPrintf ( char * fmt , . . . ) LIKEPRINTF ( 1 ) ;
2004-08-23 01:40:25 +00:00
# define IWebPrintf printf
# define com_gamedir "." //current dir.
# define IWebMalloc(x) calloc(x, 1)
# define IWebRealloc(x, y) realloc(x, y)
# define IWebFree free
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
# else
//Inside FTE
# define IWebDPrintf Con_DPrintf
# define IWebPrintf Con_Printf
# define IWebMalloc Z_Malloc
# define IWebRealloc BZF_Realloc
# define IWebFree Z_Free
void VARGS IWebWarnPrintf ( char * fmt , . . . ) LIKEPRINTF ( 1 ) ;
2009-11-04 21:16:50 +00:00
# endif
2004-08-23 01:40:25 +00:00
# define IWEBACC_READ 1
# define IWEBACC_WRITE 2
# define IWEBACC_FULL 4
struct sockaddr_in ;
struct sockaddr ;
struct sockaddr_qstorage ;
2005-11-30 01:20:53 +00:00
int NetadrToSockadr ( netadr_t * a , struct sockaddr_qstorage * s ) ;
2004-08-23 01:40:25 +00:00
2024-09-13 18:15:15 +00:00
# if defined(__unix__) && !defined(__CYGWIN__)
# include <sys/epoll.h>
# endif
2004-08-23 01:40:25 +00:00
typedef qboolean iwboolean ;
typedef struct {
float gentime ; //useful for generating a new file (if too old, removes reference)
int references ; //freed if 0
char * data ;
int len ;
} IWeb_FileGen_t ;
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
int IWebAuthorize ( const char * name , const char * password ) ;
iwboolean IWebAllowUpLoad ( const char * fname , const char * uname ) ;
2004-08-23 01:40:25 +00:00
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
vfsfile_t * IWebGenerateFile ( const char * name , const char * content , int contentlength ) ;
int IWebGetSafeListeningPort ( void ) ;
2004-08-23 01:40:25 +00:00
2015-01-07 13:34:05 +00:00
//char *COM_ParseOut (const char *data, char *out, int outlen);
2013-03-31 04:21:08 +00:00
//struct searchpath_s;
//void COM_EnumerateFiles (const char *match, int (*func)(const char *, int, void *, struct searchpath_s *), void *parm);
2004-08-23 01:40:25 +00:00
2009-04-01 22:03:56 +00:00
char * Q_strcpyline ( char * out , const char * in , int maxlen ) ;
2004-08-23 01:40:25 +00:00
//server tick/control functions
2007-09-17 20:35:39 +00:00
iwboolean FTP_ServerRun ( iwboolean ftpserverwanted , int port ) ;
2021-06-01 09:23:49 +00:00
qboolean HTTP_ServerInit ( int epfd , int port ) ;
2004-08-23 01:40:25 +00:00
//server interface called from main server routines.
void IWebInit ( void ) ;
void IWebRun ( void ) ;
void IWebShutdown ( void ) ;
2010-03-14 14:35:56 +00:00
/*
qboolean FTP_Client_Command ( char * cmd , void ( * NotifyFunction ) ( vfsfile_t * file , char * localfile , qboolean sucess ) ) ;
2004-08-23 01:40:25 +00:00
void IRC_Command ( char * imsg ) ;
void FTP_ClientThink ( void ) ;
void IRC_Frame ( void ) ;
2010-03-14 14:35:56 +00:00
*/
2004-08-23 01:40:25 +00:00
qboolean SV_POP3 ( qboolean activewanted ) ;
qboolean SV_SMTP ( qboolean activewanted ) ;
# endif
2010-03-14 14:35:56 +00:00
# if 1
struct dl_download
{
/*not used by anything in the download itself, useful for context*/
unsigned int user_num ;
2014-12-31 06:00:55 +00:00
float user_float ;
2010-03-14 14:35:56 +00:00
void * user_ctx ;
2015-07-01 23:15:25 +00:00
int user_sequence ;
2015-04-21 04:12:00 +00:00
qboolean isquery ; //will not be displayed in the download/progress bar stuff.
2010-03-14 14:35:56 +00:00
2018-11-19 06:37:25 +00:00
# ifdef HAVE_CLIENT
2014-06-12 23:08:42 +00:00
qdownload_t qdownload ;
2015-05-16 15:51:39 +00:00
# endif
2014-06-12 23:08:42 +00:00
2010-03-14 14:35:56 +00:00
/*stream config*/
2014-09-08 23:47:19 +00:00
char * url ; /*original url*/
2010-03-14 14:35:56 +00:00
char redir [ MAX_OSPATH ] ; /*current redirected url*/
2023-01-09 05:13:39 +00:00
unsigned int redircount ; /* so no infinite redirects with naughty servers.*/
2013-06-23 02:17:02 +00:00
char localname [ MAX_OSPATH ] ; /*leave empty for a temp file*/
2018-09-23 19:35:24 +00:00
enum fs_relative fsroot ;
2013-06-23 02:17:02 +00:00
struct vfsfile_s * file ; /*downloaded to, if not already set when starting will open localname or a temp file*/
2010-03-14 14:35:56 +00:00
2013-10-08 14:28:11 +00:00
char postmimetype [ 64 ] ;
char * postdata ; /*if set, this is a post and not a get*/
size_t postlen ;
2010-03-14 14:35:56 +00:00
/*stream status*/
enum
{
DL_PENDING , /*not started*/
DL_FAILED , /*gave up*/
DL_RESOLVING , /*resolving the host*/
DL_QUERY , /*sent query, waiting for response*/
DL_ACTIVE , /*receiving data*/
DL_FINISHED /*its complete*/
} status ;
2016-07-12 00:40:13 +00:00
unsigned int replycode ;
size_t totalsize ; /*max size (can be 0 for unknown)*/
size_t completed ; /*ammount correctly received so far*/
size_t sizelimit ;
2010-03-14 14:35:56 +00:00
/*internals*/
# ifdef MULTITHREAD
2016-07-12 00:40:13 +00:00
qboolean threadenable ;
2010-03-14 14:35:56 +00:00
void * threadctx ;
# endif
void * ctx ; /*internal context, depending on http/ftp/etc protocol*/
void ( * abort ) ( struct dl_download * ) ; /*cleans up the internal context*/
2013-06-23 02:17:02 +00:00
qboolean ( * poll ) ( struct dl_download * ) ;
/*not used internally by the backend, but used by HTTP_CL_Get/thread wrapper*/
struct dl_download * next ;
2015-05-14 03:06:58 +00:00
qboolean ( * notifystarted ) ( struct dl_download * dl , char * mimetype ) ; //mime can be null for some protocols, read dl->totalsize for size. false if the mime just isn't acceptable.
2023-03-27 17:19:00 +00:00
void ( * notifycomplete ) ( struct dl_download * dl ) ; //lets the requester know that the download context is complete and the handle is no longer valid.
2010-03-14 14:35:56 +00:00
} ;
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
vfsfile_t * VFSPIPE_Open ( int refs , qboolean seekable ) ; //refs should be 1 or 2, to say how many times it must be closed before its actually closed, so both ends can close separately
2021-07-17 15:11:35 +00:00
vfsfile_t * VFS_OpenPipeCallback ( void ( * callback ) ( void * ctx , vfsfile_t * file ) , void * ctx ) ;
2019-03-23 07:06:37 +00:00
void HTTP_CL_Think ( const char * * fname , float * percent ) ;
2015-06-04 06:15:14 +00:00
void HTTP_CL_Terminate ( void ) ; //kills all active downloads
2016-07-12 00:40:13 +00:00
unsigned int HTTP_CL_GetActiveDownloads ( void ) ;
2010-03-14 14:35:56 +00:00
struct dl_download * HTTP_CL_Get ( const char * url , const char * localfile , void ( * NotifyFunction ) ( struct dl_download * dl ) ) ;
2013-10-08 14:28:11 +00:00
struct dl_download * HTTP_CL_Put ( const char * url , const char * mime , const char * data , size_t datalen , void ( * NotifyFunction ) ( struct dl_download * dl ) ) ;
2010-03-14 14:35:56 +00:00
struct dl_download * DL_Create ( const char * url ) ;
qboolean DL_CreateThread ( struct dl_download * dl , vfsfile_t * file , void ( * NotifyFunction ) ( struct dl_download * dl ) ) ;
void DL_Close ( struct dl_download * dl ) ;
2016-07-12 00:40:13 +00:00
void DL_DeThread ( void ) ;
2020-10-06 03:17:28 +00:00
//internal 'http' error codes.
# define HTTP_DNSFAILURE 900 //no ip known
# define HTTP_NORESPONSE 901 //tcp failure
2021-04-14 05:21:04 +00:00
# define HTTP_REFUSED 902 //tcp failure
# define HTTP_EOF 903 //unexpected eof
# define HTTP_MITM 904 //wrong cert
# define HTTP_UNTRUSTED 905 //unverifiable cert
2020-10-06 03:17:28 +00:00
2010-03-14 14:35:56 +00:00
# endif
2004-08-23 01:40:25 +00:00
# endif