MCPcopy Create free account
hub / github.com/F-Stack/f-stack / commandFlagsFromString

Function commandFlagsFromString

app/redis-6.2.6/src/module.c:791–818  ·  view source on GitHub ↗

Helper for RM_CreateCommand(). Turns a string representing command * flags into the command flags used by the Redis core. * * It returns the set of flags, or -1 if unknown flags are found. */

Source from the content-addressed store, hash-verified

789 *
790 * It returns the set of flags, or -1 if unknown flags are found. */
791int64_t commandFlagsFromString(char *s) {
792 int count, j;
793 int64_t flags = 0;
794 sds *tokens = sdssplitlen(s,strlen(s)," ",1,&count);
795 for (j = 0; j < count; j++) {
796 char *t = tokens[j];
797 if (!strcasecmp(t,"write")) flags |= CMD_WRITE;
798 else if (!strcasecmp(t,"readonly")) flags |= CMD_READONLY;
799 else if (!strcasecmp(t,"admin")) flags |= CMD_ADMIN;
800 else if (!strcasecmp(t,"deny-oom")) flags |= CMD_DENYOOM;
801 else if (!strcasecmp(t,"deny-script")) flags |= CMD_NOSCRIPT;
802 else if (!strcasecmp(t,"allow-loading")) flags |= CMD_LOADING;
803 else if (!strcasecmp(t,"pubsub")) flags |= CMD_PUBSUB;
804 else if (!strcasecmp(t,"random")) flags |= CMD_RANDOM;
805 else if (!strcasecmp(t,"allow-stale")) flags |= CMD_STALE;
806 else if (!strcasecmp(t,"no-monitor")) flags |= CMD_SKIP_MONITOR;
807 else if (!strcasecmp(t,"no-slowlog")) flags |= CMD_SKIP_SLOWLOG;
808 else if (!strcasecmp(t,"fast")) flags |= CMD_FAST;
809 else if (!strcasecmp(t,"no-auth")) flags |= CMD_NO_AUTH;
810 else if (!strcasecmp(t,"may-replicate")) flags |= CMD_MAY_REPLICATE;
811 else if (!strcasecmp(t,"getkeys-api")) flags |= CMD_MODULE_GETKEYS;
812 else if (!strcasecmp(t,"no-cluster")) flags |= CMD_MODULE_NO_CLUSTER;
813 else break;
814 }
815 sdsfreesplitres(tokens,count);
816 if (j != count) return -1; /* Some token not processed correctly. */
817 return flags;
818}
819
820/* Register a new command in the Redis server, that will be handled by
821 * calling the function pointer 'func' using the RedisModule calling

Callers 1

RM_CreateCommandFunction · 0.85

Calls 3

sdssplitlenFunction · 0.85
strcasecmpFunction · 0.85
sdsfreesplitresFunction · 0.85

Tested by

no test coverage detected