Back to index

avfs  1.0.1
Functions | Variables
http_utils.c File Reference
#include "config.h"
#include <sys/types.h>
#include <ctype.h>
#include "dates.h"
#include "http_utils.h"

Go to the source code of this file.

Functions

void neon_debug_init (FILE *stream, int mask)
void neon_debug (int ch, const char *template,...)
const char * neon_version_string (void)
int neon_version_minimum (int major, int minor)
time_t http_dateparse (const char *date)
int http_parse_statusline (const char *status_line, http_status *st)

Variables

int neon_debug_mask = 0
FILE * neon_debug_stream
static const char * version_string = ", no OpenSSL support"

Function Documentation

time_t http_dateparse ( const char *  date)

Definition at line 100 of file http_utils.c.

                                        {
    time_t tmp;
    tmp = rfc1123_parse(date);
    if (tmp == -1) {
        tmp = rfc1036_parse(date);
       if (tmp == -1)
           tmp = asctime_parse(date);
    }
    return tmp;
}
int http_parse_statusline ( const char *  status_line,
http_status st 
)

Definition at line 111 of file http_utils.c.

                                                                    {
    const char *part;
    int major, minor, status_code, klass;
    /* Check they're speaking the right language */
    if (strncmp(status_line, "HTTP/", 5) != 0) {
       return -1;
    }
    /* And find out which dialect of this peculiar language
     * they can talk... */
    major = 0;
    minor = 0; 
    /* Note, we're good children, and accept leading zero's on the
     * version numbers */
    for (part = status_line + 5; *part != '\0' && isdigit(*part); part++) {
       major = major*10 + (*part-'0');
    }
    if (*part != '.') { 
       return -1;
    }
    for (part++ ; *part != '\0' && isdigit(*part); part++) {
       minor = minor*10 + (*part-'0');
    }
    if (*part != ' ') {
       return -1;
    }
    /* Skip any spaces */
    for (; *part == ' ' ; part++) /* noop */;
    /* Now for the Status-Code. part now points at the first Y in
     * "HTTP/x.x YYY". We want value of YYY... could use atoi, but
     * probably quicker this way. */
    if (!isdigit(part[0]) || !isdigit(part[1]) || !isdigit(part[2])) {
       return -1;
    }
    status_code = 100*(part[0]-'0') + 10*(part[1]-'0') + (part[2]-'0');
    klass = part[0]-'0';
    /* Skip whitespace between status-code and reason-phrase */
    for (part+=3; *part == ' ' || *part == '\t'; part++) /* noop */;
    if (*part == '\0') {
       return -1;
    }
    /* Fill in the results */
    st->major_version = major;
    st->minor_version = minor;
    st->reason_phrase = part;
    st->code = status_code;
    st->klass = klass;
    return 0;
}
void neon_debug ( int  ch,
const char *  template,
  ... 
)

Definition at line 49 of file http_utils.c.

{
    va_list params;
    if ((ch&neon_debug_mask) != ch) return;
    fflush(stdout);
    va_start(params, template);
    vfprintf(neon_debug_stream, template, params);
    va_end(params);
    if ((ch&DEBUG_FLUSH) == DEBUG_FLUSH) {
       fflush(neon_debug_stream);
    }
}
void neon_debug_init ( FILE *  stream,
int  mask 
)

Definition at line 43 of file http_utils.c.

{
    neon_debug_stream = stream;
    neon_debug_mask = mask;
}
int neon_version_minimum ( int  major,
int  minor 
)

Definition at line 92 of file http_utils.c.

{
    return 
       (NEON_VERSION_MAJOR < major) || 
       (NEON_VERSION_MINOR < minor);
}
const char* neon_version_string ( void  )

Definition at line 87 of file http_utils.c.

{
    return version_string;
}

Variable Documentation

int neon_debug_mask = 0

Definition at line 40 of file http_utils.c.

Definition at line 41 of file http_utils.c.

const char* version_string = ", no OpenSSL support" [static]

Definition at line 62 of file http_utils.c.