2000-11-02 14:18:34 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2004-01-08 08:18:22 +00:00
|
|
|
| PHP Version 5 |
|
2000-11-02 14:18:34 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2007-01-01 09:36:18 +00:00
|
|
|
| Copyright (c) 1997-2007 The PHP Group |
|
2000-11-02 14:18:34 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 12:51:34 +00:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2000-11-02 14:18:34 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-10 20:04:29 +00:00
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 12:51:34 +00:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
2000-11-02 14:18:34 +00:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
2002-11-25 12:30:28 +00:00
|
|
|
| Author: Hartmut Holzgraefe <hholzgra@php.net> |
|
2000-11-02 14:18:34 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2003-02-19 08:40:19 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2000-11-02 14:18:34 +00:00
|
|
|
#include "php.h"
|
|
|
|
#include "logos.h"
|
|
|
|
#include "php_logos.h"
|
|
|
|
#include "ext/standard/info.h"
|
|
|
|
#include "SAPI.h"
|
|
|
|
|
|
|
|
typedef struct _php_info_logo {
|
2006-08-12 19:33:54 +00:00
|
|
|
const char *mimetype;
|
2000-11-02 14:18:34 +00:00
|
|
|
int mimelen;
|
2006-07-13 15:05:30 +00:00
|
|
|
const unsigned char *data;
|
2000-11-02 14:18:34 +00:00
|
|
|
int size;
|
|
|
|
} php_info_logo;
|
|
|
|
|
2007-01-06 20:44:51 +00:00
|
|
|
static HashTable phpinfo_logo_hash;
|
2000-11-02 14:18:34 +00:00
|
|
|
|
2006-08-12 19:33:54 +00:00
|
|
|
PHPAPI int php_register_info_logo(char *logo_string, const char *mimetype, const unsigned char *data, int size)
|
2000-11-02 14:18:34 +00:00
|
|
|
{
|
2000-12-08 12:32:16 +00:00
|
|
|
php_info_logo info_logo;
|
2000-11-02 14:18:34 +00:00
|
|
|
|
2000-12-08 12:32:16 +00:00
|
|
|
info_logo.mimetype = mimetype;
|
|
|
|
info_logo.mimelen = strlen(mimetype);
|
|
|
|
info_logo.data = data;
|
|
|
|
info_logo.size = size;
|
2000-11-02 14:18:34 +00:00
|
|
|
|
2000-12-08 12:32:16 +00:00
|
|
|
return zend_hash_add(&phpinfo_logo_hash, logo_string, strlen(logo_string), &info_logo, sizeof(php_info_logo), NULL);
|
2000-11-02 14:18:34 +00:00
|
|
|
}
|
|
|
|
|
2001-05-21 17:48:49 +00:00
|
|
|
PHPAPI int php_unregister_info_logo(char *logo_string)
|
2000-11-02 14:18:34 +00:00
|
|
|
{
|
|
|
|
return zend_hash_del(&phpinfo_logo_hash, logo_string, strlen(logo_string));
|
|
|
|
}
|
|
|
|
|
|
|
|
int php_init_info_logos(void)
|
|
|
|
{
|
|
|
|
if(zend_hash_init(&phpinfo_logo_hash, 0, NULL, NULL, 1)==FAILURE)
|
|
|
|
return FAILURE;
|
|
|
|
|
|
|
|
php_register_info_logo(PHP_LOGO_GUID , "image/gif", php_logo , sizeof(php_logo));
|
|
|
|
php_register_info_logo(PHP_EGG_LOGO_GUID, "image/gif", php_egg_logo, sizeof(php_egg_logo));
|
|
|
|
php_register_info_logo(ZEND_LOGO_GUID , "image/gif", zend_logo , sizeof(zend_logo));
|
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int php_shutdown_info_logos(void)
|
|
|
|
{
|
|
|
|
zend_hash_destroy(&phpinfo_logo_hash);
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CONTENT_TYPE_HEADER "Content-Type: "
|
2001-07-31 06:28:05 +00:00
|
|
|
int php_info_logos(const char *logo_string TSRMLS_DC)
|
2000-11-02 14:18:34 +00:00
|
|
|
{
|
|
|
|
php_info_logo *logo_image;
|
|
|
|
char *content_header;
|
|
|
|
int len;
|
|
|
|
|
2001-08-05 01:43:02 +00:00
|
|
|
if(FAILURE==zend_hash_find(&phpinfo_logo_hash, (char *) logo_string, strlen(logo_string), (void **)&logo_image))
|
2000-11-02 14:18:34 +00:00
|
|
|
return 0;
|
|
|
|
|
2006-12-28 15:09:29 +00:00
|
|
|
len = sizeof(CONTENT_TYPE_HEADER) - 1 + logo_image->mimelen;
|
|
|
|
content_header = emalloc(len + 1);
|
|
|
|
memcpy(content_header, CONTENT_TYPE_HEADER, sizeof(CONTENT_TYPE_HEADER) - 1);
|
|
|
|
memcpy(content_header + sizeof(CONTENT_TYPE_HEADER) - 1 , logo_image->mimetype, logo_image->mimelen);
|
|
|
|
content_header[len] = '\0';
|
|
|
|
sapi_add_header(content_header, len, 0);
|
2000-11-02 14:18:34 +00:00
|
|
|
|
|
|
|
PHPWRITE(logo_image->data, logo_image->size);
|
|
|
|
return 1;
|
|
|
|
}
|
2001-06-05 13:12:10 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
2001-09-09 13:29:31 +00:00
|
|
|
* vim600: sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: sw=4 ts=4
|
2001-06-05 13:12:10 +00:00
|
|
|
*/
|