mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-26 22:01:50 +00:00
c0680334c7
Multiple consoles can now be printed/cleared via extra con commands. Fixed the tab-completion alignment, by adding support for \t characters. Changing the download mechanisms. Don't try downloading an ftp:// file. It'll probably crash you for now. Trying to fix load time issues on q3bsps with a lot of curves. Fixed sprites. Added warning prints/spam where the new backend is bypassed, thus marking things that still need to be fixed. QTV proxy fixed to not sit on qw servers unless someone is actually watching. Will ping for status requests still. QTV proxy now supports ipv6. QTV proxy now attempts to use the fte browser plugin. Reworked the browser plugin code, now uses threads instead of ugly hacks. This should make cooperation with other such plugins work. Fixes unresponsiveness of opera, and gives an API that can be used from any other bit of software you want, tbh (read: internet explorer/activex plugins). git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3516 fc73d0e0-1445-4013-8a0c-d673dee63da5
157 lines
3.9 KiB
C
157 lines
3.9 KiB
C
#ifndef IWEB_H__
|
|
#define IWEB_H__
|
|
|
|
#ifdef WEBSERVER
|
|
|
|
#ifdef WEBSVONLY
|
|
|
|
typedef unsigned char qbyte;
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <malloc.h>
|
|
|
|
#define Con_TPrintf IWebPrintf
|
|
#define TL_NETBINDINTERFACE "binding to %s"
|
|
#define TL_CONNECTIONLOSTORABORTED "connection lost or aborted"
|
|
#define TL_NETGETPACKETERROR "get packet error"
|
|
|
|
#define IWebPrintf printf
|
|
#define com_gamedir "." //current dir.
|
|
|
|
|
|
#define IWebMalloc(x) calloc(x, 1)
|
|
#define IWebRealloc(x, y) realloc(x, y)
|
|
#define IWebFree free
|
|
#endif
|
|
|
|
#include "quakedef.h"
|
|
|
|
#ifdef _WIN32
|
|
#include "winquake.h"
|
|
#endif
|
|
|
|
#define IWEBACC_READ 1
|
|
#define IWEBACC_WRITE 2
|
|
#define IWEBACC_FULL 4
|
|
struct sockaddr_in;
|
|
struct sockaddr;
|
|
struct sockaddr_qstorage;
|
|
int NetadrToSockadr (netadr_t *a, struct sockaddr_qstorage *s);
|
|
|
|
qboolean SV_AllowDownload (const char *name);
|
|
|
|
|
|
typedef qboolean iwboolean;
|
|
|
|
#ifndef _WIN32
|
|
#define INVALID_SOCKET ~0
|
|
#endif
|
|
|
|
//it's not allowed to error.
|
|
#ifndef WEBSVONLY
|
|
void VARGS IWebDPrintf(char *fmt, ...) LIKEPRINTF(1);
|
|
void VARGS IWebPrintf(char *fmt, ...) LIKEPRINTF(1);
|
|
void VARGS IWebWarnPrintf(char *fmt, ...) LIKEPRINTF(1);
|
|
#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);
|
|
|
|
vfsfile_t *IWebGenerateFile(char *name, char *content, int contentlength);
|
|
|
|
|
|
|
|
char *COM_ParseOut (const char *data, char *out, int outlen);
|
|
void COM_EnumerateFiles (const char *match, int (*func)(const char *, int, void *), void *parm);
|
|
|
|
|
|
char *Q_strcpyline(char *out, const char *in, int maxlen);
|
|
|
|
|
|
|
|
|
|
iwboolean FTP_StringToAdr (const char *s, qbyte ip[4], qbyte port[2]);
|
|
|
|
//server tick/control functions
|
|
iwboolean FTP_ServerRun(iwboolean ftpserverwanted, int port);
|
|
qboolean HTTP_ServerPoll(qboolean httpserverwanted, int port);
|
|
|
|
//server interface called from main server routines.
|
|
void IWebInit(void);
|
|
void IWebRun(void);
|
|
void IWebShutdown(void);
|
|
/*
|
|
qboolean FTP_Client_Command (char *cmd, void (*NotifyFunction)(vfsfile_t *file, char *localfile, qboolean sucess));
|
|
void IRC_Command(char *imsg);
|
|
void FTP_ClientThink (void);
|
|
void IRC_Frame(void);
|
|
*/
|
|
qboolean SV_POP3(qboolean activewanted);
|
|
qboolean SV_SMTP(qboolean activewanted);
|
|
|
|
#endif
|
|
|
|
|
|
#if 1
|
|
struct dl_download
|
|
{
|
|
/*not used by anything in the download itself, useful for context*/
|
|
unsigned int user_num;
|
|
void *user_ctx;
|
|
|
|
/*not used internally by the backend, but used by HTTP_CL_Get/thread wrapper*/
|
|
struct dl_download *next;
|
|
void (*notify) (struct dl_download *dl);
|
|
|
|
/*stream config*/
|
|
char url[MAX_OSPATH]; /*original url*/
|
|
char redir[MAX_OSPATH]; /*current redirected url*/
|
|
char localname[MAX_OSPATH];
|
|
struct vfsfile_s *file; /*downloaded to, when starting will open localname if not already set*/
|
|
qboolean (*poll) (struct dl_download *);
|
|
|
|
/*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;
|
|
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*/
|
|
};
|
|
|
|
void HTTP_CL_Think(void);
|
|
struct dl_download *HTTP_CL_Get(const char *url, const char *localfile, void (*NotifyFunction)(struct dl_download *dl));
|
|
|
|
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
|
|
|
|
#endif
|