Changeset 0504f63
- Timestamp:
- Aug 10, 2008, 5:38:44 PM (15 years ago)
- Branches:
- master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- e9bb404
- Parents:
- d81f8d0
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
filter.c
r601733d r0504f63 212 212 213 213 214 void owl_filter_print(owl_filter *f, char *out) 215 { 216 strcpy(out, owl_filter_get_name(f)); 217 strcat(out, ": "); 214 char* owl_filter_print(owl_filter *f) 215 { 216 GString *out = g_string_new(owl_filter_get_name(f)); 217 218 g_string_append(out, ": "); 218 219 219 220 if (f->fgcolor!=OWL_COLOR_DEFAULT) { 220 strcat(out, "-c ");221 g_string_append(out, "-c "); 221 222 if (f->fgcolor < 8) { 222 strcat(out, owl_util_color_to_string(f->fgcolor));223 g_string_append(out, owl_util_color_to_string(f->fgcolor)); 223 224 } 224 225 else { 225 char* c = owl_sprintf("%i",f->fgcolor); 226 strcat(out, c); 227 owl_free(c); 228 } 229 strcat(out, " "); 226 g_string_append_printf(out, "%i",f->fgcolor); 227 } 228 g_string_append(out, " "); 230 229 } 231 230 if (f->bgcolor!=OWL_COLOR_DEFAULT) { 232 strcat(out, "-b ");231 g_string_append(out, "-b "); 233 232 if (f->bgcolor < 8) { 234 strcat(out, owl_util_color_to_string(f->bgcolor));233 g_string_append(out, owl_util_color_to_string(f->bgcolor)); 235 234 } 236 235 else { 237 char* c = owl_sprintf("%i",f->bgcolor); 238 strcat(out, c); 239 owl_free(c); 240 } 241 strcat(out, " "); 242 } 243 if(!f->root) return; 244 owl_filterelement_print(f->root, out); 245 strcat(out, "\n"); 236 g_string_append_printf(out, "%i",f->fgcolor); 237 } 238 g_string_append(out, " "); 239 } 240 if(f->root) { 241 owl_filterelement_print(f->root, out); 242 g_string_append(out, "\n"); 243 } 244 245 return g_string_free(out, 0); 246 246 } 247 247 … … 249 249 int owl_filter_equiv(owl_filter *a, owl_filter *b) 250 250 { 251 char buff[LINE], buff2[LINE]; 252 253 owl_filter_print(a, buff); 254 owl_filter_print(b, buff2); 255 256 if (!strcmp(buff, buff2)) return(1); 257 return(0); 251 char *buffa, *buffb; 252 int ret; 253 254 buffa = owl_filter_print(a); 255 buffb = owl_filter_print(b); 256 257 ret = !strcmp(buffa, buffb); 258 259 owl_free(buffa); 260 owl_free(buffb); 261 262 return ret; 258 263 } 259 264 -
filterelement.c
r81655f8 r0504f63 126 126 /* Print methods */ 127 127 128 static void owl_filterelement_print_true(owl_filterelement *fe, char*buf)129 { 130 strcat(buf, "true");131 } 132 133 static void owl_filterelement_print_false(owl_filterelement *fe, char*buf)134 { 135 strcat(buf, "false");136 } 137 138 static void owl_filterelement_print_re(owl_filterelement *fe, char*buf)128 static void owl_filterelement_print_true(owl_filterelement *fe, GString *buf) 129 { 130 g_string_append(buf, "true"); 131 } 132 133 static void owl_filterelement_print_false(owl_filterelement *fe, GString *buf) 134 { 135 g_string_append(buf, "false"); 136 } 137 138 static void owl_filterelement_print_re(owl_filterelement *fe, GString *buf) 139 139 { 140 140 char *re, *q; 141 strcat(buf, fe->field);142 strcat(buf, " ");141 g_string_append(buf, fe->field); 142 g_string_append(buf, " "); 143 143 144 144 re = owl_regex_get_string(&(fe->re)); 145 145 q = owl_getquoting(re); 146 strcat(buf, q);147 strcat(buf, re);148 strcat(buf, q);149 } 150 151 static void owl_filterelement_print_filter(owl_filterelement *fe, char*buf)152 { 153 strcat(buf, "filter ");154 strcat(buf, fe->field);155 } 156 157 static void owl_filterelement_print_perl(owl_filterelement *fe, char*buf)158 { 159 strcat(buf, "perl ");160 strcat(buf, fe->field);161 } 162 163 static void owl_filterelement_print_group(owl_filterelement *fe, char*buf)164 { 165 strcat(buf, "( ");146 g_string_append(buf, q); 147 g_string_append(buf, re); 148 g_string_append(buf, q); 149 } 150 151 static void owl_filterelement_print_filter(owl_filterelement *fe, GString *buf) 152 { 153 g_string_append(buf, "filter "); 154 g_string_append(buf, fe->field); 155 } 156 157 static void owl_filterelement_print_perl(owl_filterelement *fe, GString *buf) 158 { 159 g_string_append(buf, "perl "); 160 g_string_append(buf, fe->field); 161 } 162 163 static void owl_filterelement_print_group(owl_filterelement *fe, GString *buf) 164 { 165 g_string_append(buf, "( "); 166 166 owl_filterelement_print(fe->left, buf) ; 167 strcat(buf, " )");168 } 169 170 static void owl_filterelement_print_or(owl_filterelement *fe, char*buf)167 g_string_append(buf, " )"); 168 } 169 170 static void owl_filterelement_print_or(owl_filterelement *fe, GString *buf) 171 171 { 172 172 owl_filterelement_print(fe->left, buf); 173 strcat(buf, " or ");173 g_string_append(buf, " or "); 174 174 owl_filterelement_print(fe->right, buf); 175 175 } 176 176 177 static void owl_filterelement_print_and(owl_filterelement *fe, char*buf)177 static void owl_filterelement_print_and(owl_filterelement *fe, GString *buf) 178 178 { 179 179 owl_filterelement_print(fe->left, buf); 180 strcat(buf, " and ");180 g_string_append(buf, " and "); 181 181 owl_filterelement_print(fe->right, buf); 182 182 } 183 183 184 static void owl_filterelement_print_not(owl_filterelement *fe, char*buf)185 { 186 strcat(buf, " not ");184 static void owl_filterelement_print_not(owl_filterelement *fe, GString *buf) 185 { 186 g_string_append(buf, " not "); 187 187 owl_filterelement_print(fe->left, buf); 188 188 } … … 321 321 } 322 322 323 void owl_filterelement_print(owl_filterelement *fe, char*buf)323 void owl_filterelement_print(owl_filterelement *fe, GString *buf) 324 324 { 325 325 if(!fe || !fe->print_elt) return; -
functions.c
rd81f8d0 r0504f63 2515 2515 { 2516 2516 owl_filter *f; 2517 char buff[5000];2517 char *buff; 2518 2518 2519 2519 f=owl_global_get_filter(&g, name); … … 2522 2522 return; 2523 2523 } 2524 owl_filter_print(f, buff);2524 buff = owl_filter_print(f); 2525 2525 owl_function_popless_text(buff); 2526 owl_free(buff); 2526 2527 } 2527 2528 … … 2531 2532 owl_list *fl; 2532 2533 char buff[5000]; 2534 char *tmp; 2533 2535 owl_fmtext fm; 2534 2536 int i, j; … … 2544 2546 snprintf(buff, sizeof(buff), "[% 2d] ", i+1); 2545 2547 owl_fmtext_append_normal(&fm, buff); 2546 owl_filter_print(f, buff); 2548 tmp = owl_filter_print(f); 2549 owl_fmtext_append_normal(&fm, tmp); 2550 owl_free(tmp); 2547 2551 owl_fmtext_append_normal(&fm, buff); 2548 2552 } -
owl.h
r731dd1e r0504f63 406 406 int (*match_message)(struct _owl_filterelement *fe, owl_message *m); 407 407 /* Append a string representation of the filterelement onto buf*/ 408 void (*print_elt)(struct _owl_filterelement *fe, char *buf);408 void (*print_elt)(struct _owl_filterelement *fe, GString *buf); 409 409 /* Operands for and,or,not*/ 410 410 struct _owl_filterelement *left, *right;
Note: See TracChangeset
for help on using the changeset viewer.