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
| 875 | * provided one is shorter than that, the remaining is filled with |
| 876 | * spaces. */ |
| 877 | void addReplyVerbatim(client *c, const char *s, size_t len, const char *ext) { |
| 878 | if (c->resp == 2) { |
| 879 | addReplyBulkCBuffer(c,s,len); |
| 880 | } else { |
| 881 | char buf[32]; |
| 882 | size_t preflen = snprintf(buf,sizeof(buf),"=%zu\r\nxxx:",len+4); |
| 883 | char *p = buf+preflen-4; |
| 884 | for (int i = 0; i < 3; i++) { |
| 885 | if (*ext == '\0') { |
| 886 | p[i] = ' '; |
| 887 | } else { |
| 888 | p[i] = *ext++; |
| 889 | } |
| 890 | } |
| 891 | addReplyProto(c,buf,preflen); |
| 892 | addReplyProto(c,s,len); |
| 893 | addReplyProto(c,"\r\n",2); |
| 894 | } |
| 895 | } |
| 896 | |
| 897 | /* Add an array of C strings as status replies with a heading. |
| 898 | * This function is typically invoked by from commands that support |
no test coverage detected