Annotation of embedaddon/php/sapi/litespeed/lsapilib.h, revision 1.1

1.1     ! misho       1: 
        !             2: /*
        !             3:    +----------------------------------------------------------------------+
        !             4:    | PHP Version 5                                                        |
        !             5:    +----------------------------------------------------------------------+
        !             6:    | Copyright (c) 1997-2007 The PHP Group                                |
        !             7:    +----------------------------------------------------------------------+
        !             8:    | This source file is subject to version 3.01 of the PHP license,      |
        !             9:    | that is bundled with this package in the file LICENSE, and is        |
        !            10:    | available at through the world-wide-web at the following url:        |
        !            11:    | http://www.php.net/license/3_01.txt.                                 |
        !            12:    | If you did not receive a copy of the PHP license and are unable to   |
        !            13:    | obtain it through the world-wide-web, please send a note to          |
        !            14:    | license@php.net so we can mail you a copy immediately.               |
        !            15:    +----------------------------------------------------------------------+
        !            16:    | Author: George Wang <gwang@litespeedtech.com>                        |
        !            17:    +----------------------------------------------------------------------+
        !            18: */
        !            19: 
        !            20: /*
        !            21: Copyright (c) 2007, Lite Speed Technologies Inc.
        !            22: All rights reserved.
        !            23: 
        !            24: Redistribution and use in source and binary forms, with or without
        !            25: modification, are permitted provided that the following conditions are
        !            26: met: 
        !            27: 
        !            28:     * Redistributions of source code must retain the above copyright
        !            29:       notice, this list of conditions and the following disclaimer. 
        !            30:     * Redistributions in binary form must reproduce the above
        !            31:       copyright notice, this list of conditions and the following
        !            32:       disclaimer in the documentation and/or other materials provided
        !            33:       with the distribution. 
        !            34:     * Neither the name of the Lite Speed Technologies Inc nor the
        !            35:       names of its contributors may be used to endorse or promote
        !            36:       products derived from this software without specific prior
        !            37:       written permission.  
        !            38: 
        !            39: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
        !            40: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
        !            41: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
        !            42: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
        !            43: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
        !            44: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
        !            45: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        !            46: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
        !            47: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        !            48: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        !            49: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
        !            50: */
        !            51: 
        !            52: 
        !            53: 
        !            54: #ifndef  _LSAPILIB_H_
        !            55: #define  _LSAPILIB_H_
        !            56: 
        !            57: #if defined (c_plusplus) || defined (__cplusplus)
        !            58: extern "C" {
        !            59: #endif
        !            60: 
        !            61: #include <stddef.h>
        !            62: #include <lsapidef.h>
        !            63: 
        !            64: #include <sys/time.h>
        !            65: #include <sys/types.h>
        !            66: 
        !            67: struct LSAPI_key_value_pair
        !            68: {
        !            69:     char * pKey;
        !            70:     char * pValue;
        !            71:     int    keyLen;
        !            72:     int    valLen;
        !            73: };
        !            74: 
        !            75: 
        !            76: #define LSAPI_MAX_RESP_HEADERS  100
        !            77: 
        !            78: typedef struct lsapi_request
        !            79: {
        !            80:     int               m_fdListen;
        !            81:     int               m_fd;
        !            82: 
        !            83:     long              m_lLastActive;
        !            84:     long              m_lReqBegin;
        !            85: 
        !            86:     char            * m_pReqBuf;
        !            87:     int               m_reqBufSize;
        !            88:     
        !            89:     char            * m_pRespBuf;
        !            90:     char            * m_pRespBufEnd;
        !            91:     char            * m_pRespBufPos;
        !            92: 
        !            93:     char            * m_pRespHeaderBuf;
        !            94:     char            * m_pRespHeaderBufEnd;
        !            95:     char            * m_pRespHeaderBufPos;
        !            96: 
        !            97: 
        !            98:     struct iovec    * m_pIovec;
        !            99:     struct iovec    * m_pIovecEnd;
        !           100:     struct iovec    * m_pIovecCur;
        !           101:     struct iovec    * m_pIovecToWrite;    
        !           102: 
        !           103:     struct lsapi_packet_header      * m_respPktHeaderEnd;
        !           104: 
        !           105:     struct lsapi_req_header         * m_pHeader;
        !           106:     struct LSAPI_key_value_pair     * m_pEnvList;
        !           107:     struct LSAPI_key_value_pair     * m_pSpecialEnvList;
        !           108:     int                               m_envListSize;
        !           109:     int                               m_specialEnvListSize;
        !           110: 
        !           111:     struct lsapi_http_header_index  * m_pHeaderIndex;
        !           112:     struct lsapi_header_offset      * m_pUnknownHeader;
        !           113:     
        !           114:     char            * m_pScriptFile;
        !           115:     char            * m_pScriptName;
        !           116:     char            * m_pQueryString;
        !           117:     char            * m_pHttpHeader;
        !           118:     char            * m_pRequestMethod;
        !           119:     int               m_totalLen;
        !           120:     int               m_reqState;
        !           121:     int               m_reqBodyRead;
        !           122:     int               m_bufProcessed;
        !           123:     int               m_bufRead;
        !           124:     
        !           125:     struct lsapi_packet_header        m_respPktHeader[5];
        !           126:     
        !           127:     struct lsapi_resp_header          m_respHeader;
        !           128:     short                             m_respHeaderLen[LSAPI_MAX_RESP_HEADERS];
        !           129: 
        !           130: }LSAPI_Request;
        !           131: 
        !           132: extern LSAPI_Request g_req;
        !           133: 
        !           134: 
        !           135: /* return: >0 continue, ==0 stop, -1 failed  */
        !           136: typedef int (*LSAPI_CB_EnvHandler )( const char * pKey, int keyLen,
        !           137:                 const char * pValue, int valLen, void * arg );
        !           138: 
        !           139: 
        !           140: int LSAPI_Init(void);
        !           141: 
        !           142: void LSAPI_Stop(void);
        !           143: 
        !           144: int LSAPI_Is_Listen_r( LSAPI_Request * pReq);
        !           145: 
        !           146: int LSAPI_InitRequest( LSAPI_Request * pReq, int fd );
        !           147: 
        !           148: int LSAPI_Accept_r( LSAPI_Request * pReq );
        !           149: 
        !           150: void LSAPI_Reset_r( LSAPI_Request * pReq );
        !           151: 
        !           152: int LSAPI_Finish_r( LSAPI_Request * pReq );
        !           153: 
        !           154: int LSAPI_Release_r( LSAPI_Request * pReq );
        !           155: 
        !           156: char * LSAPI_GetHeader_r( LSAPI_Request * pReq, int headerIndex );
        !           157: 
        !           158: int LSAPI_ForeachHeader_r( LSAPI_Request * pReq,
        !           159:             LSAPI_CB_EnvHandler fn, void * arg );
        !           160: 
        !           161: int LSAPI_ForeachOrgHeader_r( LSAPI_Request * pReq,
        !           162:             LSAPI_CB_EnvHandler fn, void * arg );
        !           163: 
        !           164: int LSAPI_ForeachEnv_r( LSAPI_Request * pReq,
        !           165:             LSAPI_CB_EnvHandler fn, void * arg );
        !           166: 
        !           167: int LSAPI_ForeachSpecialEnv_r( LSAPI_Request * pReq,
        !           168:             LSAPI_CB_EnvHandler fn, void * arg );
        !           169: 
        !           170: char * LSAPI_GetEnv_r( LSAPI_Request * pReq, const char * name );
        !           171:             
        !           172: 
        !           173: int LSAPI_ReadReqBody_r( LSAPI_Request * pReq, char * pBuf, int len );
        !           174: 
        !           175: int LSAPI_ReqBodyGetChar_r( LSAPI_Request * pReq );
        !           176: 
        !           177: int LSAPI_ReqBodyGetLine_r( LSAPI_Request * pReq, char * pBuf, int bufLen, int *getLF );
        !           178: 
        !           179: 
        !           180: int LSAPI_FinalizeRespHeaders_r( LSAPI_Request * pReq );
        !           181: 
        !           182: int LSAPI_Write_r( LSAPI_Request * pReq, const char * pBuf, int len );
        !           183: 
        !           184: int LSAPI_Write_Stderr_r( LSAPI_Request * pReq, const char * pBuf, int len );
        !           185: 
        !           186: int LSAPI_Flush_r( LSAPI_Request * pReq );
        !           187: 
        !           188: int LSAPI_AppendRespHeader_r( LSAPI_Request * pHeader, char * pBuf, int len );
        !           189: 
        !           190: static inline int LSAPI_SetRespStatus_r( LSAPI_Request * pReq, int code )
        !           191: {
        !           192:     if ( !pReq )
        !           193:         return -1;
        !           194:     pReq->m_respHeader.m_respInfo.m_status = code;
        !           195:     return 0;
        !           196: }
        !           197: 
        !           198: static inline char * LSAPI_GetQueryString_r( LSAPI_Request * pReq )
        !           199: {
        !           200:     if ( pReq )
        !           201:         return pReq->m_pQueryString;
        !           202:     return NULL;
        !           203: }
        !           204: 
        !           205: 
        !           206: static inline char * LSAPI_GetScriptFileName_r( LSAPI_Request * pReq )
        !           207: {
        !           208:     if ( pReq )
        !           209:         return pReq->m_pScriptFile;
        !           210:     return NULL;
        !           211: }
        !           212: 
        !           213: 
        !           214: static inline char * LSAPI_GetScriptName_r( LSAPI_Request * pReq )
        !           215: {
        !           216:     if ( pReq )
        !           217:         return pReq->m_pScriptName;
        !           218:     return NULL;
        !           219: }
        !           220: 
        !           221: 
        !           222: static inline char * LSAPI_GetRequestMethod_r( LSAPI_Request * pReq)
        !           223: {
        !           224:     if ( pReq )
        !           225:         return pReq->m_pRequestMethod;
        !           226:     return NULL;
        !           227: }
        !           228: 
        !           229: 
        !           230: 
        !           231: static inline int  LSAPI_GetReqBodyLen_r( LSAPI_Request * pReq )
        !           232: {
        !           233:     if ( pReq )
        !           234:         return pReq->m_pHeader->m_reqBodyLen;
        !           235:     return -1;
        !           236: }
        !           237: 
        !           238: static inline int LSAPI_GetReqBodyRemain_r( LSAPI_Request * pReq )
        !           239: {
        !           240:     if ( pReq )
        !           241:         return pReq->m_pHeader->m_reqBodyLen - pReq->m_reqBodyRead;
        !           242:     return -1;
        !           243: }
        !           244: 
        !           245: 
        !           246: int LSAPI_Is_Listen(void);
        !           247: 
        !           248: static inline int LSAPI_Accept( void )
        !           249: {   return LSAPI_Accept_r( &g_req );                        }
        !           250: 
        !           251: static inline int LSAPI_Finish(void)
        !           252: {   return LSAPI_Finish_r( &g_req );                        }
        !           253: 
        !           254: static inline char * LSAPI_GetHeader( int headerIndex )
        !           255: {   return LSAPI_GetHeader_r( &g_req, headerIndex );        }
        !           256: 
        !           257: static inline int LSAPI_ForeachHeader( LSAPI_CB_EnvHandler fn, void * arg )
        !           258: {   return LSAPI_ForeachHeader_r( &g_req, fn, arg );        }
        !           259: 
        !           260: static inline int LSAPI_ForeachOrgHeader(
        !           261:             LSAPI_CB_EnvHandler fn, void * arg )
        !           262: {   return LSAPI_ForeachOrgHeader_r( &g_req, fn, arg );     }
        !           263: 
        !           264: static inline int LSAPI_ForeachEnv( LSAPI_CB_EnvHandler fn, void * arg )
        !           265: {   return LSAPI_ForeachEnv_r( &g_req, fn, arg );           }
        !           266: 
        !           267: static inline int LSAPI_ForeachSpecialEnv( LSAPI_CB_EnvHandler fn, void * arg )
        !           268: {   return LSAPI_ForeachSpecialEnv_r( &g_req, fn, arg );    }
        !           269: 
        !           270: static inline char * LSAPI_GetEnv( const char * name )
        !           271: {   return LSAPI_GetEnv_r( &g_req, name );                  }
        !           272: 
        !           273: static inline char * LSAPI_GetQueryString()
        !           274: {   return LSAPI_GetQueryString_r( &g_req );                }
        !           275: 
        !           276: static inline char * LSAPI_GetScriptFileName()
        !           277: {   return LSAPI_GetScriptFileName_r( &g_req );             }
        !           278: 
        !           279: static inline char * LSAPI_GetScriptName()
        !           280: {    return LSAPI_GetScriptName_r( &g_req );                }
        !           281: 
        !           282: static inline char * LSAPI_GetRequestMethod()
        !           283: {   return LSAPI_GetRequestMethod_r( &g_req );              }
        !           284: 
        !           285: static inline int LSAPI_GetReqBodyLen()
        !           286: {   return LSAPI_GetReqBodyLen_r( &g_req );                 }
        !           287: 
        !           288: static inline int LSAPI_GetReqBodyRemain()
        !           289: {   return LSAPI_GetReqBodyRemain_r( &g_req );                 }
        !           290: 
        !           291: static inline int LSAPI_ReadReqBody( char * pBuf, int len )
        !           292: {   return LSAPI_ReadReqBody_r( &g_req, pBuf, len );        }
        !           293: 
        !           294: static inline int LSAPI_ReqBodyGetChar()
        !           295: {   return LSAPI_ReqBodyGetChar_r( &g_req );        }
        !           296: 
        !           297: static inline int LSAPI_ReqBodyGetLine( char * pBuf, int len, int *getLF )
        !           298: {   return LSAPI_ReqBodyGetLine_r( &g_req, pBuf, len, getLF );        }
        !           299: 
        !           300: 
        !           301: 
        !           302: static inline int LSAPI_FinalizeRespHeaders(void)
        !           303: {   return LSAPI_FinalizeRespHeaders_r( &g_req );           }
        !           304: 
        !           305: static inline int LSAPI_Write( const char * pBuf, int len )
        !           306: {   return LSAPI_Write_r( &g_req, pBuf, len );              }
        !           307: 
        !           308: static inline int LSAPI_Write_Stderr( const char * pBuf, int len )
        !           309: {   return LSAPI_Write_Stderr_r( &g_req, pBuf, len );       }
        !           310: 
        !           311: static inline int LSAPI_Flush()
        !           312: {   return LSAPI_Flush_r( &g_req );                         }
        !           313: 
        !           314: static inline int LSAPI_AppendRespHeader( char * pBuf, int len )
        !           315: {   return LSAPI_AppendRespHeader_r( &g_req, pBuf, len );   }
        !           316: 
        !           317: static inline int LSAPI_SetRespStatus( int code )
        !           318: {   return LSAPI_SetRespStatus_r( &g_req, code );           }
        !           319: 
        !           320: int LSAPI_IsRunning(void);
        !           321: 
        !           322: int LSAPI_CreateListenSock( const char * pBind, int backlog );
        !           323: 
        !           324: typedef int (*fn_select_t)( int, fd_set *, fd_set *, fd_set *, struct timeval * );
        !           325: 
        !           326: int LSAPI_Init_Prefork_Server( int max_children, fn_select_t fp, int avoidFork );
        !           327: 
        !           328: void LSAPI_Set_Server_fd( int fd );
        !           329: 
        !           330: int LSAPI_Prefork_Accept_r( LSAPI_Request * pReq );
        !           331: 
        !           332: void LSAPI_Set_Max_Reqs( int reqs );
        !           333: 
        !           334: void LSAPI_Set_Max_Idle( int secs );
        !           335: 
        !           336: void LSAPI_Set_Max_Children( int maxChildren );
        !           337: 
        !           338: void LSAPI_Set_Max_Idle_Children( int maxIdleChld );
        !           339: 
        !           340: void LSAPI_Set_Server_Max_Idle_Secs( int serverMaxIdle );
        !           341: 
        !           342: void LSAPI_Set_Max_Process_Time( int secs );
        !           343: 
        !           344: void LSAPI_Init_Env_Parameters( fn_select_t fp );
        !           345: 
        !           346: void LSAPI_Set_Slow_Req_Msecs( int msecs );
        !           347: 
        !           348: int  LSAPI_Get_Slow_Req_Msecs( );
        !           349: 
        !           350: 
        !           351: #if defined (c_plusplus) || defined (__cplusplus)
        !           352: }
        !           353: #endif
        !           354: 
        !           355: 
        !           356: #endif
        !           357: 
        !           358: 
        !           359: 
        !           360: 
        !           361: 
        !           362: 
        !           363: 

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