owntone-server/src/webserver.h

102 lines
2.9 KiB
C
Raw Normal View History

2003-10-13 11:03:14 -04:00
/*
* $Id$
* Webserver library
*
2003-12-29 15:41:08 -05:00
* Copyright (C) 2003 Ron Pedde (ron@pedde.com)
2003-10-13 11:03:14 -04:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _WEBSERVER_H_
#define _WEBSERVER_H_
/*
* Defines
*/
#define RT_GET 0
#define RT_POST 1
/*
* Typedefs
*/
typedef void* WSHANDLE;
typedef void* WSTHREADENUM;
2003-10-13 11:03:14 -04:00
typedef struct tag_wsconfig {
char *web_root;
char *id;
unsigned short port;
} WSCONFIG;
typedef struct tag_arglist {
char *key;
char *value;
struct tag_arglist *next;
} ARGLIST;
typedef struct tag_ws_conninfo {
WSHANDLE pwsp;
int threadno;
int error;
2003-10-13 11:03:14 -04:00
int fd;
int request_type;
char *uri;
char *hostname;
int close;
void *local_storage;
void (*storage_callback)(void*);
2003-10-13 11:03:14 -04:00
ARGLIST request_headers;
ARGLIST response_headers;
ARGLIST request_vars;
} WS_CONNINFO;
/*
* Externs
*/
#define WS_REQ_HANDLER void (*)(WS_CONNINFO *)
#define WS_AUTH_HANDLER int (*)(WS_CONNINFO*, char *, char *)
2003-10-13 11:03:14 -04:00
extern WSHANDLE ws_start(WSCONFIG *config);
extern int ws_stop(WSHANDLE ws);
extern int ws_registerhandler(WSHANDLE ws, char *regex,
2006-02-26 03:46:24 -05:00
void(*handler)(WS_CONNINFO*),
int(*auth)(WS_CONNINFO*, char *, char *),
2006-02-26 03:46:24 -05:00
int addheaders);
2005-11-13 23:30:12 -05:00
extern void ws_lock_local_storage(WS_CONNINFO *pwsc);
extern void ws_unlock_local_storage(WS_CONNINFO *pwsc);
extern void *ws_get_local_storage(WS_CONNINFO *pwsc);
extern void ws_set_local_storage(WS_CONNINFO *pwsc, void *ptr, void (*callback)(void *));
extern WS_CONNINFO *ws_thread_enum_first(WSHANDLE, WSTHREADENUM *);
extern WS_CONNINFO *ws_thread_enum_next(WSHANDLE, WSTHREADENUM *);
/* for handlers */
2003-10-13 11:03:14 -04:00
extern void ws_close(WS_CONNINFO *pwsc);
extern int ws_returnerror(WS_CONNINFO *pwsc, int error, char *description);
2003-10-30 17:42:11 -05:00
extern int ws_addresponseheader(WS_CONNINFO *pwsc, char *header, char *fmt, ...);
extern int ws_writefd(WS_CONNINFO *pwsc, char *fmt, ...);
2006-04-25 16:46:03 -04:00
extern int ws_writebinary(WS_CONNINFO *pwsc, char *data, int len);
extern char *ws_getvar(WS_CONNINFO *pwsc, char *var);
2003-12-01 01:55:36 -05:00
extern char *ws_getrequestheader(WS_CONNINFO *pwsc, char *header);
2003-10-30 17:42:11 -05:00
extern int ws_testrequestheader(WS_CONNINFO *pwsc, char *header, char *value);
2004-02-14 19:51:11 -05:00
extern void ws_emitheaders(WS_CONNINFO *pwsc);
2003-10-13 11:03:14 -04:00
#endif /* _WEBSERVER_H_ */