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

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.2     ! misho       6: * $Id: aitwww.h,v 1.1.1.1.2.2 2012/03/09 12:33:41 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.2     ! 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: 
1.2     ! misho      78: typedef int (*list_cb_t)(struct tagCGI *, void *);
        !            79: 
        !            80: 
        !            81: // www_GetErrno() Get error code of last operation
        !            82: inline int www_GetErrno();
        !            83: // www_GetError() Get error text of last operation
        !            84: inline const char *www_GetError();
        !            85: 
1.1       misho      86: 
                     87: /*
                     88:  * www_initCGI() - Init CGI program
                     89:  *
                     90:  * return: NULL error or allocated cgi session
                     91:  */
                     92: cgi_t *www_initCGI(void);
                     93: /*
                     94:  * www_closeCGI() - Close and free all CGI resources
                     95:  *
                     96:  * @cgi = Inited cgi session
                     97:  * return: none
                     98:  */
                     99: void www_closeCGI(cgi_t ** __restrict cgi);
                    100: /*
                    101:  * www_parseQuery() - Parse CGI query string
                    102:  *
                    103:  * @str = String
                    104:  * return: NULL error or allocated cgi session
                    105:  */
                    106: cgi_t *www_parseQuery(const char *str);
                    107: /*
                    108:  * www_parseMultiPart() - Parse Multi part POST CGI query string
                    109:  *
                    110:  * @str = String
                    111:  * @ctlen = Content length
                    112:  * @ct = Content type
                    113:  * return: NULL error or allocated cgi session
                    114:  */
                    115: cgi_t *www_parseMultiPart(const char *str, int ctlen, const char *ct);
                    116: /*
                    117:  * www_getValue() - Get Value from CGI session
                    118:  *
                    119:  * @cgi = Inited cgi session
                    120:  * @name = Name of cgi variable
                    121:  * return: NULL not found or !=NULL value
                    122:  */
                    123: inline const char *www_getValue(cgi_t * __restrict cgi, const char *name);
                    124: /*
                    125:  * www_addValue() - Add new or update if exists CGI variable
                    126:  *
                    127:  * @cgi = Inited cgi session
                    128:  * @name = Name of cgi variable
                    129:  * @value = Value of cgi variable
                    130:  * return: -1 error, 0 add new one or 1 updated variable
                    131:  */
                    132: int www_addValue(cgi_t * __restrict cgi, const char *name, const char *value);
                    133: /*
                    134:  * www_delPair() - Delete CGI variable from session
                    135:  *
                    136:  * @cgi = Inited cgi session
                    137:  * @name = Name of cgi variable
                    138:  * return: -1 error, 0 not found or 1 deleted ok
                    139:  */
                    140: int www_delPair(cgi_t * __restrict cgi, const char *name);
1.2     ! misho     141: /*
        !           142:  * www_listPairs() - Walk over CGI session variables
        !           143:  *
        !           144:  * @cgi = Cgi session
        !           145:  * @func = If !=NULL call function for each element
        !           146:  * @arg = Optional argument pass through callback
        !           147:  * return: -1 error or >-1 number of elements
        !           148:  */
        !           149: inline int www_listPairs(cgi_t * __restrict cgi, list_cb_t func, void *arg);
1.1       misho     150: 
                    151: /*
                    152:  * www_header() - Output initial html header
                    153:  *
                    154:  * @output = file handle
                    155:  * return: <1 error or >0 writed bytes
                    156:  */
                    157: inline int www_header(FILE *output);
                    158: 
                    159: /*
                    160:  * www_parseAttributes() - Parse attributes
                    161:  *
                    162:  * @ct = Content type
                    163:  * return: NULL error or !=NULL attributes
                    164:  */
                    165: inline cgi_t *www_parseAttributes(const char **ct);
                    166: /*
                    167:  * www_freeAttributes() - Free attributes
                    168:  *
                    169:  * @attr = Attributes
                    170:  * return: none
                    171:  */
                    172: inline void www_freeAttributes(cgi_t ** __restrict attr);
                    173: /*
                    174:  * www_getAttribute() - Get attribute by name
                    175:  *
                    176:  * @attr = Attributes
                    177:  * @name = Name of attribute
                    178:  * return: NULL not found or !=NULL attribute value
                    179:  */
                    180: inline const char *www_getAttribute(cgi_t * __restrict attr, const char *name);
                    181: 
                    182: 
                    183: #endif

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