1*99410184Ssalo /* $NetBSD: setprogname.c,v 1.3 2003/07/26 19:24:44 salo Exp $ */
221202a2cScgd
321202a2cScgd /*
421202a2cScgd * Copyright (c) 2001 Christopher G. Demetriou
521202a2cScgd * All rights reserved.
621202a2cScgd *
721202a2cScgd * Redistribution and use in source and binary forms, with or without
821202a2cScgd * modification, are permitted provided that the following conditions
921202a2cScgd * are met:
1021202a2cScgd * 1. Redistributions of source code must retain the above copyright
1121202a2cScgd * notice, this list of conditions and the following disclaimer.
1221202a2cScgd * 2. Redistributions in binary form must reproduce the above copyright
1321202a2cScgd * notice, this list of conditions and the following disclaimer in the
1421202a2cScgd * documentation and/or other materials provided with the distribution.
1521202a2cScgd * 3. All advertising materials mentioning features or use of this software
1621202a2cScgd * must display the following acknowledgement:
1721202a2cScgd * This product includes software developed for the
18*99410184Ssalo * NetBSD Project. See http://www.NetBSD.org/ for
1921202a2cScgd * information about NetBSD.
2021202a2cScgd * 4. The name of the author may not be used to endorse or promote products
2121202a2cScgd * derived from this software without specific prior written permission.
2221202a2cScgd *
2321202a2cScgd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2421202a2cScgd * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2521202a2cScgd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2621202a2cScgd * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2721202a2cScgd * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2821202a2cScgd * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2921202a2cScgd * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3021202a2cScgd * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3121202a2cScgd * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3221202a2cScgd * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3321202a2cScgd *
3421202a2cScgd * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
3521202a2cScgd */
3621202a2cScgd
3721202a2cScgd #include <sys/cdefs.h>
3821202a2cScgd #if defined(LIBC_SCCS) && !defined(lint)
39*99410184Ssalo __RCSID("$NetBSD: setprogname.c,v 1.3 2003/07/26 19:24:44 salo Exp $");
4021202a2cScgd #endif /* LIBC_SCCS and not lint */
4121202a2cScgd
4221202a2cScgd /* In NetBSD, the program name is set by crt0. It can't be overridden. */
4321202a2cScgd #undef REALLY_SET_PROGNAME
4421202a2cScgd
4521202a2cScgd #include <stdlib.h>
4621202a2cScgd
4721202a2cScgd #ifdef REALLY_SET_PROGNAME
481704d52dSsimonb #include <string.h>
491704d52dSsimonb
5021202a2cScgd extern const char *__progname;
5121202a2cScgd #endif
5221202a2cScgd
5321202a2cScgd /*ARGSUSED*/
5421202a2cScgd void
setprogname(const char * progname)5521202a2cScgd setprogname(const char *progname)
5621202a2cScgd {
5721202a2cScgd
5821202a2cScgd #ifdef REALLY_SET_PROGNAME
5921202a2cScgd __progname = strrchr(progname, '/');
6021202a2cScgd if (__progname == NULL)
6121202a2cScgd __progname = progname;
6221202a2cScgd else
6321202a2cScgd __progname++;
6421202a2cScgd #endif
6521202a2cScgd }
66