1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright(c) 1988 AT&T 24*0Sstevel@tonic-gate * All Rights Reserved 25*0Sstevel@tonic-gate * 26*0Sstevel@tonic-gate * 27*0Sstevel@tonic-gate * Copyright(c) 1995 by Sun Microsystems, Inc. 28*0Sstevel@tonic-gate * All Rights Reserved 29*0Sstevel@tonic-gate */ 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate #include "mcs.h" 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate static const char *msg[] = { 34*0Sstevel@tonic-gate /* MALLOC_ERROR */ 35*0Sstevel@tonic-gate "%s: malloc memory allocation failure.\n", 36*0Sstevel@tonic-gate /* USAGE_ERROR */ 37*0Sstevel@tonic-gate "%s: multiple -n only allowed for -d option.\n", 38*0Sstevel@tonic-gate /* ELFVER_ERROR */ 39*0Sstevel@tonic-gate "%s: elf_version() failed - libelf.a out of date.\n", 40*0Sstevel@tonic-gate /* OPEN_ERROR */ 41*0Sstevel@tonic-gate "%s: %s: cannot open file.\n", 42*0Sstevel@tonic-gate /* LIBELF_ERROR */ 43*0Sstevel@tonic-gate "%s: libelf error.\n", 44*0Sstevel@tonic-gate /* OPEN_TEMP_ERROR */ 45*0Sstevel@tonic-gate "%s: %s: cannot open temporary file\n", 46*0Sstevel@tonic-gate /* WRITE_ERROR */ 47*0Sstevel@tonic-gate "%s: %s: write system failure: %s: file not manipulated.\n", 48*0Sstevel@tonic-gate /* GETARHDR_ERROR */ 49*0Sstevel@tonic-gate "%s: %s: malformed archive at %ld\n", 50*0Sstevel@tonic-gate /* FILE_TYPE_ERROR */ 51*0Sstevel@tonic-gate "%s: %s: invalid file type\n", 52*0Sstevel@tonic-gate /* NOT_MANIPULATED_ERROR */ 53*0Sstevel@tonic-gate "%s: %s: file not manipulated\n", 54*0Sstevel@tonic-gate /* WRN_MANIPULATED_ERROR */ 55*0Sstevel@tonic-gate "%s: WARNING: %s: Cannot manipulate file.\n", 56*0Sstevel@tonic-gate /* NO_SECT_TABLE_ERROR */ 57*0Sstevel@tonic-gate "%s: %s: no section header table.\n", 58*0Sstevel@tonic-gate /* READ_ERROR */ 59*0Sstevel@tonic-gate "%s: %s: trouble reading file\n", 60*0Sstevel@tonic-gate /* READ_MANI_ERROR */ 61*0Sstevel@tonic-gate "%s: %s: read system failure: %s: file not manipulated.\n", 62*0Sstevel@tonic-gate /* WRITE_MANI_ERROR */ 63*0Sstevel@tonic-gate "%s: %s: write system failure: %s: file not manipulated.\n", 64*0Sstevel@tonic-gate /* LSEEK_MANI_ERROR */ 65*0Sstevel@tonic-gate "%s: %s: lseek system failure: %s: file not manipulated.\n", 66*0Sstevel@tonic-gate /* SYM_TAB_AR_ERROR */ 67*0Sstevel@tonic-gate "%s: WARNING: %s: symbol table deleted from archive \n", 68*0Sstevel@tonic-gate /* EXEC_AR_ERROR */ 69*0Sstevel@tonic-gate "execute `ar -ts %s` to restore symbol table.\n", 70*0Sstevel@tonic-gate /* READ_SYS_ERROR */ 71*0Sstevel@tonic-gate "%s: %s: read system failure\n", 72*0Sstevel@tonic-gate /* OPEN_WRITE_ERROR */ 73*0Sstevel@tonic-gate "%s: %s: can't open file for writing\n", 74*0Sstevel@tonic-gate /* ACT_PRINT_ERROR */ 75*0Sstevel@tonic-gate "%s: %s: Cannot print contents of a NOBITS section (%s)\n", 76*0Sstevel@tonic-gate /* ACT_DELETE1_ERROR */ 77*0Sstevel@tonic-gate "%s: %s: Warning: Cannot delete section (%s)\n\t\tfrom a segment.\n", 78*0Sstevel@tonic-gate /* ACT_DELETE2_ERROR */ 79*0Sstevel@tonic-gate "%s: %s: Warning: Cannot delete section (%s)\n" 80*0Sstevel@tonic-gate "\t\tbecause its relocation section (%s) is in a segment\n", 81*0Sstevel@tonic-gate /* ACT_APPEND1_ERROR */ 82*0Sstevel@tonic-gate "%s: %s: Cannot append to a NOBITS section (%s)\n", 83*0Sstevel@tonic-gate /* ACT_APPEND2_ERROR */ 84*0Sstevel@tonic-gate "%s: %s: Warning: Cannot append to section (%s)\n\t\tin a segment\n", 85*0Sstevel@tonic-gate /* ACT_COMPRESS1_ERROR */ 86*0Sstevel@tonic-gate "%s: %s: Cannot compress a NOBITS section (%s)\n", 87*0Sstevel@tonic-gate /* ACT_COMPRESS2_ERROR */ 88*0Sstevel@tonic-gate "%s: %s: Warning: Cannot compress a section (%s)\n\t\tin a segment\n", 89*0Sstevel@tonic-gate /* ACCESS_ERROR */ 90*0Sstevel@tonic-gate "%s: %s: access error.\n", 91*0Sstevel@tonic-gate /* WRITE_MANI_ERROR2 */ 92*0Sstevel@tonic-gate "%s: /ftruncate/lseek/write system failure: %s: file may be destroyed.\n" 93*0Sstevel@tonic-gate }; 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate void 96*0Sstevel@tonic-gate error_message(int args, ...) 97*0Sstevel@tonic-gate { 98*0Sstevel@tonic-gate int mes = args; 99*0Sstevel@tonic-gate char *message = gettext((char *)msg[mes]); 100*0Sstevel@tonic-gate int flag; 101*0Sstevel@tonic-gate char *sys_mes; 102*0Sstevel@tonic-gate va_list ap; 103*0Sstevel@tonic-gate va_start(ap, args); 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate flag = va_arg(ap, int); 106*0Sstevel@tonic-gate sys_mes = va_arg(ap, char *); 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate switch (mes) { 109*0Sstevel@tonic-gate case MALLOC_ERROR: 110*0Sstevel@tonic-gate case USAGE_ERROR: 111*0Sstevel@tonic-gate case ELFVER_ERROR: 112*0Sstevel@tonic-gate case EXEC_AR_ERROR: 113*0Sstevel@tonic-gate case LIBELF_ERROR: 114*0Sstevel@tonic-gate (void) fprintf(stderr, message, va_arg(ap, char *)); 115*0Sstevel@tonic-gate break; 116*0Sstevel@tonic-gate case OPEN_ERROR: 117*0Sstevel@tonic-gate case ACCESS_ERROR: 118*0Sstevel@tonic-gate case OPEN_TEMP_ERROR: 119*0Sstevel@tonic-gate case FILE_TYPE_ERROR: 120*0Sstevel@tonic-gate case NOT_MANIPULATED_ERROR: 121*0Sstevel@tonic-gate case WRN_MANIPULATED_ERROR: 122*0Sstevel@tonic-gate case NO_SECT_TABLE_ERROR: 123*0Sstevel@tonic-gate case READ_ERROR: 124*0Sstevel@tonic-gate case SYM_TAB_AR_ERROR: 125*0Sstevel@tonic-gate case READ_SYS_ERROR: 126*0Sstevel@tonic-gate case OPEN_WRITE_ERROR: 127*0Sstevel@tonic-gate /* LINTED */ 128*0Sstevel@tonic-gate (void) fprintf(stderr, message, va_arg(ap, char *), 129*0Sstevel@tonic-gate va_arg(ap, char *)); 130*0Sstevel@tonic-gate break; 131*0Sstevel@tonic-gate case WRITE_ERROR: 132*0Sstevel@tonic-gate case READ_MANI_ERROR: 133*0Sstevel@tonic-gate case WRITE_MANI_ERROR: 134*0Sstevel@tonic-gate case LSEEK_MANI_ERROR: 135*0Sstevel@tonic-gate case ACT_PRINT_ERROR: 136*0Sstevel@tonic-gate case ACT_DELETE1_ERROR: 137*0Sstevel@tonic-gate case ACT_APPEND1_ERROR: 138*0Sstevel@tonic-gate case ACT_APPEND2_ERROR: 139*0Sstevel@tonic-gate case ACT_COMPRESS1_ERROR: 140*0Sstevel@tonic-gate case ACT_COMPRESS2_ERROR: { 141*0Sstevel@tonic-gate char * a = va_arg(ap, char *); 142*0Sstevel@tonic-gate char * b = va_arg(ap, char *); 143*0Sstevel@tonic-gate char * c = va_arg(ap, char *); 144*0Sstevel@tonic-gate (void) fprintf(stderr, message, a, b, c); 145*0Sstevel@tonic-gate break; 146*0Sstevel@tonic-gate } 147*0Sstevel@tonic-gate case ACT_DELETE2_ERROR: { 148*0Sstevel@tonic-gate char * a = va_arg(ap, char *); 149*0Sstevel@tonic-gate char * b = va_arg(ap, char *); 150*0Sstevel@tonic-gate char * c = va_arg(ap, char *); 151*0Sstevel@tonic-gate char * d = va_arg(ap, char *); 152*0Sstevel@tonic-gate (void) fprintf(stderr, message, a, b, c, d); 153*0Sstevel@tonic-gate break; 154*0Sstevel@tonic-gate } 155*0Sstevel@tonic-gate case GETARHDR_ERROR: { 156*0Sstevel@tonic-gate char * a = va_arg(ap, char *); 157*0Sstevel@tonic-gate char * b = va_arg(ap, char *); 158*0Sstevel@tonic-gate long c = va_arg(ap, long); 159*0Sstevel@tonic-gate (void) fprintf(stderr, message, a, b, c); 160*0Sstevel@tonic-gate break; 161*0Sstevel@tonic-gate } 162*0Sstevel@tonic-gate default: 163*0Sstevel@tonic-gate (void) fprintf(stderr, "internal error: error_message(%d)\n", 164*0Sstevel@tonic-gate mes); 165*0Sstevel@tonic-gate exit(100); 166*0Sstevel@tonic-gate } 167*0Sstevel@tonic-gate 168*0Sstevel@tonic-gate if (flag != PLAIN_ERROR) 169*0Sstevel@tonic-gate (void) fprintf(stderr, "\t%s\n", sys_mes); 170*0Sstevel@tonic-gate va_end(ap); 171*0Sstevel@tonic-gate } 172