typedef struct pblock {
    int hsize;
    struct pb_entry **ht;
} pblock;

typedef struct pb_param {
    char *name,*value;
} pb_param;

typedef struct pb_entry {
    pb_param *param;
    struct pb_entry *next;
} pb_entry;

typedef struct pb_key {
    const char *name;
    int namelen;
    unsigned int hashval;
    int sizendx;
    int hashndx;
} pb_key;

typedef struct netbuf {
    uintptr_t sd; /* was PRFileDesc */
    int pos, cursize, maxsize, rdtimeout;
    unsigned char *inbuf;
    char *errmsg;
    char address[64];
} netbuf;

struct in_addr {
    union {
        struct { uint8_t s_b1, s_b2, s_b3, s_b4; } _S_un_b;
        struct { uint16_t s_w1, s_w2; } _S_un_w;
        uint32_t _S_addr; /* in_addr_t _S_addr; */
    } _S_un;
};
struct sockaddr_in {
    uint16_t     sin_family;
    uint16_t       sin_port;
    struct  in_addr sin_addr;
    char            sin_zero[8];
};

typedef void *pool_handle_t;
typedef struct PListStruct_s PListStruct_t;
struct PListStruct_s {
    pblock pl_pb;             
    uintptr_t pl_symtab; /* was PLSymbolTable_t * */
    pool_handle_t *pl_mempool;
    int pl_maxprop;  
    int pl_resvpi; 
    int pl_lastpi;
    int pl_cursize; 
};
typedef struct PRIPv6Addr {
    union {
        uint8_t  _S6_u8[16];
        uint16_t _S6_u16[8];
        uint32_t _S6_u32[4];
        uint64_t _S6_u64[2];
    } _S6_un;
} PRIPv6Addr;

typedef union PRNetAddr {
    struct {
        uint16_t family;
        char data[14];
    } raw;
    struct {
        uint16_t family;
        uint16_t port;
        uint32_t ip;
        char pad[8];
    } inet;
    struct {
        uint16_t family;
        uint16_t port;
        uint32_t flowinfo;
        PRIPv6Addr ip;
        uint32_t scope_id;
    } ipv6;
    struct {
        uint16_t family;
        char path[104];
    } local;
} PRNetAddr;

typedef struct Session Session;
typedef struct Session {
    pblock *client;
    uintptr_t *csd; /* was PRFileDesc * */
    netbuf *inbuf;
    int csd_open;
    struct in_addr iaddr;
    void **pool;
    void *clauth; 
    struct Session *next;
    int fill;
    struct sockaddr_in local_addr;
    struct PListStruct_s *subject;
    int ssl;
    int clientauth;

    PRNetAddr *pr_client_addr;
    PRNetAddr *pr_local_addr;
} Session;

typedef struct httpd_object {
    pblock *name;

    int nd;
    uintptr_t dt; /* was dtable * */

    int np;
    pblock **pb;

    int nm;
    uintptr_t *model; /* was ModelPblock ** */

    int nc;
    uintptr_t *cond; /* was Condition ** */
} httpd_object;

typedef struct httpd_objset {
    int pos;
    httpd_object **obj;
    pblock **initfns;
} httpd_objset;

typedef long time_t;

typedef struct Request {
    pblock *vars;
    pblock *reqpb;
    int loadhdrs;
    pblock *headers;
    int senthdrs;
    pblock *srvhdrs;

    httpd_objset *os;
    httpd_objset *tmpos;

    char *statpath;
    char *staterr;
    struct stat *finfo;

    int aclstate;
    int acldirno;
    char *aclname;
    pblock *aclpb;
    uintptr_t acllist; /* was  ACLListHandle * */

    int request_is_cacheable;
    int directive_is_cacheable;

    char *cached_headers;
    int cached_headers_len;
    char *unused;

    time_t req_start;
    short protv_num;
    short method_num;
    struct rq_attr {
        unsigned long abs_uri:1;
        unsigned long chunked:1;
        unsigned long keep_alive:1;
        unsigned long pipelined:1;
        unsigned long internal_req:1;
        unsigned long perm_req:1;
        unsigned long header_file_present:1;
        unsigned long footer_file_present:1;
        unsigned long jvm_attached:1;
        unsigned long req_restarted:1;
        unsigned long jvm_request_locked:1;
        unsigned long default_type_set:1;      
        unsigned long is_web_app:1;
        unsigned long ssl_unclean_shutdown:1;
        unsigned long vary_accept_language:1; 
        unsigned long reserved:17;
    } rq_attr;
    char *hostname;
    int allowed;
    int byterange;
    short status_num;

    int staterrno;
    uintptr_t orig_rq; /* was Request * */
} Request;

provider sjsws {
    probe saf__entry(const char *, pblock *, Session *, Request *);
    probe saf__exit(const char *, int, pblock *, Session *, Request *);
};