xlswriter.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. +----------------------------------------------------------------------+
  3. | XlsWriter Extension |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 2017-2018 The Viest |
  6. +----------------------------------------------------------------------+
  7. | http://www.viest.me |
  8. +----------------------------------------------------------------------+
  9. | Author: viest <[email protected]> |
  10. +----------------------------------------------------------------------+
  11. */
  12. #ifdef HAVE_CONFIG_H
  13. #include "config.h"
  14. #endif
  15. #include "php.h"
  16. #include "ext/standard/info.h"
  17. #include "xlswriter.h"
  18. #if ENABLE_READER
  19. #include <xlsxio_version.h>
  20. #include <xlsxio_read.h>
  21. #endif
  22. int le_xls_writer;
  23. ZEND_BEGIN_ARG_INFO_EX(xlswriter_get_version_arginfo, 0, 0, 0)
  24. ZEND_END_ARG_INFO()
  25. ZEND_BEGIN_ARG_INFO_EX(xlswriter_get_auther_arginfo, 0, 0, 0)
  26. ZEND_END_ARG_INFO()
  27. /* {{{ xlswriter_get_version
  28. */
  29. PHP_FUNCTION(xlswriter_get_version)
  30. {
  31. RETURN_STRINGL(PHP_XLSWRITER_VERSION, strlen(PHP_XLSWRITER_VERSION));
  32. }
  33. /* }}} */
  34. /* {{{ xlswriter_get_author
  35. */
  36. PHP_FUNCTION(xlswriter_get_author)
  37. {
  38. RETURN_STRINGL(PHP_XLSWRITER_AUTHOR, strlen(PHP_XLSWRITER_AUTHOR));
  39. }
  40. /* }}} */
  41. /* {{{ PHP_MINIT_FUNCTION
  42. */
  43. PHP_MINIT_FUNCTION(xlswriter)
  44. {
  45. VTIFUL_STARTUP_MODULE(exception);
  46. VTIFUL_STARTUP_MODULE(excel);
  47. VTIFUL_STARTUP_MODULE(format);
  48. VTIFUL_STARTUP_MODULE(chart);
  49. VTIFUL_STARTUP_MODULE(validation);
  50. VTIFUL_STARTUP_MODULE(rich_string);
  51. le_xls_writer = zend_register_list_destructors_ex(_php_vtiful_xls_close, NULL, VTIFUL_RESOURCE_NAME, module_number);
  52. return SUCCESS;
  53. }
  54. /* }}} */
  55. /* {{{ PHP_MSHUTDOWN_FUNCTION
  56. */
  57. PHP_MSHUTDOWN_FUNCTION(xlswriter)
  58. {
  59. return SUCCESS;
  60. }
  61. /* }}} */
  62. /* {{{ PHP_RINIT_FUNCTION
  63. */
  64. PHP_RINIT_FUNCTION(xlswriter)
  65. {
  66. #if defined(COMPILE_DL_VTIFUL) && defined(ZTS)
  67. ZEND_TSRMLS_CACHE_UPDATE();
  68. #endif
  69. return SUCCESS;
  70. }
  71. /* }}} */
  72. /* {{{ PHP_RSHUTDOWN_FUNCTION
  73. */
  74. PHP_RSHUTDOWN_FUNCTION(xlswriter)
  75. {
  76. return SUCCESS;
  77. }
  78. /* }}} */
  79. /* {{{ PHP_MINFO_FUNCTION
  80. */
  81. PHP_MINFO_FUNCTION(xlswriter)
  82. {
  83. php_info_print_table_start();
  84. php_info_print_table_header(2, "xlswriter support", "enabled");
  85. #if defined(PHP_XLSWRITER_VERSION)
  86. php_info_print_table_row(2, "Version", PHP_XLSWRITER_VERSION);
  87. #endif
  88. #ifdef LXW_VERSION
  89. #ifdef HAVE_LIBXLSXWRITER
  90. /* Build time */
  91. php_info_print_table_row(2, "libxlsxwriter headers version", LXW_VERSION);
  92. /* Run time, available since 0.7.9 */
  93. php_info_print_table_row(2, "libxlsxwriter library version", lxw_version());
  94. #else
  95. php_info_print_table_row(2, "bundled libxlsxwriter version", LXW_VERSION);
  96. #endif
  97. #endif
  98. #if ENABLE_READER
  99. #if HAVE_LIBXLSXIO
  100. /* Build time */
  101. php_info_print_table_row(2, "libxlsxio headers version", XLSXIO_VERSION_STRING);
  102. /* Run time */
  103. php_info_print_table_row(2, "libxlsxio library version", xlsxioread_get_version_string());
  104. #else
  105. php_info_print_table_row(2, "bundled libxlsxio version", XLSXIO_VERSION_STRING);
  106. #endif
  107. #endif
  108. php_info_print_table_end();
  109. }
  110. /* }}} */
  111. /* {{{ xlswriter_functions[]
  112. *
  113. * Every user visible function must have an entry in xlswriter_functions[].
  114. */
  115. const zend_function_entry xlswriter_functions[] = {
  116. PHP_FE(xlswriter_get_version, xlswriter_get_version_arginfo)
  117. PHP_FE(xlswriter_get_author, xlswriter_get_auther_arginfo)
  118. PHP_FE_END
  119. };
  120. /* }}} */
  121. /* {{{ vtiful_module_entry
  122. */
  123. zend_module_entry xlswriter_module_entry = {
  124. STANDARD_MODULE_HEADER,
  125. "xlswriter",
  126. xlswriter_functions,
  127. PHP_MINIT(xlswriter),
  128. PHP_MSHUTDOWN(xlswriter),
  129. PHP_RINIT(xlswriter), /* Replace with NULL if there's nothing to do at request start */
  130. PHP_RSHUTDOWN(xlswriter), /* Replace with NULL if there's nothing to do at request end */
  131. PHP_MINFO(xlswriter),
  132. PHP_XLSWRITER_VERSION,
  133. STANDARD_MODULE_PROPERTIES
  134. };
  135. /* }}} */
  136. #ifdef COMPILE_DL_XLSWRITER
  137. #ifdef ZTS
  138. ZEND_TSRMLS_CACHE_DEFINE();
  139. #endif
  140. ZEND_GET_MODULE(xlswriter)
  141. #endif
  142. /*
  143. * Local variables:
  144. * tab-width: 4
  145. * c-basic-offset: 4
  146. * End:
  147. * vim600: noet sw=4 ts=4 fdm=marker
  148. * vim<600: noet sw=4 ts=4
  149. */