Try to parse a SCAN cursor stored at object 'o': * if the cursor is valid, store it as unsigned integer into *cursor and * returns C_OK. Otherwise return C_ERR and send an error to the * client. */
| 1128 | * returns C_OK. Otherwise return C_ERR and send an error to the |
| 1129 | * client. */ |
| 1130 | int parseScanCursorOrReply(client *c, robj *o, unsigned long *cursor) { |
| 1131 | char *eptr; |
| 1132 | |
| 1133 | /* Use strtoul() because we need an *unsigned* long, so |
| 1134 | * getLongLongFromObject() does not cover the whole cursor space. */ |
| 1135 | errno = 0; |
| 1136 | *cursor = strtoul(szFromObj(o), &eptr, 10); |
| 1137 | if (isspace(((char*)ptrFromObj(o))[0]) || eptr[0] != '\0' || errno == ERANGE) |
| 1138 | { |
| 1139 | addReplyError(c, "invalid cursor"); |
| 1140 | return C_ERR; |
| 1141 | } |
| 1142 | return C_OK; |
| 1143 | } |
| 1144 | |
| 1145 | |
| 1146 | static bool filterKey(robj_roptr kobj, sds pat, int patlen) |
no test coverage detected