Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/lib-imap/imap-util.c @ 8729:b7ebdade6cbd HEAD
Added imap_args_to_str()
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 06 Feb 2009 13:38:54 -0500 |
parents | b9faf4db2a9f |
children | 743cc6ff3d89 |
comparison
equal
deleted
inserted
replaced
8728:da19acbae79e | 8729:b7ebdade6cbd |
---|---|
1 /* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */ | 1 /* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */ |
2 | 2 |
3 #include "lib.h" | 3 #include "lib.h" |
4 #include "array.h" | 4 #include "array.h" |
5 #include "str.h" | 5 #include "str.h" |
6 #include "strescape.h" | |
6 #include "mail-types.h" | 7 #include "mail-types.h" |
8 #include "imap-parser.h" | |
7 #include "imap-util.h" | 9 #include "imap-util.h" |
8 | 10 |
9 void imap_write_flags(string_t *dest, enum mail_flags flags, | 11 void imap_write_flags(string_t *dest, enum mail_flags flags, |
10 const char *const *keywords) | 12 const char *const *keywords) |
11 { | 13 { |
50 str_printfa(dest, "%u", range[i].seq1); | 52 str_printfa(dest, "%u", range[i].seq1); |
51 if (range[i].seq1 != range[i].seq2) | 53 if (range[i].seq1 != range[i].seq2) |
52 str_printfa(dest, ":%u", range[i].seq2); | 54 str_printfa(dest, ":%u", range[i].seq2); |
53 } | 55 } |
54 } | 56 } |
57 | |
58 void imap_args_to_str(string_t *dest, const struct imap_arg *args) | |
59 { | |
60 const ARRAY_TYPE(imap_arg_list) *list; | |
61 bool first = TRUE; | |
62 | |
63 for (; args->type != IMAP_ARG_EOL; args++) { | |
64 if (first) | |
65 first = FALSE; | |
66 else | |
67 str_append_c(dest, ' '); | |
68 | |
69 switch (args->type) { | |
70 case IMAP_ARG_NIL: | |
71 str_append(dest, "NIL"); | |
72 break; | |
73 case IMAP_ARG_ATOM: | |
74 str_append(dest, IMAP_ARG_STR(args)); | |
75 break; | |
76 case IMAP_ARG_STRING: | |
77 str_append_c(dest, '"'); | |
78 str_append(dest, str_escape(IMAP_ARG_STR(args))); | |
79 str_append_c(dest, '"'); | |
80 break; | |
81 case IMAP_ARG_LITERAL: { | |
82 const char *strarg = IMAP_ARG_STR(args); | |
83 str_printfa(dest, "{%"PRIuSIZE_T"}\r\n", | |
84 strlen(strarg)); | |
85 str_append(dest, strarg); | |
86 break; | |
87 } | |
88 case IMAP_ARG_LIST: | |
89 str_append_c(dest, '('); | |
90 list = IMAP_ARG_LIST(args); | |
91 imap_args_to_str(dest, array_idx(list, 0)); | |
92 str_append_c(dest, ')'); | |
93 break; | |
94 case IMAP_ARG_LITERAL_SIZE: | |
95 case IMAP_ARG_LITERAL_SIZE_NONSYNC: | |
96 str_printfa(dest, "{%"PRIuUOFF_T"}\r\n", | |
97 IMAP_ARG_LITERAL_SIZE(args)); | |
98 str_append(dest, "<too large>"); | |
99 break; | |
100 case IMAP_ARG_EOL: | |
101 i_unreached(); | |
102 } | |
103 } | |
104 } |