Commit 21476083 214760832d70f58e1d64e3b74bbac710f284546d by Sergey Poznyakoff

(sieve_get_mailer,sieve_set_mailer,sieve_get_daemo_email,sieve_set_daemon_email): New functions.

1 parent ca113f17
...@@ -361,39 +361,39 @@ sieve_machine_init (sieve_machine_t *pmach, void *data) ...@@ -361,39 +361,39 @@ sieve_machine_init (sieve_machine_t *pmach, void *data)
361 } 361 }
362 362
363 void 363 void
364 sieve_machine_set_error (sieve_machine_t mach, sieve_printf_t error_printer) 364 sieve_set_error (sieve_machine_t mach, sieve_printf_t error_printer)
365 { 365 {
366 mach->error_printer = error_printer ? 366 mach->error_printer = error_printer ?
367 error_printer : _sieve_default_error_printer; 367 error_printer : _sieve_default_error_printer;
368 } 368 }
369 369
370 void 370 void
371 sieve_machine_set_parse_error (sieve_machine_t mach, sieve_parse_error_t p) 371 sieve_set_parse_error (sieve_machine_t mach, sieve_parse_error_t p)
372 { 372 {
373 mach->parse_error_printer = p ? p : _sieve_default_parse_error; 373 mach->parse_error_printer = p ? p : _sieve_default_parse_error;
374 } 374 }
375 375
376 void 376 void
377 sieve_machine_set_debug (sieve_machine_t mach, sieve_printf_t debug) 377 sieve_set_debug (sieve_machine_t mach, sieve_printf_t debug)
378 { 378 {
379 mach->debug_printer = debug; 379 mach->debug_printer = debug;
380 } 380 }
381 381
382 void 382 void
383 sieve_machine_set_debug_level (sieve_machine_t mach, mu_debug_t dbg, int level) 383 sieve_set_debug_level (sieve_machine_t mach, mu_debug_t dbg, int level)
384 { 384 {
385 mach->mu_debug = dbg; 385 mach->mu_debug = dbg;
386 mach->debug_level = level; 386 mach->debug_level = level;
387 } 387 }
388 388
389 void 389 void
390 sieve_machine_set_logger (sieve_machine_t mach, sieve_action_log_t logger) 390 sieve_set_logger (sieve_machine_t mach, sieve_action_log_t logger)
391 { 391 {
392 mach->logger = logger; 392 mach->logger = logger;
393 } 393 }
394 394
395 void 395 void
396 sieve_machine_set_ticket (sieve_machine_t mach, ticket_t ticket) 396 sieve_set_ticket (sieve_machine_t mach, ticket_t ticket)
397 { 397 {
398 mach->ticket = ticket; 398 mach->ticket = ticket;
399 } 399 }
...@@ -404,6 +404,46 @@ sieve_get_ticket (sieve_machine_t mach) ...@@ -404,6 +404,46 @@ sieve_get_ticket (sieve_machine_t mach)
404 return mach->ticket; 404 return mach->ticket;
405 } 405 }
406 406
407 mailer_t
408 sieve_get_mailer (sieve_machine_t mach)
409 {
410 if (!mach->mailer)
411 mailer_create (&mach->mailer, NULL);
412 return mach->mailer;
413 }
414
415 void
416 sieve_set_mailer (sieve_machine_t mach, mailer_t mailer)
417 {
418 mailer_destroy (&mach->mailer);
419 mach->mailer = mailer;
420 }
421
422 #define MAILER_DAEMON_PFX "MAILER-DAEMON@"
423
424 char *
425 sieve_get_daemon_email (sieve_machine_t mach)
426 {
427 if (!mach->daemon_email)
428 {
429 const char *domain = NULL;
430
431 mu_get_user_email_domain (&domain);
432 mach->daemon_email = sieve_palloc (&mach->memory_pool,
433 sizeof(MAILER_DAEMON_PFX) +
434 strlen (domain));
435 sprintf (mach->daemon_email, "%s%s", MAILER_DAEMON_PFX, domain);
436 }
437 return mach->daemon_email;
438 }
439
440 void
441 sieve_set_daemon_email (sieve_machine_t mach, const char *email)
442 {
443 sieve_pfree (&mach->memory_pool, (void *)mach->daemon_email);
444 mach->daemon_email = sieve_pstrdup (&mach->memory_pool, email);
445 }
446
407 struct sieve_destr_record 447 struct sieve_destr_record
408 { 448 {
409 sieve_destructor_t destr; 449 sieve_destructor_t destr;
...@@ -441,6 +481,7 @@ sieve_machine_destroy (sieve_machine_t *pmach) ...@@ -441,6 +481,7 @@ sieve_machine_destroy (sieve_machine_t *pmach)
441 list_do (mach->destr_list, _run_destructor, NULL); 481 list_do (mach->destr_list, _run_destructor, NULL);
442 list_destroy (&mach->destr_list); 482 list_destroy (&mach->destr_list);
443 sieve_slist_destroy (&mach->memory_pool); 483 sieve_slist_destroy (&mach->memory_pool);
484 mailer_destroy (&mach->mailer);
444 free (mach); 485 free (mach);
445 *pmach = NULL; 486 *pmach = NULL;
446 } 487 }
......