Input Argument Helper. * Extract height and width from the specified three arguments starting at 'argv' * that should be in the form: , and return C_OK or C_ERR means success or failure * *conversions is populated with the coefficient to use in order to convert meters to the unit.*/
| 175 | * that should be in the form: <number> <number> <unit>, and return C_OK or C_ERR means success or failure |
| 176 | * *conversions is populated with the coefficient to use in order to convert meters to the unit.*/ |
| 177 | int extractBoxOrReply(client *c, robj **argv, double *conversion, |
| 178 | double *width, double *height) { |
| 179 | double h, w; |
| 180 | if ((getDoubleFromObjectOrReply(c, argv[0], &w, "need numeric width") != C_OK) || |
| 181 | (getDoubleFromObjectOrReply(c, argv[1], &h, "need numeric height") != C_OK)) { |
| 182 | return C_ERR; |
| 183 | } |
| 184 | |
| 185 | if (h < 0 || w < 0) { |
| 186 | addReplyError(c, "height or width cannot be negative"); |
| 187 | return C_ERR; |
| 188 | } |
| 189 | if (height) *height = h; |
| 190 | if (width) *width = w; |
| 191 | |
| 192 | double to_meters = extractUnitOrReply(c,argv[2]); |
| 193 | if (to_meters < 0) { |
| 194 | return C_ERR; |
| 195 | } |
| 196 | |
| 197 | if (conversion) *conversion = to_meters; |
| 198 | return C_OK; |
| 199 | } |
| 200 | |
| 201 | /* The default addReplyDouble has too much accuracy. We use this |
| 202 | * for returning location distances. "5.2145 meters away" is nicer |
no test coverage detected