author | Tero Marttila <terom@fixme.fi> |
Fri, 29 Aug 2008 23:31:17 +0300 | |
changeset 48 | 1c67f512779b |
parent 27 | 1e79b4cc8f1b |
permissions | -rw-r--r-- |
27
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
#ifndef STATIC_H |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
#define STATIC_H |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
#include <event2/http.h> |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
5 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
6 |
/* |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
* I serve up simple static files over HTTP by just loading them directly into memory. |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
8 |
* |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
9 |
* This is inefficient, but for small files it's OK. |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
*/ |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
12 |
struct static_file { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
13 |
// the file descriptor |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
int fh; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
16 |
// the size of the file in bytes |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
17 |
off_t size; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
18 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
19 |
// the mmap address |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
20 |
void *mmap_addr; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
21 |
}; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
22 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
23 |
int static_init (struct static_file *ctx, struct evhttp *http_server, const char *url, const char *path); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
24 |
void static_deinit (struct static_file *ctx); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
25 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
26 |
#define STATIC_DIR_MAX 16 |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
27 |
#define STATIC_PATH_MAX 1024 |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
28 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
29 |
struct static_dir { |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
30 |
struct static_file files[STATIC_DIR_MAX]; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
31 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
int file_count; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
}; |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
35 |
int static_dir_init (struct static_dir *ctx, struct evhttp *http_server, const char *url_prefix, const char *dir_path); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
36 |
void static_dir_deinit (struct static_dir *ctx); |
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
37 |
|
1e79b4cc8f1b
support for static files (.css, .html, .js), and tiles - serves up a full viewer at / now, but the JS code needs cleaning up
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
38 |
#endif /* STATIC_H */ |