Annotation of embedaddon/axTLS/httpd/axhttp.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (c) 2007, Cameron Rich
        !             3:  * 
        !             4:  * All rights reserved.
        !             5:  * 
        !             6:  * Redistribution and use in source and binary forms, with or without 
        !             7:  * modification, are permitted provided that the following conditions are met:
        !             8:  *
        !             9:  * * Redistributions of source code must retain the above copyright notice, 
        !            10:  *   this list of conditions and the following disclaimer.
        !            11:  * * Redistributions in binary form must reproduce the above copyright notice, 
        !            12:  *   this list of conditions and the following disclaimer in the documentation 
        !            13:  *   and/or other materials provided with the distribution.
        !            14:  * * Neither the name of the axTLS project nor the names of its contributors 
        !            15:  *   may be used to endorse or promote products derived from this software 
        !            16:  *   without specific prior written permission.
        !            17:  *
        !            18:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
        !            19:  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
        !            20:  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
        !            21:  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
        !            22:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
        !            23:  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
        !            24:  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
        !            25:  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
        !            26:  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
        !            27:  * 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:  */
        !            30: 
        !            31: #include "os_port.h"
        !            32: #include "ssl.h"
        !            33: 
        !            34: #define BACKLOG 15
        !            35: #define VERSION "1.0.0"
        !            36: #ifdef CONFIG_HTTP_HAS_IPV6
        !            37: #define HAVE_IPV6
        !            38: #endif
        !            39: 
        !            40: #define MAXPOSTDATASIZE                     30000 /* adjust for file upload
        !            41:                                                      size*/
        !            42: #define MAXREQUESTLENGTH                    256
        !            43: #define MAXREADLENGTH                       8800  /* FF3=4096, IE7=8760 */
        !            44: #define BLOCKSIZE                           4096
        !            45: 
        !            46: #define INITIAL_CONNECTION_SLOTS            10
        !            47: #define CONFIG_HTTP_DEFAULT_SSL_OPTIONS     SSL_DISPLAY_CERTS
        !            48: 
        !            49: #define STATE_WANT_TO_READ_HEAD             1
        !            50: #define STATE_WANT_TO_SEND_HEAD             2
        !            51: #define STATE_WANT_TO_READ_FILE             3
        !            52: #define STATE_WANT_TO_SEND_FILE             4
        !            53: #define STATE_DOING_DIR                     5
        !            54: 
        !            55: enum
        !            56: {
        !            57:     TYPE_GET,
        !            58:     TYPE_HEAD,
        !            59:     TYPE_POST
        !            60: };
        !            61: 
        !            62: struct connstruct 
        !            63: {
        !            64:     struct connstruct *next;
        !            65:     int state;
        !            66:     int reqtype;
        !            67:     int networkdesc;
        !            68:     int filedesc;
        !            69:     SSL *ssl;
        !            70: 
        !            71: #if defined(CONFIG_HTTP_DIRECTORIES)
        !            72: #ifdef WIN32
        !            73:     HANDLE dirp;
        !            74:     WIN32_FIND_DATA file_data;
        !            75: #else
        !            76:     DIR *dirp;
        !            77: #endif
        !            78: #endif
        !            79: 
        !            80:     time_t timeout;
        !            81:     char actualfile[MAXREQUESTLENGTH];
        !            82:     char filereq[MAXREQUESTLENGTH];
        !            83:     char dirname[MAXREQUESTLENGTH];
        !            84:     char server_name[MAXREQUESTLENGTH];
        !            85:     int numbytes;
        !            86:     char databuf[BLOCKSIZE];
        !            87:     uint8_t is_ssl;
        !            88:     uint8_t is_v1_0;
        !            89:     uint8_t close_when_done;
        !            90:     time_t if_modified_since;
        !            91: 
        !            92: #if defined(CONFIG_HTTP_HAS_CGI)
        !            93:     uint8_t is_cgi;
        !            94:     char cgicontenttype[MAXREQUESTLENGTH];
        !            95:     int content_length;
        !            96:     char remote_addr[MAXREQUESTLENGTH];
        !            97:     char uri_request[MAXREQUESTLENGTH];
        !            98:     char uri_path_info[MAXREQUESTLENGTH];
        !            99:     char uri_query[MAXREQUESTLENGTH];
        !           100:     char cookie[MAXREQUESTLENGTH];
        !           101: #endif
        !           102: #if defined(CONFIG_HTTP_HAS_AUTHORIZATION)
        !           103:     char authorization[MAXREQUESTLENGTH];
        !           104: #endif
        !           105:   int post_read;
        !           106:   int post_state;
        !           107:   char *post_data;
        !           108: };
        !           109: 
        !           110: struct serverstruct 
        !           111: {
        !           112:     struct serverstruct *next;
        !           113:     int sd;
        !           114:     int is_ssl;
        !           115:     SSL_CTX *ssl_ctx;
        !           116: };
        !           117: 
        !           118: #if defined(CONFIG_HTTP_HAS_CGI)
        !           119: struct cgiextstruct 
        !           120: {
        !           121:     struct cgiextstruct *next;
        !           122:     char *ext;
        !           123: };
        !           124: #endif
        !           125: 
        !           126: /* global prototypes */
        !           127: extern struct serverstruct *servers;
        !           128: extern struct connstruct *usedconns;
        !           129: extern struct connstruct *freeconns;
        !           130: extern const char * const server_version;
        !           131: 
        !           132: #if defined(CONFIG_HTTP_HAS_CGI)
        !           133: extern struct cgiextstruct *cgiexts;
        !           134: #endif
        !           135: 
        !           136: /* conn.c prototypes */
        !           137: void removeconnection(struct connstruct *cn);
        !           138: 
        !           139: /* proc.c prototypes */
        !           140: void procdodir(struct connstruct *cn);
        !           141: void procreadhead(struct connstruct *cn);
        !           142: void procsendhead(struct connstruct *cn);
        !           143: void procreadfile(struct connstruct *cn);
        !           144: void procsendfile(struct connstruct *cn);
        !           145: #if defined(CONFIG_HTTP_HAS_CGI)
        !           146: void read_post_data(struct connstruct *cn);
        !           147: #endif
        !           148: 
        !           149: /* misc.c prototypes */
        !           150: char *my_strncpy(char *dest, const char *src, size_t n);
        !           151: int isdir(const char *name);
        !           152: 
        !           153: /* tdate prototypes */
        !           154: void tdate_init(void);
        !           155: time_t tdate_parse(const char* str);
        !           156: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>