See addReplyErrorLength for expectations from the formatted string. * The formatted string is safe to contain \r and \n anywhere. */
| 498 | /* See addReplyErrorLength for expectations from the formatted string. |
| 499 | * The formatted string is safe to contain \r and \n anywhere. */ |
| 500 | void addReplyErrorFormat(client *c, const char *fmt, ...) { |
| 501 | va_list ap; |
| 502 | va_start(ap,fmt); |
| 503 | sds s = sdscatvprintf(sdsempty(),fmt,ap); |
| 504 | va_end(ap); |
| 505 | /* Trim any newlines at the end (ones will be added by addReplyErrorLength) */ |
| 506 | s = sdstrim(s, "\r\n"); |
| 507 | /* Make sure there are no newlines in the middle of the string, otherwise |
| 508 | * invalid protocol is emitted. */ |
| 509 | s = sdsmapchars(s, "\r\n", " ", 2); |
| 510 | addReplyErrorLength(c,s,sdslen(s)); |
| 511 | afterErrorReply(c,s,sdslen(s)); |
| 512 | sdsfree(s); |
| 513 | } |
| 514 | |
| 515 | void addReplyStatusLength(client *c, const char *s, size_t len) { |
| 516 | addReplyProto(c,"+",1); |
no test coverage detected