type
stringclasses
5 values
content
stringlengths
9
163k
includes
#include <errno.h>
includes
#include <unistd.h>
includes
#include <stdarg.h>
includes
#include <stdio.h>
includes
#include <stdlib.h>
includes
#include <string.h>
defines
#define HTTPH(a, b, c, d, e, f, g) char b[] = "*" a ":";
defines
#define LOGMTX2(ax, bx, cx) [bx] = SLT_##ax##cx
defines
#define LOGMTX1(ax) { \
defines
#define HTTP_RESP(n, t) { n, t},
defines
#define HTTPH(a, b, c, d, e, f, g) \
defines
#define HTTPH(a, b, c, d, e, f, g) \
defines
#define HTTPH(a, b, c, d, e, f, g) b[0] = (char)strlen(b + 1);
functions
vsl_tag http2shmlog(const struct http *hp, int t) { CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); if (t > HTTP_HDR_FIRST) t = HTTP_HDR_FIRST; assert(hp->logtag >= HTTP_Rx && hp->logtag <= HTTP_Obj); /*lint !e685*/ assert(t >= HTTP_HDR_REQ && t <= HTTP_HDR_FIRST); return (logmtx[hp->logtag][t]); }
functions
void WSLH(struct worker *w, int fd, const struct http *hp, unsigned hdr) { WSLR(w, http2shmlog(hp, hdr), fd, hp->hd[hdr]); }
functions
unsigned HTTP_estimate(unsigned nhttp) { /* XXX: We trust the structs to size-aligned as necessary */ return (sizeof (struct http) + (sizeof (txt) + 1) * nhttp); }
functions
void http_Setup(struct http *hp, struct ws *ws) { unsigned shd; txt *hd; unsigned char *hdf; /* XXX: This is not elegant, is it efficient ? */ shd = hp->shd; hd = hp->hd; hdf = hp->hdf; memset(hp, 0, sizeof *hp); memset(hd, 0, sizeof *hd * shd); memset(hdf, 0, sizeof *hdf * shd); hp->magic = HTTP_MAGIC; hp...
functions
int http_IsHdr(const txt *hh, const char *hdr) { unsigned l; Tcheck(*hh); AN(hdr); l = hdr[0]; assert(l == strlen(hdr + 1)); assert(hdr[l] == ':'); hdr++; return (!strncasecmp(hdr, hh->b, l)); }
functions
void http_CollectHdr(struct http *hp, const char *hdr) { unsigned u, v, ml, f = 0, x; char *b = NULL, *e = NULL; for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) { while (u < hp->nhd && http_IsHdr(&hp->hd[u], hdr)) { Tcheck(hp->hd[u]); if (f == 0) { /* Found first header, just record the fact */ f = u; ...
functions
unsigned http_findhdr(const struct http *hp, unsigned l, const char *hdr) { unsigned u; for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) { Tcheck(hp->hd[u]); if (hp->hd[u].e < hp->hd[u].b + l + 1) continue; if (hp->hd[u].b[l] != ':') continue; if (strncasecmp(hdr, hp->hd[u].b, l)) continue; return (u); ...
functions
int http_GetHdr(const struct http *hp, const char *hdr, char **ptr) { unsigned u, l; char *p; l = hdr[0]; diagnostic(l == strlen(hdr + 1)); assert(hdr[l] == ':'); hdr++; u = http_findhdr(hp, l - 1, hdr); if (u == 0) { if (ptr != NULL) *ptr = NULL; return (0); }
functions
int http_GetHdrData(const struct http *hp, const char *hdr, const char *field, char **ptr) { char *h, *e; unsigned fl; if (ptr != NULL) *ptr = NULL; if (!http_GetHdr(hp, hdr, &h)) return (0); AN(h); e = strchr(h, '\0'); fl = strlen(field); while (h + fl <= e) { /* Skip leading whitespace and commas *...
functions
double http_GetHdrQ(const struct http *hp, const char *hdr, const char *field) { char *h; int i; double a, b; h = NULL; i = http_GetHdrData(hp, hdr, field, &h); if (!i) return (0.); if (h == NULL) return (1.); /* Skip whitespace, looking for '=' */ while (*h && vct_issp(*h)) h++; if (*h++ != ';') re...
functions
int http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr) { char *h; int i; if (ptr != NULL) *ptr = NULL; h = NULL; i = http_GetHdrData(hp, hdr, field, &h); if (!i) return (i); if (ptr != NULL && h != NULL) { /* Skip whitespace, looking for '=' */ while (*h && vct...
functions
int http_HdrIs(const struct http *hp, const char *hdr, const char *val) { char *p; if (!http_GetHdr(hp, hdr, &p)) return (0); AN(p); if (!strcasecmp(p, val)) return (1); return (0); }
functions
int http_GetStatus(const struct http *hp) { return (hp->status); }
functions
int http_dissect_hdrs(struct worker *w, struct http *hp, int fd, char *p, const struct http_conn *htc) { char *q, *r; txt t = htc->rxbuf; if (*p == '\r') p++; hp->nhd = HTTP_HDR_FIRST; hp->conds = 0; r = NULL; /* For FlexeLint */ for (; p < t.e; p = r) { /* Find end of next header */ q = r = p; w...
functions
int http_splitline(struct worker *w, int fd, struct http *hp, const struct http_conn *htc, int h1, int h2, int h3) { char *p, *q; CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); /* XXX: Assert a NUL at rx.e ? */ Tcheck(htc->rxbuf); /* Skip leading LWS */ for (p = htc->rxbuf.b ;...
functions
void http_ProtoVer(struct http *hp) { if (!strcasecmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.0")) hp->protover = 1.0; else if (!strcasecmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.1")) hp->protover = 1.1; else hp->protover = 0.9; }
functions
int http_DissectRequest(struct sess *sp) { struct http_conn *htc; struct http *hp; int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); htc = sp->htc; CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); hp = sp->http; CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); hp->logtag = HTTP_Rx; i = http_splitline(sp->wrk, sp->fd, hp, htc, HTTP...
functions
int http_DissectResponse(struct worker *w, const struct http_conn *htc, struct http *hp) { int i = 0; CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); hp->logtag = HTTP_Rx; if (http_splitline(w, htc->fd, hp, htc, HTTP_HDR_PROTO, HTTP_HDR_STATUS, HTTP_HDR_RESPONSE)) i = 503; ...
functions
void http_SetH(const struct http *to, unsigned n, const char *fm) { assert(n < to->shd); AN(fm); to->hd[n].b = TRUST_ME(fm); to->hd[n].e = strchr(to->hd[n].b, '\0'); to->hdf[n] = 0; }
functions
void http_copyh(const struct http *to, const struct http *fm, unsigned n) { assert(n < HTTP_HDR_FIRST); Tcheck(fm->hd[n]); to->hd[n] = fm->hd[n]; to->hdf[n] = fm->hdf[n]; }
functions
void http_ForceGet(const struct http *to) { if (strcmp(http_GetReq(to), "GET")) http_SetH(to, HTTP_HDR_REQ, "GET"); }
functions
void http_CopyResp(struct http *to, const struct http *fm) { CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1"); to->status = fm->status; http_copyh(to, fm, HTTP_HDR_RESPONSE); }
functions
void http_SetResp(struct http *to, const char *proto, int status, const char *response) { CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); http_SetH(to, HTTP_HDR_PROTO, proto); to->status = status; http_SetH(to, HTTP_HDR_RESPONSE, response); }
functions
void http_copyheader(struct worker *w, int fd, struct http *to, const struct http *fm, unsigned n) { CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); assert(n < fm->shd); Tcheck(fm->hd[n]); if (to->nhd < to->shd) { to->hd[to->nhd] = fm->hd[n]; to->hdf[to->nhd] = 0; to->nhd++; }
functions
unsigned http_EstimateWS(const struct http *fm, unsigned how, unsigned *nhd) { unsigned u, l; l = 0; *nhd = HTTP_HDR_FIRST; CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); for (u = 0; u < fm->nhd; u++) { if (fm->hd[u].b == NULL) continue; if (fm->hdf[u] & HDF_FILTER) continue; if (((e) & how) && http_IsHdr(&fm->h...
functions
void http_FilterFields(struct worker *w, int fd, struct http *to, const struct http *fm, unsigned how) { unsigned u; CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); to->nhd = HTTP_HDR_FIRST; to->status = fm->status; for (u = HTTP_HDR_FIRST; u < fm->nhd; u++) { if (fm->hd[u].b == NULL)...
functions
void http_FilterHeader(const struct sess *sp, unsigned how) { struct http *hp; hp = sp->wrk->bereq; CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); hp->logtag = HTTP_Tx; http_copyh(hp, sp->http, HTTP_HDR_REQ); http_copyh(hp, sp->http, HTTP_HDR_URL); if (how == HTTPH_R_FETCH) http_SetH(hp, HTTP_HDR_PROTO, "HTTP/1.1"); el...
functions
void http_CopyHome(struct worker *w, int fd, const struct http *hp) { unsigned u, l; char *p; for (u = 0; u < hp->nhd; u++) { if (hp->hd[u].b == NULL) continue; if (hp->hd[u].b >= hp->ws->s && hp->hd[u].e <= hp->ws->e) { WSLH(w, fd, hp, u); continue; }
functions
void http_ClrHeader(struct http *to) { CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); /* XXX: don't to->f = to->v; it would kill pipelining */ to->nhd = HTTP_HDR_FIRST; memset(to->hd, 0, sizeof to->hd); }
functions
void http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr) { CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); if (to->nhd >= to->shd) { VSC_main->losthdr++; WSL(w, SLT_LostHeader, fd, "%s", hdr); return; }
functions
void http_PutField(struct worker *w, int fd, const struct http *to, int field, const char *string) { char *p; unsigned l; CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); l = strlen(string); p = WS_Alloc(to->ws, l + 1); if (p == NULL) { WSL(w, SLT_LostHeader, fd, "%s", string); to->hd[field].b = NULL; to->hd[field]....
functions
void http_PutProtocol(struct worker *w, int fd, const struct http *to, const char *protocol) { http_PutField(w, fd, to, HTTP_HDR_PROTO, protocol); }
functions
void http_PutStatus(struct http *to, int status) { assert(status >= 0 && status <= 999); to->status = status; }
functions
void http_PutResponse(struct worker *w, int fd, const struct http *to, const char *response) { http_PutField(w, fd, to, HTTP_HDR_RESPONSE, response); }
functions
void http_PrintfHeader(struct worker *w, int fd, struct http *to, const char *fmt, ...) { va_list ap; unsigned l, n; CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); l = WS_Reserve(to->ws, 0); va_start(ap, fmt); n = vsnprintf(to->ws->f, l, fmt, ap); va_end(ap); if (n + 1 >= l || to->nhd >= to->shd) { VSC_main->losthdr...
functions
void http_Unset(struct http *hp, const char *hdr) { unsigned u, v; for (v = u = HTTP_HDR_FIRST; u < hp->nhd; u++) { if (hp->hd[u].b == NULL) continue; if (http_IsHdr(&hp->hd[u], hdr)) continue; if (v != u) { memcpy(&hp->hd[v], &hp->hd[u], sizeof *hp->hd); memcpy(&hp->hdf[v], &hp->hdf[u], sizeof *hp...
functions
void HTTP_Copy(struct http *to, const struct http * const fm) { to->conds = fm->conds; to->logtag = fm->logtag; to->status = fm->status; to->protover = fm->protover; to->nhd = fm->nhd; assert(fm->nhd <= to->shd); memcpy(to->hd, fm->hd, fm->nhd * sizeof *to->hd); memcpy(to->hdf, fm->hdf, fm->nhd * sizeof *to->h...
functions
unsigned http_Write(struct worker *w, const struct http *hp, int resp) { unsigned u, l; int fd = *(w->wrw.wfd); if (resp) { l = WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], " "); WSLH(w, fd, hp, HTTP_HDR_PROTO); hp->hd[HTTP_HDR_STATUS].b = WS_Alloc(w->ws, 4); AN(hp->hd[HTTP_HDR_STATUS].b); sprintf(hp->hd[HTTP...
functions
void HTTP_Init(void) { #include "http_headers.h" #undef HTTPH }
includes
#include <sys/cdefs.h>
includes
#include <sys/param.h>
includes
#include <sys/kernel.h>
includes
#include <sys/systm.h>
includes
#include <dev/vt/vt.h>
includes
#include <dev/vt/hw/vga/vga_reg.h>
includes
#include <machine/bus.h>
includes
#include <vm/vm.h>
includes
#include <vm/pmap.h>
includes
#include <machine/pmap.h>
includes
#include <machine/vmparam.h>
defines
#define MEM_READ1(sc, ofs) \
defines
#define MEM_WRITE1(sc, ofs, val) \
defines
#define REG_READ1(sc, reg) \
defines
#define REG_WRITE1(sc, reg, val) \
defines
#define VT_VGA_WIDTH 640
defines
#define VT_VGA_HEIGHT 480
defines
#define VT_VGA_MEMSIZE (VT_VGA_WIDTH * VT_VGA_HEIGHT / 8)
structs
struct vga_softc { bus_space_tag_t vga_fb_tag; bus_space_handle_t vga_fb_handle; bus_space_tag_t vga_reg_tag; bus_space_handle_t vga_reg_handle; int vga_curcolor; };
structs
struct unicp437 { uint16_t unicode_base; uint8_t cp437_base; uint8_t length; };
functions
void vga_setcolor(struct vt_device *vd, term_color_t color) { struct vga_softc *sc = vd->vd_softc; if (sc->vga_curcolor != color) { REG_WRITE1(sc, VGA_GC_ADDRESS, VGA_GC_SET_RESET); REG_WRITE1(sc, VGA_GC_DATA, color); sc->vga_curcolor = color; }
functions
void vga_blank(struct vt_device *vd, term_color_t color) { struct vga_softc *sc = vd->vd_softc; u_int ofs; vga_setcolor(vd, color); for (ofs = 0; ofs < VT_VGA_MEMSIZE; ofs++) MEM_WRITE1(sc, ofs, 0xff); }
functions
void vga_bitblt_put(struct vt_device *vd, u_long dst, term_color_t color, uint8_t v) { struct vga_softc *sc = vd->vd_softc; /* Skip empty writes, in order to avoid palette changes. */ if (v != 0x00) { vga_setcolor(vd, color); /* * When this MEM_READ1() gets disabled, all sorts of * artifacts occur. T...
functions
void vga_setpixel(struct vt_device *vd, int x, int y, term_color_t color) { vga_bitblt_put(vd, (y * VT_VGA_WIDTH / 8) + (x / 8), color, 0x80 >> (x % 8)); }
functions
void vga_drawrect(struct vt_device *vd, int x1, int y1, int x2, int y2, int fill, term_color_t color) { int x, y; for (y = y1; y <= y2; y++) { if (fill || (y == y1) || (y == y2)) { for (x = x1; x <= x2; x++) vga_setpixel(vd, x, y, color); }
functions
void vga_bitblt_draw(struct vt_device *vd, const uint8_t *src, u_long ldst, uint8_t shift, unsigned int width, unsigned int height, term_color_t color, int negate) { u_long dst; int w; uint8_t b, r, out; for (; height > 0; height--) { dst = ldst; ldst += VT_VGA_WIDTH / 8; r = 0; for (w = width; w >...
functions
void vga_bitbltchr(struct vt_device *vd, const uint8_t *src, const uint8_t *mask, int bpl, vt_axis_t top, vt_axis_t left, unsigned int width, unsigned int height, term_color_t fg, term_color_t bg) { u_long dst, ldst; int w; /* Don't try to put off screen pixels */ if (((left + width) > VT_VGA_WIDTH) || ((t...
functions
void vga_maskbitbltchr(struct vt_device *vd, const uint8_t *src, const uint8_t *mask, int bpl, vt_axis_t top, vt_axis_t left, unsigned int width, unsigned int height, term_color_t fg, term_color_t bg) { struct vga_softc *sc = vd->vd_softc; u_long dst; uint8_t shift; dst = (VT_VGA_WIDTH * top + left) / 8; ...
functions
uint8_t vga_get_cp437(term_char_t c) { int min, mid, max; min = 0; max = (sizeof(cp437table) / sizeof(struct unicp437)) - 1; if (c < cp437table[0].unicode_base || c > cp437table[max].unicode_base + cp437table[max].length) return '?'; while (max >= min) { mid = (min + max) / 2; if (c < cp437table[mid]...
functions
void vga_putchar(struct vt_device *vd, term_char_t c, vt_axis_t top, vt_axis_t left, term_color_t fg, term_color_t bg) { struct vga_softc *sc = vd->vd_softc; uint8_t ch, attr; /* * Convert character to CP437, which is the character set used * by the VGA hardware by default. */ ch = vga_get_cp437(c); /*...
functions
void vga_initialize_graphics(struct vt_device *vd) { struct vga_softc *sc = vd->vd_softc; /* Clock select. */ REG_WRITE1(sc, VGA_GEN_MISC_OUTPUT_W, VGA_GEN_MO_VSP | VGA_GEN_MO_HSP | VGA_GEN_MO_PB | VGA_GEN_MO_ER | VGA_GEN_MO_IOA); /* Set sequencer clocking and memory mode. */ REG_WRITE1(sc, VGA_SEQ_ADDRESS, ...
functions
void vga_initialize(struct vt_device *vd, int textmode) { struct vga_softc *sc = vd->vd_softc; uint8_t x; /* Make sure the VGA adapter is not in monochrome emulation mode. */ x = REG_READ1(sc, VGA_GEN_MISC_OUTPUT_R); REG_WRITE1(sc, VGA_GEN_MISC_OUTPUT_W, x | VGA_GEN_MO_IOA); /* Unprotect CRTC registers 0-7. */ ...
functions
int vga_init(struct vt_device *vd) { struct vga_softc *sc = vd->vd_softc; int textmode = 0; #if defined(__amd64__) || defined(__i386__) sc->vga_fb_tag = X86_BUS_SPACE_MEM; sc->vga_fb_handle = KERNBASE + VGA_MEM_BASE; sc->vga_reg_tag = X86_BUS_SPACE_IO; sc->vga_reg_handle = VGA_REG_BASE; #elif defined(__ia64__) ...
functions
void vga_postswitch(struct vt_device *vd) { /* Reinit VGA mode, to restore view after app which change mode. */ vga_initialize(vd, (vd->vd_flags & VDF_TEXTMODE)); /* Ask vt(9) to update chars on visible area. */ vd->vd_flags |= VDF_INVALID; }
includes
#include <sys/param.h>
includes
#include <sys/ioccom.h>
includes
#include <sys/malloc.h>
includes
#include <sys/uio.h>
includes
#include <sys/ioctl.h>
includes
#include <sys/kernel.h>
includes
#include <sys/systm.h>
includes
#include <sys/conf.h>
includes
#include <sys/mbuf.h>
includes
#include <sys/proc.h>
includes
#include <sys/fcntl.h>
includes
#include <sys/socket.h>
includes
#include <sys/select.h>
includes
#include <net/if.h>