Input Argument Helper. * Extract the distance from the specified two 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.*/
| 148 | * that should be in the form: <number> <unit>, and return C_OK or C_ERR means success or failure |
| 149 | * *conversions is populated with the coefficient to use in order to convert meters to the unit.*/ |
| 150 | int extractDistanceOrReply(client *c, robj **argv, |
| 151 | double *conversion, double *radius) { |
| 152 | double distance; |
| 153 | if (getDoubleFromObjectOrReply(c, argv[0], &distance, |
| 154 | "need numeric radius") != C_OK) { |
| 155 | return C_ERR; |
| 156 | } |
| 157 | |
| 158 | if (distance < 0) { |
| 159 | addReplyError(c,"radius cannot be negative"); |
| 160 | return C_ERR; |
| 161 | } |
| 162 | if (radius) *radius = distance; |
| 163 | |
| 164 | double to_meters = extractUnitOrReply(c,argv[1]); |
| 165 | if (to_meters < 0) { |
| 166 | return C_ERR; |
| 167 | } |
| 168 | |
| 169 | if (conversion) *conversion = to_meters; |
| 170 | return C_OK; |
| 171 | } |
| 172 | |
| 173 | /* Input Argument Helper. |
| 174 | * Extract height and width from the specified three arguments starting at 'argv' |
no test coverage detected