#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <locale.h>
#include <libintl.h>
#include "libinst.h"
#include "messages.h"
static char *qreasonNoZonename(int caller, int retcode, int started);
static char *qreasonWithZonename(int caller, int retcode, int started);
char *
qreason(int caller, int retcode, int started, int includeZonename)
{
if (includeZonename == 0) {
return (qreasonNoZonename(caller, retcode, started));
}
return (qreasonWithZonename(caller, retcode, started));
}
static char *
qreasonNoZonename(int caller, int retcode, int started)
{
switch (retcode) {
case 0:
case 10:
case 20:
switch (caller) {
case 0:
return (MSG_RE_SUC);
case 1:
return (MSG_IN_SUC0);
case 2:
return (MSG_IN_SUC1);
case 3:
return (MSG_RM_SUC0);
case 4:
return (MSG_RM_SUC1);
default:
return (MSG_UNKREQ);
}
case 1:
case 11:
case 21:
switch (caller) {
case 0:
return (MSG_RE_FAIL);
case 1:
return (MSG_IN_FAIL0);
case 2:
return (MSG_IN_FAIL1);
case 3:
return (MSG_RM_FAIL0);
case 4:
return (MSG_RM_FAIL1);
default:
return (MSG_UNKREQ);
}
case 2:
case 12:
case 22:
switch (caller) {
case 0:
return (MSG_RE_PARFAIL);
case 1:
return (MSG_IN_PARFAIL0);
case 2:
return (MSG_IN_PARFAIL1);
case 3:
return (MSG_RM_PARFAIL0);
case 4:
return (MSG_RM_PARFAIL1);
default:
return (MSG_UNKREQ);
}
case 3:
case 13:
case 23:
switch (caller) {
case 0:
return (MSG_RE_USER);
case 1:
return (MSG_IN_USER0);
case 2:
return (MSG_IN_USER1);
case 3:
return (MSG_RM_USER0);
case 4:
return (MSG_RM_USER1);
default:
return (MSG_UNKREQ);
}
case 4:
case 14:
case 24:
switch (caller) {
case 0:
return (MSG_RE_SUA);
case 1:
return (MSG_IN_SUA0);
case 2:
return (MSG_IN_SUA1);
case 3:
return (MSG_RM_SUA0);
case 4:
return (MSG_RM_SUA1);
default:
return (MSG_UNKREQ);
}
case 5:
case 15:
case 25:
switch (caller) {
case 0:
return (MSG_RE_SUI);
case 1:
return (MSG_IN_SUI0);
case 2:
return (MSG_IN_SUI1);
case 3:
return (MSG_RM_SUI0);
case 4:
return (MSG_RM_SUI1);
default:
return (MSG_UNKREQ);
}
case 99:
if (started) {
switch (caller) {
case 0:
return (MSG_RE_IEPI);
case 1:
return (MSG_IN_IEPI0);
case 2:
return (MSG_IN_IEPI1);
case 3:
return (MSG_RM_IEPI0);
case 4:
return (MSG_RM_IEPI1);
default:
return (MSG_UNKREQ);
}
}
switch (caller) {
case 0:
return (MSG_RE_IE);
case 1:
return (MSG_IN_IE0);
case 2:
return (MSG_IN_IE1);
case 3:
return (MSG_RM_IE0);
case 4:
return (MSG_RM_IE1);
default:
return (MSG_UNKREQ);
}
default:
switch (caller) {
case 0:
return (MSG_RE_UNK);
case 1:
return (MSG_IN_UNK0);
case 2:
return (MSG_IN_UNK1);
case 3:
return (MSG_RM_UNK0);
case 4:
return (MSG_RM_UNK1);
default:
return (MSG_UNKREQ);
}
}
}
static char *
qreasonWithZonename(int caller, int retcode, int started)
{
switch (retcode) {
case 0:
case 10:
case 20:
switch (caller) {
case 0:
return (MSG_RE_SUC_ZONE);
case 1:
return (MSG_IN_SUC0_ZONE);
case 2:
return (MSG_IN_SUC1_ZONE);
case 3:
return (MSG_RM_SUC0_ZONE);
case 4:
return (MSG_RM_SUC1_ZONE);
default:
return (MSG_UNKREQ_ZONE);
}
case 1:
case 11:
case 21:
switch (caller) {
case 0:
return (MSG_RE_FAIL_ZONE);
case 1:
return (MSG_IN_FAIL0_ZONE);
case 2:
return (MSG_IN_FAIL1_ZONE);
case 3:
return (MSG_RM_FAIL0_ZONE);
case 4:
return (MSG_RM_FAIL1_ZONE);
default:
return (MSG_UNKREQ_ZONE);
}
case 2:
case 12:
case 22:
switch (caller) {
case 0:
return (MSG_RE_PARFAIL_ZONE);
case 1:
return (MSG_IN_PARFAIL0_ZONE);
case 2:
return (MSG_IN_PARFAIL1_ZONE);
case 3:
return (MSG_RM_PARFAIL0_ZONE);
case 4:
return (MSG_RM_PARFAIL1_ZONE);
default:
return (MSG_UNKREQ_ZONE);
}
case 3:
case 13:
case 23:
switch (caller) {
case 0:
return (MSG_RE_USER_ZONE);
case 1:
return (MSG_IN_USER0_ZONE);
case 2:
return (MSG_IN_USER1_ZONE);
case 3:
return (MSG_RM_USER0_ZONE);
case 4:
return (MSG_RM_USER1_ZONE);
default:
return (MSG_UNKREQ_ZONE);
}
case 4:
case 14:
case 24:
switch (caller) {
case 0:
return (MSG_RE_SUA_ZONE);
case 1:
return (MSG_IN_SUA0_ZONE);
case 2:
return (MSG_IN_SUA1_ZONE);
case 3:
return (MSG_RM_SUA0_ZONE);
case 4:
return (MSG_RM_SUA1_ZONE);
default:
return (MSG_UNKREQ_ZONE);
}
case 5:
case 15:
case 25:
switch (caller) {
case 0:
return (MSG_RE_SUI_ZONE);
case 1:
return (MSG_IN_SUI0_ZONE);
case 2:
return (MSG_IN_SUI1_ZONE);
case 3:
return (MSG_RM_SUI0_ZONE);
case 4:
return (MSG_RM_SUI1_ZONE);
default:
return (MSG_UNKREQ_ZONE);
}
case 99:
if (started) {
switch (caller) {
case 0:
return (MSG_RE_IEPI_ZONE);
case 1:
return (MSG_IN_IEPI0_ZONE);
case 2:
return (MSG_IN_IEPI1_ZONE);
case 3:
return (MSG_RM_IEPI0_ZONE);
case 4:
return (MSG_RM_IEPI1_ZONE);
default:
return (MSG_UNKREQ_ZONE);
}
}
switch (caller) {
case 0:
return (MSG_RE_IE_ZONE);
case 1:
return (MSG_IN_IE0_ZONE);
case 2:
return (MSG_IN_IE1_ZONE);
case 3:
return (MSG_RM_IE0_ZONE);
case 4:
return (MSG_RM_IE1_ZONE);
default:
return (MSG_UNKREQ_ZONE);
}
default:
switch (caller) {
case 0:
return (MSG_RE_UNK_ZONE);
case 1:
return (MSG_IN_UNK0_ZONE);
case 2:
return (MSG_IN_UNK1_ZONE);
case 3:
return (MSG_RM_UNK0_ZONE);
case 4:
return (MSG_RM_UNK1_ZONE);
default:
return (MSG_UNKREQ_ZONE);
}
}
}