/* {{{ proto double deg2rad(double number) Converts the number in degrees to the radian equivalent */ void php3_deg2rad(INTERNAL_FUNCTION_PARAMETERS) { pval *deg; TLS_VARS; if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, °) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_double(deg); RETVAL_DOUBLE((deg->value.dval / 180.0) * M_PI); }
/* {{{ proto double rad2deg(double number) Converts the radian number to the equivalent number in degrees */ void php3_rad2deg(INTERNAL_FUNCTION_PARAMETERS) { pval *rad; TLS_VARS; if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &rad) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_double(rad); RETVAL_DOUBLE((rad->value.dval / M_PI) * 180); }
/* {{{ proto float GmagickPixel::getColorValue(int color ) Gets the normalized color of the GmagickPixel. */ PHP_METHOD(gmagickpixel, getcolorvalue) { php_gmagickpixel_object *internp; zend_long color; double color_value = 0; /* Parse parameters given to function */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color) == FAILURE) { return; } internp = Z_GMAGICKPIXEL_OBJ_P(getThis()); switch (color) { case GMAGICK_COLOR_BLACK: color_value = PixelGetBlack(internp->pixel_wand); break; case GMAGICK_COLOR_BLUE: color_value = PixelGetBlue(internp->pixel_wand); break; case GMAGICK_COLOR_CYAN: color_value = PixelGetCyan(internp->pixel_wand); break; case GMAGICK_COLOR_GREEN: color_value = PixelGetGreen(internp->pixel_wand); break; case GMAGICK_COLOR_RED: color_value = PixelGetRed(internp->pixel_wand); break; case GMAGICK_COLOR_YELLOW: color_value = PixelGetYellow(internp->pixel_wand); break; case GMAGICK_COLOR_MAGENTA: color_value = PixelGetMagenta(internp->pixel_wand); break; case GMAGICK_COLOR_OPACITY: color_value = PixelGetOpacity(internp->pixel_wand); break; default: GMAGICK_THROW_GMAGICKPIXEL_EXCEPTION(internp->pixel_wand, "Unknown color type"); break; } RETVAL_DOUBLE(color_value); }
/* {{{ proto float GmagickDraw::getStrokeWidth() Returns the width of the stroke used to draw object outlines. */ PHP_METHOD(gmagickdraw, getstrokewidth) { php_gmagickdraw_object *internd; double width; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { return; } internd = (php_gmagickdraw_object *)zend_object_store_get_object(getThis() TSRMLS_CC); width = DrawGetStrokeWidth(internd->drawing_wand); RETVAL_DOUBLE(width); }
/* {{{ proto float GmagickDraw::getFillOpacity() Returns the opacity used when drawing using the fill color or fill texture. Fully opaque is 1.0. */ PHP_METHOD(gmagickdraw, getfillopacity) { php_gmagickdraw_object *internd; double opacity; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { return; } internd = (php_gmagickdraw_object *)zend_object_store_get_object(getThis() TSRMLS_CC); opacity = DrawGetFillOpacity(internd->drawing_wand); RETVAL_DOUBLE(opacity); }
/* {{{ proto float GmagickDraw::getStrokeDashOffset() Returns the offset into the dash pattern to start the dash. */ PHP_METHOD(gmagickdraw, getstrokedashoffset) { php_gmagickdraw_object *internd; double offset; if (zend_parse_parameters_none() == FAILURE) { return; } internd = (php_gmagickdraw_object *)zend_object_store_get_object(getThis() TSRMLS_CC); offset = DrawGetStrokeDashOffset(internd->drawing_wand); RETVAL_DOUBLE(offset); }
bool ssdb_geo_distance( SSDBSock *ssdb_sock, char *key, int key_len, char *member_a_key, int member_a_key_len, char *member_b_key, int member_b_key_len, INTERNAL_FUNCTION_PARAMETERS) { double a_latlong[2] = {0}; if (!ssdb_geo_member(ssdb_sock, key, key_len, member_a_key, member_a_key_len, (double *)a_latlong)) { return false; } double b_latlong[2] = {0}; if (!ssdb_geo_member(ssdb_sock, key, key_len, member_b_key, member_b_key_len, (double *)b_latlong)) { return false; } RETVAL_DOUBLE(geohashDistanceEarth(a_latlong[0], a_latlong[1], b_latlong[0], b_latlong[1])); return true; }
/* {{{ proto Quantum ImagickPixel::getColorValueQuantum(int color) Gets the quantum value of a color in the ImagickPixel. Quantum is a float if ImageMagick was compiled with HDRI otherwise an integer. */ PHP_METHOD(imagickpixel, getcolorvaluequantum) { php_imagickpixel_object *internp; im_long color; Quantum color_value; /* Parse parameters given to function */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color) == FAILURE) { return; } internp = Z_IMAGICKPIXEL_P(getThis()); switch (color) { case PHP_IMAGICK_COLOR_BLACK: color_value = PixelGetBlackQuantum(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_BLUE: color_value = PixelGetBlueQuantum(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_CYAN: color_value = PixelGetCyanQuantum(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_GREEN: color_value = PixelGetGreenQuantum(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_RED: color_value = PixelGetRedQuantum(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_YELLOW: color_value = PixelGetYellowQuantum(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_MAGENTA: color_value = PixelGetMagentaQuantum(internp->pixel_wand); break; #if MagickLibVersion < 0x700 case PHP_IMAGICK_COLOR_OPACITY: color_value = PixelGetOpacityQuantum(internp->pixel_wand); break; #endif case PHP_IMAGICK_COLOR_ALPHA: color_value = PixelGetAlphaQuantum(internp->pixel_wand); break; default: php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC); return; break; } #if MAGICKCORE_HDRI_ENABLE RETVAL_DOUBLE(color_value); #else RETVAL_LONG(color_value); #endif }
/* {{{ proto float ImagickPixel::getColorValue(int color) Gets the normalized value of a color in the ImagickPixel. */ PHP_METHOD(imagickpixel, getcolorvalue) { php_imagick_color_t color_enum; php_imagickpixel_object *internp; im_long color; double color_value = 0; /* Parse parameters given to function */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color) == FAILURE) { return; } internp = Z_IMAGICKPIXEL_P(getThis()); if (color <= PHP_IMAGICK_COLOR_MIN || color >= PHP_IMAGICK_COLOR_MAX) { php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC); return; } color_enum = color; switch (color_enum) { case PHP_IMAGICK_COLOR_BLACK: color_value = PixelGetBlack(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_BLUE: color_value = PixelGetBlue(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_CYAN: color_value = PixelGetCyan(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_GREEN: color_value = PixelGetGreen(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_RED: color_value = PixelGetRed(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_YELLOW: color_value = PixelGetYellow(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_MAGENTA: color_value = PixelGetMagenta(internp->pixel_wand); break; #if MagickLibVersion < 0x700 case PHP_IMAGICK_COLOR_OPACITY: color_value = PixelGetOpacity(internp->pixel_wand); break; #endif case PHP_IMAGICK_COLOR_ALPHA: color_value = PixelGetAlpha(internp->pixel_wand); break; #if MagickLibVersion > 0x628 case PHP_IMAGICK_COLOR_FUZZ: color_value = PixelGetFuzz(internp->pixel_wand); break; #endif default: php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC); return; break; } RETVAL_DOUBLE(color_value); }
/* {{{ proto float ImagickPixel::getColorValue(int color) Gets the normalized color of the ImagickPixel. */ PHP_METHOD(imagickpixel, getcolorvalue) { php_imagickpixel_object *internp; long color; double color_value = 0; /* Parse parameters given to function */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color) == FAILURE) { return; } internp = (php_imagickpixel_object *)zend_object_store_get_object(getThis() TSRMLS_CC); switch (color) { case IMAGICKCOLORBLACK: color_value = PixelGetBlack(internp->pixel_wand); break; case IMAGICKCOLORBLUE: color_value = PixelGetBlue(internp->pixel_wand); break; case IMAGICKCOLORCYAN: color_value = PixelGetCyan(internp->pixel_wand); break; case IMAGICKCOLORGREEN: color_value = PixelGetGreen(internp->pixel_wand); break; case IMAGICKCOLORRED: color_value = PixelGetRed(internp->pixel_wand); break; case IMAGICKCOLORYELLOW: color_value = PixelGetYellow(internp->pixel_wand); break; case IMAGICKCOLORMAGENTA: color_value = PixelGetMagenta(internp->pixel_wand); break; case IMAGICKCOLOROPACITY: color_value = PixelGetOpacity(internp->pixel_wand); break; case IMAGICKCOLORALPHA: color_value = PixelGetAlpha(internp->pixel_wand); break; #if MagickLibVersion > 0x628 case IMAGICKCOLORFUZZ: color_value = PixelGetFuzz(internp->pixel_wand); break; #endif default: php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC); return; break; } RETVAL_DOUBLE(color_value); }
static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */ { zval *id, retval, *context = NULL; xmlXPathContextPtr ctxp; xmlNodePtr nodep = NULL; xmlXPathObjectPtr xpathobjp; size_t expr_len, nsnbr = 0, xpath_type; dom_xpath_object *intern; dom_object *nodeobj; char *expr; xmlDoc *docp = NULL; xmlNsPtr *ns = NULL; zend_bool register_node_ns = 1; id = ZEND_THIS; if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|O!b", &expr, &expr_len, &context, dom_node_class_entry, ®ister_node_ns) == FAILURE) { return; } intern = Z_XPATHOBJ_P(id); ctxp = (xmlXPathContextPtr) intern->dom.ptr; if (ctxp == NULL) { php_error_docref(NULL, E_WARNING, "Invalid XPath Context"); RETURN_FALSE; } docp = (xmlDocPtr) ctxp->doc; if (docp == NULL) { php_error_docref(NULL, E_WARNING, "Invalid XPath Document Pointer"); RETURN_FALSE; } if (context != NULL) { DOM_GET_OBJ(nodep, context, xmlNodePtr, nodeobj); } if (!nodep) { nodep = xmlDocGetRootElement(docp); } if (nodep && docp != nodep->doc) { php_error_docref(NULL, E_WARNING, "Node From Wrong Document"); RETURN_FALSE; } ctxp->node = nodep; if (register_node_ns) { /* Register namespaces in the node */ ns = xmlGetNsList(docp, nodep); if (ns != NULL) { while (ns[nsnbr] != NULL) nsnbr++; } } ctxp->namespaces = ns; ctxp->nsNr = nsnbr; xpathobjp = xmlXPathEvalExpression((xmlChar *) expr, ctxp); ctxp->node = NULL; if (ns != NULL) { xmlFree(ns); ctxp->namespaces = NULL; ctxp->nsNr = 0; } if (! xpathobjp) { RETURN_FALSE; } if (type == PHP_DOM_XPATH_QUERY) { xpath_type = XPATH_NODESET; } else { xpath_type = xpathobjp->type; } switch (xpath_type) { case XPATH_NODESET: { int i; xmlNodeSetPtr nodesetp; if (xpathobjp->type == XPATH_NODESET && NULL != (nodesetp = xpathobjp->nodesetval) && nodesetp->nodeNr) { array_init(&retval); for (i = 0; i < nodesetp->nodeNr; i++) { xmlNodePtr node = nodesetp->nodeTab[i]; zval child; if (node->type == XML_NAMESPACE_DECL) { xmlNsPtr curns; xmlNodePtr nsparent; nsparent = node->_private; curns = xmlNewNs(NULL, node->name, NULL); if (node->children) { curns->prefix = xmlStrdup((xmlChar *) node->children); } if (node->children) { node = xmlNewDocNode(docp, NULL, (xmlChar *) node->children, node->name); } else { node = xmlNewDocNode(docp, NULL, (xmlChar *) "xmlns", node->name); } node->type = XML_NAMESPACE_DECL; node->parent = nsparent; node->ns = curns; } php_dom_create_object(node, &child, &intern->dom); add_next_index_zval(&retval, &child); } } else { ZVAL_EMPTY_ARRAY(&retval); } php_dom_create_interator(return_value, DOM_NODELIST); nodeobj = Z_DOMOBJ_P(return_value); dom_xpath_iter(&retval, nodeobj); break; } case XPATH_BOOLEAN: RETVAL_BOOL(xpathobjp->boolval); break; case XPATH_NUMBER: RETVAL_DOUBLE(xpathobjp->floatval); break; case XPATH_STRING: RETVAL_STRING((char *) xpathobjp->stringval); break; default: RETVAL_NULL(); break; } xmlXPathFreeObject(xpathobjp); }