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. */
| 809 | * returns C_OK. Otherwise return C_ERR and send an error to the |
| 810 | * client. */ |
| 811 | int parseScanCursorOrReply(client *c, robj *o, unsigned long *cursor) { |
| 812 | char *eptr; |
| 813 | |
| 814 | /* Use strtoul() because we need an *unsigned* long, so |
| 815 | * getLongLongFromObject() does not cover the whole cursor space. */ |
| 816 | errno = 0; |
| 817 | *cursor = strtoul(o->ptr, &eptr, 10); |
| 818 | if (isspace(((char*)o->ptr)[0]) || eptr[0] != '\0' || errno == ERANGE) |
| 819 | { |
| 820 | addReplyError(c, "invalid cursor"); |
| 821 | return C_ERR; |
| 822 | } |
| 823 | return C_OK; |
| 824 | } |
| 825 | |
| 826 | /* This command implements SCAN, HSCAN and SSCAN commands. |
| 827 | * If object 'o' is passed, then it must be a Hash, Set or Zset object, otherwise |
no test coverage detected