author | Mahlon E. Smith <mahlon@martini.nu> |
Fri, 26 Aug 2011 14:40:51 -0700 | |
changeset 0 | eac7211fe522 |
child 1 | 823d42546cea |
permissions | -rw-r--r-- |
0
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
1 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
2 |
#ifndef _VOLTA_H |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
3 |
#define _VOLTA_H |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
4 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
5 |
#ifndef PROG |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
6 |
#define PROG "volta" |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
7 |
#endif |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
8 |
#define VERSION "$Version$" /* expanded by mercurial */ |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
9 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
10 |
#include <stdio.h> |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
11 |
#include <stdlib.h> |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
12 |
#include <stdarg.h> |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
13 |
#include <string.h> |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
14 |
#include <unistd.h> |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
15 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
16 |
#include <sys/types.h> |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
17 |
#include <sys/socket.h> |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
18 |
#include <netinet/in.h> |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
19 |
#include <arpa/inet.h> |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
20 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
21 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
22 |
/* Maximum length per line from Squid */ |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
23 |
#define LINE_BUFSIZE 2048 |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
24 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
25 |
/* URL <SP> client_ip "/" fqdn <SP> user <SP> method [<SP> kvpairs]<NL> */ |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
26 |
typedef struct request { |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
27 |
char *url; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
28 |
char *host; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
29 |
struct sockaddr_in ip; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
30 |
char *ip_fqdn; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
31 |
char *user; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
32 |
char *method; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
33 |
char *kvpairs; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
34 |
} request; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
35 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
36 |
/* An "empty" request struct used for re-assignment */ |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
37 |
static const struct request reset_request; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
38 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
39 |
/* Prototypes */ |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
40 |
void usage( char *prg ); |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
41 |
void debug( const char *fmt, ... ); |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
42 |
int parse( char *p ); |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
43 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
44 |
#endif |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
45 |