util.c revision 57ef7aa924e4bfdf3118d9b5b4285dfc94b632f3
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Utility functions
*/
#include <libintl.h>
#include <stdio.h>
#include <dlfcn.h>
#include <string.h>
#include <errno.h>
#include <alloca.h>
#include "sgs.h"
#include "rtc.h"
#include "_crle.h"
#include "msg.h"
/*
* Add an environment string. A list of environment variable descriptors is
* maintained so that duplicate definitions can be caught, the first one wins.
*/
int
{
char *str;
/*
* Determine "=" location so as to separated the variable name from
* its value.
*/
/*
* Traverse any existing environment variables to see if we've
* caught a duplicate.
*/
/*
* If the user has already specified this string
* given them a warning, and ignore the new one.
*/
return (2);
}
/*
* Otherwise the original string must have been
* retrieved from a config file. In this case
* allow the user to override it.
*/
return (0);
}
return (1);
}
}
} else {
/*
* Although this is just a plain environment definition (no "=")
* and probably has no effect on ld.so.1 anyway, we might as
* well make sure we're not duplicating the same string.
*/
continue;
return (2);
}
return (1);
}
}
varsz = 0;
}
/*
* Allocate a new environment descriptor.
*/
return (0);
}
return (0);
/*
* Update the number of environment variables found, and the string
* table requirement.
*/
return (1);
}
/*
* Add a library path. Multiple library paths are concatenated together into a
* colon separated string suitable for runtime processing. These colon
* separated strings can also be passed in as arguments to addlib(), e.g.,
*/
int
{
char *lasts;
/*
* Parse the argument for any ":" separated elements.
*/
do {
if (*lib) {
/*
* Determine whether this argument exists in the
* existing string buffer.
*/
continue;
} else {
/*
* This is the first argument to be added.
*/
llen = 0;
tlen = 0;
}
/*
* This is a new string, so add it to the buffer. If
* this is the first occurrence of a string the size is
* simply the size of the string + a trailing null.
* Otherwise the size is the old string + ":" + the
* size of the new string + a trailing null.
*/
alen += 1;
return (1);
}
if (llen == 0)
else {
/* LINTED */
}
}
return (0);
}
/*
* -f option expansion. Interpret its argument as a numeric or symbolic
* representation of the dldump(3dl) flags.
*/
int
{
int _flags;
char *lasts;
/*
* Scan the argument looking for allowable tokens. First determine if
* the string is numeric, otherwise try and parse any known flags.
*/
return (_flags);
return (0);
/* BEGIN CSTYLED */
do {
_flags |= RTLD_REL_EXEC;
_flags |= RTLD_REL_SELF;
_flags |= RTLD_REL_WEAK;
_flags |= RTLD_REL_ALL;
_flags |= RTLD_MEMORY;
_flags |= RTLD_STRIP;
_flags |= RTLD_NOHEAP;
_flags |= RTLD_CONFGEN;
else {
return (0);
}
/* END CSTYLED */
}
if (_flags == 0)
return (_flags);
}
/*
* Internationalization interface for sgsmsg(1l) use.
*/
const char *
{
}