/** * Copyright (c) 2008 Lars Strojny * Copyright (c) 2008 Timu Eren * Copyright (c) 2007 Khalid Ahsein * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the PHP MogileFS authors nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef MOGILEFS_H #define MOGILEFS_H #include "php.h" #include "ext/standard/url.h" #include "ext/standard/php_string.h" PHPAPI int le_mogilefs_sock; /* zend_class_entry {{{ */ PHPAPI zend_class_entry *mogilefs_ce; PHPAPI zend_class_entry *mogilefs_exception_ce; /* }}} */ #define mogilefs_sock_name "MogileFS Socket Buffer" /* MOGILEFS_SOCK_WRITE_FREE(socket, cmd, cmd_len) {{{ */ #define MOGILEFS_SOCK_WRITE_FREE(socket, cmd, cmd_len) \ mogilefs_sock_write (socket, cmd, cmd_len, 1 TSRMLS_CC) /* }}} */ /* MOGILEFS_SOCK_WRITE(socket, cmd, cmd_len) {{{ */ #define MOGILEFS_SOCK_WRITE(socket, cmd, cmd_len) \ mogilefs_sock_write (socket, cmd, cmd_len, 0 TSRMLS_CC) /* }}} */ /* libneon constants {{{ */ #define MOGILEFS_SOCK_BUF_SIZE 4096 #define MOGILEFS_DAV_SESSION_TIMEOUT 8 #define MOGILEFS_SOCK_STATUS_FAILED 0 #define MOGILEFS_SOCK_STATUS_DISCONNECTED 1 #define MOGILEFS_SOCK_STATUS_UNKNOWN 2 #define MOGILEFS_SOCK_STATUS_CONNECTED 3 /* }}} */ PHP_MINIT_FUNCTION(mogilefs); PHP_MSHUTDOWN_FUNCTION(mogilefs); /* {{{ struct MogilefsSock */ typedef struct MogilefsSock_ { php_stream *stream; char *host; char *domain; unsigned short port; long timeout; long failed; int status; } MogilefsSock; /* }}} */ /* {{{ internal function protos */ PHPAPI void mogilefs_destructor_mogilefs_sock(zend_rsrc_list_entry *rsrc TSRMLS_DC); PHPAPI int mogilefs_parse_response_to_array(INTERNAL_FUNCTION_PARAMETERS, char *result, int result_len); PHPAPI MogilefsSock* mogilefs_sock_server_init(char *m_host, int m_host_len, unsigned short m_port, char *m_domain, int m_domain_len, long timeout); PHPAPI int mogilefs_sock_connect(MogilefsSock *mogilefs_sock TSRMLS_DC); PHPAPI int mogilefs_sock_disconnect(MogilefsSock *mogilefs_sock TSRMLS_DC); PHPAPI int mogilefs_sock_server_open(MogilefsSock *mogilefs_sock, int TSRMLS_DC); PHPAPI int mogilefs_sock_get(zval *id, MogilefsSock **mogilefs_sock TSRMLS_DC); PHPAPI int mogilefs_sock_write(MogilefsSock *mogilefs_sock, char *cmd, int cmd_len, short free_cmd TSRMLS_DC); PHPAPI char * mogilefs_sock_read(MogilefsSock *mogilefs_sock, int *buf_len TSRMLS_DC); PHPAPI char * mogilefs_file_to_mem(char *filename, int *file_buffer_len TSRMLS_DC); PHPAPI char * mogilefs_create_open(MogilefsSock *mogilefs_sock, const char * const key, const char * const class, int multi_dest TSRMLS_DC); PHPAPI int mogilefs_create_close(MogilefsSock *mogilefs_sock, const char * const m_key, const char * const class, const char * const close_request TSRMLS_DC); PHPAPI int mogilefs_get_uri_path(const char * const url, php_url **p_url TSRMLS_DC); PHPAPI void mogilefs_free_socket(MogilefsSock *mogilefs_sock); /* }}} */ #endif /* * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */