|
Lines 710-751
bool verify_hint(const char *arg, int *min_sockets, int *min_cores,
Link Here
|
| 710 |
|
710 |
|
| 711 |
uint16_t parse_mail_type(const char *arg) |
711 |
uint16_t parse_mail_type(const char *arg) |
| 712 |
{ |
712 |
{ |
| 713 |
uint16_t rc; |
713 |
char *buf, *tok, *save_ptr = NULL; |
| 714 |
|
714 |
uint16_t rc = 0; |
| 715 |
if (strcasecmp(arg, "BEGIN") == 0) |
715 |
|
| 716 |
rc = MAIL_JOB_BEGIN; |
716 |
if (!arg) |
| 717 |
else if (strcasecmp(arg, "END") == 0) |
717 |
return rc; |
| 718 |
rc = MAIL_JOB_END; |
718 |
|
| 719 |
else if (strcasecmp(arg, "FAIL") == 0) |
719 |
buf = xstrdup(arg); |
| 720 |
rc = MAIL_JOB_FAIL; |
720 |
tok = strtok_r(buf, ",", &save_ptr); |
| 721 |
else if (strcasecmp(arg, "REQUEUE") == 0) |
721 |
while (tok) { |
| 722 |
rc = MAIL_JOB_REQUEUE; |
722 |
if (strcasecmp(tok, "BEGIN") == 0) |
| 723 |
else if (strcasecmp(arg, "ALL") == 0) |
723 |
rc |= MAIL_JOB_BEGIN; |
| 724 |
rc = MAIL_JOB_BEGIN | MAIL_JOB_END | MAIL_JOB_FAIL | |
724 |
else if (strcasecmp(tok, "END") == 0) |
| 725 |
MAIL_JOB_REQUEUE; |
725 |
rc |= MAIL_JOB_END; |
| 726 |
else |
726 |
else if (strcasecmp(tok, "FAIL") == 0) |
| 727 |
rc = 0; /* failure */ |
727 |
rc |= MAIL_JOB_FAIL; |
|
|
728 |
else if (strcasecmp(tok, "REQUEUE") == 0) |
| 729 |
rc |= MAIL_JOB_REQUEUE; |
| 730 |
else if (strcasecmp(tok, "ALL") == 0) |
| 731 |
rc |= MAIL_JOB_BEGIN | MAIL_JOB_END | MAIL_JOB_FAIL | |
| 732 |
MAIL_JOB_REQUEUE; |
| 733 |
else if (strcasecmp(tok, "TIME_LIMIT") == 0) |
| 734 |
rc |= MAIL_JOB_TIME100; |
| 735 |
else if (strcasecmp(tok, "TIME_LIMIT_90") == 0) |
| 736 |
rc |= MAIL_JOB_TIME90; |
| 737 |
else if (strcasecmp(tok, "TIME_LIMIT_80") == 0) |
| 738 |
rc |= MAIL_JOB_TIME80; |
| 739 |
else if (strcasecmp(tok, "TIME_LIMIT_50") == 0) |
| 740 |
rc |= MAIL_JOB_TIME50; |
| 741 |
tok = strtok_r(NULL, ",", &save_ptr); |
| 742 |
} |
| 743 |
xfree(buf); |
| 728 |
|
744 |
|
| 729 |
return rc; |
745 |
return rc; |
| 730 |
} |
746 |
} |
| 731 |
char *print_mail_type(const uint16_t type) |
747 |
char *print_mail_type(const uint16_t type) |
| 732 |
{ |
748 |
{ |
|
|
749 |
static char buf[256]; |
| 750 |
|
| 751 |
buf[0] = '\0'; |
| 752 |
|
| 733 |
if (type == 0) |
753 |
if (type == 0) |
| 734 |
return "NONE"; |
754 |
return "NONE"; |
| 735 |
|
755 |
|
| 736 |
if (type == MAIL_JOB_BEGIN) |
756 |
if (type & MAIL_JOB_BEGIN) { |
| 737 |
return "BEGIN"; |
757 |
if (buf[0]) |
| 738 |
if (type == MAIL_JOB_END) |
758 |
strcat(buf, ","); |
| 739 |
return "END"; |
759 |
strcat(buf, "BEGIN"); |
| 740 |
if (type == MAIL_JOB_FAIL) |
760 |
} |
| 741 |
return "FAIL"; |
761 |
if (type & MAIL_JOB_END) { |
| 742 |
if (type == MAIL_JOB_REQUEUE) |
762 |
if (buf[0]) |
| 743 |
return "REQUEUE"; |
763 |
strcat(buf, ","); |
| 744 |
if (type == (MAIL_JOB_BEGIN | MAIL_JOB_END | MAIL_JOB_FAIL | |
764 |
strcat(buf, "END"); |
| 745 |
MAIL_JOB_REQUEUE)) |
765 |
} |
| 746 |
return "ALL"; |
766 |
if (type & MAIL_JOB_FAIL) { |
| 747 |
|
767 |
if (buf[0]) |
| 748 |
return "MULTIPLE"; |
768 |
strcat(buf, ","); |
|
|
769 |
strcat(buf, "FAIL"); |
| 770 |
} |
| 771 |
if (type & MAIL_JOB_REQUEUE) { |
| 772 |
if (buf[0]) |
| 773 |
strcat(buf, ","); |
| 774 |
strcat(buf, "REQUEUE"); |
| 775 |
} |
| 776 |
if (type & MAIL_JOB_TIME50) { |
| 777 |
if (buf[0]) |
| 778 |
strcat(buf, ","); |
| 779 |
strcat(buf, "TIME_LIMIT_50"); |
| 780 |
} |
| 781 |
if (type & MAIL_JOB_TIME80) { |
| 782 |
if (buf[0]) |
| 783 |
strcat(buf, ","); |
| 784 |
strcat(buf, "TIME_LIMIT_80"); |
| 785 |
} |
| 786 |
if (type & MAIL_JOB_TIME90) { |
| 787 |
if (buf[0]) |
| 788 |
strcat(buf, ","); |
| 789 |
strcat(buf, "TIME_LIMIT_90"); |
| 790 |
} |
| 791 |
if (type & MAIL_JOB_TIME100) { |
| 792 |
if (buf[0]) |
| 793 |
strcat(buf, ","); |
| 794 |
strcat(buf, "TIME_LIMIT"); |
| 795 |
} |
| 796 |
|
| 797 |
return buf; |
| 749 |
} |
798 |
} |
| 750 |
|
799 |
|
| 751 |
static void |
800 |
static void |