summaryrefslogtreecommitdiffstats
path: root/src/haserl.h
blob: 6791e749c9d441c90f8a7d758a530439a137be39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* --------------------------------------------------------------------------
 * Copyright 2003-2011 (inclusive) Nathan Angelacos 
 *                   (nangel@users.sourceforge.net)
 * 
 *   This file is part of haserl.
 *
 *   Haserl is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License version 2,
 *   as published by the Free Software Foundation.
 *
 *   Haserl 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 haserl.  If not, see <http://www.gnu.org/licenses/>.
 *
 * ------------------------------------------------------------------------ */

#ifndef _HASERL_H
#define _HASERL_H	1


/* Just a silly construct to contain global variables    */
typedef struct
{
  unsigned long uploadkb;       /* how big an upload do we allow (0 for none)*/
  char *shell;                  /* The shell we use                          */
  char *uploaddir;              /* where we upload to                        */
  char *uploadhandler;		/* a handler for uploads		     */
  char *var_prefix;		/* what name we give to FORM variables	     */
  char *get_prefix;		/* what name we give to POST variables	     */
  char *post_prefix;		/* what name we give to POST variables       */
  char *cookie_prefix;		/* what name we give to COOKIE variables     */
  char *nul_prefix;		/* what name we give to environment variables*/
  char *haserl_prefix;		/* what name we give to HASERL variables     */
  token_t *uploadlist;		/* a linked list of pathspecs	             */
  int debug;                    /* true if in "debug" mode                   */
  int acceptall;                /* true if we'll accept POST data on 
  					GETs and vice versa 		     */
  int silent;                   /* true if we never print errors             */
} haserl_t;

extern haserl_t global;
	
char x2c(char *what);
void unescape_url(char *url);
void *xmalloc (size_t size);
void *xrealloc (void *buf, size_t size);
list_t *myputenv(list_t *cur, char *str, char *prefix);
void free_list_chain ( list_t *);
void readenv(list_t *env);
void CookieVars(list_t *env);
void sessionid(list_t *env);
list_t *wcversion(list_t *env);
void haserlflags(list_t *env);
int ReadCGIQueryString(list_t *env);
int ReadCGIPOSTValues(list_t *env);
int LineToStr(char *string, size_t max);
int ReadMimeEncodedInput(list_t *env);
void PrintParseError(char *error, int linenum);
int parseCommandLine(int argc, char *argv[]);
int BecomeUser(uid_t uid, gid_t gid);
void assignGlobalStartupValues(void);
void unlink_uploadlist (void);
int main(int argc, char *argv[]);


extern void (*shell_exec)(buffer_t *buf, char *str);
extern void (*shell_echo)(buffer_t *buf, char *str, size_t len);
extern void (*shell_eval)(buffer_t *buf, char *str, size_t len);
extern void (*shell_setup)( char *, list_t *);
extern void (*shell_doscript)( buffer_t *, char *);
extern void (*shell_destroy) (void);

#ifdef BASHEXTENSIONS
extern void (*shell_if)(buffer_t *buf, char *str, size_t len);
extern void (*shell_elif)(buffer_t *buf, char *str, size_t len);
extern void (*shell_else)(buffer_t *buf, char *str, size_t len);
extern void (*shell_endif)(buffer_t *buf, char *str, size_t len);
extern void (*shell_case)(buffer_t *buf, char *str, size_t len);
extern void (*shell_when)(buffer_t *buf, char *str, size_t len);
extern void (*shell_otherwise)(buffer_t *buf, char *str, size_t len);
extern void (*shell_endcase)(buffer_t *buf, char *str, size_t len);
extern void (*shell_while)(buffer_t *buf, char *str, size_t len);
extern void (*shell_endwhile)(buffer_t *buf, char *str, size_t len);
extern void (*shell_until)(buffer_t *buf, char *str, size_t len);
extern void (*shell_enduntil)(buffer_t *buf, char *str, size_t len);
extern void (*shell_for)(buffer_t *buf, char *str, size_t len);
extern void (*shell_endfor)(buffer_t *buf, char *str, size_t len);
extern void (*shell_unless)(buffer_t *buf, char *str, size_t len);
extern void (*shell_elun)(buffer_t *buf, char *str, size_t len);
extern void (*shell_unelse)(buffer_t *buf, char *str, size_t len);
extern void (*shell_endunless)(buffer_t *buf, char *str, size_t len);
#endif
#endif /* !_HASERL_H */