2004-08-23 01:40:25 +00:00
|
|
|
#ifndef IWEB_H__
|
|
|
|
#define IWEB_H__
|
|
|
|
|
2010-03-14 14:35:56 +00:00
|
|
|
#ifdef WEBSERVER
|
2004-08-23 01:40:25 +00:00
|
|
|
|
|
|
|
#ifdef WEBSVONLY
|
|
|
|
|
2012-01-21 07:53:49 +00:00
|
|
|
#include "quakedef.h"
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include "winquake.h"
|
|
|
|
#endif
|
2004-08-23 01:40:25 +00:00
|
|
|
|
|
|
|
#define Con_TPrintf IWebPrintf
|
|
|
|
#define IWebPrintf printf
|
|
|
|
#define com_gamedir "." //current dir.
|
|
|
|
|
|
|
|
|
|
|
|
#define IWebMalloc(x) calloc(x, 1)
|
|
|
|
#define IWebRealloc(x, y) realloc(x, y)
|
|
|
|
#define IWebFree free
|
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
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
qboolean SV_AllowDownload (const char *name);
|
2004-08-23 01:40:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef qboolean iwboolean;
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
#define INVALID_SOCKET ~0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//it's not allowed to error.
|
|
|
|
#ifndef WEBSVONLY
|
2009-11-04 21:16:50 +00:00
|
|
|
void VARGS IWebDPrintf(char *fmt, ...) LIKEPRINTF(1);
|
|
|
|
void VARGS IWebPrintf(char *fmt, ...) LIKEPRINTF(1);
|
|
|
|
void VARGS IWebWarnPrintf(char *fmt, ...) LIKEPRINTF(1);
|
2004-08-23 01:40:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
#ifndef WEBSVONLY
|
|
|
|
void *IWebMalloc(int size);
|
|
|
|
void *IWebRealloc(void *old, int size);
|
|
|
|
void IWebFree(void *mem);
|
|
|
|
#define IWebFree Z_Free
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int IWebAuthorize(char *name, char *password);
|
|
|
|
iwboolean IWebAllowUpLoad(char *fname, char *uname);
|
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
vfsfile_t *IWebGenerateFile(char *name, char *content, int contentlength);
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
iwboolean FTP_StringToAdr (const char *s, qbyte ip[4], qbyte port[2]);
|
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);
|
|
|
|
qboolean HTTP_ServerPoll(qboolean httpserverwanted, 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;
|
|
|
|
|
2014-06-12 23:08:42 +00:00
|
|
|
qdownload_t qdownload;
|
|
|
|
|
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*/
|
2013-06-23 02:17:02 +00:00
|
|
|
char localname[MAX_OSPATH]; /*leave empty for a temp file*/
|
|
|
|
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;
|
2012-11-27 03:23:19 +00:00
|
|
|
unsigned int replycode;
|
2010-03-14 14:35:56 +00:00
|
|
|
unsigned int totalsize; /*max size (can be 0 for unknown)*/
|
|
|
|
unsigned int completed; /*ammount correctly received so far*/
|
|
|
|
|
|
|
|
/*internals*/
|
|
|
|
#ifdef MULTITHREAD
|
|
|
|
qboolean threaddie;
|
|
|
|
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;
|
2013-11-28 00:45:22 +00:00
|
|
|
void (*notifystarted) (struct dl_download *dl, char *mimetype); //mime can be null for some protocols, read dl->totalsize for size.
|
|
|
|
void (*notifycomplete) (struct dl_download *dl);
|
2010-03-14 14:35:56 +00:00
|
|
|
};
|
|
|
|
|
2013-11-28 00:45:22 +00:00
|
|
|
vfsfile_t *VFSPIPE_Open(void);
|
2010-03-14 14:35:56 +00:00
|
|
|
void HTTP_CL_Think(void);
|
|
|
|
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);
|
|
|
|
#endif
|
|
|
|
|
2004-08-23 01:40:25 +00:00
|
|
|
#endif
|