1*ce099b40Smartin /* $NetBSD: setprogname.c,v 1.5 2008/04/28 20:24:12 martin Exp $ */
287d14ee4Stv
387d14ee4Stv /*-
487d14ee4Stv * Copyright (c) 2001 The NetBSD Foundation, Inc.
587d14ee4Stv * All rights reserved.
687d14ee4Stv *
787d14ee4Stv * This code is derived from software contributed to The NetBSD Foundation
887d14ee4Stv * by Todd Vierling.
987d14ee4Stv *
1087d14ee4Stv * Redistribution and use in source and binary forms, with or without
1187d14ee4Stv * modification, are permitted provided that the following conditions
1287d14ee4Stv * are met:
1387d14ee4Stv * 1. Redistributions of source code must retain the above copyright
1487d14ee4Stv * notice, this list of conditions and the following disclaimer.
1587d14ee4Stv * 2. Redistributions in binary form must reproduce the above copyright
1687d14ee4Stv * notice, this list of conditions and the following disclaimer in the
1787d14ee4Stv * documentation and/or other materials provided with the distribution.
1887d14ee4Stv *
1987d14ee4Stv * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2087d14ee4Stv * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2187d14ee4Stv * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2287d14ee4Stv * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2387d14ee4Stv * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2487d14ee4Stv * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2587d14ee4Stv * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2687d14ee4Stv * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2787d14ee4Stv * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2887d14ee4Stv * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2987d14ee4Stv * POSSIBILITY OF SUCH DAMAGE.
3087d14ee4Stv */
3187d14ee4Stv
32171d6532Slukem #include "nbtool_config.h"
3387d14ee4Stv
344ada6634Stv #if !HAVE_SETPROGNAME
3596119ca8Slukem #include <string.h>
3696119ca8Slukem
374ada6634Stv static const char *__progname = "command line";
3887d14ee4Stv
3996119ca8Slukem void
setprogname(const char * progname)4096119ca8Slukem setprogname(const char *progname)
4196119ca8Slukem {
4296119ca8Slukem __progname = strrchr(progname, '/');
4396119ca8Slukem if (__progname == NULL)
4487d14ee4Stv __progname = progname;
4596119ca8Slukem else
4696119ca8Slukem __progname++;
4787d14ee4Stv }
4887d14ee4Stv
4996119ca8Slukem const char *
getprogname(void)5096119ca8Slukem getprogname(void)
5196119ca8Slukem {
5287d14ee4Stv return __progname;
5387d14ee4Stv }
5487d14ee4Stv #endif
55