moe.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <dlfcn.h>
#include <link.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <libintl.h>
#include <locale.h>
#include <conv.h>
#include <msg.h>
void
locale()
{
static int localeinit = 0;
/*
* Defer localization overhead until a localized message, is required.
* For successful specific (32-bit or 64-bit) commands, none of this
* overhead should be incurred.
*/
if (localeinit++)
return;
}
const char *
{
}
/*
* Error messages from ld.so.1 are formatted as:
*
* ld.so.1: app-name: fatal: ....
*
* Here, we skip over these three components. Thus the message a little less
* hostile when displayed by moe(). Really, it would be nice to have some
* flexibility over what ld.so.1 displays.
*/
static char *
{
int cnt = 0;
/*
* Skip the first three components.
*/
while (*ptr) {
if (*ptr == ':') {
if (++cnt == 3)
break;
}
ptr++;
}
if (*ptr == '\0')
return (str);
else
return (ptr + 2);
}
#define ONLY32 1
#define ONLY64 2
static int
{
void *handle;
const char *modestr;
/*
* If the class of object is required, localize the prefix message.
*/
if (class) {
locale();
#if defined(_LP64)
#else
#endif
} else
/*
* Open the optimal object, and determine its full name from the
* returned handle. Borrow the internal mode, RTLD_CONFGEN, from
* crle(1). This flag allows us to process incomplete objects, as
* would occur if the object couldn't find its dependencies or relocate
* itself.
*/
if (verbose)
return (1);
}
if (verbose)
return (1);
}
if (silent == 0) {
if (verbose)
else
}
return (0);
}
int
/* ARGSUSED2 */
{
char *prog;
else
prog++;
opterr = 0;
switch (var) {
case 'c':
class++;
break;
case '3':
#if !defined(_LP64)
else
#endif
error++;
break;
case '6':
else
error++;
break;
case 's':
if (verbose == 0)
silent++;
else
error++;
break;
case 'v':
if (silent == 0)
verbose++;
else
error++;
break;
case '?':
error++;
break;
default:
break;
}
}
locale();
return (1);
}
if (silent)
class = 0;
/*
* Process any 32-bit expansion.
*/
#if !defined(_LP64)
#endif
if (mode)
error++;
#if !defined(_LP64)
}
#endif
return (0);
/*
* Re-exec ourselves to process any 64-bit expansion.
*/
#endif
return (error);
}