Annotation of libaitwww/inc/aitwww.h, revision 1.1.1.1.2.1

1.1       misho       1: /*************************************************************************
                      2: * (C) 2012 AITNET ltd - Sofia/Bulgaria - <misho@aitnet.org>
                      3: *  by Michael Pounov <misho@elwix.org>
                      4: *
                      5: * $Author: misho $
1.1.1.1.2.1! misho       6: * $Id: aitwww.h,v 1.1.1.1 2012/03/08 23:40:21 misho Exp $
1.1       misho       7: *
                      8: **************************************************************************
                      9: The ELWIX and AITNET software is distributed under the following
                     10: terms:
                     11: 
                     12: All of the documentation and software included in the ELWIX and AITNET
                     13: Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
                     14: 
                     15: Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
                     16:        by Michael Pounov <misho@elwix.org>.  All rights reserved.
                     17: 
                     18: Redistribution and use in source and binary forms, with or without
                     19: modification, are permitted provided that the following conditions
                     20: are met:
                     21: 1. Redistributions of source code must retain the above copyright
                     22:    notice, this list of conditions and the following disclaimer.
                     23: 2. Redistributions in binary form must reproduce the above copyright
                     24:    notice, this list of conditions and the following disclaimer in the
                     25:    documentation and/or other materials provided with the distribution.
                     26: 3. All advertising materials mentioning features or use of this software
                     27:    must display the following acknowledgement:
                     28: This product includes software developed by Michael Pounov <misho@elwix.org>
                     29: ELWIX - Embedded LightWeight unIX and its contributors.
                     30: 4. Neither the name of AITNET nor the names of its contributors
                     31:    may be used to endorse or promote products derived from this software
                     32:    without specific prior written permission.
                     33: 
                     34: THIS SOFTWARE IS PROVIDED BY AITNET AND CONTRIBUTORS ``AS IS'' AND
                     35: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     36: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     37: ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     38: FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     39: DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     40: OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     41: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     42: LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     43: OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     44: SUCH DAMAGE.
                     45: */
                     46: #ifndef __AITWWW_H
                     47: #define __AITWWW_H
                     48: 
                     49: 
1.1.1.1.2.1! misho      50: #include <sys/types.h>
        !            51: #include <sys/queue.h>
        !            52: #include <sys/uio.h>
        !            53: 
        !            54: 
1.1       misho      55: struct tagCGI {
                     56:        char                    *cgi_name;
                     57:        char                    *cgi_value;
                     58: 
                     59:        SLIST_ENTRY(tagCGI)     cgi_node;
                     60: };
                     61: typedef SLIST_HEAD(, tagCGI) cgi_t;
                     62: 
                     63: struct tagMIME;
                     64: typedef SLIST_HEAD(, tagMIME) mime_t;
                     65: 
                     66: struct tagMIME {
                     67:        cgi_t                   mime_header;
                     68: 
                     69:        struct iovec            mime_body;
                     70:        struct iovec            mime_prolog;
                     71:        struct iovec            mime_epilog;
                     72: 
                     73:        mime_t                  *mime_attach;
                     74: 
                     75:        SLIST_ENTRY(tagMIME)    mime_node;
                     76: };
                     77: 
                     78: 
1.1.1.1.2.1! misho      79: // www_GetErrno() Get error code of last operation
        !            80: inline int www_GetErrno();
        !            81: // www_GetError() Get error text of last operation
        !            82: inline const char *www_GetError();
        !            83: 
        !            84: 
1.1       misho      85: /*
                     86:  * www_initCGI() - Init CGI program
                     87:  *
                     88:  * return: NULL error or allocated cgi session
                     89:  */
                     90: cgi_t *www_initCGI(void);
                     91: /*
                     92:  * www_closeCGI() - Close and free all CGI resources
                     93:  *
                     94:  * @cgi = Inited cgi session
                     95:  * return: none
                     96:  */
                     97: void www_closeCGI(cgi_t ** __restrict cgi);
                     98: /*
                     99:  * www_parseQuery() - Parse CGI query string
                    100:  *
                    101:  * @str = String
                    102:  * return: NULL error or allocated cgi session
                    103:  */
                    104: cgi_t *www_parseQuery(const char *str);
                    105: /*
                    106:  * www_parseMultiPart() - Parse Multi part POST CGI query string
                    107:  *
                    108:  * @str = String
                    109:  * @ctlen = Content length
                    110:  * @ct = Content type
                    111:  * return: NULL error or allocated cgi session
                    112:  */
                    113: cgi_t *www_parseMultiPart(const char *str, int ctlen, const char *ct);
                    114: /*
                    115:  * www_getValue() - Get Value from CGI session
                    116:  *
                    117:  * @cgi = Inited cgi session
                    118:  * @name = Name of cgi variable
                    119:  * return: NULL not found or !=NULL value
                    120:  */
                    121: inline const char *www_getValue(cgi_t * __restrict cgi, const char *name);
                    122: /*
                    123:  * www_addValue() - Add new or update if exists CGI variable
                    124:  *
                    125:  * @cgi = Inited cgi session
                    126:  * @name = Name of cgi variable
                    127:  * @value = Value of cgi variable
                    128:  * return: -1 error, 0 add new one or 1 updated variable
                    129:  */
                    130: int www_addValue(cgi_t * __restrict cgi, const char *name, const char *value);
                    131: /*
                    132:  * www_delPair() - Delete CGI variable from session
                    133:  *
                    134:  * @cgi = Inited cgi session
                    135:  * @name = Name of cgi variable
                    136:  * return: -1 error, 0 not found or 1 deleted ok
                    137:  */
                    138: int www_delPair(cgi_t * __restrict cgi, const char *name);
                    139: 
                    140: /*
                    141:  * www_header() - Output initial html header
                    142:  *
                    143:  * @output = file handle
                    144:  * return: <1 error or >0 writed bytes
                    145:  */
                    146: inline int www_header(FILE *output);
                    147: 
                    148: /*
                    149:  * www_parseAttributes() - Parse attributes
                    150:  *
                    151:  * @ct = Content type
                    152:  * return: NULL error or !=NULL attributes
                    153:  */
                    154: inline cgi_t *www_parseAttributes(const char **ct);
                    155: /*
                    156:  * www_freeAttributes() - Free attributes
                    157:  *
                    158:  * @attr = Attributes
                    159:  * return: none
                    160:  */
                    161: inline void www_freeAttributes(cgi_t ** __restrict attr);
                    162: /*
                    163:  * www_getAttribute() - Get attribute by name
                    164:  *
                    165:  * @attr = Attributes
                    166:  * @name = Name of attribute
                    167:  * return: NULL not found or !=NULL attribute value
                    168:  */
                    169: inline const char *www_getAttribute(cgi_t * __restrict attr, const char *name);
                    170: 
                    171: 
                    172: #endif

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