summaryrefslogtreecommitdiffabout
path: root/kmicromail/libetpan
authorzautrix <zautrix>2005-01-24 12:16:16 (UTC)
committer zautrix <zautrix>2005-01-24 12:16:16 (UTC)
commitd4f5ce1bedd03191da5ecef2dc68381c10ef1fba (patch) (unidiff)
tree2d6860078083e588f8f365b308ee4ffb2c34f1c1 /kmicromail/libetpan
parent485a6b28e3be6437742852970fdd122ba071b726 (diff)
downloadkdepimpi-d4f5ce1bedd03191da5ecef2dc68381c10ef1fba.zip
kdepimpi-d4f5ce1bedd03191da5ecef2dc68381c10ef1fba.tar.gz
kdepimpi-d4f5ce1bedd03191da5ecef2dc68381c10ef1fba.tar.bz2
more imap fixes
Diffstat (limited to 'kmicromail/libetpan') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libetpan/imap/mailimap_parser.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/kmicromail/libetpan/imap/mailimap_parser.c b/kmicromail/libetpan/imap/mailimap_parser.c
index 1c2ecde..560e58a 100644
--- a/kmicromail/libetpan/imap/mailimap_parser.c
+++ b/kmicromail/libetpan/imap/mailimap_parser.c
@@ -2306,194 +2306,212 @@ mailimap_body_fld_dsp_parse(mailstream * fd, MMAPString * buffer,
2306 } 2306 }
2307 2307
2308 body_fld_dsp = mailimap_body_fld_dsp_new(name, body_fld_param); 2308 body_fld_dsp = mailimap_body_fld_dsp_new(name, body_fld_param);
2309 if (body_fld_dsp == NULL) { 2309 if (body_fld_dsp == NULL) {
2310 res = MAILIMAP_ERROR_MEMORY; 2310 res = MAILIMAP_ERROR_MEMORY;
2311 goto fld_param_free; 2311 goto fld_param_free;
2312 } 2312 }
2313 2313
2314 * index = cur_token; 2314 * index = cur_token;
2315 * result = body_fld_dsp; 2315 * result = body_fld_dsp;
2316 2316
2317 return MAILIMAP_NO_ERROR; 2317 return MAILIMAP_NO_ERROR;
2318 2318
2319 fld_param_free: 2319 fld_param_free:
2320 if (body_fld_param != NULL) 2320 if (body_fld_param != NULL)
2321 mailimap_body_fld_param_free(body_fld_param); 2321 mailimap_body_fld_param_free(body_fld_param);
2322 string_free: 2322 string_free:
2323 mailimap_string_free(name); 2323 mailimap_string_free(name);
2324 err: 2324 err:
2325 return res; 2325 return res;
2326} 2326}
2327 2327
2328/* 2328/*
2329 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ 2329 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/
2330 "QUOTED-PRINTABLE") DQUOTE) / string 2330 "QUOTED-PRINTABLE") DQUOTE) / string
2331*/ 2331*/
2332 2332
2333static inline int 2333static inline int
2334mailimap_body_fld_known_enc_parse(mailstream * fd, MMAPString * buffer, 2334mailimap_body_fld_known_enc_parse(mailstream * fd, MMAPString * buffer,
2335 size_t * index, 2335 size_t * index,
2336 int * result, 2336 int * result,
2337 size_t progr_rate, 2337 size_t progr_rate,
2338 progress_function * progr_fun) 2338 progress_function * progr_fun)
2339{ 2339{
2340 size_t cur_token; 2340 size_t cur_token;
2341 int type; 2341 int type;
2342 int r; 2342 int r;
2343 int res; 2343 int res;
2344 2344
2345 cur_token = * index; 2345 cur_token = * index;
2346 2346
2347 r = mailimap_dquote_parse(fd, buffer, &cur_token); 2347 r = mailimap_dquote_parse(fd, buffer, &cur_token);
2348 if (r != MAILIMAP_NO_ERROR) { 2348 if (r != MAILIMAP_NO_ERROR) {
2349 res = r; 2349 res = r;
2350 goto err; 2350 goto err;
2351 } 2351 }
2352 2352
2353 type = mailimap_encoding_get_token_value(fd, buffer, &cur_token); 2353 type = mailimap_encoding_get_token_value(fd, buffer, &cur_token);
2354 2354
2355 if (type == -1) { 2355 if (type == -1) {
2356 res = MAILIMAP_ERROR_PARSE; 2356 res = MAILIMAP_ERROR_PARSE;
2357 goto err; 2357 goto err;
2358 } 2358 }
2359 2359
2360 r = mailimap_dquote_parse(fd, buffer, &cur_token); 2360 r = mailimap_dquote_parse(fd, buffer, &cur_token);
2361 if (r != MAILIMAP_NO_ERROR) { 2361 if (r != MAILIMAP_NO_ERROR) {
2362 res = r; 2362 res = r;
2363 goto err; 2363 goto err;
2364 } 2364 }
2365 2365
2366 * result = type; 2366 * result = type;
2367 * index = cur_token; 2367 * index = cur_token;
2368 2368
2369 return MAILIMAP_NO_ERROR; 2369 return MAILIMAP_NO_ERROR;
2370 2370
2371 err: 2371 err:
2372 return res; 2372 return res;
2373} 2373}
2374 2374
2375static int 2375static int
2376mailimap_body_fld_enc_parse(mailstream * fd, MMAPString * buffer, 2376mailimap_body_fld_enc_parse(mailstream * fd, MMAPString * buffer,
2377 size_t * index, 2377 size_t * index,
2378 struct mailimap_body_fld_enc ** result, 2378 struct mailimap_body_fld_enc ** result,
2379 size_t progr_rate, 2379 size_t progr_rate,
2380 progress_function * progr_fun) 2380 progress_function * progr_fun)
2381{ 2381{
2382 size_t cur_token; 2382 size_t cur_token;
2383 int type; 2383 int type;
2384 char * value; 2384 char * value;
2385 struct mailimap_body_fld_enc * body_fld_enc; 2385 struct mailimap_body_fld_enc * body_fld_enc;
2386 int r; 2386 int r;
2387 int res; 2387 int res;
2388 2388
2389 cur_token = * index; 2389 cur_token = * index;
2390 2390
2391 r = mailimap_body_fld_known_enc_parse(fd, buffer, &cur_token, 2391 r = mailimap_body_fld_known_enc_parse(fd, buffer, &cur_token,
2392 &type, progr_rate, progr_fun); 2392 &type, progr_rate, progr_fun);
2393 if (r == MAILIMAP_NO_ERROR) { 2393 if (r == MAILIMAP_NO_ERROR) {
2394 value = NULL; 2394 value = NULL;
2395 } 2395 }
2396 else if (r == MAILIMAP_ERROR_PARSE) { 2396 else if (r == MAILIMAP_ERROR_PARSE) {
2397 type = MAILIMAP_BODY_FLD_ENC_OTHER; 2397 type = MAILIMAP_BODY_FLD_ENC_OTHER;
2398 2398
2399 r = mailimap_string_parse(fd, buffer, &cur_token, &value, NULL, 2399 r = mailimap_string_parse(fd, buffer, &cur_token, &value, NULL,
2400 progr_rate, progr_fun); 2400 progr_rate, progr_fun);
2401 if (r != MAILIMAP_NO_ERROR) { 2401 if (r != MAILIMAP_NO_ERROR) {
2402 res = r; 2402 // LR start
2403 goto err; 2403 // accept NIL and set type to utf8
2404 int ret = r;
2405 r = mailimap_char_parse(fd, buffer, &cur_token, 'N');
2406 if (r == MAILIMAP_NO_ERROR) {
2407 r = mailimap_char_parse(fd, buffer, &cur_token, 'I');
2408 if (r == MAILIMAP_NO_ERROR) {
2409 r = mailimap_char_parse(fd, buffer, &cur_token, 'L');
2410 if (r == MAILIMAP_NO_ERROR) {
2411 type = 4;
2412 ret = MAILIMAP_NO_ERROR;
2413 value = NULL;
2414 }
2415 }
2416 }
2417 if ( ret != MAILIMAP_NO_ERROR ) {
2418 res = ret;
2419 goto err;
2420 }
2421 // LR end
2404 } 2422 }
2405 } 2423 }
2406 else { 2424 else {
2407 res = r; 2425 res = r;
2408 goto err; 2426 goto err;
2409 } 2427 }
2410 2428
2411 body_fld_enc = mailimap_body_fld_enc_new(type, value); 2429 body_fld_enc = mailimap_body_fld_enc_new(type, value);
2412 if (body_fld_enc == NULL) { 2430 if (body_fld_enc == NULL) {
2413 res = MAILIMAP_ERROR_MEMORY; 2431 res = MAILIMAP_ERROR_MEMORY;
2414 goto value_free; 2432 goto value_free;
2415 } 2433 }
2416 2434
2417 * result = body_fld_enc; 2435 * result = body_fld_enc;
2418 * index = cur_token; 2436 * index = cur_token;
2419 2437
2420 return MAILIMAP_NO_ERROR; 2438 return MAILIMAP_NO_ERROR;
2421 2439
2422 value_free: 2440 value_free:
2423 if (value) 2441 if (value)
2424 mailimap_string_free(value); 2442 mailimap_string_free(value);
2425 err: 2443 err:
2426 return res; 2444 return res;
2427} 2445}
2428 2446
2429/* 2447/*
2430 body-fld-id = nstring 2448 body-fld-id = nstring
2431*/ 2449*/
2432 2450
2433static int mailimap_body_fld_id_parse(mailstream * fd, MMAPString * buffer, 2451static int mailimap_body_fld_id_parse(mailstream * fd, MMAPString * buffer,
2434 size_t * index, char ** result, 2452 size_t * index, char ** result,
2435 size_t progr_rate, 2453 size_t progr_rate,
2436 progress_function * progr_fun) 2454 progress_function * progr_fun)
2437{ 2455{
2438 return mailimap_nstring_parse(fd, buffer, index, result, NULL, 2456 return mailimap_nstring_parse(fd, buffer, index, result, NULL,
2439 progr_rate, progr_fun); 2457 progr_rate, progr_fun);
2440} 2458}
2441 2459
2442 2460
2443/* 2461/*
2444 body-fld-lang = nstring / "(" string *(SP string) ")" 2462 body-fld-lang = nstring / "(" string *(SP string) ")"
2445*/ 2463*/
2446 2464
2447/* 2465/*
2448"(" string *(SP string) ")" 2466"(" string *(SP string) ")"
2449*/ 2467*/
2450 2468
2451static int 2469static int
2452mailimap_body_fld_lang_list_parse(mailstream * fd, MMAPString * buffer, 2470mailimap_body_fld_lang_list_parse(mailstream * fd, MMAPString * buffer,
2453 size_t * index, clist ** result, 2471 size_t * index, clist ** result,
2454 size_t progr_rate, 2472 size_t progr_rate,
2455 progress_function * progr_fun) 2473 progress_function * progr_fun)
2456{ 2474{
2457 size_t cur_token; 2475 size_t cur_token;
2458 clist * list; 2476 clist * list;
2459 int r; 2477 int r;
2460 int res; 2478 int res;
2461 2479
2462 cur_token = * index; 2480 cur_token = * index;
2463 2481
2464 r = mailimap_oparenth_parse(fd, buffer, &cur_token); 2482 r = mailimap_oparenth_parse(fd, buffer, &cur_token);
2465 if (r != MAILIMAP_NO_ERROR) { 2483 if (r != MAILIMAP_NO_ERROR) {
2466 res = r; 2484 res = r;
2467 goto err; 2485 goto err;
2468 } 2486 }
2469 2487
2470 list = clist_new(); 2488 list = clist_new();
2471 if (list == NULL) { 2489 if (list == NULL) {
2472 res = MAILIMAP_ERROR_MEMORY; 2490 res = MAILIMAP_ERROR_MEMORY;
2473 goto err; 2491 goto err;
2474 } 2492 }
2475 2493
2476 while (1) { 2494 while (1) {
2477 char * elt; 2495 char * elt;
2478 2496
2479 r = mailimap_string_parse(fd, buffer, &cur_token, &elt, NULL, 2497 r = mailimap_string_parse(fd, buffer, &cur_token, &elt, NULL,
2480 progr_rate, progr_fun); 2498 progr_rate, progr_fun);
2481 if (r != MAILIMAP_ERROR_PARSE) 2499 if (r != MAILIMAP_ERROR_PARSE)
2482 break; 2500 break;
2483 else if (r == MAILIMAP_NO_ERROR) { 2501 else if (r == MAILIMAP_NO_ERROR) {
2484 r = clist_append(list, elt); 2502 r = clist_append(list, elt);
2485 if (r < 0) { 2503 if (r < 0) {
2486 mailimap_string_free(elt); 2504 mailimap_string_free(elt);
2487 res = r; 2505 res = r;
2488 goto list_free; 2506 goto list_free;
2489 } 2507 }
2490 } 2508 }
2491 else { 2509 else {
2492 res = r; 2510 res = r;
2493 goto list_free; 2511 goto list_free;
2494 } 2512 }
2495 } 2513 }
2496 2514
2497 r = mailimap_cparenth_parse(fd, buffer, &cur_token); 2515 r = mailimap_cparenth_parse(fd, buffer, &cur_token);
2498 if (r != MAILIMAP_NO_ERROR) { 2516 if (r != MAILIMAP_NO_ERROR) {
2499 res = r; 2517 res = r;