volta.h
changeset 2 8c88756f81b0
parent 1 823d42546cea
child 4 5701b7859a31
equal deleted inserted replaced
1:823d42546cea 2:8c88756f81b0
       
     1 /* vim: set noet nosta sw=4 ts=4 ft=c : */
       
     2 /*
       
     3 Copyright (c) 2011, Mahlon E. Smith <mahlon@martini.nu>
       
     4 All rights reserved.
       
     5 Redistribution and use in source and binary forms, with or without
       
     6 modification, are permitted provided that the following conditions are met:
       
     7 
       
     8     * Redistributions of source code must retain the above copyright
       
     9       notice, this list of conditions and the following disclaimer.
       
    10 
       
    11     * Redistributions in binary form must reproduce the above copyright
       
    12       notice, this list of conditions and the following disclaimer in the
       
    13       documentation and/or other materials provided with the distribution.
       
    14 
       
    15     * Neither the name of Mahlon E. Smith nor the names of his
       
    16       contributors may be used to endorse or promote products derived
       
    17       from this software without specific prior written permission.
       
    18 
       
    19 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
       
    20 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
    21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
       
    22 DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
       
    23 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
       
    24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
       
    25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
       
    26 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
       
    28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    29 */
     1 
    30 
     2 #ifndef _VOLTA_H
    31 #ifndef _VOLTA_H
     3 #define _VOLTA_H
    32 #define _VOLTA_H
     4 
    33 
     5 #ifndef PROG
    34 #ifndef PROG
     8 #define VERSION "$Version$" /* expanded by mercurial */
    37 #define VERSION "$Version$" /* expanded by mercurial */
     9 
    38 
    10 #include <stdio.h>
    39 #include <stdio.h>
    11 #include <stdlib.h>
    40 #include <stdlib.h>
    12 #include <stdarg.h>
    41 #include <stdarg.h>
       
    42 #include <errno.h>
    13 #include <string.h>
    43 #include <string.h>
    14 #include <unistd.h>
    44 #include <unistd.h>
    15 #include <time.h>
    45 #include <time.h>
    16 
    46 
    17 #include <sys/types.h>
    47 #include <sys/types.h>
    19 #include <netinet/in.h>
    49 #include <netinet/in.h>
    20 #include <arpa/inet.h>
    50 #include <arpa/inet.h>
    21 
    51 
    22 #include <sqlite3.h>
    52 #include <sqlite3.h>
    23 
    53 
       
    54 #ifdef DEBUG
       
    55 #include <google/profiler.h>
       
    56 #endif
    24 
    57 
    25 /* Maximum length per line from Squid */
    58 /* Default line size we accept from squid, longer lines (huge URLs?) malloc. */
    26 #define LINE_BUFSIZE 2048
    59 #define LINE_BUFSIZE 2048
    27 
    60 
    28 /* Aid debugging */
    61 /* Aid debugging */
    29 #define LOC __FILE__, __LINE__
    62 #define LOC __FILE__, __LINE__
    30 /* Global debug toggle */
    63 /* Global debug toggle */
    40 	char   *user;
    73 	char   *user;
    41 	char   *method;
    74 	char   *method;
    42 	char   *kvpairs;
    75 	char   *kvpairs;
    43 } request;
    76 } request;
    44 
    77 
    45 /* An "empty" request struct used for re-assignment */
    78 /* FIXME: An "empty" request struct used for re-assignment */
    46 static const struct request reset_request;
    79 static const struct request reset_request;
    47 
    80 
    48 /* Function prototypes */
    81 /*
       
    82  *
       
    83  * Function prototypes
       
    84  *
       
    85  */
       
    86 
    49 void usage( char *prg );
    87 void usage( char *prg );
    50 void debug( int level, char *file, int line, const char *fmt, ... );
    88 void debug( int level, char *file, int line, const char *fmt, ... );
    51 int  parse( char *p );
    89 char *extend_line( char *line, const char *buf );
       
    90 
       
    91 int db_initialize( void );
       
    92 
       
    93 int accept_loop( void );
       
    94 struct request *parse( char *p );
    52 
    95 
    53 #endif
    96 #endif
    54 
    97