MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / populateCommandTableParseFlags

Function populateCommandTableParseFlags

src/server.cpp:4160–4224  ·  view source on GitHub ↗

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). */

Source from the content-addressed store, hash-verified

4158 * command 'c'. If the flags are all valid C_OK is returned, otherwise
4159 * C_ERR is returned (yet the recognized flags are set in the command). */
4160int populateCommandTableParseFlags(struct redisCommand *c, const char *strflags) {
4161 int argc;
4162 sds *argv;
4163
4164 /* Split the line into arguments for processing. */
4165 argv = sdssplitargs(strflags,&argc);
4166 if (argv == NULL) return C_ERR;
4167
4168 for (int j = 0; j < argc; j++) {
4169 char *flag = argv[j];
4170 if (!strcasecmp(flag,"write")) {
4171 c->flags |= CMD_WRITE|CMD_CATEGORY_WRITE;
4172 } else if (!strcasecmp(flag,"read-only")) {
4173 c->flags |= CMD_READONLY|CMD_CATEGORY_READ;
4174 } else if (!strcasecmp(flag,"use-memory")) {
4175 c->flags |= CMD_DENYOOM;
4176 } else if (!strcasecmp(flag,"admin")) {
4177 c->flags |= CMD_ADMIN|CMD_CATEGORY_ADMIN|CMD_CATEGORY_DANGEROUS;
4178 } else if (!strcasecmp(flag,"pub-sub")) {
4179 c->flags |= CMD_PUBSUB|CMD_CATEGORY_PUBSUB;
4180 } else if (!strcasecmp(flag,"no-script")) {
4181 c->flags |= CMD_NOSCRIPT;
4182 } else if (!strcasecmp(flag,"random")) {
4183 c->flags |= CMD_RANDOM;
4184 } else if (!strcasecmp(flag,"to-sort")) {
4185 c->flags |= CMD_SORT_FOR_SCRIPT;
4186 } else if (!strcasecmp(flag,"ok-loading")) {
4187 c->flags |= CMD_LOADING;
4188 } else if (!strcasecmp(flag,"ok-stale")) {
4189 c->flags |= CMD_STALE;
4190 } else if (!strcasecmp(flag,"no-monitor")) {
4191 c->flags |= CMD_SKIP_MONITOR;
4192 } else if (!strcasecmp(flag,"no-slowlog")) {
4193 c->flags |= CMD_SKIP_SLOWLOG;
4194 } else if (!strcasecmp(flag,"cluster-asking")) {
4195 c->flags |= CMD_ASKING;
4196 } else if (!strcasecmp(flag,"fast")) {
4197 c->flags |= CMD_FAST | CMD_CATEGORY_FAST;
4198 } else if (!strcasecmp(flag,"noprop")) {
4199 c->flags |= CMD_SKIP_PROPOGATE;
4200 } else if (!strcasecmp(flag,"no-auth")) {
4201 c->flags |= CMD_NO_AUTH;
4202 } else if (!strcasecmp(flag,"may-replicate")) {
4203 c->flags |= CMD_MAY_REPLICATE;
4204 } else if (!strcasecmp(flag,"async")) {
4205 c->flags |= CMD_ASYNC_OK;
4206 } else {
4207 /* Parse ACL categories here if the flag name starts with @. */
4208 uint64_t catflag;
4209 if (flag[0] == '@' &&
4210 (catflag = ACLGetCommandCategoryFlagByName(flag+1)) != 0)
4211 {
4212 c->flags |= catflag;
4213 } else {
4214 sdsfreesplitres(argv,argc);
4215 return C_ERR;
4216 }
4217 }

Callers 2

populateCommandTableFunction · 0.85
initSentinelFunction · 0.85

Calls 3

sdssplitargsFunction · 0.85
sdsfreesplitresFunction · 0.85

Tested by

no test coverage detected