resource.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #include "xlswriter.h"
  13. /* {{{ */
  14. xls_resource_t * zval_get_resource(zval *handle)
  15. {
  16. xls_resource_t *res;
  17. if((res = (xls_resource_t *)zend_fetch_resource(Z_RES_P(handle), VTIFUL_RESOURCE_NAME, le_xls_writer)) == NULL) {
  18. zend_throw_exception(vtiful_exception_ce, "XLS resources resolution fail", 210);
  19. }
  20. return res;
  21. }
  22. /* }}} */
  23. /* {{{ */
  24. lxw_format * zval_get_format(zval *handle)
  25. {
  26. lxw_format *res;
  27. if((res = (lxw_format *)zend_fetch_resource(Z_RES_P(handle), VTIFUL_RESOURCE_NAME, le_xls_writer)) == NULL) {
  28. zend_throw_exception(vtiful_exception_ce, "format resources resolution fail", 210);
  29. }
  30. return res;
  31. }
  32. /* }}} */
  33. xls_resource_chart_t *zval_get_chart(zval *resource)
  34. {
  35. xls_resource_chart_t *res;
  36. if((res = (xls_resource_chart_t *)zend_fetch_resource(Z_RES_P(resource), VTIFUL_RESOURCE_NAME, le_xls_writer)) == NULL) {
  37. zend_throw_exception(vtiful_exception_ce, "chart resources resolution fail", 210);
  38. }
  39. return res;
  40. }