Parse the flags string description 'strflags' and set them to the * command 'c'. If the flags are all valid C_OK is returned, otherwise * C_ERR is returned (yet the recognized flags are set in the command). */
| 3383 | * command 'c'. If the flags are all valid C_OK is returned, otherwise |
| 3384 | * C_ERR is returned (yet the recognized flags are set in the command). */ |
| 3385 | int populateCommandTableParseFlags(struct redisCommand *c, char *strflags) { |
| 3386 | int argc; |
| 3387 | sds *argv; |
| 3388 | |
| 3389 | /* Split the line into arguments for processing. */ |
| 3390 | argv = sdssplitargs(strflags,&argc); |
| 3391 | if (argv == NULL) return C_ERR; |
| 3392 | |
| 3393 | for (int j = 0; j < argc; j++) { |
| 3394 | char *flag = argv[j]; |
| 3395 | if (!strcasecmp(flag,"write")) { |
| 3396 | c->flags |= CMD_WRITE|CMD_CATEGORY_WRITE; |
| 3397 | } else if (!strcasecmp(flag,"read-only")) { |
| 3398 | c->flags |= CMD_READONLY|CMD_CATEGORY_READ; |
| 3399 | } else if (!strcasecmp(flag,"use-memory")) { |
| 3400 | c->flags |= CMD_DENYOOM; |
| 3401 | } else if (!strcasecmp(flag,"admin")) { |
| 3402 | c->flags |= CMD_ADMIN|CMD_CATEGORY_ADMIN|CMD_CATEGORY_DANGEROUS; |
| 3403 | } else if (!strcasecmp(flag,"pub-sub")) { |
| 3404 | c->flags |= CMD_PUBSUB|CMD_CATEGORY_PUBSUB; |
| 3405 | } else if (!strcasecmp(flag,"no-script")) { |
| 3406 | c->flags |= CMD_NOSCRIPT; |
| 3407 | } else if (!strcasecmp(flag,"random")) { |
| 3408 | c->flags |= CMD_RANDOM; |
| 3409 | } else if (!strcasecmp(flag,"to-sort")) { |
| 3410 | c->flags |= CMD_SORT_FOR_SCRIPT; |
| 3411 | } else if (!strcasecmp(flag,"ok-loading")) { |
| 3412 | c->flags |= CMD_LOADING; |
| 3413 | } else if (!strcasecmp(flag,"ok-stale")) { |
| 3414 | c->flags |= CMD_STALE; |
| 3415 | } else if (!strcasecmp(flag,"no-monitor")) { |
| 3416 | c->flags |= CMD_SKIP_MONITOR; |
| 3417 | } else if (!strcasecmp(flag,"no-slowlog")) { |
| 3418 | c->flags |= CMD_SKIP_SLOWLOG; |
| 3419 | } else if (!strcasecmp(flag,"cluster-asking")) { |
| 3420 | c->flags |= CMD_ASKING; |
| 3421 | } else if (!strcasecmp(flag,"fast")) { |
| 3422 | c->flags |= CMD_FAST | CMD_CATEGORY_FAST; |
| 3423 | } else if (!strcasecmp(flag,"no-auth")) { |
| 3424 | c->flags |= CMD_NO_AUTH; |
| 3425 | } else if (!strcasecmp(flag,"may-replicate")) { |
| 3426 | c->flags |= CMD_MAY_REPLICATE; |
| 3427 | } else { |
| 3428 | /* Parse ACL categories here if the flag name starts with @. */ |
| 3429 | uint64_t catflag; |
| 3430 | if (flag[0] == '@' && |
| 3431 | (catflag = ACLGetCommandCategoryFlagByName(flag+1)) != 0) |
| 3432 | { |
| 3433 | c->flags |= catflag; |
| 3434 | } else { |
| 3435 | sdsfreesplitres(argv,argc); |
| 3436 | return C_ERR; |
| 3437 | } |
| 3438 | } |
| 3439 | } |
| 3440 | /* If it's not @fast is @slow in this binary world. */ |
| 3441 | if (!(c->flags & CMD_CATEGORY_FAST)) c->flags |= CMD_CATEGORY_SLOW; |
| 3442 |
no test coverage detected