FTEQW
Documentation of the FTE engine source tree.
iweb.h
Go to the documentation of this file.
1#ifndef IWEB_H__
2#define IWEB_H__
3
4qboolean SV_AllowDownload (const char *name);
5
6#if defined(WEBSERVER) || defined(FTPSERVER)
7
8#ifdef WEBSVONLY
9//When running standalone
10#define Con_TPrintf IWebPrintf
11void VARGS IWebDPrintf(char *fmt, ...) LIKEPRINTF(1);
12#define IWebPrintf printf
13#define com_gamedir "." //current dir.
14
15
16#define IWebMalloc(x) calloc(x, 1)
17#define IWebRealloc(x, y) realloc(x, y)
18#define IWebFree free
19#else
20//Inside FTE
21#define IWebDPrintf Con_DPrintf
22#define IWebPrintf Con_Printf
23
24#define IWebMalloc Z_Malloc
25#define IWebRealloc BZF_Realloc
26#define IWebFree Z_Free
27
28void VARGS IWebWarnPrintf(char *fmt, ...) LIKEPRINTF(1);
29#endif
30
31#define IWEBACC_READ 1
32#define IWEBACC_WRITE 2
33#define IWEBACC_FULL 4
34struct sockaddr_in;
35struct sockaddr;
38
39
41
42typedef struct {
43 float gentime; //useful for generating a new file (if too old, removes reference)
44 int references; //freed if 0
45 char *data;
46 int len;
48
49int IWebAuthorize(const char *name, const char *password);
50iwboolean IWebAllowUpLoad(const char *fname, const char *uname);
51
52vfsfile_t *IWebGenerateFile(const char *name, const char *content, int contentlength);
54
55//char *COM_ParseOut (const char *data, char *out, int outlen);
56//struct searchpath_s;
57//void COM_EnumerateFiles (const char *match, int (*func)(const char *, int, void *, struct searchpath_s *), void *parm);
58
59
60char *Q_strcpyline(char *out, const char *in, int maxlen);
61
62
63//server tick/control functions
64iwboolean FTP_ServerRun(iwboolean ftpserverwanted, int port);
65
66qboolean HTTP_ServerInit(int epfd, int port);
67
68//server interface called from main server routines.
69void IWebInit(void);
70void IWebRun(void);
71void IWebShutdown(void);
72/*
73qboolean FTP_Client_Command (char *cmd, void (*NotifyFunction)(vfsfile_t *file, char *localfile, qboolean sucess));
74void IRC_Command(char *imsg);
75void FTP_ClientThink (void);
76void IRC_Frame(void);
77*/
80
81#endif
82
83
84#if 1
86{
87 /*not used by anything in the download itself, useful for context*/
88 unsigned int user_num;
90 void *user_ctx;
92
93 qboolean isquery; //will not be displayed in the download/progress bar stuff.
94
95#ifdef HAVE_CLIENT
97#endif
98
99 /*stream config*/
100 char *url; /*original url*/
101 char redir[MAX_OSPATH]; /*current redirected url*/
102 unsigned int redircount; /* so no infinite redirects with naughty servers.*/
103 char localname[MAX_OSPATH]; /*leave empty for a temp file*/
105 struct vfsfile_s *file; /*downloaded to, if not already set when starting will open localname or a temp file*/
106
107 char postmimetype[64];
108 char *postdata; /*if set, this is a post and not a get*/
109 size_t postlen;
110
111 /*stream status*/
112 enum
113 {
114 DL_PENDING, /*not started*/
115 DL_FAILED, /*gave up*/
116 DL_RESOLVING, /*resolving the host*/
117 DL_QUERY, /*sent query, waiting for response*/
118 DL_ACTIVE, /*receiving data*/
119 DL_FINISHED /*its complete*/
121 unsigned int replycode;
122 size_t totalsize; /*max size (can be 0 for unknown)*/
123 size_t completed; /*ammount correctly received so far*/
124
125 size_t sizelimit;
126
127 /*internals*/
128#ifdef MULTITHREAD
131#endif
132 void *ctx; /*internal context, depending on http/ftp/etc protocol*/
133 void (*abort) (struct dl_download *); /*cleans up the internal context*/
134 qboolean (*poll) (struct dl_download *);
135
136 /*not used internally by the backend, but used by HTTP_CL_Get/thread wrapper*/
138 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.
139 void (*notifycomplete) (struct dl_download *dl); //lets the requester know that the download context is complete and the handle is no longer valid.
140};
141
142vfsfile_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
144void HTTP_CL_Think(const char **fname, float *percent);
145void HTTP_CL_Terminate(void); //kills all active downloads
146unsigned int HTTP_CL_GetActiveDownloads(void);
147struct dl_download *HTTP_CL_Get(const char *url, const char *localfile, void (*NotifyFunction)(struct dl_download *dl));
148struct dl_download *HTTP_CL_Put(const char *url, const char *mime, const char *data, size_t datalen, void (*NotifyFunction)(struct dl_download *dl));
149
150struct dl_download *DL_Create(const char *url);
151qboolean DL_CreateThread(struct dl_download *dl, vfsfile_t *file, void (*NotifyFunction)(struct dl_download *dl));
152void DL_Close(struct dl_download *dl);
153void DL_DeThread(void);
154
155//internal 'http' error codes.
156#define HTTP_DNSFAILURE 900 //no ip known
157#define HTTP_NORESPONSE 901 //tcp failure
158#define HTTP_REFUSED 902 //tcp failure
159#define HTTP_EOF 903 //unexpected eof
160#define HTTP_MITM 904 //wrong cert
161#define HTTP_UNTRUSTED 905 //unverifiable cert
162
163#endif
164
165#endif
qboolean
Definition: api_menu.h:34
cvar_t password
Definition: cl_main.c:148
void(QDECL *vgui_frame)(void)
void dNearCallback * callback
Definition: com_phys_ode.c:655
fs_relative
Definition: common.h:661
s
Definition: execloop.h:53
static EGLSurface EGLSurface EGLContext ctx
Definition: gl_videgl.c:47
GLuint GLcharARB * name
Definition: glquake.h:155
void HTTP_CL_Terminate(void)
Definition: httpclient.c:1502
qboolean SV_POP3(qboolean activewanted)
void HTTP_CL_Think(const char **fname, float *percent)
Definition: httpclient.c:1398
unsigned int HTTP_CL_GetActiveDownloads(void)
Definition: httpclient.c:1340
struct dl_download * DL_Create(const char *url)
Definition: httpclient.c:1257
void VARGS IWebDPrintf(char *fmt,...) LIKEPRINTF(1)
Definition: iwebiface.c:453
struct dl_download * HTTP_CL_Put(const char *url, const char *mime, const char *data, size_t datalen, void(*NotifyFunction)(struct dl_download *dl))
Definition: httpclient.c:1381
void IWebShutdown(void)
Definition: iwebiface.c:813
vfsfile_t * IWebGenerateFile(const char *name, const char *content, int contentlength)
Definition: webgen.c:443
iwboolean IWebAllowUpLoad(const char *fname, const char *uname)
Definition: iwebiface.c:914
void IWebInit(void)
Definition: iwebiface.c:763
qboolean HTTP_ServerInit(int epfd, int port)
Definition: httpserver.c:158
int NetadrToSockadr(netadr_t *a, struct sockaddr_qstorage *s)
Definition: net_wins.c:299
void DL_Close(struct dl_download *dl)
Definition: httpclient.c:1283
void IWebRun(void)
Definition: iwebiface.c:785
int IWebGetSafeListeningPort(void)
Definition: iwebiface.c:727
qboolean iwboolean
Definition: iweb.h:40
iwboolean FTP_ServerRun(iwboolean ftpserverwanted, int port)
Definition: ftpserver.c:1389
void VARGS IWebWarnPrintf(char *fmt,...) LIKEPRINTF(1)
Definition: iwebiface.c:751
qboolean SV_AllowDownload(const char *name)
Definition: iwebiface.c:51
qboolean SV_SMTP(qboolean activewanted)
char * Q_strcpyline(char *out, const char *in, int maxlen)
Definition: iwebiface.c:927
struct dl_download * HTTP_CL_Get(const char *url, const char *localfile, void(*NotifyFunction)(struct dl_download *dl))
Definition: httpclient.c:1351
qboolean DL_CreateThread(struct dl_download *dl, vfsfile_t *file, void(*NotifyFunction)(struct dl_download *dl))
Definition: httpclient.c:1218
void DL_DeThread(void)
Definition: httpclient.c:1322
int IWebAuthorize(const char *name, const char *password)
Definition: iwebiface.c:874
vfsfile_t * VFSPIPE_Open(int refs, qboolean seekable)
Definition: httpclient.c:1675
vfsfile_t * VFS_OpenPipeCallback(void(*callback)(void *ctx, vfsfile_t *file), void *ctx)
Definition: httpclient.c:1670
char fname[MAX_QPATH]
Definition: m_mp3.c:160
char ** data
Definition: p_script.c:63
const char * file
Definition: qcc_pr_lex.c:2518
uploadfmt_t fmt
Definition: r_2d.c:48
static spx_int16_t * in
Definition: snd_dma.c:488
static SpeexBits spx_int16_t * out
Definition: snd_dma.c:492
Definition: iweb.h:42
int references
Definition: iweb.h:44
char * data
Definition: iweb.h:45
int len
Definition: iweb.h:46
float gentime
Definition: iweb.h:43
Definition: iweb.h:86
size_t postlen
Definition: iweb.h:109
void * ctx
Definition: iweb.h:132
void(* notifycomplete)(struct dl_download *dl)
Definition: iweb.h:139
struct dl_download * next
Definition: iweb.h:137
qboolean isquery
Definition: iweb.h:93
unsigned int replycode
Definition: iweb.h:121
float user_float
Definition: iweb.h:89
size_t sizelimit
Definition: iweb.h:125
qboolean(* poll)(struct dl_download *)
Definition: iweb.h:134
unsigned int redircount
Definition: iweb.h:102
char * postdata
Definition: iweb.h:108
void(* abort)(struct dl_download *)
Definition: iweb.h:133
void * threadctx
Definition: iweb.h:130
size_t completed
Definition: iweb.h:123
enum dl_download::@334 status
enum fs_relative fsroot
Definition: iweb.h:104
char postmimetype[64]
Definition: iweb.h:107
size_t totalsize
Definition: iweb.h:122
void * user_ctx
Definition: iweb.h:90
char * url
Definition: iweb.h:100
char redir[MAX_OSPATH]
Definition: iweb.h:101
qboolean(* notifystarted)(struct dl_download *dl, char *mimetype)
Definition: iweb.h:138
qboolean threadenable
Definition: iweb.h:129
int user_sequence
Definition: iweb.h:91
@ DL_QUERY
Definition: iweb.h:117
@ DL_PENDING
Definition: iweb.h:114
@ DL_FINISHED
Definition: iweb.h:119
@ DL_FAILED
Definition: iweb.h:115
@ DL_ACTIVE
Definition: iweb.h:118
@ DL_RESOLVING
Definition: iweb.h:116
qdownload_t qdownload
Definition: iweb.h:96
char localname[MAX_OSPATH]
Definition: iweb.h:103
struct vfsfile_s * file
Definition: iweb.h:105
unsigned int user_num
Definition: iweb.h:88
Definition: net.h:71
Definition: client.h:384
Definition: net.h:107
Definition: common.h:620
netadr_t a
Definition: sv_master.c:141
unsigned int datalen
Definition: sv_user.c:2880
void * vfsfile_t
Definition: sys_plugfte.h:2