Create a new RedisModuleCallReply object. The processing of the reply * is lazy, the object is just populated with the raw protocol and later * is processed as needed. Initially we just make sure to set the right * reply type, which is extremely cheap to do. */
| 3843 | * is processed as needed. Initially we just make sure to set the right |
| 3844 | * reply type, which is extremely cheap to do. */ |
| 3845 | RedisModuleCallReply *moduleCreateCallReplyFromProto(RedisModuleCtx *ctx, sds proto) { |
| 3846 | RedisModuleCallReply *reply = (RedisModuleCallReply*)zmalloc(sizeof(*reply), MALLOC_LOCAL); |
| 3847 | reply->ctx = ctx; |
| 3848 | reply->proto = proto; |
| 3849 | reply->protolen = sdslen(proto); |
| 3850 | reply->flags = REDISMODULE_REPLYFLAG_TOPARSE; /* Lazy parsing. */ |
| 3851 | switch(proto[0]) { |
| 3852 | case '$': |
| 3853 | case '+': reply->type = REDISMODULE_REPLY_STRING; break; |
| 3854 | case '-': reply->type = REDISMODULE_REPLY_ERROR; break; |
| 3855 | case ':': reply->type = REDISMODULE_REPLY_INTEGER; break; |
| 3856 | case '*': reply->type = REDISMODULE_REPLY_ARRAY; break; |
| 3857 | default: reply->type = REDISMODULE_REPLY_UNKNOWN; break; |
| 3858 | } |
| 3859 | if ((proto[0] == '*' || proto[0] == '$') && proto[1] == '-') |
| 3860 | reply->type = REDISMODULE_REPLY_NULL; |
| 3861 | return reply; |
| 3862 | } |
| 3863 | |
| 3864 | void moduleParseCallReply_Int(RedisModuleCallReply *reply); |
| 3865 | void moduleParseCallReply_BulkString(RedisModuleCallReply *reply); |