You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.1 KiB

26 years ago
26 years ago
26 years ago
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP version 4.0 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2001 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.02 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available at through the world-wide-web at |
  10. | http://www.php.net/license/2_02.txt. |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Hartmut Holzgraefe <hartmut@six.de> |
  16. +----------------------------------------------------------------------+
  17. */
  18. #include "php.h"
  19. #include "logos.h"
  20. #include "php_logos.h"
  21. #include "ext/standard/info.h"
  22. #include "SAPI.h"
  23. typedef struct _php_info_logo {
  24. char *mimetype;
  25. int mimelen;
  26. unsigned char *data;
  27. int size;
  28. } php_info_logo;
  29. HashTable phpinfo_logo_hash;
  30. PHPAPI int php_register_info_logo(char *logo_string, char *mimetype, unsigned char *data, int size)
  31. {
  32. php_info_logo info_logo;
  33. info_logo.mimetype = mimetype;
  34. info_logo.mimelen = strlen(mimetype);
  35. info_logo.data = data;
  36. info_logo.size = size;
  37. return zend_hash_add(&phpinfo_logo_hash, logo_string, strlen(logo_string), &info_logo, sizeof(php_info_logo), NULL);
  38. }
  39. PHPAPI int php_unregister_info_logo(char *logo_string)
  40. {
  41. return zend_hash_del(&phpinfo_logo_hash, logo_string, strlen(logo_string));
  42. }
  43. int php_init_info_logos(void)
  44. {
  45. if(zend_hash_init(&phpinfo_logo_hash, 0, NULL, NULL, 1)==FAILURE)
  46. return FAILURE;
  47. php_register_info_logo(PHP_LOGO_GUID , "image/gif", php_logo , sizeof(php_logo));
  48. php_register_info_logo(PHP_EGG_LOGO_GUID, "image/gif", php_egg_logo, sizeof(php_egg_logo));
  49. php_register_info_logo(ZEND_LOGO_GUID , "image/gif", zend_logo , sizeof(zend_logo));
  50. return SUCCESS;
  51. }
  52. int php_shutdown_info_logos(void)
  53. {
  54. zend_hash_destroy(&phpinfo_logo_hash);
  55. return SUCCESS;
  56. }
  57. #define CONTENT_TYPE_HEADER "Content-Type: "
  58. int php_info_logos(const char *logo_string)
  59. {
  60. php_info_logo *logo_image;
  61. char *content_header;
  62. int len;
  63. if(FAILURE==zend_hash_find(&phpinfo_logo_hash,(char *) logo_string,strlen(logo_string),(void **)&logo_image))
  64. return 0;
  65. len=strlen(CONTENT_TYPE_HEADER)+logo_image->mimelen;
  66. content_header=malloc(len+1);
  67. if(!content_header) return 0;
  68. strcpy(content_header,CONTENT_TYPE_HEADER);
  69. strcat(content_header,logo_image->mimetype);
  70. sapi_add_header(content_header, len, 1);
  71. free(content_header);
  72. PHPWRITE(logo_image->data, logo_image->size);
  73. return 1;
  74. }
  75. /*
  76. * Local variables:
  77. * tab-width: 4
  78. * c-basic-offset: 4
  79. * End:
  80. * vim600: sw=4 ts=4 tw=78 fdm=marker
  81. * vim<600: sw=4 ts=4 tw=78
  82. */