Reply with a verbatim type having the specified extension. * * The 'ext' is the "extension" of the file, actually just a three * character type that describes the format of the verbatim string. * For instance "txt" means it should be interpreted as a text only * file by the receiver, "md " as markdown, and so forth. Only the * three first characters of the extension are used, and if the * p
| 1038 | * provided one is shorter than that, the remaining is filled with |
| 1039 | * spaces. */ |
| 1040 | void addReplyVerbatim(client *c, const char *s, size_t len, const char *ext) { |
| 1041 | if (c->resp == 2) { |
| 1042 | addReplyBulkCBuffer(c,s,len); |
| 1043 | } else { |
| 1044 | char buf[32]; |
| 1045 | size_t preflen = snprintf(buf,sizeof(buf),"=%zu\r\nxxx:",len+4); |
| 1046 | char *p = buf+preflen-4; |
| 1047 | for (int i = 0; i < 3; i++) { |
| 1048 | if (*ext == '\0') { |
| 1049 | p[i] = ' '; |
| 1050 | } else { |
| 1051 | p[i] = *ext++; |
| 1052 | } |
| 1053 | } |
| 1054 | addReplyProto(c,buf,preflen); |
| 1055 | addReplyProto(c,s,len); |
| 1056 | addReplyProto(c,"\r\n",2); |
| 1057 | } |
| 1058 | } |
| 1059 | |
| 1060 | /* Add an array of C strings as status replies with a heading. |
| 1061 | * This function is typically invoked by from commands that support |
no test coverage detected