Lines Matching refs:reply
298 void RM_FreeCallReply(RedisModuleCallReply *reply);
1271 int RM_ReplyWithCallReply(RedisModuleCtx *ctx, RedisModuleCallReply *reply) { in RM_ReplyWithCallReply() argument
1274 sds proto = sdsnewlen(reply->proto, reply->protolen); in RM_ReplyWithCallReply()
2454 RedisModuleCallReply *reply = zmalloc(sizeof(*reply)); in moduleCreateCallReplyFromProto() local
2455 reply->ctx = ctx; in moduleCreateCallReplyFromProto()
2456 reply->proto = proto; in moduleCreateCallReplyFromProto()
2457 reply->protolen = sdslen(proto); in moduleCreateCallReplyFromProto()
2458 reply->flags = REDISMODULE_REPLYFLAG_TOPARSE; /* Lazy parsing. */ in moduleCreateCallReplyFromProto()
2461 case '+': reply->type = REDISMODULE_REPLY_STRING; break; in moduleCreateCallReplyFromProto()
2462 case '-': reply->type = REDISMODULE_REPLY_ERROR; break; in moduleCreateCallReplyFromProto()
2463 case ':': reply->type = REDISMODULE_REPLY_INTEGER; break; in moduleCreateCallReplyFromProto()
2464 case '*': reply->type = REDISMODULE_REPLY_ARRAY; break; in moduleCreateCallReplyFromProto()
2465 default: reply->type = REDISMODULE_REPLY_UNKNOWN; break; in moduleCreateCallReplyFromProto()
2468 reply->type = REDISMODULE_REPLY_NULL; in moduleCreateCallReplyFromProto()
2469 return reply; in moduleCreateCallReplyFromProto()
2472 void moduleParseCallReply_Int(RedisModuleCallReply *reply);
2473 void moduleParseCallReply_BulkString(RedisModuleCallReply *reply);
2474 void moduleParseCallReply_SimpleString(RedisModuleCallReply *reply);
2475 void moduleParseCallReply_Array(RedisModuleCallReply *reply);
2480 void moduleParseCallReply(RedisModuleCallReply *reply) { in moduleParseCallReply() argument
2481 if (!(reply->flags & REDISMODULE_REPLYFLAG_TOPARSE)) return; in moduleParseCallReply()
2482 reply->flags &= ~REDISMODULE_REPLYFLAG_TOPARSE; in moduleParseCallReply()
2484 switch(reply->proto[0]) { in moduleParseCallReply()
2485 case ':': moduleParseCallReply_Int(reply); break; in moduleParseCallReply()
2486 case '$': moduleParseCallReply_BulkString(reply); break; in moduleParseCallReply()
2488 case '+': moduleParseCallReply_SimpleString(reply); break; in moduleParseCallReply()
2489 case '*': moduleParseCallReply_Array(reply); break; in moduleParseCallReply()
2493 void moduleParseCallReply_Int(RedisModuleCallReply *reply) { in moduleParseCallReply_Int() argument
2494 char *proto = reply->proto; in moduleParseCallReply_Int()
2497 string2ll(proto+1,p-proto-1,&reply->val.ll); in moduleParseCallReply_Int()
2498 reply->protolen = p-proto+2; in moduleParseCallReply_Int()
2499 reply->type = REDISMODULE_REPLY_INTEGER; in moduleParseCallReply_Int()
2502 void moduleParseCallReply_BulkString(RedisModuleCallReply *reply) { in moduleParseCallReply_BulkString() argument
2503 char *proto = reply->proto; in moduleParseCallReply_BulkString()
2509 reply->protolen = p-proto+2; in moduleParseCallReply_BulkString()
2510 reply->type = REDISMODULE_REPLY_NULL; in moduleParseCallReply_BulkString()
2512 reply->val.str = p+2; in moduleParseCallReply_BulkString()
2513 reply->len = bulklen; in moduleParseCallReply_BulkString()
2514 reply->protolen = p-proto+2+bulklen+2; in moduleParseCallReply_BulkString()
2515 reply->type = REDISMODULE_REPLY_STRING; in moduleParseCallReply_BulkString()
2519 void moduleParseCallReply_SimpleString(RedisModuleCallReply *reply) { in moduleParseCallReply_SimpleString() argument
2520 char *proto = reply->proto; in moduleParseCallReply_SimpleString()
2523 reply->val.str = proto+1; in moduleParseCallReply_SimpleString()
2524 reply->len = p-proto-1; in moduleParseCallReply_SimpleString()
2525 reply->protolen = p-proto+2; in moduleParseCallReply_SimpleString()
2526 reply->type = proto[0] == '+' ? REDISMODULE_REPLY_STRING : in moduleParseCallReply_SimpleString()
2530 void moduleParseCallReply_Array(RedisModuleCallReply *reply) { in moduleParseCallReply_Array() argument
2531 char *proto = reply->proto; in moduleParseCallReply_Array()
2539 reply->protolen = p-proto; in moduleParseCallReply_Array()
2540 reply->type = REDISMODULE_REPLY_NULL; in moduleParseCallReply_Array()
2544 reply->val.array = zmalloc(sizeof(RedisModuleCallReply)*arraylen); in moduleParseCallReply_Array()
2545 reply->len = arraylen; in moduleParseCallReply_Array()
2547 RedisModuleCallReply *ele = reply->val.array+j; in moduleParseCallReply_Array()
2551 ele->ctx = reply->ctx; in moduleParseCallReply_Array()
2555 reply->protolen = p-proto; in moduleParseCallReply_Array()
2556 reply->type = REDISMODULE_REPLY_ARRAY; in moduleParseCallReply_Array()
2561 void RM_FreeCallReply_Rec(RedisModuleCallReply *reply, int freenested){ in RM_FreeCallReply_Rec() argument
2565 if (!freenested && reply->flags & REDISMODULE_REPLYFLAG_NESTED) return; in RM_FreeCallReply_Rec()
2567 if (!(reply->flags & REDISMODULE_REPLYFLAG_TOPARSE)) { in RM_FreeCallReply_Rec()
2568 if (reply->type == REDISMODULE_REPLY_ARRAY) { in RM_FreeCallReply_Rec()
2570 for (j = 0; j < reply->len; j++) in RM_FreeCallReply_Rec()
2571 RM_FreeCallReply_Rec(reply->val.array+j,1); in RM_FreeCallReply_Rec()
2572 zfree(reply->val.array); in RM_FreeCallReply_Rec()
2580 if (!(reply->flags & REDISMODULE_REPLYFLAG_NESTED)) { in RM_FreeCallReply_Rec()
2581 if (reply->proto) sdsfree(reply->proto); in RM_FreeCallReply_Rec()
2582 zfree(reply); in RM_FreeCallReply_Rec()
2589 void RM_FreeCallReply(RedisModuleCallReply *reply) { in RM_FreeCallReply() argument
2591 RedisModuleCtx *ctx = reply->ctx; in RM_FreeCallReply()
2592 RM_FreeCallReply_Rec(reply,0); in RM_FreeCallReply()
2593 autoMemoryFreed(ctx,REDISMODULE_AM_REPLY,reply); in RM_FreeCallReply()
2597 int RM_CallReplyType(RedisModuleCallReply *reply) { in RM_CallReplyType() argument
2598 if (!reply) return REDISMODULE_REPLY_UNKNOWN; in RM_CallReplyType()
2599 return reply->type; in RM_CallReplyType()
2603 size_t RM_CallReplyLength(RedisModuleCallReply *reply) { in RM_CallReplyLength() argument
2604 moduleParseCallReply(reply); in RM_CallReplyLength()
2605 switch(reply->type) { in RM_CallReplyLength()
2609 return reply->len; in RM_CallReplyLength()
2617 RedisModuleCallReply *RM_CallReplyArrayElement(RedisModuleCallReply *reply, size_t idx) { in RM_CallReplyArrayElement() argument
2618 moduleParseCallReply(reply); in RM_CallReplyArrayElement()
2619 if (reply->type != REDISMODULE_REPLY_ARRAY) return NULL; in RM_CallReplyArrayElement()
2620 if (idx >= reply->len) return NULL; in RM_CallReplyArrayElement()
2621 return reply->val.array+idx; in RM_CallReplyArrayElement()
2625 long long RM_CallReplyInteger(RedisModuleCallReply *reply) { in RM_CallReplyInteger() argument
2626 moduleParseCallReply(reply); in RM_CallReplyInteger()
2627 if (reply->type != REDISMODULE_REPLY_INTEGER) return LLONG_MIN; in RM_CallReplyInteger()
2628 return reply->val.ll; in RM_CallReplyInteger()
2632 const char *RM_CallReplyStringPtr(RedisModuleCallReply *reply, size_t *len) { in RM_CallReplyStringPtr() argument
2633 moduleParseCallReply(reply); in RM_CallReplyStringPtr()
2634 if (reply->type != REDISMODULE_REPLY_STRING && in RM_CallReplyStringPtr()
2635 reply->type != REDISMODULE_REPLY_ERROR) return NULL; in RM_CallReplyStringPtr()
2636 if (len) *len = reply->len; in RM_CallReplyStringPtr()
2637 return reply->val.str; in RM_CallReplyStringPtr()
2642 RedisModuleString *RM_CreateStringFromCallReply(RedisModuleCallReply *reply) { in RM_CreateStringFromCallReply() argument
2643 moduleParseCallReply(reply); in RM_CreateStringFromCallReply()
2644 switch(reply->type) { in RM_CreateStringFromCallReply()
2647 return RM_CreateString(reply->ctx,reply->val.str,reply->len); in RM_CreateStringFromCallReply()
2650 int len = ll2string(buf,sizeof(buf),reply->val.ll); in RM_CreateStringFromCallReply()
2651 return RM_CreateString(reply->ctx,buf,len); in RM_CreateStringFromCallReply()
2746 RedisModuleCallReply *reply = NULL; in RM_Call() local
2819 while(listLength(c->reply)) { in RM_Call()
2820 clientReplyBlock *o = listNodeValue(listFirst(c->reply)); in RM_Call()
2823 listDelNode(c->reply,listFirst(c->reply)); in RM_Call()
2825 reply = moduleCreateCallReplyFromProto(ctx,proto); in RM_Call()
2826 autoMemoryAdd(ctx,REDISMODULE_AM_REPLY,reply); in RM_Call()
2831 return reply; in RM_Call()
2836 const char *RM_CallReplyProto(RedisModuleCallReply *reply, size_t *len) { in RM_CallReplyProto() argument
2837 if (reply->proto) *len = sdslen(reply->proto); in RM_CallReplyProto()
2838 return reply->proto; in RM_CallReplyProto()