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. */
| 3755 | * is processed as needed. Initially we just make sure to set the right |
| 3756 | * reply type, which is extremely cheap to do. */ |
| 3757 | RedisModuleCallReply *moduleCreateCallReplyFromProto(RedisModuleCtx *ctx, sds proto) { |
| 3758 | RedisModuleCallReply *reply = zmalloc(sizeof(*reply)); |
| 3759 | reply->ctx = ctx; |
| 3760 | reply->proto = proto; |
| 3761 | reply->protolen = sdslen(proto); |
| 3762 | reply->flags = REDISMODULE_REPLYFLAG_TOPARSE; /* Lazy parsing. */ |
| 3763 | switch(proto[0]) { |
| 3764 | case '$': |
| 3765 | case '+': reply->type = REDISMODULE_REPLY_STRING; break; |
| 3766 | case '-': reply->type = REDISMODULE_REPLY_ERROR; break; |
| 3767 | case ':': reply->type = REDISMODULE_REPLY_INTEGER; break; |
| 3768 | case '*': reply->type = REDISMODULE_REPLY_ARRAY; break; |
| 3769 | default: reply->type = REDISMODULE_REPLY_UNKNOWN; break; |
| 3770 | } |
| 3771 | if ((proto[0] == '*' || proto[0] == '$') && proto[1] == '-') |
| 3772 | reply->type = REDISMODULE_REPLY_NULL; |
| 3773 | return reply; |
| 3774 | } |
| 3775 | |
| 3776 | void moduleParseCallReply_Int(RedisModuleCallReply *reply); |
| 3777 | void moduleParseCallReply_BulkString(RedisModuleCallReply *reply); |